Execute post-processing step on a sublattice.
722{
723
724 const T C_nu = 0.04;
725 const T C_alpha = 0.5;
726
727
728 const T
invCs2 = descriptors::invCs2<T,DESCRIPTOR>();
729 const T invCs2_g = descriptors::invCs2<T,descriptors::D3Q7<>>();
730
731 int newX0, newX1, newY0, newY1, newZ1, newZ0;
733 x0, x1, y0, y1, z0, z1,
734 x0_, x1_, y0_, y1_, z0_, z1_,
735 newX0, newX1, newY0, newY1, newZ1, newZ0 ) ) {
736
737 auto& heatFluxCache = blockLattice.template getField<HEAT_FLUX_CACHE>()[0];
738 for (int iX=newX0-1; iX<=newX1+1; ++iX) {
739 for (int iY=newY0-1; iY<=newY1+1; ++iY) {
740 for (int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
741 const T temperature = tPartner->get(iX,iY,iZ).computeRho();
742 heatFluxCache[blockLattice.getCellId(iX, iY, iZ)] = temperature;
743
744
745 T temperatureDifference = temperature - T0;
746 blockLattice.get(iX,iY,iZ).template setField<descriptors::FORCE>(temperatureDifference*forcePrefactor);
747
748 FieldD<T,DESCRIPTOR,descriptors::VELOCITY> u;
749 blockLattice.get(iX,iY,iZ).computeU(u.data());
750 tPartner->get(iX,iY,iZ).template setField<descriptors::VELOCITY>(u);
751 }
752 }
753 }
754
755 for (int iX=newX0; iX<=newX1; ++iX) {
756 for (int iY=newY0; iY<=newY1; ++iY) {
757 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
758
759 auto u_ppp = tPartner->get(iX+1, iY+1, iZ+1).template getField<descriptors::VELOCITY>();
760 auto u_0pp = tPartner->get(iX, iY+1, iZ+1).template getField<descriptors::VELOCITY>();
761 auto u_npp = tPartner->get(iX-1, iY+1, iZ+1).template getField<descriptors::VELOCITY>();
762 auto u_p0p = tPartner->get(iX+1, iY, iZ+1).template getField<descriptors::VELOCITY>();
763 auto u_00p = tPartner->get(iX, iY, iZ+1).template getField<descriptors::VELOCITY>();
764 auto u_n0p = tPartner->get(iX-1, iY, iZ+1).template getField<descriptors::VELOCITY>();
765 auto u_pnp = tPartner->get(iX+1, iY-1, iZ+1).template getField<descriptors::VELOCITY>();
766 auto u_0np = tPartner->get(iX, iY-1, iZ+1).template getField<descriptors::VELOCITY>();
767 auto u_nnp = tPartner->get(iX-1, iY-1, iZ+1).template getField<descriptors::VELOCITY>();
768
769 auto u_pp0 = tPartner->get(iX+1, iY+1, iZ ).template getField<descriptors::VELOCITY>();
770 auto u_0p0 = tPartner->get(iX, iY+1, iZ ).template getField<descriptors::VELOCITY>();
771 auto u_np0 = tPartner->get(iX-1, iY+1, iZ ).template getField<descriptors::VELOCITY>();
772 auto u_p00 = tPartner->get(iX+1, iY, iZ ).template getField<descriptors::VELOCITY>();
773 auto u_000 = tPartner->get(iX, iY, iZ ).template getField<descriptors::VELOCITY>();
774 auto u_n00 = tPartner->get(iX-1, iY, iZ ).template getField<descriptors::VELOCITY>();
775 auto u_pn0 = tPartner->get(iX+1, iY-1, iZ ).template getField<descriptors::VELOCITY>();
776 auto u_0n0 = tPartner->get(iX, iY-1, iZ ).template getField<descriptors::VELOCITY>();
777 auto u_nn0 = tPartner->get(iX-1, iY-1, iZ ).template getField<descriptors::VELOCITY>();
778
779 auto u_ppn = tPartner->get(iX+1, iY+1, iZ-1).template getField<descriptors::VELOCITY>();
780 auto u_0pn = tPartner->get(iX, iY+1, iZ-1).template getField<descriptors::VELOCITY>();
781 auto u_npn = tPartner->get(iX-1, iY+1, iZ-1).template getField<descriptors::VELOCITY>();
782 auto u_p0n = tPartner->get(iX+1, iY, iZ-1).template getField<descriptors::VELOCITY>();
783 auto u_00n = tPartner->get(iX, iY, iZ-1).template getField<descriptors::VELOCITY>();
784 auto u_n0n = tPartner->get(iX-1, iY, iZ-1).template getField<descriptors::VELOCITY>();
785 auto u_pnn = tPartner->get(iX+1, iY-1, iZ-1).template getField<descriptors::VELOCITY>();
786 auto u_0nn = tPartner->get(iX, iY-1, iZ-1).template getField<descriptors::VELOCITY>();
787 auto u_nnn = tPartner->get(iX-1, iY-1, iZ-1).template getField<descriptors::VELOCITY>();
788
789 const T *h_ppp = & heatFluxCache[blockLattice.getCellId(iX+1, iY+1, iZ+1)];
790 const T *h_0pp = & heatFluxCache[blockLattice.getCellId(iX, iY+1, iZ+1)];
791 const T *h_npp = & heatFluxCache[blockLattice.getCellId(iX-1, iY+1, iZ+1)];
792 const T *h_p0p = & heatFluxCache[blockLattice.getCellId(iX+1, iY, iZ+1)];
793 const T *h_pnp = & heatFluxCache[blockLattice.getCellId(iX+1, iY-1, iZ+1)];
794 const T *h_00p = & heatFluxCache[blockLattice.getCellId(iX, iY, iZ+1)];
795 const T *h_0np = & heatFluxCache[blockLattice.getCellId(iX, iY-1, iZ+1)];
796 const T *h_n0p = & heatFluxCache[blockLattice.getCellId(iX-1, iY, iZ+1)];
797 const T *h_nnp = & heatFluxCache[blockLattice.getCellId(iX-1, iY-1, iZ+1)];
798
799 const T *h_pp0 = & heatFluxCache[blockLattice.getCellId(iX+1, iY+1, iZ )];
800 const T *h_0p0 = & heatFluxCache[blockLattice.getCellId(iX, iY+1, iZ )];
801 const T *h_np0 = & heatFluxCache[blockLattice.getCellId(iX-1, iY+1, iZ )];
802 const T *h_p00 = & heatFluxCache[blockLattice.getCellId(iX+1, iY, iZ )];
803 const T *h_pn0 = & heatFluxCache[blockLattice.getCellId(iX+1, iY-1, iZ )];
804 const T *h_000 = & heatFluxCache[blockLattice.getCellId(iX, iY, iZ )];
805 const T *h_0n0 = & heatFluxCache[blockLattice.getCellId(iX, iY-1, iZ )];
806 const T *h_n00 = & heatFluxCache[blockLattice.getCellId(iX-1, iY, iZ )];
807 const T *h_nn0 = & heatFluxCache[blockLattice.getCellId(iX-1, iY-1, iZ )];
808
809 const T *h_ppn = & heatFluxCache[blockLattice.getCellId(iX+1, iY+1, iZ-1)];
810 const T *h_0pn = & heatFluxCache[blockLattice.getCellId(iX, iY+1, iZ-1)];
811 const T *h_npn = & heatFluxCache[blockLattice.getCellId(iX-1, iY+1, iZ-1)];
812 const T *h_p0n = & heatFluxCache[blockLattice.getCellId(iX+1, iY, iZ-1)];
813 const T *h_pnn = & heatFluxCache[blockLattice.getCellId(iX+1, iY-1, iZ-1)];
814 const T *h_00n = & heatFluxCache[blockLattice.getCellId(iX, iY, iZ-1)];
815 const T *h_0nn = & heatFluxCache[blockLattice.getCellId(iX, iY-1, iZ-1)];
816 const T *h_n0n = & heatFluxCache[blockLattice.getCellId(iX-1, iY, iZ-1)];
817 const T *h_nnn = & heatFluxCache[blockLattice.getCellId(iX-1, iY-1, iZ-1)];
818
819
820
821
822
823
824
825
826
827
828
829
830 Vector<T,3> filtered_u;
831 T filtered_h = (
832 (
833 ( h_ppp[0] + 2. * h_0pp[0] + h_npp[0]) + 2.*
834 ( h_p0p[0] + 2. * h_00p[0] + h_n0p[0]) +
835 ( h_pnp[0] + 2. * h_0np[0] + h_nnp[0])
836 ) * 0.25 * 0.25 + 2. *
837
838 (
839 ( h_pp0[0] + 2. * h_0p0[0] + h_np0[0]) + 2.*
840 ( h_p00[0] + 2. * h_000[0] + h_n00[0]) +
841 ( h_pn0[0] + 2. * h_0n0[0] + h_nn0[0])
842 ) * 0.25 * 0.25 +
843
844 (
845 ( h_ppn[0] + 2. * h_0pn[0] + h_npn[0]) + 2.*
846 ( h_p0n[0] + 2. * h_00n[0] + h_n0n[0]) +
847 ( h_pnn[0] + 2. * h_0nn[0] + h_nnn[0])
848 ) * 0.25 * 0.25
849 ) * 0.25;
850
851
852 filtered_u = (
853 (
854 ( u_ppp + 2. * u_0pp + u_npp) + 2.*
855 ( u_p0p + 2. * u_00p + u_n0p) +
856 ( u_pnp + 2. * u_0np + u_nnp)
857 ) * 0.25 * 0.25 + 2. *
858
859 (
860 ( u_pp0 + 2. * u_0p0 + u_np0) + 2.*
861 ( u_p00 + 2. * u_000 + u_n00) +
862 ( u_pn0 + 2. * u_0n0 + u_nn0)
863 ) * 0.25 * 0.25 +
864
865 (
866 ( u_ppn + 2. * u_0pn + u_npn) + 2.*
867 ( u_p0n + 2. * u_00n + u_n0n) +
868 ( u_pnn + 2. * u_0nn + u_nnn)
869 ) * 0.25 * 0.25
870 ) * 0.25;
871
872
873
874
875
876
877 const Vector<T,3> filtered_u_reduced = u_000 - filtered_u;
878 const Vector<T,3> filtered_heatFlux_reduced = u_000*h_000[0] - filtered_u*filtered_h;
879 T cutoffKinEnergy = filtered_u_reduced[0] * filtered_u_reduced[0]
880 + filtered_u_reduced[1] * filtered_u_reduced[1]
881 + filtered_u_reduced[2] * filtered_u_reduced[2];
882 T cutoffHeatFlux = filtered_heatFlux_reduced[0] * filtered_heatFlux_reduced[0]
883 + filtered_heatFlux_reduced[1] * filtered_heatFlux_reduced[1]
884 + filtered_heatFlux_reduced[2] * filtered_heatFlux_reduced[2];
885
886
887
888
889
890 blockLattice.get(iX,iY,iZ).template setField<descriptors::CUTOFF_KIN_ENERGY>(
util::pow(0.5*cutoffKinEnergy, 0.25));
891 tPartner->get(iX,iY,iZ).template setField<descriptors::CUTOFF_HEAT_FLUX>(
util::pow(0.5*cutoffHeatFlux, 0.25));
892
893
894
895
896
897
898 auto tauNS = blockLattice.get(iX,iY,iZ).template getField<descriptors::TAU_EFF>();
899 auto tauAD = tPartner->get(iX,iY,iZ).template getField<descriptors::TAU_EFF>();
900
901
902
903
904
906 T tau_mol_NS = 1. / blockLattice.get(iX, iY, iZ).getDynamics()->getParameters(blockLattice).template getOrFallback<descriptors::OMEGA>(0);
907 T tau_mol_AD = 1. / tPartner->get(iX, iY, iZ).getDynamics()->getParameters(*tPartner).template getOrFallback<descriptors::OMEGA>(0);
908
909 const T temperature = h_000[0];
910
911
912 auto force = blockLattice.get(iX,iY,iZ).template getField<descriptors::FORCE>();
913
914
915
916
917
918 auto u = tPartner->get(iX,iY,iZ).template getFieldPointer<descriptors::VELOCITY>();
920
921 rho = blockLattice.get(iX,iY,iZ).computeRho();
922 blockLattice.get(iX,iY,iZ).computeStress(pi);
923
924 int iPi = 0;
925 const int dim = DESCRIPTOR::d;
926 for (int Alpha=0; Alpha<dim; ++Alpha) {
927 for (int Beta=Alpha; Beta<dim; ++Beta) {
928 pi[iPi] += rho/2.*(force[Alpha]*u[Beta] + u[Alpha]*force[Beta]);
929 ++iPi;
930 }
931 }
932 const T piSqr[6] = {pi[0]*pi[0], pi[1]*pi[1], pi[2]*pi[2], pi[3]*pi[3], pi[4]*pi[4], pi[5]*pi[5]};
933 const T PiNeqNormSqr = piSqr[0] + 2.0 * piSqr[1] + 2.0 * piSqr[2] + piSqr[3] + 2.0 * piSqr[4] + piSqr[5];
935
936 tPartner->get(iX, iY, iZ).computeJ(j);
937
938 const Vector<T,3> jNeq = {(j[0] - temperature * u[0]), (j[1] - temperature * u[1]), (j[2] - temperature * u[2])};
939
940 const Vector<T,6>
t = { 2.0 * jNeq[0] * pi[0], (jNeq[0] + jNeq[1]) * pi[1], (jNeq[0] + jNeq[2]) * pi[2], 2.0 * jNeq[1] * pi[3], (jNeq[1] + jNeq[2]) * pi[4], 2.0 * jNeq[2] * pi[5]};
941 const Vector<T,6> tSqr = {
t[0]*
t[0],
t[1]*
t[1],
t[2]*
t[2],
t[3]*
t[3],
t[4]*
t[4],
t[5]*
t[5]};
942 const T TnormSqr = tSqr[0] + 2.0 * tSqr[1] + 2.0 * tSqr[2] + tSqr[3] + 2.0 * tSqr[4] + tSqr[5];
943 const T Tnorm =
util::sqrt(2.0 * 0.25 * TnormSqr);
944
945 auto cutoffKinEnergy_14 = blockLattice.get(iX,iY,iZ).template getField<descriptors::CUTOFF_KIN_ENERGY>();
946 auto cutoffHeatFlux_14 = tPartner->get(iX,iY,iZ).template getField<descriptors::CUTOFF_HEAT_FLUX>();
947
949 const T tau_turb_AD = C_alpha *
invCs2 / rho *
util::sqrt(Tnorm * invCs2_g / tauNS / tauAD) * cutoffHeatFlux_14;
950
952 blockLattice.get(iX,iY,iZ).template setField<descriptors::TAU_EFF>(tau_mol_NS + tau_turb_NS);
953 tPartner->get(iX,iY,iZ).template setField<descriptors::TAU_EFF>(tau_mol_AD + tau_turb_AD);
954
955 }
956 }
957 }
958 }
959}
platform_constant Fraction t[Q]
constexpr T invCs2() any_platform
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