8#ifndef PECLET_FLOW_FLOW_IBM_PHASE_CHANGE_HPP
9#define PECLET_FLOW_FLOW_IBM_PHASE_CHANGE_HPP
15 if constexpr (Grid::collocated)
16 throw std::runtime_error(
17 "enable_phase_change: rungs P0/P1 are STAGGERED-ONLY (the collocated variable-density "
18 "pair has not been composed with the divergence-source deposit).");
21 throw std::runtime_error(
22 "enable_phase_change: an immersed solid is out of scope at rungs P0/P1 (the source "
23 "deposit and the regression would need the solid-clipped flux polygons of rung V5a's "
24 "follow-on). Use an all-fluid set_pressure_geometry.");
26 throw std::runtime_error(
27 "enable_phase_change is not composable with enable_vof_momentum at this rung: both own "
28 "the head of the step, and momentum consistency would have to carry the interfacial mass "
29 "transfer in its own fluxes.");
30 if (!(rhoG > 0.0) || !(rhoL > 0.0))
31 throw std::runtime_error(
"enable_phase_change: both phase densities must be > 0");
33 throw std::runtime_error(
"enable_phase_change: the latent heat h_lv must be > 0");
53 if (pcArea_.extent(0) != n_) {
54 pcArea_ =
CCField(
"pc_area", n_);
55 pcNrm_[0] =
CCField(
"pc_nx", n_);
56 pcNrm_[1] =
CCField(
"pc_ny", n_);
57 pcNrm_[2] =
CCField(
"pc_nz", n_);
60 pcCnew_ =
CCField(
"pc_cnew", n_);
61 pcDefic_ =
CCField(
"pc_defic", n_);
75 Kokkos::deep_copy(pcMdot_, v * u_.mdotToInt());
83 const double k = u_.mdotToInt();
85 std::vector<double> vi(v.size());
86 for (std::size_t i = 0; i < v.size(); ++i)
100 if (!u_.tRefSet || (needRho && !u_.rhoRefSet))
101 throw std::runtime_error(
103 ": under a physical domain this writes a dimensional value into a field, converted once "
104 "with the reference scales; call set_rho and set_dt first (the first of each pins the "
105 "scale, and a field converted before that would be left in the wrong units)");
111 pcRhoG_ = pcRhoGPhys_ * u_.rhoToInt();
112 pcRhoL_ = pcRhoLPhys_ * u_.rhoToInt();
113 pcHlv_ = pcHlvPhys_ * u_.latentToInt();
114 pcKg_ = pcKgPhys_ * u_.condToInt();
115 pcKl_ = pcKlPhys_ * u_.condToInt();
116 pcRint_ = pcRintPhys_ * u_.rintToInt();
117 pcRcpG_ = pcRcpGPhys_ * u_.rcpToInt();
118 pcRcpL_ = pcRcpLPhys_ * u_.rcpToInt();
120 if (vofEnergy_.initialized())
121 vofEnergy_.setPhaseRcp(pcRcpG_, pcRcpL_);
128 double kl,
double Rint) {
131 throw std::runtime_error(
"set_phase_change_thermal: no scalar named '" + tname +
132 "' (call add_scalar first)");
134 throw std::invalid_argument(
"set_phase_change_thermal: '" + tname +
135 "' is a cut-cell scalar; the phase-change energy path takes a "
136 "legacy scalar only (doc/scalar_ibm_design.md §8.1)");
175 if (mode < 0 || mode > 7)
176 throw std::runtime_error(
177 "set_phase_change_area: mode must be 0 (PLIC/MYC), 1 (cascade metric), 2 (cascade "
178 "normal), 3 (cascade footprint) or 4-7 (the joined marching-tetrahedra sheet: 4 colour/"
179 "centroid, 5 colour/split, 6 PLIC-distance/centroid, 7 PLIC-distance/split)");
191 throw std::runtime_error(
"vof_interface_area: VoF is not enabled (call enable_vof first)");
195 const I3 e3 =
I3{e3_.x, e3_.y, e3_.z};
197 const long sy = e3.x, sz = (long)e3.x * e3.y;
202 const vof::VofMetric gme = u_.vofMetric();
203 Kokkos::parallel_reduce(
204 "peclet::flow::vof_area_plic",
206 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& acc) {
207 const long i = (long)x + (
long)y * e3.x + (long)z * sz;
211 for (
int kk = -1; kk <= 1; ++kk)
212 for (
int jj = -1; jj <= 1; ++jj)
213 for (
int ii = -1; ii <= 1; ++ii)
214 st[vof::plicSt(ii + 1, jj + 1, kk + 1)] = c(i + ii + jj * sy + kk * sz);
216 vof::mycNormal(st, m);
224#ifdef PECLET_FLOW_MPI
227 MPI_Allreduce(&a, &gsum, 1, MPI_DOUBLE, MPI_SUM, comm_);
231 return a * u_.areaToPhys();
237 if (!pcAreaMc_.ready())
238 pcAreaMc_.init(nx_, ny_, nz_,
kVofG);
240 const auto m = pcAreaMc_.compute(vofAdv_.colour(), pcAreaMode_);
242 s.interfacial = m.cells;
243 s.hf = m.cells - m.orphanCells;
246 s.noEstimate = m.orphanCells;
248 pcMcOrphanArea_ = m.orphanArea;
251 pcMcOrphanArea_ = 0.0;
252 if (!pcAreaC_.ready())
253 pcAreaC_.init(nx_, ny_, nz_,
kVofG);
255 pcAreaC_.pureEps = vofAdv_.wispEps;
256 return pcAreaC_.compute(vofAdv_.colour(), pcAreaMode_);
268 throw std::runtime_error(
269 "set_phase_change_energy: call set_phase_change_thermal first (the consistent transport "
270 "is for the energy scalar it names)");
271 if (!(rcpGas > 0.0) || !(rcpLiquid > 0.0))
272 throw std::runtime_error(
"set_phase_change_energy: both phase rho*c_p must be > 0");
273 pcRcpGPhys_ = rcpGas;
274 pcRcpLPhys_ = rcpLiquid;
276 if (pcKcell_.extent(0) != n_) {
277 pcKcell_ =
CCField(
"pc_k", n_);
278 pcRcp_ =
CCField(
"pc_rcp", n_);
284 if (!vofEnergy_.initialized())
285 vofEnergy_.init(vofAdv_, pcRcpG_, pcRcpL_);
287 vofEnergy_.setPhaseRcp(pcRcpG_, pcRcpL_);
295 vofEnergy_.energyMuscl = on;
300 return vofEnergy_.energyMuscl;
306 if (!pcTName_.empty() &&
hasScalar(pcTName_))
319 if (on && pcClsPrev_.extent(0) != n_) {
320 pcClsPrev_ =
CCField(
"pc_cls_prev", n_);
321 Kokkos::deep_copy(pcClsPrev_, -1.0);
333 pcCarryConserve_ = on;
334 if (on && pcCarrySrc_.extent(0) != n_) {
335 pcCarrySrc_ =
CCField(
"pc_carry_src", n_);
336 Kokkos::deep_copy(pcCarrySrc_, 0.0);
342 return pcCarryConserve_;
348 pcFitKappa_ = kappa / u_.curvToPhys();
353 return pcFitKappa_ * u_.curvToPhys();
359 if (order != 1 && order != 2)
360 throw std::runtime_error(
"set_phase_change_energy_order: order must be 1 or 2");
369 return (pcMdotOperator_ && pcGfmOrder_ == 2 && pcCurvDist_ && pcCarryConserve_) ? 2 : 1;
375 if (on && pcRint_ != 0.0 && !pcThermal_)
376 throw std::runtime_error(
"set_phase_change_mdot_operator: needs the thermal mass flux");
377 pcMdotOperator_ = on;
378 if (on && pcMdotFit_.extent(0) != n_)
379 pcMdotFit_ =
CCField(
"pc_mdot_fit", n_);
384 return pcMdotOperator_;
390 if (order != 1 && order != 2)
391 throw std::runtime_error(
"set_phase_change_gfm_order: order must be 1 or 2");
404 if (on && pcKappa_.extent(0) != n_)
405 pcKappa_ =
CCField(
"pc_kappa", n_);
406 pcMaskFresh_ =
false;
417 pcDepositFallback_ = on;
422 return pcDepositFallback_;
427 return pcQOperator_ * u_.powerToPhys();
432 return pcQOrphan_ * u_.powerToPhys();
450 return (pcEnergy_ ? u_.energyToPhys() : u_.volToPhys()) * u_.vol;
459 const double kq = pcEnergy_ ? u_.powerToPhys() : u_.volToPhys() * u_.divToPhys();
465 b.dEoverwriteNew *= ke;
476 const long sx = 1, sy = e_.x, sz = (long)e_.x * e_.y;
481 Kokkos::parallel_reduce(
482 "peclet::flow::pc_band_div",
484 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& acc) {
485 const long i = (long)x + (
long)y * sy + (long)z * sz;
488 const double d = (ox(i + sx) *
U(i + sx) - ox(i) *
U(i)) +
489 (oy(i + sy) * V(i + sy) - oy(i) * V(i)) +
490 (oz(i + sz) * W(i + sz) - oz(i) * W(i));
491 acc = Kokkos::fmax(acc, Kokkos::fabs(d));
493 Kokkos::Max<double>(m));
495 return Kokkos::fmax(m, 0.0);
503 CCField kf = pcKcell_, rf = pcRcp_;
505 const double kg = pcKg_, kl = pcKl_, rg = pcRcpG_, rl = pcRcpL_;
506 Kokkos::parallel_for(
507 "peclet::flow::pc_energy_props",
509 KOKKOS_LAMBDA(
int x,
int y,
int z) {
510 const long i = (long)x + (
long)y * e.x + (long)z * (
long)e.x * e.y;
511 const double cl = Kokkos::fmin(Kokkos::fmax(c(i), 0.0), 1.0);
523 if (pcUser_.extent(0) != n_)
525 const double k = u_.divToInt();
527 std::vector<double> vi(v.size());
528 for (std::size_t i = 0; i < v.size(); ++i)
546 if (pcSink_.extent(0) != n_)
553 Kokkos::parallel_reduce(
554 "peclet::flow::pc_sink_weight",
556 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& a) {
557 a += wv((
long)x + (
long)y * e.x + (
long)z * (
long)e.x * e.y);
561#ifdef PECLET_FLOW_MPI
564 MPI_Allreduce(&acc, &g, 1, MPI_DOUBLE, MPI_SUM, comm_);
569 throw std::runtime_error(
"set_divergence_sink: the weights must have a positive global sum");
581 const double dt = dtPhysArg * u_.timeToInt();
593 if (pcBudgetOn_ && pcThermal_ && pcClsPrev_.extent(0) == n_) {
595 if (sc.dmask.extent(0) == n_)
616 double mn = 1e300, mx = -1e300;
617 Kokkos::parallel_reduce(
618 "peclet::flow::pc_extrema",
620 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& lo,
double& hi) {
621 const long i = (long)x + (
long)y * e.x + (long)z * (
long)e.x * e.y;
622 lo = Kokkos::fmin(lo, c(i));
623 hi = Kokkos::fmax(hi, c(i));
625 Kokkos::Min<double>(mn), Kokkos::Max<double>(mx));
630 if (pcEnergy_ && vofEnergy_.initialized())
631 vofEnergy_.extrema(d.Tmin, d.Tmax);
634 const double km = u_.mdotToPhys(), ka = u_.areaToPhys(), kq = u_.powerToPhys(),
635 kv = u_.volToPhys() * u_.vol, kd = u_.divToPhys();
644 d.removedVolume *= kv;
645 d.redistributed *= kv;
653bool Solver<Grid>::pcBuildInputs() {
664 scalarFillGhosts(scalarField(pcTName_));
672 if (pcMdotOperator_ && pcThermal_ && !pcMaskFresh_) {
673 pcUpdateEnergyProps();
674 pcUpdateThermalMask();
682 if (pcAreaCg2_.extent(0) != n_)
683 pcAreaCg2_ =
CCField(
"pc_area_cascade", n_);
685 const auto as = pcAreaCascadeCompute();
686 pcDiag_.areaHf = as.hf + as.hfMixed;
687 pcDiag_.areaPv = as.pv;
688 pcDiag_.areaNone = as.noEstimate;
689 pcDiag_.areaOrphan = pcMcOrphanArea_;
690 copyInner(pcAreaCg2_, e_,
G,
CCConst(pcAreaCascadeField()), e3_, kVofG);
696void Solver<Grid>::pcOperatorDomain(
bool opMode,
bool opEnergy) {
702 if (opMode && !opEnergy && u_.physical)
703 throw std::runtime_error(
704 "set_phase_change_mdot_operator / set_phase_change_energy_order(2) under a physical "
705 "domain need set_phase_change_energy(True, rho_cp_gas, rho_cp_liquid): without it the "
706 "operator's interfacial heat is a diffusivity flux with an implicit rho*c_p of one "
707 "internal unit, which is not a physical heat capacity");
715 const long sz = (long)e_.x * e_.y;
717 double mn = 0.0, mx = 0.0;
722 Kokkos::parallel_reduce(
723 "peclet::flow::pc_mdot_extrema",
725 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& lo,
double& hi) {
726 const long i = (long)x + (
long)y * e.x + (long)z * sz;
728 lo = Kokkos::fmin(lo, md(i));
729 hi = Kokkos::fmax(hi, md(i));
732 Kokkos::Min<double>(mn), Kokkos::Max<double>(mx));
735 pcDiag_.mdotMin = mn;
736 pcDiag_.mdotMax = mx;
740void Solver<Grid>::pcExchangeInterfaceGhosts() {
748 for (
int d = 0; d < 3; ++d)
749 fillGhosts(pcNrm_[d]);
750 pcZeroDomainGhosts(pcMdot_);
751 pcZeroDomainGhosts(pcArea_);
752 pcZeroDomainGhosts(pcDep_);
753 pcZeroDomainGhosts(pcTgt_);
754 for (
int d = 0; d < 3; ++d)
755 pcZeroDomainGhosts(pcNrm_[d]);
760 const bool cascadeArea = pcBuildInputs();
763 const long sy = e_.x, sz = (long)e_.x * e_.y;
764 CCField mdot = pcMdot_, area = pcArea_, dep = pcDep_, tgt = pcTgt_;
767 const bool thermal = pcThermal_;
770 const bool quad = pcQuadFit_;
771 const bool depFallback = pcDepositFallback_;
772 const double Tsat = pcTsat_, kg = pcKg_, kl = pcKl_, hlv = pcHlv_, Rint = pcRint_;
773 const double kapPresc = pcFitKappa_;
774 const double rhoG = pcRhoG_, rhoL = pcRhoL_;
778 const bool curvDist = pcCurvDist_ && pcKappa_.extent(0) == n_;
782 pcMdotOperator_ && thermal && pcGphi_.extent(0) == n_ && scT->
dmask.extent(0) == n_;
783 const bool opEnergy = opMode && scT->
energy && scT->
kcell.extent(0) == n_;
784 pcOperatorDomain(opMode, opEnergy);
789 const double Dconst = thermal ? scT->
D : 0.0, thMin = pcGfmThMin_, thMax = pcGfmThMax_;
790 const int gfmOrder = pcGfmOrder_;
794 const vof::VofMetric gme = u_.vofMetric();
795 const double vCell = u_.vol;
796 CCField mdotFit = opMode ? pcMdotFit_ : pcMdot_;
797 long nIface = 0, nFallback = 0;
798 double sumArea = 0.0, sumMdot = 0.0, sumQ = 0.0, sumQorph = 0.0, sumMdotFitA = 0.0;
799 Kokkos::parallel_reduce(
801 KOKKOS_LAMBDA(
int x,
int y,
int z,
long& nif,
long& nfb,
double& aacc,
double& macc,
802 double& qacc,
double& qorph,
double& mfacc) {
803 const long i = (long)x + (
long)y * e.x + (long)z * sz;
816 for (
int kk = -1; kk <= 1; ++kk)
817 for (
int jj = -1; jj <= 1; ++jj)
818 for (
int ii = -1; ii <= 1; ++ii)
819 st[vof::plicSt(ii + 1, jj + 1, kk + 1)] = c(i + ii + jj * sy + kk * sz);
821 vof::mycNormal(st, m);
822 const double al = vof::plicAlpha(m[0], m[1], m[2], c(i));
824 const double A = cascadeArea ? areaCasc(i) :
vof::plicAreaMetric(m[0], m[1], m[2], al, gme);
827 double n[3] = {1.0, 0.0, 0.0};
828 const double sMet = vof::vofPhysNormal(m, gme, n);
850 const double kapFit = curvDist ? kapF(i) : kapPresc;
852 for (
int dz = -2; dz <= 2; ++dz)
853 for (
int dy = -2; dy <= 2; ++dy)
854 for (
int dx = -2; dx <= 2; ++dx) {
855 if (dx == 0 && dy == 0 && dz == 0)
861 const double di[3] = {(double)dx, (
double)dy, (double)dz};
867 const long j = i + dx + dy * sy + dz * sz;
868 const double cj = c(j);
873 if (cj <= pureEps && phi > 0.0)
875 else if (cj >= 1.0 - pureEps && phi < 0.0)
895 const long stq[3] = {1, sy, sz};
896 double qsum = 0.0, csum = 0.0;
897 for (
int d = 0; d < 3; ++d)
898 for (
int sg = -1; sg <= 1; sg += 2) {
899 const long pc = i + (long)sg * stq[d];
902 if (!(inD(pc) > 0.5))
904 const double of = (d == 0) ? ((sg > 0) ? oxF(i + 1) : oxF(i))
905 : (d == 1) ? ((sg > 0) ? oyF(i + sy) : oyF(i))
906 : ((sg > 0) ? ozF(i + sz) : ozF(i));
909 const double ofB = (d == 0) ? ((sg > 0) ? oxF(pc + 1) : oxF(pc))
910 : (d == 1) ? ((sg > 0) ? oyF(pc + sy) : oyF(pc))
911 : ((sg > 0) ? ozF(pc + sz) : ozF(pc));
912 const long jb = pc + (long)sg * stq[d];
913 const bool behind = !(mkF(jb) > 0.5) && ofB > 0.0;
919 phic, n, d, (
double)(-sg), curvDist ? kapF(i) : 0.0, thMin, thMax, gme);
921 const double cf = (opEnergy ? kcF(pc) : Dconst) * of * row.aGamma;
922 qsum += cf * (T(pc) - Tsat);
931 if (behind && row.aBehind != 1.0) {
932 const double kb = opEnergy ? 0.5 * (kcF(pc) + kcF(jb)) : Dconst;
933 qsum += (row.aBehind - 1.0) * kb * ofB * (T(pc) - T(jb));
937 Aeff = (A > 0.0) ? A : 1.0;
942 mfacc += mdotFit(i) * A;
969 int tx = 0, ty = 0, tz = 0;
971 for (
int k = 1; k <= 2 && !found; ++k) {
972 const int ox = (int)Kokkos::round(k * n[0]);
973 const int oy = (int)Kokkos::round(k * n[1]);
974 const int oz = (int)Kokkos::round(k * n[2]);
975 if (ox == 0 && oy == 0 && oz == 0)
977 if (c(i + ox + oy * sy + oz * sz) <= pureEps) {
984 if (!found && depFallback) {
999 for (
int dz = -2; dz <= 2; ++dz)
1000 for (
int dy = -2; dy <= 2; ++dy)
1001 for (
int dx = -2; dx <= 2; ++dx) {
1002 if (dx == 0 && dy == 0 && dz == 0)
1007 const double di[3] = {(double)dx, (
double)dy, (double)dz};
1010 if (!(dp[0] * n[0] + dp[1] * n[1] + dp[2] * n[2] > 0.0))
1015 if (c(i + dx + dy * sy + dz * sz) > pureEps)
1024 }
else if (!found) {
1028 tgt(i) = (double)((tx + 2) + 5 * (ty + 2) + 25 * (tz + 2));
1031 nIface, nFallback, sumArea, sumMdot, sumQ, sumQorph, sumMdotFitA);
1033 pcQOperator_ = sumQ;
1034 pcQOrphan_ = sumQorph;
1035 pcMdotFitMean_ = sumArea > 0.0 ? sumMdotFitA / sumArea : 0.0;
1036 pcDiag_.qOperator = sumQ;
1037 pcDiag_.qOrphan = sumQorph;
1038 pcDiag_.mdotFit = pcMdotFitMean_;
1039 pcDiag_.interfaceCells = nIface;
1040 pcDiag_.fallbackCells = nFallback;
1041 pcDiag_.area = sumArea;
1042 pcDiag_.mdotMean = nIface > 0 ? sumMdot / (double)nIface : 0.0;
1044 pcExchangeInterfaceGhosts();
1047template <
class Gr
id>
1050 const long sy = e_.x, sz = (long)e_.x * e_.y;
1055 Kokkos::parallel_reduce(
1056 "peclet::flow::pc_source_gather",
1058 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& acc,
long& nc) {
1059 const long i = (long)x + (
long)y * e.x + (long)z * sz;
1061 for (
int dz = -2; dz <= 2; ++dz)
1062 for (
int dy = -2; dy <= 2; ++dy)
1063 for (
int dx = -2; dx <= 2; ++dx) {
1064 const long j = i + dx + dy * sy + dz * sz;
1065 const double dj = dep(j);
1068 const int code = (int)tgt(j);
1069 const int tx = code % 5 - 2, ty = (code / 5) % 5 - 2, tz = code / 25 - 2;
1070 if (tx + dx == 0 && ty + dy == 0 && tz + dz == 0)
1080#ifdef PECLET_FLOW_MPI
1083 MPI_Allreduce(&sum, &g, 1, MPI_DOUBLE, MPI_SUM, comm_);
1090 const double f = sum / pcSinkW_;
1092 Kokkos::parallel_for(
1093 "peclet::flow::pc_sink_apply",
1095 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1096 const long i = (long)x + (
long)y * e.x + (long)z * sz;
1097 src(i) -= f * wv(i);
1101 pcDiag_.sourceSum = sum;
1102 pcDiag_.sourceCells = ncell;
1106template <
class Gr
id>
1109 const long sy = e_.x, sz = (long)e_.x * e_.y;
1110 CCField Cf = cField_, cnew = pcCnew_, defic = pcDefic_;
1112 const double rhoL = pcRhoL_;
1115 const double vCell = u_.vol;
1116 double removed = 0.0;
1117 long ndef = 0, nexc = 0;
1118 double redist = 0.0;
1119 Kokkos::parallel_reduce(
1121 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& rem,
long& nd,
long& ne,
double& rd) {
1122 const long i = (long)x + (
long)y * e.x + (long)z * sz;
1123 const double A = ar(i);
1130 const double raw = Cf(i) - dV;
1131 const double cl = Kokkos::fmin(Kokkos::fmax(raw, 0.0), 1.0);
1133 defic(i) = raw - cl;
1135 (x >=
G && x < e.x -
G && y >=
G && y < e.y -
G && z >=
G && z < e.z -
G);
1142 rd += Kokkos::fabs(raw - cl);
1145 removed, ndef, nexc, redist);
1149 Kokkos::parallel_for(
1150 "peclet::flow::pc_regress_apply",
1152 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1153 const long i = (long)x + (
long)y * e.x + (long)z * sz;
1155 const long st[3] = {1, sy, sz};
1156 for (
int d = 0; d < 3; ++d)
1157 for (
int s = -1; s <= 1; s += 2) {
1158 const long j = i + (long)s * st[d];
1159 const double dj = df(j);
1165 const double sgn = dj < 0.0 ? -1.0 : 1.0;
1166 double n[3] = {nxv(j), nyv(j), nzv(j)};
1170 for (
int q = 0; q < 3; ++q) {
1171 const double p = sgn * n[q];
1172 const int sq = (p > 0.0) ? 1 : ((p < 0.0) ? -1 : 0);
1173 const double ct = sq == 0 ? 0.0 : cn(j + (
long)sq * st[q]);
1174 avail[q] = sq != 0 && (dj < 0.0 ? (ct > 0.0) : (ct < 1.0));
1184 pcDiag_.removedVolume = removed;
1185 pcDiag_.deficitCells = ndef;
1186 pcDiag_.excessCells = nexc;
1187 pcDiag_.redistributed = redist;
1191 Kokkos::parallel_reduce(
1192 "peclet::flow::pc_unresolved",
1194 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& acc) {
1195 const long i = (long)x + (
long)y * e.x + (long)z * sz;
1196 const double dj = df(i);
1199 const double sgn = dj < 0.0 ? -1.0 : 1.0;
1200 const long st[3] = {1, sy, sz};
1201 double n[3] = {nxv(i), nyv(i), nzv(i)};
1203 for (
int q = 0; q < 3; ++q) {
1204 const double p = sgn * n[q];
1205 const int sq = (p > 0.0) ? 1 : ((p < 0.0) ? -1 : 0);
1206 const double ct = sq == 0 ? 0.0 : cn(i + (
long)sq * st[q]);
1207 avail[q] = sq != 0 && (dj < 0.0 ? (ct > 0.0) : (ct < 1.0));
1212 acc += Kokkos::fabs(dj);
1216 pcDiag_.unresolved = unres;
1220template <
class Gr
id>
1222 if (pcKappa_.extent(0) != n_)
1223 pcKappa_ =
CCField(
"pc_kappa", n_);
1225 vofCurv_.compute(vofAdv_.colour());
1233template <
class Gr
id>
1235 if (pcInDomain_.extent(0) == n_)
1237 pcInDomain_ =
CCField(
"pc_indomain", n_);
1238 Kokkos::deep_copy(pcInDomain_, 0.0);
1241 Kokkos::parallel_for(
1242 "peclet::flow::pc_indomain",
1244 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1245 f((
long)x + (
long)y * e.x + (
long)z * (
long)e.x * e.y) = 1.0;
1252template <
class Gr
id>
1259 scalarFillGhosts(sc);
1261 const long sy = e_.x, sz = (long)e_.x * e_.y;
1262 CCField mk = sc.dmask, dv = sc.dval, tg = pcTgam_;
1263 CCField gn0 = pcGn_[0], gn1 = pcGn_[1], gn2 = pcGn_[2], gph = pcGphi_;
1266 const double kapPresc = pcFitKappa_;
1267 const vof::VofMetric gme = u_.vofMetric();
1268 const bool curvDist = pcCurvDist_ && pcKappa_.extent(0) == n_;
1270 const bool carry = pcPlaneDir_, quad = pcQuadFit_;
1271 const long syl = sy, szl = sz;
1272 Kokkos::parallel_for(
1273 "peclet::flow::pc_thermal_mask",
1275 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1276 const long i = (long)x + (
long)y * e.x + (long)z * sz;
1279 mk(i) = on ? 1.0 : 0.0;
1293 for (
int kk = -1; kk <= 1; ++kk)
1294 for (
int jj = -1; jj <= 1; ++jj)
1295 for (
int ii = -1; ii <= 1; ++ii)
1296 st[vof::plicSt(ii + 1, jj + 1, kk + 1)] = c(i + ii + jj * sy + kk * sz);
1298 vof::mycNormal(st, m);
1302 double n[3] = {0.0, 0.0, 0.0};
1303 const double sMet = vof::vofPhysNormal(m, gme, n);
1306 const double al = vof::plicAlpha(m[0], m[1], m[2], c(i));
1317 const bool gasSide = phic > 0.0;
1318 const double kapFit = curvDist ? kapF(i) : kapPresc;
1320 for (
int dz = -2; dz <= 2; ++dz)
1321 for (
int dy = -2; dy <= 2; ++dy)
1322 for (
int dx = -2; dx <= 2; ++dx) {
1323 if (dx == 0 && dy == 0 && dz == 0)
1325 const double di[3] = {(double)dx, (
double)dy, (double)dz};
1331 const long j = i + dx + dy * syl + dz * szl;
1332 const double cj = c(j);
1337 if (cj <= pureEps && phi > 0.0)
1339 }
else if (cj >= 1.0 - pureEps && phi < 0.0) {
1367 if (pcCarryConserve_ && pcCarrySrc_.extent(0) == n_)
1371 pcMaskFresh_ =
true;
1374template <
class Gr
id>
1376 for (
int face = 0; face < 6; ++face) {
1377 if (bc_[face] == 0 || !touchesGlobalFace(face))
1379 const int a = face / 2, side = face % 2;
1380 const int t1 = (a + 1) % 3, t2 = (a + 2) % 3;
1381 const int nt1 = (t1 == 0) ? nx_ : (t1 == 1) ? ny_ : nz_;
1382 const int nt2 = (t2 == 0) ? nx_ : (t2 == 1) ? ny_ : nz_;
1383 const int na = (a == 0) ? nx_ : (a == 1) ? ny_ : nz_;
1384 const long sx = 1, sy = e_.x, sz = (long)e_.x * e_.y;
1385 const long sa = (a == 0) ? sx : (a == 1) ? sy : sz;
1386 const long st1 = (t1 == 0) ? sx : (t1 == 1) ? sy : sz;
1387 const long st2 = (t2 == 0) ? sx : (t2 == 1) ? sy : sz;
1388 const int aInner = (side == 0) ?
G : (
G + na - 1);
1389 const int dir = (side == 0) ? -1 : +1;
1390 Kokkos::parallel_for(
1392 KOKKOS_LAMBDA(
int j1,
int j2) {
1393 const long base = (long)aInner * sa + (
long)j1 * st1 + (long)j2 * st2;
1394 for (
int L = 1; L <= 2; ++L)
1395 f(base + (
long)dir * L * sa) = 0.0;
1401template <
class Gr
id>
1404 const long sx = 1, sy = e_.x, sz = (long)e_.x * e_.y;
1409 const bool useRcp = pcEnergy_;
1410 const double rcpG = pcRcpG_, rcpL = pcRcpL_;
1411 double dep = 0.0, lost = 0.0;
1413 Kokkos::parallel_reduce(
1414 "peclet::flow::pc_carry_deposit", MD(
CCExec(), {
G,
G,
G}, {e.x -
G, e.y -
G, e.z -
G}),
1415 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& acc) {
1416 const long st[3] = {sx, sy, sz};
1417 const long i = (long)x + (
long)y * sy + (long)z * sz;
1421 for (
int d = 0; d < 3; ++d)
1422 for (
int sg = -1; sg <= 1; sg += 2) {
1423 const long j = i + (long)sg * st[d];
1427 const double dE = rj * (T(j) - dv(j));
1430 const double nn[3] = {gn0(j), gn1(j), gn2(j)};
1431 const double devj = T(j) - tg(j);
1432 int chosen[3] = {0, 0, 0};
1433 double w[3] = {0.0, 0.0, 0.0}, wsum = 0.0;
1434 for (
int dd = 0; dd < 3; ++dd) {
1437 const int sL = (nn[dd] > 0.0) ? -1 : +1;
1438 const double dl = T(j + (
long)sL * st[dd]) - tg(j);
1439 const double dg = T(j - (
long)sL * st[dd]) - tg(j);
1440 const int s = (dl * devj >= dg * devj) ? sL : -sL;
1441 if (mk(j + (
long)s * st[dd]) > 0.5)
1444 w[dd] = nn[dd] * nn[dd];
1449 if (chosen[d] != -sg)
1451 add += (w[d] / wsum) * dE;
1456 srcF(i) += add / ri;
1464 Kokkos::parallel_reduce(
1465 "peclet::flow::pc_carry_total", MD(
CCExec(), {
G,
G,
G}, {e.x -
G, e.y -
G, e.z -
G}),
1466 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& tot) {
1467 const long i = (long)x + (
long)y * sy + (long)z * sz;
1471 tot += ri * (T(i) - dv(i));
1475 pcCarryDeposited_ = dep;
1476 pcCarryLost_ = lost - dep;
1479template <
class Gr
id>
1482 const long sy = e_.x, sz = (long)e_.x * e_.y;
1483 CCField cOld = sc.cOld, srcF = pcCarrySrc_;
1485 Kokkos::parallel_for(
1486 "peclet::flow::pc_carry_apply",
1488 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1489 const long i = (long)x + (
long)y * sy + (long)z * sz;
1497template <
class Gr
id>
1500 const long sy = e_.x, sz = (long)e_.x * e_.y;
1503 const bool useRcp = sc.energy && sc.rcp.extent(0) == n_;
1505 const double Tsat = pcTsat_;
1506 double hOpen = 0, hLiq = 0, hMask = 0, dEo = 0, dEoN = 0, eEnt = 0, eLev = 0;
1507 long nEL = 0, nEG = 0, nLL = 0, nLG = 0, nM = 0;
1509 Kokkos::parallel_reduce(
1510 "peclet::flow::pc_budget_pre", MD(
CCExec(), {
G,
G,
G}, {e.x -
G, e.y -
G, e.z -
G}),
1511 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& a1,
double& a2,
double& a3,
double& a4,
double& a5,
1512 double& a6,
double& a7) {
1513 const long i = (long)x + (
long)y * sy + (long)z * sz;
1514 const double r = useRcp ? rcp(i) : 1.0;
1515 const double h = r * (T(i) - Tsat);
1516 const bool msk = mk(i) > 0.5;
1519 a4 += r * (dvl(i) - T(i));
1525 const double cp = cls(i);
1528 const bool wasMsk = (cp > 0.5 && cp < 1.5);
1529 if (msk && !wasMsk) {
1531 a5 += r * (dvl(i) - T(i));
1532 }
else if (!msk && wasMsk) {
1536 hOpen, hLiq, hMask, dEo, dEoN, eEnt, eLev);
1537 Kokkos::parallel_reduce(
1538 "peclet::flow::pc_budget_counts", MD(
CCExec(), {
G,
G,
G}, {e.x -
G, e.y -
G, e.z -
G}),
1539 KOKKOS_LAMBDA(
int x,
int y,
int z,
long& c1,
long& c2,
long& c3,
long& c4,
long& c5) {
1540 const long i = (long)x + (
long)y * sy + (long)z * sz;
1541 const bool msk = mk(i) > 0.5;
1544 const double cp = cls(i);
1547 const bool wasMsk = (cp > 0.5 && cp < 1.5);
1548 if (msk && !wasMsk) {
1553 }
else if (!msk && wasMsk) {
1560 nEL, nEG, nLL, nLG, nM);
1562 pcBudget_.hOpen = hOpen;
1563 pcBudget_.hLiquid = hLiq;
1564 pcBudget_.hMasked = hMask;
1565 pcBudget_.dEoverwrite = dEo;
1566 pcBudget_.dEoverwriteNew = dEoN;
1567 pcBudget_.eEnter = eEnt;
1568 pcBudget_.eLeave = eLev;
1569 pcBudget_.nEnterLiquid = nEL;
1570 pcBudget_.nEnterGas = nEG;
1571 pcBudget_.nLeaveLiquid = nLL;
1572 pcBudget_.nLeaveGas = nLG;
1573 pcBudget_.nMasked = nM;
1576template <
class Gr
id>
1579 const long sx = 1, sy = e_.x, sz = (long)e_.x * e_.y;
1584 const bool useRcp = sc.energy && sc.rcp.extent(0) == n_;
1585 const bool useK = sc.energy && sc.kcell.extent(0) == n_;
1588 const double Tsat = pcTsat_, Dc = sc.D, thMin = pcGfmThMin_, thMax = pcGfmThMax_;
1589 const bool gfm = pcPlaneDir_ && pcGphi_.extent(0) == n_;
1591 const int gfmOrder = pcGfmOrder_;
1592 const bool curvDist = pcCurvDist_ && pcKappa_.extent(0) == n_;
1594 const vof::VofMetric gme = u_.vofMetric();
1596 double hOpen = 0, q = 0, qb = 0;
1598 Kokkos::parallel_reduce(
1599 "peclet::flow::pc_budget_post", MD(
CCExec(), {
G,
G,
G}, {e.x -
G, e.y -
G, e.z -
G}),
1600 KOKKOS_LAMBDA(
int x,
int y,
int z,
double& a1,
double& a2,
double& a3) {
1601 const long i = (long)x + (
long)y * sy + (long)z * sz;
1602 const double r = useRcp ? rcp(i) : 1.0;
1603 const bool msk = mk(i) > 0.5;
1604 clsOut(i) = msk ? 1.0 : (c(i) >= 0.5 ? 2.0 : 0.0);
1607 a1 += r * (T(i) - Tsat);
1610 const long st[3] = {sx, sy, sz};
1611 const double kd = useK ? kc(i) : Dc;
1612 for (
int d = 0; d < 3; ++d)
1613 for (
int sgn = -1; sgn <= 1; sgn += 2) {
1614 const long j = i + (long)sgn * st[d];
1617 const double of = (d == 0) ? ((sgn < 0) ? ox(i) : ox(i + sx))
1618 : (d == 1) ? ((sgn < 0) ? oy(i) : oy(i + sy))
1619 : ((sgn < 0) ? oz(i) : oz(i + sz));
1620 const double nvec[3] = {gnx(j), gny(j), gnz(j)};
1622 curvDist ? kapF(j) : 0.0, thMin, thMax, gme);
1623 const long jb = i - (long)sgn * st[d];
1624 const double ofB = (d == 0) ? ((sgn < 0) ? ox(i + sx) : ox(i))
1625 : (d == 1) ? ((sgn < 0) ? oy(i + sy) : oy(i))
1626 : ((sgn < 0) ? oz(i + sz) : oz(i));
1627 const bool behind = !(mk(jb) > 0.5) && ofB > 0.0;
1629 a2 += kd * of * row.aGamma * (tg(j) - T(i));
1630 if (behind && row.aBehind != 1.0) {
1631 const double kb = useK ? 0.5 * (kc(i) + kc(jb)) : Dc;
1632 a3 += (row.aBehind - 1.0) * kb * ofB * (T(jb) - T(i));
1638 pcBudget_.hOpenNew = hOpen;
1640 pcBudget_.qBehind = qb;
1641 pcBudget_.calls += 1;
1644template <
class Gr
id>
1646 if (!pcEnabled_ && !pcHasUser_)
1649 const bool hasPc = pcEnabled_, hasUser = pcHasUser_;
1652 Kokkos::parallel_for(
1653 "peclet::flow::pc_div_source",
1655 KOKKOS_LAMBDA(
int x,
int y,
int z) {
1656 const long i = (long)x + (
long)y * e.x + (long)z * (
long)e.x * e.y;
1666template <
class Gr
id>
1668 return Kokkos::fmax(pcInterfaceEps_, vofAdv_.wispEps);
1671template <
class Gr
id>
1673 return Kokkos::fmax(pcPureEps_, vofAdv_.wispEps);
1676template <
class Gr
id>
1679 throw std::runtime_error(std::string(who) +
1680 ": phase change is not enabled (call "
1681 "enable_phase_change first)");
1684template <
class Gr
id>
1685double Solver<Grid>::phaseTick() {
1688 CCExec().fence(
"peclet::flow::phase_tick");
1689 return std::chrono::duration<double>(std::chrono::steady_clock::now().time_since_epoch()).count();
void vofExchangeScalar(CCField f)
The colour block's ghost policy WITHOUT the colour-specific rules (no solid-band fill,...
int phaseChangeArea() const
void setPhaseChangeGfmOrder(int order)
WO-P3g item 2: the order of the one-sided (ghost-fluid) Dirichlet row.
void setPhaseChangeEnergyMuscl(bool on)
MinMod-limited donor reconstruction of the face temperature in the consistent energy flux (vof/energy...
void pcMdotExtrema(long nIface)
static constexpr int kVofG
bool phaseChangeEnergyMuscl() const
void setPhaseChangeThermalOff()
void pcZeroDomainGhosts(CCField f)
Zero the two ghost layers on every NON-periodic domain face this rank owns.
void pcCarryDeposit(ScalarField &sc)
WO-P3f — the enthalpy the per-cell Dirichlet overwrite destroys, returned to the phase it came from.
void scatterInner(CCField fld, const std::vector< double > &in)
void phaseChangeStep()
The in-step driver: everything applyPhaseChange does, at the head of step().
ScalarField & scalarField(const std::string &name)
PhaseChangeDiagnostics phaseChangeDiagnostics()
bool phaseChangeDepositFallback() const
void fillGhosts(CCField f)
void setMassFluxUniform(double v)
Prescribe a UNIFORM mass flux (P0), in mass per area per time.
void setPhaseChangeFitCurvature(double kappa)
WO-P3f INSTRUMENT: prescribe the interface curvature kappa = div(n) the one-sided fits use to correct...
void fillPropGhosts(CCField f, bool edges=false)
void pcScatterSource()
(2) Deposit each interfacial cell's source into its chosen pure-gas cell, as a GATHER (each receiving...
void pcApplyDivergenceSource(CCField div)
Subtract the phase-change (and any prescribed) divergence source from div_ so the deflated pressure s...
void setPhaseChangeMdotOperator(bool on)
WO-P3g item 1: take mdot from the energy operator's own interfacial flux instead of the one-sided lea...
double phaseChangeCarryDeposited() const
The carry ledger, physical: an energy with the consistent transport on, and a temperature times a vol...
CCField addField(const std::string &name)
void pcRegress(double dt)
(3) The regression: two Jacobi passes over the exchanged per-cell data, so the clip deficit is redist...
vof::VofInterfaceArea::Stats pcAreaCascadeCompute()
Run the cascade area driver on the (already bridged) g = 3 colour block.
SField pcAreaCascadeField() const
The area field the last pcAreaCascadeCompute filled (either driver).
double pcEffPureEps() const
…and the mirror statement: a cell the ADVECTOR treats as a pure phase is a pure phase here too,...
double phaseChangeQOrphan() const
void pcUpdateThermalMask()
void pcUpdateEnergyProps()
Refresh k(C) and (rho c_p)(C) on the G=2 block from the current colour.
void requireScalesPinned(const char *who, bool needRho) const
Under an armed extent, refuse a call that writes a dimensional value into a FIELD before the referenc...
double phaseChangeQOperator() const
The operator's interfacial heat (power), physical.
bool phaseChangeEnabled() const
void copyInner(CCField dst, C3 de, int dg, CCConst src, C3 se, int sg)
void setDivergenceSink(const std::vector< double > &w)
WO-P23: an AUTO-BALANCED sink region for the phase-change divergence source.
bool phaseChangeEnergy() const
bool phaseChangeMdotOperator() const
void setPhaseChangeThermal(const std::string &tname, double Tsat, double kg, double kl, double Rint)
P1: compute mdot each step from the registered scalar tname by the one-sided pure-cell weighted least...
void pcBudgetPost(ScalarField &sc)
WO-P3f, part 2: the state AFTER the energy solve, the heat the plane-anchored rows actually delivered...
void setPhaseChangePlaneDirichlet(bool on)
The PLANE-ANCHORED (ghost-fluid) Dirichlet condition, ON by default.
double vofInterfaceArea()
The summed interfacial area over the inner region, PHYSICAL (globally reduced under MPI) — the E7 gal...
void setPhaseChangeQuadraticFit(bool on)
The QUADRATIC one-sided gradient fit (T - T_G = G phi + Q phi^2) instead of the linear one.
void clearDivergenceSink()
double phaseChangeFitCurvature() const
double pcBandDivergence()
The BAND-EXTENDED LIQUID VELOCITY of VOF_PLAN §9 item 3, as a MEASUREMENT rather than a switch.
void pcBudgetPre(ScalarField &sc)
WO-P3f, the energy-budget instrument, part 1: the state BEFORE the energy solve, and the class-change...
void applyPhaseChange(double dtPhysArg)
Kinematic entry point (the P0a/P1 driver): build mdot/A_G/n from the current colour and temperature,...
void setPhaseChangeCarryConserve(bool on)
WO-P3f: make the per-cell Dirichlet overwrite ENTHALPY-CONSERVING.
void setPhaseChangeEnergyOff()
void pcBuildInterface()
(1) The interface build: for every inner interfacial cell reconstruct the PLIC plane from the canonic...
double pcLedgerEnergyToPhys() const
The factor from an internal phase-change ledger entry (a per-cell sum of rcp' dT) to the caller's uni...
void clearDivergenceSource()
void enablePhaseChange(double rhoG, double rhoL, double hlv)
Turn on phase change.
bool hasScalar(const std::string &name) const
void pcBuildInDomain()
WO-P3g — 1 on every cell that CARRIES A ROW in the energy solve, 0 otherwise.
int phaseChangeGfmOrder() const
void pcCarryApply(ScalarField &sc)
WO-P3f: consume pcCarrySrc_ into the energy solve's time base.
void pcUpdateCurvature()
The per-cell Dirichlet mask of the energy scalar: T = T_sat + mdot R_int in every interfacial cell,...
double pcEffInterfaceEps() const
The colour tolerance that decides which cells are INTERFACIAL, and it has to be at least the colour a...
void setVofWispEps(double eps)
WO-R2 item 4 — the wisp threshold on the advector's mixed-cell predicate and on the interface Courant...
bool phaseChangeBudget() const
bool phaseChangeQuadraticFit() const
void setPhaseChangeCurvatureDistance(bool on)
WO-P3g item 3: measure the GFM row's theta and the one-sided fits' sample distances to the CURVED int...
void setPhaseChangeEnergyOrder(int order)
WO-P3g — the SECOND-ORDER interfacial energy operator, as one package.
void requirePhaseChange(const char *who) const
int phaseChangeEnergyOrder() const
void setMassFlux(const std::vector< double > &v)
Prescribe a per-cell mass flux (P0), x-fastest over the inner region; units and call-order rule as se...
void setPhaseChangeEnergy(double rcpGas, double rcpLiquid)
Turn on the CONSISTENT energy transport (VOF_PLAN §9 item 6) for the scalar set_phase_change_thermal ...
double phaseChangeCarryLost() const
void scalarDirichletMask(const std::string &name)
Allocate (idempotently) the per-cell Dirichlet mask + value of a registered scalar.
bool phaseChangeCurvatureDistance() const
bool phaseChangePlaneDirichlet() const
bool phaseChangeCarryConserve() const
void pcRefreshUnits()
Re-derive the INTERNAL phase-change constants (pcRhoG_ ... pcRcpL_) from the caller's physical ones (...
void setPhaseChangeBudget(bool on)
WO-P3f: turn the ENERGY BUDGET instrument on.
PhaseChangeBudget phaseChangeBudgetValues() const
The budget, physical: energies and powers with the consistent transport on, temperature x volume (and...
void setDivergenceSource(const std::vector< double > &v)
A PRESCRIBED extra divergence source (1/time, physical; set_dt must precede it under an extent,...
void setPhaseChangeDepositFallback(bool on)
WO-P3f open item 6 / WO-P3g — the divergence source's 5^3 fallback target, as a setter (it was only r...
bool isCutcellScalar(const std::string &name) const
void setPhaseChangeArea(int mode)
WO-P3c — which geometry the interfacial AREA comes from.
double pcGradSolve2(const PcGradFit &f)
The QUADRATIC one-sided fit (WO-P23): T - T_G = G phi + Q phi^2, returning G.
double pcMassFlux(double kg, double gradG, double kl, double gradL, double hlv)
mdot = (k_g dT_g/dn - k_l dT_l/dn)/h_lv with n the PLIC normal (liquid -> gas).
void pcGradAdd(PcGradFit &f, double w, double phi, double T, double Tg)
Add one pure-phase sample at normal distance phi with temperature T.
double pcCentreDistance(double mx, double my, double mz, double alpha)
Signed distance (in cells) from the CELL CENTRE to the PLIC plane, measured along n and POSITIVE ON T...
double pcRegressVolume(double mdot, double area, double dt, double rhoL)
Liquid volume (fraction of a cell) removed from an interfacial cell in one step: dV = mdot A_G dt / r...
bool pcPushWeights(const double n[3], double sgn, const bool avail[3], int step[3], double w[3])
The clip-and-redistribute allocation: which face neighbours a clipped cell's residue is pushed into,...
double pcDivSource(double mdot, double area, double rhoG, double rhoL)
The volumetric divergence source of one interfacial cell (1/s, cell volume = 1): S = mdot A_G (1/rho_...
PcGfmRow pcGfmRow(double theta, bool behind, int order)
double pcCurvedDistance(double phi, double dx, double dy, double dz, const double n[3], double kappa)
WO-P3f — the sample's distance to the CURVED interface, not to the tangent plane.
double pcCarriedValue(double Tg, double grad, double phic)
The plane-anchored (ghost-fluid) interfacial Dirichlet condition (WO-P23, the first item).
bool pcIsInterfacial(double c, double eps)
Is this a cell the regression acts on?
double pcInterfaceTemperature(double Tsat, double mdot, double Rint)
Interfacial temperature under the Schrage-derived interfacial heat-transfer resistance (Bureš & Sato)...
double pcOffsetDistance(double phic, const double n[3], double dx, double dy, double dz)
Signed distance from the plane of the neighbour at INTEGER cell offset d, given the centre distance p...
double pcGfmThetaKAniso(double phiC, const double n[3], int d, double s, double kappa, double thetaMin, double thetaMax, const VofMetric &g)
The same on an ANISOTROPIC cell (Phase 3, flow/doc/anisotropic_vof.md §7, V5.3).
double pcOperatorMassFlux(double q, double coefSum, double area, double hlv, double Rint)
WO-P3g item 1 — mdot from the ENERGY OPERATOR's own interfacial flux.
double pcPhaseMix(double vg, double vl, double c)
Linear-in-C phase property (k, rho c_p), written so that C = 0 and C = 1 return the endpoint EXACTLY ...
@ kAreaMcColour
the C = 1/2 level set, whole triangles to the centroid's cell
@ kAreaPlic
rung P0/P1: plicArea on the MYC normal. The old numbers.
double plicAreaMetric(double mx, double my, double mz, double alpha, const VofMetric &g)
The PHYSICAL area of the PLIC polygon of an ANISOTROPIC cell, in hRef^2 (flow/doc/anisotropic_vof....
double pcGradSolve(const PcGradFit &f)
The fitted normal derivative dT/dn (0 if the side carried no usable sample).
double pcGradWeight(double dx, double dy, double dz, const double n[3])
Malan's collinearity weight for a sample at cell offset d: w = xi / |d| with xi = (d....
Kokkos::DefaultExecutionSpace CCExec
Kokkos::MDRangePolicy< Exec, Kokkos::Rank< 3, Kokkos::Iterate::Left, Kokkos::Iterate::Left > > MDRange3
3-D range, x (the first index) fastest (both the tile order and the order within a tile).
Kokkos::View< double *, SMem > SField
Kokkos::View< const double *, CCMem > CCConst
Kokkos::View< double *, CCMem > CCField
Kokkos::MDRangePolicy< Exec, Kokkos::Rank< 2, Kokkos::Iterate::Left, Kokkos::Iterate::Left > > MDRange2
2-D range, first index fastest (both the tile order and the order within a tile).
WO-P3f — the ENERGY BUDGET of the phase-change energy solve.
WO-P3g item 2 — the Gibou–Fedkiw second-order one-sided (ghost-fluid) row.
Accumulator for dT/dn fitted through the interface value: T - T_G = G * phi, so G = sum_j w_j phi_j (...
Per-call census over the inner region (LOCAL; a distributed caller sums it).
static constexpr double U