165 int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_)
168 int newX0, newX1, newY0, newY1, newZ0, newZ1;
170 x0, x1, y0, y1, z0, z1,
171 x0_, x1_, y0_, y1_, z0_, z1_,
172 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
175 auto& phi_cache = blockLattice.template getField<PHI_CACHE>()[0];
176 for (
int iX=newX0-1; iX<=newX1+1; ++iX) {
177 for (
int iY=newY0-1; iY<=newY1+1; ++iY) {
178 for (
int iZ=newZ0-1; iZ<=newZ1+1; ++iZ) {
184 for (
int iX=newX0; iX<=newX1; ++iX) {
185 for (
int iY=newY0; iY<=newY1; ++iY) {
186 for (
int iZ=newZ0; iZ<=newZ1; ++iZ) {
187 T phi = phi_cache[blockLattice.
getCellId(iX, iY, iZ)];
190 T rho = _rho_L + phi * _delta_rho;
193 T viscosity = _mu_L + phi * (_mu_H - _mu_L);
196 auto tau = blockLattice.
get(iX,iY,iZ).template getFieldPointer<descriptors::TAU_EFF>();
201 for (
int iPop = 1; iPop < L::q; ++iPop) {
202 int nextX = iX + descriptors::c<L>(iPop,0);
203 int nextY = iY + descriptors::c<L>(iPop,1);
204 int nextZ = iZ + descriptors::c<L>(iPop,2);
205 T neighbor_phi = phi_cache[blockLattice.
getCellId(nextX, nextY, nextZ)];
207 laplace_phi += (neighbor_phi - phi) * descriptors::t<T,L>(iPop);
208 neighbor_phi *= descriptors::t<T,L>(iPop);
209 grad_phi += neighbor_phi * descriptors::c<L>(iPop);
211 grad_phi *= descriptors::invCs2<T,L>();
212 laplace_phi *= 2.0 * descriptors::invCs2<T,L>();
218 T norm_grad_phi =
util::max(
norm(grad_phi), std::numeric_limits<T>::epsilon());
219 tPartner->get(iX,iY,iZ).template setField<descriptors::INTERPHASE_NORMAL>(grad_phi / norm_grad_phi);
223 T chemical_potential = (4.0 * _beta * (phi - 0.0) * (phi - 0.5) * (phi - 1.0)) - _kappa * laplace_phi;
224 Vector<T,3> surface_tension_force = chemical_potential * grad_phi;
230 T pressure = blockLattice.
get(iX,iY,iZ).computeRho();
231 Vector<T,3> pressure_force = -pressure / descriptors::invCs2<T,L>() * grad_rho;
236 blockLattice.
get(iX,iY,iZ).computeRhoU( rho_tmp, u_tmp );
237 T p_tmp = rho_tmp / descriptors::invCs2<T,DESCRIPTOR>();
238 T uSqr_tmp = util::normSqr<T,DESCRIPTOR::d>(u_tmp);
239 for (
int iPop = 0; iPop < L::q; ++iPop) {
240 T fEq = blockLattice.
get(iX,iY,iZ).getDynamics()->computeEquilibrium( iPop, p_tmp, u_tmp );
241 T fNeq = blockLattice.
get(iX,iY,iZ)[iPop] - fEq;
242 for (
int iD = 0; iD < L::d; ++iD) {
243 for (
int jD = 0; jD < L::d; ++jD) {
244 viscous_force[iD] += descriptors::c<L>(iPop,iD) * descriptors::c<L>(iPop,jD) * fNeq * grad_rho[jD];
248 viscous_force *= -viscosity / rho / tau[0] * descriptors::invCs2<T,L>();
251 blockLattice.
get(iX,iY,iZ).template setField<descriptors::FORCE>(
252 (surface_tension_force + body_force + pressure_force + viscous_force) / rho
256 auto u = tPartner->get(iX,iY,iZ).template getField<descriptors::VELOCITY>();
257 blockLattice.
get(iX,iY,iZ).computeU(u.data());
258 tPartner->get(iX,iY,iZ).template setField<descriptors::VELOCITY>(u);
261 tau[0] = viscosity / rho * descriptors::invCs2<T,L>() + 0.5;
336 int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_)
339 int newX0, newX1, newY0, newY1, newZ0, newZ1;
341 x0, x1, y0, y1, z0, z1,
342 x0_, x1_, y0_, y1_, z0_, z1_,
343 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
345 for (
int iX=newX0; iX<=newX1; ++iX) {
346 for (
int iY=newY0; iY<=newY1; ++iY) {
347 for (
int iZ=newZ0; iZ<=newZ1; ++iZ) {
350 auto force = blockLattice.
get(iX,iY,iZ).template getFieldPointer<descriptors::FORCE>();
351 T temperatureDifference = tPartner->get(iX,iY,iZ).computeRho() - T0;
352 for (
unsigned iD = 0; iD < L::d; ++iD) {
353 force[iD] = forcePrefactor[iD] * temperatureDifference;
357 auto u = tPartner->get(iX,iY,iZ).template getField<descriptors::VELOCITY>();
360 auto tauNS = blockLattice.
get(iX,iY,iZ).template getFieldPointer<descriptors::TAU_EFF>();
361 auto tauAD = tPartner->get(iX,iY,iZ).template getFieldPointer<descriptors::TAU_EFF>();
364 blockLattice.
get(iX,iY,iZ).computeAllMomenta(rho, u.data(), pi);
365 tPartner->get(iX,iY,iZ).template setField<descriptors::VELOCITY>(u);
366 T PiNeqNormSqr = pi[0]*pi[0] + 2.0*pi[1]*pi[1] + pi[2]*pi[2];
368 PiNeqNormSqr += pi[2]*pi[2] + pi[3]*pi[3] + 2*pi[4]*pi[4] +pi[5]*pi[5];
372 T tau_mol_NS = 1. / blockLattice.
get(iX,iY,iZ).getDynamics()->getParameters(blockLattice).template getOrFallback<descriptors::OMEGA>(0);
373 T tau_mol_AD = 1. / tPartner->get(iX,iY,iZ).getDynamics()->getParameters(*tPartner).template getOrFallback<descriptors::OMEGA>(0);
375 T tau_turb_NS = 0.5*(
util::sqrt(tau_mol_NS*tau_mol_NS + smagoPrefactor/rho*PiNeqNorm) - tau_mol_NS);
376 if (tau_turb_NS != tau_turb_NS) {
380 tauNS[0] = tau_mol_NS+tau_turb_NS;
382 T tau_turb_AD = tau_turb_NS * tauTurbADPrefactor;
383 tauAD[0] = tau_mol_AD+tau_turb_AD;
449 int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_)
451 auto vel = par ? _cell.template getField<FIELD_B>() : _cell.template getField<FIELD_A>();
454 auto velXp = par ? _cellXp.template getField<FIELD_B>() : _cellXp.template getField<FIELD_A>();
455 auto velXn = par ? _cellXn.template getField<FIELD_B>() : _cellXn.template getField<FIELD_A>();
456 auto velYp = par ? _cellYp.template getField<FIELD_B>() : _cellYp.template getField<FIELD_A>();
457 auto velYn = par ? _cellYn.template getField<FIELD_B>() : _cellYn.template getField<FIELD_A>();
458 auto velZp = par ? _cellZp.template getField<FIELD_B>() : _cellZp.template getField<FIELD_A>();
459 auto velZn = par ? _cellZn.template getField<FIELD_B>() : _cellZn.template getField<FIELD_A>();
461 int newX0, newX1, newY0, newY1, newZ0, newZ1;
464 x0, x1, y0, y1, z0, z1,
465 x0_, x1_, y0_, y1_, z0_, z1_,
466 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
468 for (
int iX=newX0; iX<=newX1; ++iX) {
469 for (
int iY=newY0; iY<=newY1; ++iY) {
470 for (
int iZ=newZ0; iZ<=newZ1; ++iZ) {
471 int latticeR[4] = {iC, iX, iY, iZ};
472 T velGrad[3] = {0.,0.,0.};
473 T forceValue[3] = {0.,0.,0.};
474 T velF[3] = {0.,0.,0.};
476 auto nsCell = blockLattice.
get(iX,iY,iZ);
478 if (_forces.begin() != _forces.end()) {
483 velGrad[0] = vel[0]*(velXp[0]-vel[0]);
484 velGrad[1] = vel[0]*(velXp[1]-vel[1]);
485 velGrad[2] = vel[0]*(velXp[2]-vel[2]);
488 velGrad[0] = vel[0]*(vel[0]-velXn[0]);
489 velGrad[1] = vel[0]*(vel[1]-velXn[1]);
490 velGrad[2] = vel[0]*(vel[2]-velXn[2]);
493 velGrad[0] += vel[1]*(velYp[0]-vel[0]);
494 velGrad[1] += vel[1]*(velYp[1]-vel[1]);
495 velGrad[2] += vel[1]*(velYp[2]-vel[2]);
498 velGrad[0] += vel[1]*(vel[0]-velYn[0]);
499 velGrad[1] += vel[1]*(vel[1]-velYn[1]);
500 velGrad[2] += vel[1]*(vel[2]-velYn[2]);
503 velGrad[0] += vel[2]*(velZp[0]-vel[0]);
504 velGrad[1] += vel[2]*(velZp[1]-vel[1]);
505 velGrad[2] += vel[2]*(velZp[2]-vel[2]);
508 velGrad[0] += vel[2]*(vel[0]-velZn[0]);
509 velGrad[1] += vel[2]*(vel[1]-velZn[1]);
510 velGrad[2] += vel[2]*(vel[2]-velZn[2]);
515 auto adCell = _partnerLattice->get(x0,y0,z0);
516 f.applyForce(forceValue, &nsCell, &adCell, vel.data(), latticeR);
518 _cell.template setField<FIELD_B>(vel);
521 _cell.template setField<FIELD_A>(vel);
527 for (
int i=0; i < DESCRIPTOR::d; i++) {
528 newVel[i] = vel[i] + forceValue[i] - velGrad[i];
531 _cell.template setField<FIELD_A>(newVel);
533 _cell.template setField<FIELD_B>(newVel);
537 nsCell.computeU(velF);
539 for (
int i = 0; i < DESCRIPTOR::d; i++) {
543 _cell.template setField<FIELD_A>(newVel);
545 _cell.template setField<FIELD_B>(newVel);
721 int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_)
725 const T C_alpha = 0.5;
728 const T invCs2 = descriptors::invCs2<T,DESCRIPTOR>();
729 const T invCs2_g = descriptors::invCs2<T,descriptors::D3Q7<>>();
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 ) ) {
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;
745 T temperatureDifference = temperature - T0;
746 blockLattice.
get(iX,iY,iZ).template setField<descriptors::FORCE>(temperatureDifference*forcePrefactor);
749 blockLattice.
get(iX,iY,iZ).computeU(u.
data());
750 tPartner->get(iX,iY,iZ).template setField<descriptors::VELOCITY>(u);
755 for (
int iX=newX0; iX<=newX1; ++iX) {
756 for (
int iY=newY0; iY<=newY1; ++iY) {
757 for (
int iZ=newZ0; iZ<=newZ1; ++iZ) {
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>();
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>();
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>();
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)];
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 )];
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)];
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. *
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])
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])
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. *
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)
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)
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];
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));
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>();
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);
909 const T temperature = h_000[0];
912 auto force = blockLattice.
get(iX,iY,iZ).template getField<descriptors::FORCE>();
918 auto u = tPartner->get(iX,iY,iZ).template getFieldPointer<descriptors::VELOCITY>();
921 rho = blockLattice.
get(iX,iY,iZ).computeRho();
922 blockLattice.
get(iX,iY,iZ).computeStress(pi);
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]);
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];
936 tPartner->get(iX, iY, iZ).computeJ(j);
938 const Vector<T,3> jNeq = {(j[0] - temperature * u[0]), (j[1] - temperature * u[1]), (j[2] - temperature * u[2])};
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);
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>();
949 const T tau_turb_AD = C_alpha * invCs2 / rho *
util::sqrt(Tnorm * invCs2_g / tauNS / tauAD) * cutoffHeatFlux_14;
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);
1019 int x0_,
int x1_,
int y0_,
int y1_,
int z0_,
int z1_)
1021 auto vel = par ? _cell.template getField<FIELD_B>() : _cell.template getField<FIELD_A>();
1022 auto vel_new = par ? _cell.template getFieldPointer<FIELD_A>() : _cell.template getFieldPointer<FIELD_B>();
1024 auto velXp = par ? _cellXp.template getFieldPointer<FIELD_B>() : _cellXp.template getFieldPointer<FIELD_A>();
1025 auto velXn = par ? _cellXn.template getFieldPointer<FIELD_B>() : _cellXn.template getFieldPointer<FIELD_A>();
1026 auto velYp = par ? _cellYp.template getFieldPointer<FIELD_B>() : _cellYp.template getFieldPointer<FIELD_A>();
1027 auto velYn = par ? _cellYn.template getFieldPointer<FIELD_B>() : _cellYn.template getFieldPointer<FIELD_A>();
1028 auto velZp = par ? _cellZp.template getFieldPointer<FIELD_B>() : _cellZp.template getFieldPointer<FIELD_A>();
1029 auto velZn = par ? _cellZn.template getFieldPointer<FIELD_B>() : _cellZn.template getFieldPointer<FIELD_A>();
1031 auto forceNS = blockLattice.
get(x0,y0,z0).template getFieldPointer<descriptors::FORCE>();
1033 auto _cellNSXp = blockLattice.
get(x0+1,y0,z0);
1034 auto _cellNSXn = blockLattice.
get(x0-1,y0,z0);
1035 auto _cellNSYp = blockLattice.
get(x0,y0+1,z0);
1036 auto _cellNSYn = blockLattice.
get(x0,y0-1,z0);
1037 auto _cellNSZp = blockLattice.
get(x0,y0,z0+1);
1038 auto _cellNSZn = blockLattice.
get(x0,y0,z0-1);
1040 int newX0, newX1, newY0, newY1, newZ0, newZ1;
1045 x0, x1, y0, y1, z0, z1,
1046 x0_, x1_, y0_, y1_, z0_, z1_,
1047 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
1049 for (
int iX=newX0; iX<=newX1; ++iX) {
1050 for (
int iY=newY0; iY<=newY1; ++iY) {
1051 for (
int iZ=newZ0; iZ<=newZ1; ++iZ) {
1052 auto nsCell = blockLattice.
get(iX,iY,iZ);
1053 T porosityNS = 1. - _cell.computeRho();
1054 nsCell.template setField<POROSITY>(porosityNS);
1059 for (
int iX=newX0; iX<=newX1; ++iX) {
1060 for (
int iY=newY0; iY<=newY1; ++iY) {
1061 for (
int iZ=newZ0; iZ<=newZ1; ++iZ) {
1062 int latticeR[4] = {iC, iX, iY, iZ};
1063 T velGrad[3] = {0.,0.,0.};
1064 T forceValue[3] = {0.,0.,0.};
1065 T velF[3] = {0.,0.,0.};
1067 auto nsCell = blockLattice.
get(iX,iY,iZ);
1068 pressure = nsCell.computeRho() / descriptors::invCs2<T,DESCRIPTOR>();
1070 if (_forces.begin() != _forces.end()) {
1075 velGrad[0] = vel[0]*(velXp[0]-vel[0]);
1076 velGrad[1] = vel[0]*(velXp[1]-vel[1]);
1077 velGrad[2] = vel[0]*(velXp[2]-vel[2]);
1080 velGrad[0] = vel[0]*(vel[0]-velXn[0]);
1081 velGrad[1] = vel[0]*(vel[1]-velXn[1]);
1082 velGrad[2] = vel[0]*(vel[2]-velXn[2]);
1085 velGrad[0] += vel[1]*(velYp[0]-vel[0]);
1086 velGrad[1] += vel[1]*(velYp[1]-vel[1]);
1087 velGrad[2] += vel[1]*(velYp[2]-vel[2]);
1090 velGrad[0] += vel[1]*(vel[0]-velYn[0]);
1091 velGrad[1] += vel[1]*(vel[1]-velYn[1]);
1092 velGrad[2] += vel[1]*(vel[2]-velYn[2]);
1095 velGrad[0] += vel[2]*(velZp[0]-vel[0]);
1096 velGrad[1] += vel[2]*(velZp[1]-vel[1]);
1097 velGrad[2] += vel[2]*(velZp[2]-vel[2]);
1100 velGrad[0] += vel[2]*(vel[0]-velZn[0]);
1101 velGrad[1] += vel[2]*(vel[1]-velZn[1]);
1102 velGrad[2] += vel[2]*(vel[2]-velZn[2]);
1107 auto adCell = _partnerLattice->get(x0,y0,z0);
1108 f.applyForce(forceValue, &nsCell, &adCell, vel.data(), latticeR);
1110 _cell.template setField<FIELD_B>(vel);
1112 _cell.template setField<FIELD_A>(vel);
1117 for (
int i=0; i < DESCRIPTOR::d; i++) {
1118 vel_new[i] = vel[i] + forceValue[i] - velGrad[i];
1119 forceNS[i] = -forceValue[i];
1124 T porXp = _cellNSXp.template getField<POROSITY>();
1125 T porXn = _cellNSXn.template getField<POROSITY>();
1126 T porYp = _cellNSYp.template getField<POROSITY>();
1127 T porYn = _cellNSYn.template getField<POROSITY>();
1128 T porZp = _cellNSZp.template getField<POROSITY>();
1129 T porZn = _cellNSZn.template getField<POROSITY>();
1131 porosityForce[0] = 0.5 * pressure * (porXp - porXn);
1132 porosityForce[1] = 0.5 * pressure * (porYp - porYn);
1133 porosityForce[2] = 0.5 * pressure * (porZp - porZn);
1135 for (
int i = 0; i < DESCRIPTOR::d; i++) {
1136 forceNS[i] += porosityForce[i];
1139 nsCell.computeU(velF);
1141 for (
int i = 0; i < DESCRIPTOR::d; i++) {
1142 vel_new[i] = velF[i];