Execute post-processing step on a sublattice.
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;
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
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
525
526
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
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>();
543
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];
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;
568
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
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
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
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)
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)
static constexpr int n
result stored in n