22#ifndef PECLET_FLOW_VOF_INTERFACE_AREA_FIELD_HPP
23#define PECLET_FLOW_VOF_INTERFACE_AREA_FIELD_HPP
25#include <Kokkos_Core.hpp>
50 void init(
int nx,
int ny,
int nz,
int ghost) {
52 throw std::invalid_argument(
"peclet::flow::vof::VofInterfaceArea: ghost width must be >= 3");
53 if (nx < 1 || ny < 1 || nz < 1)
54 throw std::invalid_argument(
"peclet::flow::vof::VofInterfaceArea: empty block");
57 e_ =
I3{nx + 2 * ghost, ny + 2 * ghost, nz + 2 * ghost};
58 len_ =
static_cast<long>(e_.
x) * e_.
y * e_.
z;
59 mx_ =
SField(
"vof::area::mx", len_);
60 my_ =
SField(
"vof::area::my", len_);
61 mz_ =
SField(
"vof::area::mz", len_);
62 alpha_ =
SField(
"vof::area::alpha", len_);
63 area_ =
SField(
"vof::area::A", len_);
64 branch_ =
SField(
"vof::area::branch", len_);
67 bool ready()
const {
return area_.extent(0) != 0; }
89 throw std::runtime_error(
"peclet::flow::vof::VofInterfaceArea::compute: init() not called");
98 const I3 e = e_, n = n_;
100 const long sy = e_.
x, sz =
static_cast<long>(e_.
x) * e_.
y;
101 SField mx = mx_, my = my_, mz = mz_, al = alpha_;
103 Kokkos::parallel_for(
106 {g + n.x + gr, g + n.y + gr, g + n.z + gr}),
108 const long i =
L3(x, y, z, e);
126 const I3 e = e_, n = n_;
128 const long st[3] = {1, e_.
x,
static_cast<long>(e_.
x) * e_.
y};
129 SField mx = mx_, my = my_, mz = mz_, al = alpha_,
ar = area_, br = branch_;
132 const VofMetric gm =
metric;
134 Kokkos::parallel_for(
137 const long i =
L3(x, y, z, e);
143 const double am[3] = {Kokkos::fabs(mx(i)), Kokkos::fabs(my(i)), Kokkos::fabs(mz(i))};
144 int ord[3] = {0, 1, 2};
145 for (
int p = 1; p < 3; ++p)
146 for (
int q = p; q > 0 && am[
ord[q]] > am[
ord[q - 1]]; --q) {
147 const int t =
ord[q];
151 for (
int t = 0; t < 3; ++t) {
152 const int d =
ord[t];
153 const int d1 = (d + 1) % 3,
d2 = (d + 2) % 3;
154 const long sd = st[d], s1 = st[
d1], s2 = st[
d2];
158 for (
int q = 0; q < 3 && ok; ++q)
159 for (
int p = 0; p < 3 && ok; ++p) {
160 const long base = i + (p - 1) * s1 + (q - 1) * s2;
198 const I3 e = e_, n = n_;
199 const int g = g_, gr =
kPvHalf;
200 SField mx = mx_, my = my_, mz = mz_, al = alpha_,
ar = area_, br = branch_;
202 const VofMetric gm =
metric;
204 Kokkos::parallel_for(
207 const long i =
L3(x, y, z, e);
210 const double m0 = mx(i), m1 = my(i), m2 = mz(i);
211 const double mi[3] = {
m0, m1, m2};
212 double nn[3] = {0.0, 0.0, 0.0};
224 const double org[3] = {
ctr[0] - 0.5,
ctr[1] - 0.5,
ctr[2] - 0.5};
227 for (
int oz = -gr; oz <= gr; ++oz)
228 for (
int oy = -gr; oy <= gr; ++oy)
229 for (
int ox = -gr; ox <= gr; ++ox) {
230 const long j =
L3(x + ox, y + oy, z + oz, e);
233 const double off[3] = {
static_cast<double>(ox),
static_cast<double>(oy),
234 static_cast<double>(oz)};
235 pvFitAdd(fit, mx(j), my(j), mz(j), al(j), off, org,
t1,
t2,
nn, dW, cmin, gm);
253 al(i), c(i), ns, gm);
260 const I3 e = e_, n = n_;
264 Kokkos::parallel_reduce(
268 const long i =
L3(x, y, z, e);
269 const int b =
static_cast<int>(br(i));
283 s.interfacial, s.hf, s.hfMixed, s.pv, s.noEstimate, s.area);
289 I3 n_{0, 0, 0}, e_{0, 0, 0};
292 SField mx_, my_, mz_, alpha_, area_, branch_;
flow — VoF rung V1: Weymouth & Yue (2010) directionally-split, exactly volume-conserving geometric ad...
Interfacial area per cell from the V3 curvature cascade's own geometry.
void fallbackPass(SField c, int mode)
Tier 3: the PLIC-volumetric paraboloid fit, whose GRADIENT at the origin is the accurate normal here ...
double interfaceEps
The interfacial predicate's wisp threshold.
VofMetric metric
The anisotropic cell metric (Phase 3); {1,1,1} == the pre-Phase-3 arithmetic.
void reconstructPlanes(SField c)
void init(int nx, int ny, int nz, int ghost)
void heightPass(SField c, int mode)
Tiers 1 and 2a: the height function in the preferred direction, then the other two,...
Stats compute(SField c, int mode)
double pureEps
Purity tolerance of the height-function column walk – the same contract as VofCurvature::pureEps: set...
flow — thin shim: the container-free VoF height-function / paraboloid curvature kernels (rung V3) now...
flow — VoF rung V3 (WO-O): the view-level driver for the curvature cascade.
flow — WO-P3c: the interfacial AREA taken from the CURVATURE cascade's geometry.
flow — portable (Kokkos) MAC stencil operators: Red-Black Gauss-Seidel smoothers + divergence.
bool vofIsInterface(double c, double eps)
wyIsMixed with a wisp threshold: the cell carries an interface only while eps < C < 1 - eps.
void wyReconstructCell(const SF &c, long i, long sy, long sz, SF mx, SF my, SF mz, SF alpha)
PLIC reconstruction of one cell: MYC normal from the 3^3 colour stencil + the analytic plane offset.
@ kAreaFootprint
variant C: the height function's OWN footprint x its own metric.
@ kAreaNormal
variant B: plicArea rebuilt on the cascade's normal.
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....
void pvSurfaceNormal(const double a[6], const double t1[3], const double t2[3], const double nn[3], double m[3])
The unit normal of the fitted paraboloid z = a0 + a1 x + a2 y + ... AT THE ORIGIN of its own frame (t...
double interfaceAreaFromNormal(int mode, double mx, double my, double mz, double alpha, double c, const double ns[3], const VofMetric &g)
The projection axis of kAreaMetric is the one ns is most aligned with — the column direction on tiers...
double hfFootprintArea(const double h[9])
Variant C — the height function's own footprint times its own metric (kAreaFootprint).
void hfSurfaceNormal(const double h[9], int d, double m[3])
The unit surface normal implied by the SAME 3x3 patch of heights, in world components.
long L3(int x, int y, int z, I3 e)
Kokkos::DefaultExecutionSpace SExec
Kokkos::View< double *, SMem > SField
flow — the multidimensional iteration policies: iteration order follows storage.
Per-call census over the inner region (LOCAL; a distributed caller sums it).
long hf
tier 1: HF in the preferred (largest |n_d|) direction
long pv
tier 3: PV paraboloid fit (full or reduced model)
long hfMixed
tier 2a: HF in one of the other two directions
long noEstimate
no cascade geometry at all — the cell keeps its MYC PLIC area
double area
the sum this rung exists to get right