OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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 182 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 421 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

425 : x0(x0_), x1(x1_), y0(y0_), y1(y1_),
426 gravity(gravity_), T0(T0_), deltaTemp(deltaTemp_),
427 dir(dir_), PrTurb(PrTurb_), partners(partners_)
428{
429 // we normalize the direction of force vector
430 T normDir = T();
431 for (unsigned iD = 0; iD < dir.size(); ++iD) {
432 normDir += dir[iD]*dir[iD];
433 }
434 normDir = util::sqrt(normDir);
435 for (unsigned iD = 0; iD < dir.size(); ++iD) {
436 dir[iD] /= normDir;
437 }
438
439 for (unsigned iD = 0; iD < dir.size(); ++iD) {
440 forcePrefactor[iD] = gravity * dir[iD];
441 }
442
443 tauTurbADPrefactor = descriptors::invCs2<T,descriptors::D2Q5<descriptors::VELOCITY,descriptors::TAU_EFF,descriptors::CUTOFF_HEAT_FLUX>>() / descriptors::invCs2<T,DESCRIPTOR>() / PrTurb;
444 tPartner = static_cast<BlockLattice<T,descriptors::D2Q5<descriptors::VELOCITY,descriptors::TAU_EFF,descriptors::CUTOFF_HEAT_FLUX>> *>(partners[0]);
445}
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100

References 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 187 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

188 {
189 return 0;
190 }

◆ 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 191 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.h.

192 {
193 return 0;
194 }

◆ 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 618 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

620{
621 processSubDomain(blockLattice, x0, x1, y0, y1);
622}
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 448 of file navierStokesAdvectionDiffusionCouplingPostProcessor2D.hh.

451{
452
453 const T C_nu = 0.04;
454 const T C_alpha = 0.5;
455 const T deltaT = 1.0;
456
457 const T invCs2_g = descriptors::invCs2<T,descriptors::D2Q5<descriptors::VELOCITY,descriptors::TAU_EFF,descriptors::CUTOFF_HEAT_FLUX>>();
458
459 int newX0, newX1, newY0, newY1;
460 if ( util::intersect (
461 x0, x1, y0, y1,
462 x0_, x1_, y0_, y1_,
463 newX0, newX1, newY0, newY1 ) ) {
464
465 auto& heatFluxCache = blockLattice.template getField<HEAT_FLUX_CACHE>()[0];
466 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
467 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
468 const T temperature = tPartner->get(iX,iY).computeRho();
469 heatFluxCache[blockLattice.getCellId(iX, iY)] = temperature;
470
471 // computation of the bousinessq force
472 T temperatureDifference = temperature - T0;
473 blockLattice.get(iX,iY).template setField<descriptors::FORCE>(temperatureDifference*forcePrefactor);
474
475 FieldD<T,DESCRIPTOR,descriptors::VELOCITY> u;
476 blockLattice.get(iX,iY).computeU(u.data());
477 tPartner->get(iX,iY).template setField<descriptors::VELOCITY>(u);
478 }
479 }
480
481 for (int iX=newX0; iX<=newX1; ++iX) {
482 for (int iY=newY0; iY<=newY1; ++iY) {
483
484 auto u_pp = tPartner->get(iX+1, iY+1).template getField<descriptors::VELOCITY>();
485 auto u_0p = tPartner->get(iX, iY+1).template getField<descriptors::VELOCITY>();
486 auto u_np = tPartner->get(iX-1, iY+1).template getField<descriptors::VELOCITY>();
487 auto u_p0 = tPartner->get(iX+1, iY ).template getField<descriptors::VELOCITY>();
488 auto u_pn = tPartner->get(iX+1, iY-1).template getField<descriptors::VELOCITY>();
489 auto u_00 = tPartner->get(iX, iY ).template getField<descriptors::VELOCITY>();
490 auto u_0n = tPartner->get(iX, iY-1).template getField<descriptors::VELOCITY>();
491 auto u_n0 = tPartner->get(iX-1, iY ).template getField<descriptors::VELOCITY>();
492 auto u_nn = tPartner->get(iX-1, iY-1).template getField<descriptors::VELOCITY>();
493
494 const T *h_pp = & heatFluxCache[blockLattice.getCellId(iX+1, iY+1)];
495 const T *h_0p = & heatFluxCache[blockLattice.getCellId(iX, iY+1)];
496 const T *h_np = & heatFluxCache[blockLattice.getCellId(iX-1, iY+1)];
497 const T *h_p0 = & heatFluxCache[blockLattice.getCellId(iX+1, iY )];
498 const T *h_pn = & heatFluxCache[blockLattice.getCellId(iX+1, iY-1)];
499 const T *h_00 = & heatFluxCache[blockLattice.getCellId(iX, iY )];
500 const T *h_0n = & heatFluxCache[blockLattice.getCellId(iX, iY-1)];
501 const T *h_n0 = & heatFluxCache[blockLattice.getCellId(iX-1, iY )];
502 const T *h_nn = & heatFluxCache[blockLattice.getCellId(iX-1, iY-1)];
503
504 Vector<T, 2> filtered_u;
505 T filtered_h;
506 filtered_h =((h_pp[0] + 2.*h_0p[0] + h_np[0])
507 + 2.*(h_p0[0] + 2.*h_00[0] + h_n0[0])
508 + (h_pn[0] + 2.*h_0n[0] + h_nn[0]))*0.25*0.25;
509
510 filtered_u =((u_pp + 2.*u_0p + u_np)
511 + 2.*(u_p0 + 2.*u_00 + u_n0)
512 + (u_pn + 2.*u_0n + u_nn))*0.25*0.25;
513
514 Vector<T,2> filtered_u_reduced = u_00 - filtered_u;
515 Vector<T,2> filtered_heatFlux_reduced = h_00[0]*u_00 - filtered_h*filtered_u;
516
517 T cutoffKinEnergy = filtered_u_reduced[0]*filtered_u_reduced[0]
518 + filtered_u_reduced[1]*filtered_u_reduced[1];
519 T cutoffHeatFlux = filtered_heatFlux_reduced[0]*filtered_heatFlux_reduced[0]
520 + filtered_heatFlux_reduced[1]*filtered_heatFlux_reduced[1];
521
522 blockLattice.get(iX,iY).template setField<descriptors::CUTOFF_KIN_ENERGY>(util::pow(0.5*cutoffKinEnergy, 0.25));
523 tPartner->get(iX,iY).template setField<descriptors::CUTOFF_HEAT_FLUX>(util::pow(0.5*cutoffHeatFlux, 0.25));
524 // cout << cutoffKinEnergy << " " << u_00[0] << " " << u_00[1] << " " << cutoffKinEnergy_14[0] << std::endl;
525
526 // tau coupling
527 auto tauNS = blockLattice.get(iX,iY).template getField<descriptors::TAU_EFF>();
528 auto tauAD = tPartner->get(iX,iY).template getField<descriptors::TAU_EFF>();
529
531 T tau_mol_NS = 1. / blockLattice.get(iX,iY).getDynamics()->getParameters(blockLattice).template getOrFallback<descriptors::OMEGA>(0);
532 T tau_mol_AD = 1. / tPartner->get(iX,iY).getDynamics()->getParameters(*tPartner).template getOrFallback<descriptors::OMEGA>(0);
533
534 const T temperature = tPartner->get(iX,iY).computeRho();
535
536 // computation of the bousinessq force
537 T temperatureDifference = temperature - T0;
538 blockLattice.get(iX,iY).template
539 setField<descriptors::FORCE>(temperatureDifference*forcePrefactor);
540
541 auto u = tPartner->get(iX,iY).template getField<descriptors::VELOCITY>();
542 T rho, pi[util::TensorVal<DESCRIPTOR>::n], j[DESCRIPTOR::d];
543 // blockLattice.get(iX,iY).computeAllMomenta(rho, u, pi);
544 rho = blockLattice.get(iX,iY).computeRho();
545 blockLattice.get(iX,iY).computeStress(pi);
546
547 auto force = blockLattice.get(iX,iY).template getField<descriptors::FORCE>();
548
549 int iPi = 0;
550 for (int Alpha=0; Alpha<DESCRIPTOR::d; ++Alpha) {
551 for (int Beta=Alpha; Beta<DESCRIPTOR::d; ++Beta) {
552 pi[iPi] += rho/2.*(force[Alpha]*u[Beta] + u[Alpha]*force[Beta]);
553 ++iPi;
554 }
555 }
556 const Vector<T,3> piSqr = {pi[0]*pi[0], pi[1]*pi[1], pi[2]*pi[2]};
557 const T PiNeqNormSqr = piSqr[0] + 2.0*piSqr[1] + piSqr[2];
558 const T PiNeqNorm = util::sqrt(PiNeqNormSqr);
559
560 tPartner->get(iX,iY).computeJ(j);
561 const T tmp_preFactor = invCs2_g / rho / tauAD;
562 const Vector<T,2> jNeq = {(j[0] - temperature * u[0]), (j[1] - temperature * u[1])};
563 const Vector<T,2> jNeqSqr = {jNeq[0]*jNeq[0], jNeq[1]*jNeq[1]};
564 const T jNeqSqr_prefacor = 2. * 0.25 * (jNeq[0] + jNeq[1]) * (jNeq[0] + jNeq[1]);
565
566 const T TnormSqr = jNeqSqr_prefacor*PiNeqNormSqr;
567 const T Tnorm = util::sqrt(TnormSqr);
568
570 // 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);
571
572 // 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];
573 // const T tmp_A_2 = tmp_A * tmp_A;
574 // const T tmp_A_4 = tmp_A_2 * tmp_A_2;
575
576 // const T tau_mol_NS_2 = tau_mol_NS * tau_mol_NS;
577 // const T tau_mol_NS_3 = tau_mol_NS_2 * tau_mol_NS;
578
579 // const T tmp_1_3 = 1./3.;
580 // const T tmp_2_13 = util::pow(2., tmp_1_3);
581 // const T tmp_3_3_12 = 3. * util::sqrt(3.);
582
583 // const T tmp_sqrtA = util::sqrt(27.*tmp_A_4-4.*tmp_A_2*tau_mol_NS_3);
584
585 // // 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)
586 // 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
587 // + (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)
588 // - tau_mol_NS
589 // ) * tmp_1_3;
590
591 // if ( tau_turb_NS != tau_turb_NS )
592 // tau_turb_NS = 0.;
593
594 //cout << tau_turb_NS << " " << 27. * tmp_A_2 << " " << 4. * tau_mol_NS_3 << " " << PiNeqNorm << " " << " " << rho << std::endl;
595
596 auto cutoffKinEnergy_14 = blockLattice.get(iX,iY).template getField<descriptors::CUTOFF_KIN_ENERGY>();
597 auto cutoffHeatFlux_14 = tPartner->get(iX,iY).template getField<descriptors::CUTOFF_HEAT_FLUX>();
598
599 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;
600 const T tau_turb_NS = tmp_A;
601
602 // T tau_turb_AD = tau_turb_NS * tauTurbADPrefactor;
603 const T tmp_B = C_alpha * descriptors::invCs2<T,DESCRIPTOR>() / rho * util::sqrt(2.0 * Tnorm * invCs2_g / tauNS / tauAD) * cutoffHeatFlux_14;
604 const T tau_turb_AD = tmp_B;
605 // cout << jNeq[0] << " " << jNeq[1] << " " << util::sqrt(Tnorm * invCs2_g / tauNS / tauAD) << " " << TnormSqr << std::endl;
606
608 blockLattice.get(iX,iY).template setField<descriptors::TAU_EFF>(tau_mol_NS+tau_turb_NS);
609 tPartner->get(iX,iY).template setField<descriptors::TAU_EFF>(tau_mol_AD+tau_turb_AD);
610
611 }
612 }
613 }
614
615}
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
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:89
static constexpr int n
result stored in n
Definition util.h:211

References olb::Vector< T, D >::data(), olb::BlockLattice< T, DESCRIPTOR >::get(), olb::BlockStructureD< D >::getCellId(), olb::util::intersect(), 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: