OpenLB 1.8.1
Loading...
Searching...
No Matches
navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2008 Orestis Malaspinas, Andrea Parmigiani, Jonas Latt
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef NAVIER_STOKES_ADVECTION_DIFFUSION_COUPLING_POST_PROCESSOR_2D_HH
25#define NAVIER_STOKES_ADVECTION_DIFFUSION_COUPLING_POST_PROCESSOR_2D_HH
26
29#include "core/util.h"
31
32
33namespace olb {
34
35//=====================================================================================
36//============== PhaseFieldCouplingPostProcessor2D ===============
37//=====================================================================================
38
39template<typename T, typename DESCRIPTOR>
41PhaseFieldCouplingPostProcessor2D(int x0_, int x1_, int y0_, int y1_,
42 T rho_L, T rho_H, T mu_L, T mu_H, T surface_tension, T interface_thickness,
43 std::vector<BlockStructureD<2>* > partners_)
44 : x0(x0_), x1(x1_), y0(y0_), y1(y1_),
45 _rho_L(rho_L), _rho_H(rho_H), _delta_rho(rho_H - rho_L), _mu_L(mu_L), _mu_H(mu_H), _surface_tension(surface_tension), _interface_thickness(interface_thickness),
46 _beta(12.0 * surface_tension / interface_thickness), _kappa(1.5 * surface_tension * interface_thickness)
47{
48 this->getName() = "PhaseFieldCouplingPostProcessor2D";
50}
51
52template<typename T, typename DESCRIPTOR>
55 int x0_, int x1_, int y0_, int y1_)
56{
57
58 int newX0, newX1, newY0, newY1;
59 if ( util::intersect ( x0, x1, y0, y1,
60 x0_, x1_, y0_, y1_,
61 newX0, newX1, newY0, newY1 ) ) {
62
63 // generate phi cache
64 auto& phi_cache = blockLattice.template getField<PHI_CACHE>()[0];
65 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
66 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
67 phi_cache[blockLattice.getCellId(iX,iY)] = util::max(util::min(tPartner->get(iX,iY).computeRho(), 1.0), 0.0);
68 }
69 }
70
71 for (int iX=newX0; iX<=newX1; ++iX) {
72 for (int iY=newY0; iY<=newY1; ++iY) {
73 auto cell = blockLattice.get(iX,iY);
74 auto partnerCell = tPartner->get(iX,iY);
75
76 T phi = phi_cache[blockLattice.getCellId(iX,iY)];
77
78 // compute rho from phi
79 T rho = _rho_L + phi * _delta_rho;
80
81 // compute dynamic viscosity
82 T viscosity = _mu_L + phi * (_mu_H - _mu_L);
83
84 // get relaxation time
85 T tau = cell.template getField<descriptors::TAU_EFF>();
86
87 // compute grad phi and laplace phi
88 Vector<T,L::d> grad_phi(0.0, 0.0);
89 T laplace_phi = 0.0;
90 for (int iPop = 1; iPop < L::q; ++iPop) {
91 int nextX = iX + descriptors::c<L>(iPop,0);
92 int nextY = iY + descriptors::c<L>(iPop,1);
93 T neighbor_phi = phi_cache[blockLattice.getCellId(nextX,nextY)];
94
95 laplace_phi += (neighbor_phi - phi) * descriptors::t<T,L>(iPop);
96
97 neighbor_phi *= descriptors::t<T,L>(iPop);
98 grad_phi += neighbor_phi * descriptors::c<L>(iPop);
99 }
100 grad_phi *= descriptors::invCs2<T,L>();
101 laplace_phi *= 2.0 * descriptors::invCs2<T,L>();
102
103 // compute grad rho
104 Vector<T,L::d> grad_rho(_delta_rho, _delta_rho);
105 grad_rho *= grad_phi;
106
107 // compute interphase normal, save to external field
108 T norm_grad_phi = norm(grad_phi);
109 norm_grad_phi = util::max(norm_grad_phi, std::numeric_limits<T>::epsilon());
110 partnerCell.template setField<descriptors::INTERPHASE_NORMAL>(grad_phi / norm_grad_phi);
111
112 // compute forces (F_s, F_b, F_p, F_nu)
113 // F_s (surface tension)
114 T chemical_potential = (4.0 * _beta * (phi - 0.0) * (phi - 0.5) * (phi - 1.0)) - _kappa * laplace_phi;
115 T surface_tension_force[] = {chemical_potential*grad_phi[0], chemical_potential*grad_phi[1]};
116
117 // F_b (body force, e.g. bouyancy)
118 T body_force[] = {0.0, 0.0};
119
120 // F_p (pressure)
121 T pressure = blockLattice.get(iX,iY).computeRho();
122 T pressure_force[] = {-pressure / descriptors::invCs2<T,L>() * grad_rho[0], -pressure / descriptors::invCs2<T,L>() * grad_rho[1]};
123
124 // F_nu (viscous)
125 T viscous_force[] = {0.0, 0.0};
126 T rho_tmp, u_tmp[2];
127 cell.computeRhoU( rho_tmp, u_tmp );
128 T p_tmp = rho_tmp / descriptors::invCs2<T,DESCRIPTOR>();
129 T uSqr_tmp = util::normSqr<T,DESCRIPTOR::d>(u_tmp);
130 T fEq[DESCRIPTOR::q] { };
131 cell.getDynamics()->computeEquilibrium(cell, p_tmp, u_tmp, fEq);
132 for (int iPop = 0; iPop < L::q; ++iPop) {
133 T fNeq = cell[iPop] - fEq[iPop];
134 for (int iD = 0; iD < L::d; ++iD) {
135 for (int jD = 0; jD < L::d; ++jD) {
136 viscous_force[iD] += descriptors::c<L>(iPop,iD) * descriptors::c<L>(iPop,jD) * fNeq * grad_rho[jD];
137 }
138 }
139 }
140 for (int iD = 0; iD < L::d; ++iD) {
141 viscous_force[iD] *= - viscosity / rho / tau * descriptors::invCs2<T,L>();
142 }
143
144 // save force/rho to external field
145 auto force = cell.template getFieldPointer<descriptors::FORCE>();
146 for (int iD = 0; iD < L::d; ++iD) {
147 force[iD] = (surface_tension_force[iD] + body_force[iD] + pressure_force[iD] + viscous_force[iD]) / rho;
148 }
149
150 // compute u, save to external field
152 cell.computeU(u.data());
153 partnerCell.template setField<descriptors::VELOCITY>(u);
154
155 // compute relaxation time, save to external field
156
157 tau = viscosity / rho * descriptors::invCs2<T,L>() + 0.5;
158 cell.template setField<descriptors::TAU_EFF>(tau);
159 }
160 }
161 }
162}
163
164template<typename T, typename DESCRIPTOR>
167{
168 processSubDomain(blockLattice, x0, x1, y0, y1);
169}
170
172
173template<typename T, typename DESCRIPTOR>
175PhaseFieldCouplingGenerator2D(int x0_, int x1_, int y0_, int y1_,
176 T rho_L, T rho_H, T mu_L, T mu_H, T surface_tension, T interface_thickness)
177 : LatticeCouplingGenerator2D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_),
178 _rho_L(rho_L), _rho_H(rho_H), _mu_L(mu_L), _mu_H(mu_H), _surface_tension(surface_tension), _interface_thickness(interface_thickness)
179{ }
180
181template<typename T, typename DESCRIPTOR>
183 std::vector<BlockStructureD<2>* > partners) const
184{
186 this->x0,this->x1,this->y0,this->y1, _rho_L, _rho_H, _mu_L, _mu_H, _surface_tension, _interface_thickness, partners);
187}
188
189template<typename T, typename DESCRIPTOR>
194
195
196//=====================================================================================
197//============== SmagorinskyBoussinesqCouplingPostProcessor2D ===============
198//=====================================================================================
199
200template<typename T, typename DESCRIPTOR>
202SmagorinskyBoussinesqCouplingPostProcessor2D(int x0_, int x1_, int y0_, int y1_,
203 T gravity_, T T0_, T deltaTemp_, std::vector<T> dir_, T PrTurb_, T smagoPrefactor_,
204 std::vector<BlockStructureD<2>* > partners_)
205 : x0(x0_), x1(x1_), y0(y0_), y1(y1_),
206 gravity(gravity_), T0(T0_), deltaTemp(deltaTemp_),
207 dir(dir_), PrTurb(PrTurb_), smagoPrefactor(smagoPrefactor_), partners(partners_)
208{
209 this->getName() = "SmagorinskyBoussinesqCouplingPostProcessor2D";
210 // we normalize the direction of force vector
211 T normDir = T();
212 for (unsigned iD = 0; iD < dir.size(); ++iD) {
213 normDir += dir[iD]*dir[iD];
214 }
215 normDir = util::sqrt(normDir);
216 for (unsigned iD = 0; iD < dir.size(); ++iD) {
217 dir[iD] /= normDir;
218 }
219
220 for (unsigned iD = 0; iD < dir.size(); ++iD) {
221 forcePrefactor[iD] = gravity * dir[iD];
222 }
223
226}
227
228template<typename T, typename DESCRIPTOR>
231 int x0_, int x1_, int y0_, int y1_)
232{
233
234 int newX0, newX1, newY0, newY1;
235 if ( util::intersect (
236 x0, x1, y0, y1,
237 x0_, x1_, y0_, y1_,
238 newX0, newX1, newY0, newY1 ) ) {
239
240 for (int iX=newX0; iX<=newX1; ++iX) {
241 for (int iY=newY0; iY<=newY1; ++iY) {
242
243 // computation of the bousinessq force
244 auto force = blockLattice.get(iX,iY).template getFieldPointer<descriptors::FORCE>();
245 T temperatureDifference = tPartner->get(iX,iY).computeRho() - T0;
246 for (unsigned iD = 0; iD < L::d; ++iD) {
247 force[iD] = forcePrefactor[iD] * temperatureDifference;
248 }
249
250 // Velocity coupling
251 auto u = tPartner->get(iX,iY).template getField<descriptors::VELOCITY>();
252 // tau coupling
253 auto tauNS = blockLattice.get(iX,iY).template getFieldPointer<descriptors::TAU_EFF>();
254 auto tauAD = tPartner->get(iX,iY).template getFieldPointer<descriptors::TAU_EFF>();
255
257 blockLattice.get(iX,iY).computeAllMomenta(rho, u.data(), pi);
258 tPartner->get(iX,iY).template setField<descriptors::VELOCITY>(u);
259 T PiNeqNormSqr = pi[0]*pi[0] + 2.0*pi[1]*pi[1] + pi[2]*pi[2];
261 PiNeqNormSqr += pi[2]*pi[2] + pi[3]*pi[3] + 2*pi[4]*pi[4] +pi[5]*pi[5];
262 }
263 T PiNeqNorm = util::sqrt(PiNeqNormSqr);
265 T tau_mol_NS = 1. / blockLattice.get(iX,iY).getDynamics()->getParameters(blockLattice).template getOrFallback<descriptors::OMEGA>(0);
266 T tau_mol_AD = 1. / tPartner->get(iX,iY).getDynamics()->getParameters(*tPartner).template getOrFallback<descriptors::OMEGA>(0);
268 T tau_turb_NS = 0.5*(util::sqrt(tau_mol_NS*tau_mol_NS + smagoPrefactor/rho*PiNeqNorm) - tau_mol_NS);
270 tauNS[0] = tau_mol_NS+tau_turb_NS;
271
272 T tau_turb_AD = tau_turb_NS * tauTurbADPrefactor;
273 tauAD[0] = tau_mol_AD+tau_turb_AD;
274 }
275 }
276 }
277
278}
279
280template<typename T, typename DESCRIPTOR>
283{
284 processSubDomain(blockLattice, x0, x1, y0, y1);
285}
286
288
289template<typename T, typename DESCRIPTOR>
291SmagorinskyBoussinesqCouplingGenerator2D(int x0_, int x1_, int y0_, int y1_,
292 T gravity_, T T0_, T deltaTemp_, std::vector<T> dir_, T PrTurb_, T smagoPrefactor_)
293 : LatticeCouplingGenerator2D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_),
294 gravity(gravity_), T0(T0_), deltaTemp(deltaTemp_), dir(dir_), PrTurb(PrTurb_), smagoPrefactor(smagoPrefactor_)
295{ }
296
297template<typename T, typename DESCRIPTOR>
299 std::vector<BlockStructureD<2>* > partners) const
300{
302 this->x0,this->x1,this->y0,this->y1, gravity, T0, deltaTemp, dir, PrTurb, smagoPrefactor, partners);
303}
304
305template<typename T, typename DESCRIPTOR>
310
311
312//=====================================================================================
313//============== MixedScaleBoussinesqCouplingPostProcessor2D ===============
314//=====================================================================================
315
316template<typename T, typename DESCRIPTOR>
318MixedScaleBoussinesqCouplingPostProcessor2D(int x0_, int x1_, int y0_, int y1_,
319 T gravity_, T T0_, T deltaTemp_, std::vector<T> dir_, T PrTurb_,
320 std::vector<BlockStructureD<2>* > partners_)
321 : x0(x0_), x1(x1_), y0(y0_), y1(y1_),
322 gravity(gravity_), T0(T0_), deltaTemp(deltaTemp_),
323 dir(dir_), PrTurb(PrTurb_), partners(partners_)
324{
325 // we normalize the direction of force vector
326 T normDir = T();
327 for (unsigned iD = 0; iD < dir.size(); ++iD) {
328 normDir += dir[iD]*dir[iD];
329 }
330 normDir = util::sqrt(normDir);
331 for (unsigned iD = 0; iD < dir.size(); ++iD) {
332 dir[iD] /= normDir;
333 }
334
335 for (unsigned iD = 0; iD < dir.size(); ++iD) {
336 forcePrefactor[iD] = gravity * dir[iD];
337 }
338
341}
342
343template<typename T, typename DESCRIPTOR>
346 int x0_, int x1_, int y0_, int y1_)
347{
348
349 const T C_nu = 0.04;
350 const T C_alpha = 0.5;
351 const T deltaT = 1.0;
352
354
355 int newX0, newX1, newY0, newY1;
356 if ( util::intersect (
357 x0, x1, y0, y1,
358 x0_, x1_, y0_, y1_,
359 newX0, newX1, newY0, newY1 ) ) {
360
361 auto& heatFluxCache = blockLattice.template getField<HEAT_FLUX_CACHE>()[0];
362 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
363 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
364 const T temperature = tPartner->get(iX,iY).computeRho();
365 heatFluxCache[blockLattice.getCellId(iX, iY)] = temperature;
366
367 // computation of the bousinessq force
368 T temperatureDifference = temperature - T0;
369 blockLattice.get(iX,iY).template setField<descriptors::FORCE>(temperatureDifference*forcePrefactor);
370
372 blockLattice.get(iX,iY).computeU(u.data());
373 tPartner->get(iX,iY).template setField<descriptors::VELOCITY>(u);
374 }
375 }
376
377 for (int iX=newX0; iX<=newX1; ++iX) {
378 for (int iY=newY0; iY<=newY1; ++iY) {
379
380 auto u_pp = tPartner->get(iX+1, iY+1).template getField<descriptors::VELOCITY>();
381 auto u_0p = tPartner->get(iX, iY+1).template getField<descriptors::VELOCITY>();
382 auto u_np = tPartner->get(iX-1, iY+1).template getField<descriptors::VELOCITY>();
383 auto u_p0 = tPartner->get(iX+1, iY ).template getField<descriptors::VELOCITY>();
384 auto u_pn = tPartner->get(iX+1, iY-1).template getField<descriptors::VELOCITY>();
385 auto u_00 = tPartner->get(iX, iY ).template getField<descriptors::VELOCITY>();
386 auto u_0n = tPartner->get(iX, iY-1).template getField<descriptors::VELOCITY>();
387 auto u_n0 = tPartner->get(iX-1, iY ).template getField<descriptors::VELOCITY>();
388 auto u_nn = tPartner->get(iX-1, iY-1).template getField<descriptors::VELOCITY>();
389
390 const T *h_pp = & heatFluxCache[blockLattice.getCellId(iX+1, iY+1)];
391 const T *h_0p = & heatFluxCache[blockLattice.getCellId(iX, iY+1)];
392 const T *h_np = & heatFluxCache[blockLattice.getCellId(iX-1, iY+1)];
393 const T *h_p0 = & heatFluxCache[blockLattice.getCellId(iX+1, iY )];
394 const T *h_pn = & heatFluxCache[blockLattice.getCellId(iX+1, iY-1)];
395 const T *h_00 = & heatFluxCache[blockLattice.getCellId(iX, iY )];
396 const T *h_0n = & heatFluxCache[blockLattice.getCellId(iX, iY-1)];
397 const T *h_n0 = & heatFluxCache[blockLattice.getCellId(iX-1, iY )];
398 const T *h_nn = & heatFluxCache[blockLattice.getCellId(iX-1, iY-1)];
399
400 Vector<T, 2> filtered_u;
401 T filtered_h;
402 filtered_h =((h_pp[0] + 2.*h_0p[0] + h_np[0])
403 + 2.*(h_p0[0] + 2.*h_00[0] + h_n0[0])
404 + (h_pn[0] + 2.*h_0n[0] + h_nn[0]))*0.25*0.25;
405
406 filtered_u =((u_pp + 2.*u_0p + u_np)
407 + 2.*(u_p0 + 2.*u_00 + u_n0)
408 + (u_pn + 2.*u_0n + u_nn))*0.25*0.25;
409
410 Vector<T,2> filtered_u_reduced = u_00 - filtered_u;
411 Vector<T,2> filtered_heatFlux_reduced = h_00[0]*u_00 - filtered_h*filtered_u;
412
413 T cutoffKinEnergy = filtered_u_reduced[0]*filtered_u_reduced[0]
414 + filtered_u_reduced[1]*filtered_u_reduced[1];
415 T cutoffHeatFlux = filtered_heatFlux_reduced[0]*filtered_heatFlux_reduced[0]
416 + filtered_heatFlux_reduced[1]*filtered_heatFlux_reduced[1];
417
418 blockLattice.get(iX,iY).template setField<descriptors::CUTOFF_KIN_ENERGY>(util::pow(0.5*cutoffKinEnergy, 0.25));
419 tPartner->get(iX,iY).template setField<descriptors::CUTOFF_HEAT_FLUX>(util::pow(0.5*cutoffHeatFlux, 0.25));
420 // cout << cutoffKinEnergy << " " << u_00[0] << " " << u_00[1] << " " << cutoffKinEnergy_14[0] << std::endl;
421
422 // tau coupling
423 auto tauNS = blockLattice.get(iX,iY).template getField<descriptors::TAU_EFF>();
424 auto tauAD = tPartner->get(iX,iY).template getField<descriptors::TAU_EFF>();
425
427 T tau_mol_NS = 1. / blockLattice.get(iX,iY).getDynamics()->getParameters(blockLattice).template getOrFallback<descriptors::OMEGA>(0);
428 T tau_mol_AD = 1. / tPartner->get(iX,iY).getDynamics()->getParameters(*tPartner).template getOrFallback<descriptors::OMEGA>(0);
429
430 const T temperature = tPartner->get(iX,iY).computeRho();
431
432 // computation of the bousinessq force
433 T temperatureDifference = temperature - T0;
434 blockLattice.get(iX,iY).template
435 setField<descriptors::FORCE>(temperatureDifference*forcePrefactor);
436
437 auto u = tPartner->get(iX,iY).template getField<descriptors::VELOCITY>();
438 T rho, pi[util::TensorVal<DESCRIPTOR>::n], j[DESCRIPTOR::d];
439 // blockLattice.get(iX,iY).computeAllMomenta(rho, u, pi);
440 rho = blockLattice.get(iX,iY).computeRho();
441 blockLattice.get(iX,iY).computeStress(pi);
442
443 auto force = blockLattice.get(iX,iY).template getField<descriptors::FORCE>();
444
445 int iPi = 0;
446 for (int Alpha=0; Alpha<DESCRIPTOR::d; ++Alpha) {
447 for (int Beta=Alpha; Beta<DESCRIPTOR::d; ++Beta) {
448 pi[iPi] += rho/2.*(force[Alpha]*u[Beta] + u[Alpha]*force[Beta]);
449 ++iPi;
450 }
451 }
452 const Vector<T,3> piSqr = {pi[0]*pi[0], pi[1]*pi[1], pi[2]*pi[2]};
453 const T PiNeqNormSqr = piSqr[0] + 2.0*piSqr[1] + piSqr[2];
454 const T PiNeqNorm = util::sqrt(PiNeqNormSqr);
455
456 tPartner->get(iX,iY).computeJ(j);
457 const T tmp_preFactor = invCs2_g / rho / tauAD;
458 const Vector<T,2> jNeq = {(j[0] - temperature * u[0]), (j[1] - temperature * u[1])};
459 const Vector<T,2> jNeqSqr = {jNeq[0]*jNeq[0], jNeq[1]*jNeq[1]};
460 const T jNeqSqr_prefacor = 2. * 0.25 * (jNeq[0] + jNeq[1]) * (jNeq[0] + jNeq[1]);
461
462 const T TnormSqr = jNeqSqr_prefacor*PiNeqNormSqr;
463 const T Tnorm = util::sqrt(TnormSqr);
464
466 // T tau_turb_NS = 0.5*(util::sqrt(tau_mol_NS*tau_mol_NS + dynamic_cast<SmagorinskyDynamics<T,DESCRIPTOR>*>(blockLattice.get(iX,iY).getDynamics())->getPreFactor()/rho*PiNeqNorm) - tau_mol_NS);
467
468 // const T tmp_A = C_nu * util::sqrt(util::sqrt(2.)/2.) * descriptors::invCs2<T,DESCRIPTOR>() * descriptors::invCs2<T,DESCRIPTOR>() * util::sqrt(PiNeqNorm / rho) * cutoffKinEnergy_14[0];
469 // const T tmp_A_2 = tmp_A * tmp_A;
470 // const T tmp_A_4 = tmp_A_2 * tmp_A_2;
471
472 // const T tau_mol_NS_2 = tau_mol_NS * tau_mol_NS;
473 // const T tau_mol_NS_3 = tau_mol_NS_2 * tau_mol_NS;
474
475 // const T tmp_1_3 = 1./3.;
476 // const T tmp_2_13 = util::pow(2., tmp_1_3);
477 // const T tmp_3_3_12 = 3. * util::sqrt(3.);
478
479 // const T tmp_sqrtA = util::sqrt(27.*tmp_A_4-4.*tmp_A_2*tau_mol_NS_3);
480
481 // // T tau_turb_NS = 1/3 ((27 A^2 + 3 util::sqrt(3) util::sqrt(27 A^4 - 4 A^2 b^3) - 2 b^3)^(1/3)/2^(1/3) + (2^(1/3) b^2)/(27 A^2 + 3 util::sqrt(3) util::sqrt(27 A^4 - 4 A^2 b^3) - 2 b^3)^(1/3) - b)
482 // T tau_turb_NS = ( util::pow(27.*tmp_A_2 + tmp_3_3_12*util::sqrt(27.*tmp_A_4-4.*tmp_A_2*tau_mol_NS_3)-2.*tau_mol_NS_3, tmp_1_3) / tmp_2_13
483 // + (tmp_2_13*tau_mol_NS_2) / util::pow(27.*tmp_A_2+tmp_3_3_12*util::sqrt(27.*tmp_A_4-4.*tmp_A_2*tau_mol_NS_3) - 2.*tau_mol_NS_3, tmp_1_3)
484 // - tau_mol_NS
485 // ) * tmp_1_3;
486
487 // if ( tau_turb_NS != tau_turb_NS )
488 // tau_turb_NS = 0.;
489
490 //cout << tau_turb_NS << " " << 27. * tmp_A_2 << " " << 4. * tau_mol_NS_3 << " " << PiNeqNorm << " " << " " << rho << std::endl;
491
492 auto cutoffKinEnergy_14 = blockLattice.get(iX,iY).template getField<descriptors::CUTOFF_KIN_ENERGY>();
493 auto cutoffHeatFlux_14 = tPartner->get(iX,iY).template getField<descriptors::CUTOFF_HEAT_FLUX>();
494
495 const T tmp_A = C_nu * util::sqrt(util::sqrt(2.)/2.) * descriptors::invCs2<T,DESCRIPTOR>() * descriptors::invCs2<T,DESCRIPTOR>() * util::sqrt(PiNeqNorm / rho / tauNS) * cutoffKinEnergy_14;
496 const T tau_turb_NS = tmp_A;
497
498 // T tau_turb_AD = tau_turb_NS * tauTurbADPrefactor;
499 const T tmp_B = C_alpha * descriptors::invCs2<T,DESCRIPTOR>() / rho * util::sqrt(2.0 * Tnorm * invCs2_g / tauNS / tauAD) * cutoffHeatFlux_14;
500 const T tau_turb_AD = tmp_B;
501 // cout << jNeq[0] << " " << jNeq[1] << " " << util::sqrt(Tnorm * invCs2_g / tauNS / tauAD) << " " << TnormSqr << std::endl;
502
504 blockLattice.get(iX,iY).template setField<descriptors::TAU_EFF>(tau_mol_NS+tau_turb_NS);
505 tPartner->get(iX,iY).template setField<descriptors::TAU_EFF>(tau_mol_AD+tau_turb_AD);
506
507 }
508 }
509 }
510
511}
512
513template<typename T, typename DESCRIPTOR>
516{
517 processSubDomain(blockLattice, x0, x1, y0, y1);
518}
519
521
522template<typename T, typename DESCRIPTOR>
524MixedScaleBoussinesqCouplingGenerator2D(int x0_, int x1_, int y0_, int y1_,
525 T gravity_, T T0_, T deltaTemp_, std::vector<T> dir_, T PrTurb_)
526 : LatticeCouplingGenerator2D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_),
527 gravity(gravity_), T0(T0_), deltaTemp(deltaTemp_), dir(dir_), PrTurb(PrTurb_)
528{ }
529
530template<typename T, typename DESCRIPTOR>
532 std::vector<BlockStructureD<2>* > partners) const
533{
535 this->x0,this->x1,this->y0,this->y1, gravity, T0, deltaTemp, dir, PrTurb, partners);
536}
537
538template<typename T, typename DESCRIPTOR>
543
544} // namespace olb
545
546#endif
Base of a regular block.
MixedScaleBoussinesqCouplingGenerator2D(int x0_, int x1_, int y0_, int y1_, T gravity_, T T0_, T deltaTemp_, std::vector< T > dir_, T PrTurb_)
LatticeCouplingGenerator for advectionDiffusion coupling.
PostProcessor2D< T, DESCRIPTOR > * generate(std::vector< BlockStructureD< 2 > * > partners) const override
LatticeCouplingGenerator2D< T, DESCRIPTOR > * clone() const override
MixedScaleBoussinesqCouplingPostProcessor2D(int x0_, int x1_, int y0_, int y1_, T gravity_, T T0_, T deltaTemp_, std::vector< T > dir_, T PrTurb_, std::vector< BlockStructureD< 2 > * > partners_)
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
PostProcessor2D< T, DESCRIPTOR > * generate(std::vector< BlockStructureD< 2 > * > partners) const override
LatticeCouplingGenerator2D< T, DESCRIPTOR > * clone() const override
PhaseFieldCouplingGenerator2D(int x0_, int x1_, int y0_, int y1_, T rho_L, T rho_H, T mu_L, T mu_H, T surface_tension, T interface_thickness)
LatticeCouplingGenerator for advectionDiffusion coupling.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
PhaseFieldCouplingPostProcessor2D(int x0_, int x1_, int y0_, int y1_, T rho_L, T rho_H, T mu_L, T mu_H, T surface_tension, T interface_thickness, std::vector< BlockStructureD< 2 > * > partners_)
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.
Interface of 2D post-processing steps.
Definition aliases.h:43
std::string & getName()
read and write access to name
LatticeCouplingGenerator2D< T, DESCRIPTOR > * clone() const override
PostProcessor2D< T, DESCRIPTOR > * generate(std::vector< BlockStructureD< 2 > * > partners) const override
SmagorinskyBoussinesqCouplingGenerator2D(int x0_, int x1_, int y0_, int y1_, T gravity_, T T0_, T deltaTemp_, std::vector< T > dir_, T PrTurb_, T smagoPrefactor_)
LatticeCouplingGenerator for advectionDiffusion coupling.
SmagorinskyBoussinesqCouplingPostProcessor2D(int x0_, int x1_, int y0_, int y1_, T gravity_, T T0_, T deltaTemp_, std::vector< T > dir_, T PrTurb_, T smagoPrefactor_, std::vector< BlockStructureD< 2 > * > partners_)
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
Plain old scalar vector.
constexpr const T * data() const any_platform
Definition vector.h:172
constexpr T invCs2() any_platform
Definition functions.h:107
constexpr T t(unsigned iPop, tag::CUM) any_platform
Definition cum.h:108
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83
Expr sqrt(Expr x)
Definition expr.cpp:225
Expr min(Expr a, Expr b)
Definition expr.cpp:249
Expr max(Expr a, Expr b)
Definition expr.cpp:245
auto normSqr(const ARRAY_LIKE &u) any_platform
Compute norm square of a d-dimensional vector.
Definition util.h:145
Expr pow(Expr base, Expr exp)
Definition expr.cpp:235
bool intersect(int x0, int x1, int y0, int y1, int x0_, int x1_, int y0_, int y1_, int &newX0, int &newX1, int &newY0, int &newY1)
Definition util.h:85
Top level namespace for all of OpenLB.
Vector(T &&t, Ts &&... ts) -> Vector< std::remove_cvref_t< T >, 1+sizeof...(Ts)>
constexpr T norm(const ScalarVector< T, D, IMPL > &a) any_platform
Euclidean vector norm.
Compute number of elements of a symmetric d-dimensional tensor.
Definition util.h:216
Set of functions commonly used in LB computations – header file.