OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR > Class Template Reference

#include <navierStokesAdvectionDiffusionCouplingPostProcessor2D.h>

+ Inheritance diagram for olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >:
+ Collaboration diagram for olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >:

Public Member Functions

 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_)
 
int extent () const override
 Extent of application area (0 for purely local operations)
 
int extent (int whichDirection) const override
 Extent of application area along a direction (0 or 1)
 
void process (BlockLattice< T, DESCRIPTOR > &blockLattice) override
 Execute post-processing step.
 
void processSubDomain (BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
 Execute post-processing step on a sublattice.
 
- Public Member Functions inherited from olb::PostProcessor2D< T, DESCRIPTOR >
 PostProcessor2D ()
 
virtual ~PostProcessor2D ()
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
int getPriority () const
 read only access to priority
 

Additional Inherited Members

- Protected Attributes inherited from olb::PostProcessor2D< T, DESCRIPTOR >
int _priority
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >

Definition at line 137 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

Constructor & Destructor Documentation

◆ MixedScaleBoussinesqCouplingPostProcessor2D()

template<typename T , typename DESCRIPTOR >
olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >::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_ )

Definition at line 317 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

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
340 tPartner = static_cast<BlockLattice<T,descriptors::D2Q5<descriptors::VELOCITY,descriptors::TAU_EFF,descriptors::CUTOFF_HEAT_FLUX>> *>(partners[0]);
341}
constexpr T invCs2() any_platform
Definition functions.h:107
Expr sqrt(Expr x)
Definition expr.cpp:225

References olb::descriptors::invCs2(), and olb::util::sqrt().

+ Here is the call graph for this function:

Member Function Documentation

◆ extent() [1/2]

template<typename T , typename DESCRIPTOR >
int olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >::extent ( ) const
inlineoverridevirtual

Extent of application area (0 for purely local operations)

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 142 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

143 {
144 return 0;
145 }

◆ extent() [2/2]

template<typename T , typename DESCRIPTOR >
int olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >::extent ( int direction) const
inlineoverridevirtual

Extent of application area along a direction (0 or 1)

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 146 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

147 {
148 return 0;
149 }

◆ process()

template<typename T , typename DESCRIPTOR >
void olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >::process ( BlockLattice< T, DESCRIPTOR > & blockLattice)
overridevirtual

Execute post-processing step.

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 514 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

516{
517 processSubDomain(blockLattice, x0, x1, y0, y1);
518}
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.

◆ processSubDomain()

template<typename T , typename DESCRIPTOR >
void olb::MixedScaleBoussinesqCouplingPostProcessor2D< T, DESCRIPTOR >::processSubDomain ( BlockLattice< T, DESCRIPTOR > & blockLattice,
int x0_,
int x1_,
int y0_,
int y1_ )
overridevirtual

Execute post-processing step on a sublattice.

Molecular realaxation time

Turbulent realaxation time

Effective realaxation time

Implements olb::PostProcessor2D< T, DESCRIPTOR >.

Definition at line 344 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

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}
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
Vector< typename FIELD::template value_type< T >, DESCRIPTOR::template size< FIELD >() > FieldD
Vector storing a single field instance.
Definition vector.h:480
static constexpr int n
result stored in n
Definition util.h:217

References olb::Vector< T, Size >::data(), olb::util::intersect(), olb::descriptors::invCs2(), olb::util::pow(), and olb::util::sqrt().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: