113#ifndef PECLET_CORE_VOF_WETTING_HPP
114#define PECLET_CORE_VOF_WETTING_HPP
116#include <Kokkos_Core.hpp>
117#include <Kokkos_MathematicalFunctions.hpp>
168 for (
int d = 0; d < 3; ++d) {
169 double s[3] = {0.0, 0.0, 0.0}, w[3] = {0.0, 0.0, 0.0};
170 for (
int q = 0; q < 27; ++q) {
173 const int o[3] = {q % 3 - 1, (q / 3) % 3 - 1, q / 9 - 1};
174 const int t1 = o[(d + 1) % 3], t2 = o[(d + 2) % 3];
175 const double ww = (2.0 - (t1 < 0 ? -t1 : t1)) * (2.0 - (t2 < 0 ? -t2 : t2));
176 const int p = o[d] + 1;
180 if (w[0] > 0.0 && w[2] > 0.0)
181 m[d] = s[0] / w[0] - s[2] / w[2];
182 else if (w[0] > 0.0 && w[1] > 0.0)
183 m[d] = 2.0 * (s[0] / w[0] - s[1] / w[1]);
184 else if (w[2] > 0.0 && w[1] > 0.0)
185 m[d] = 2.0 * (s[1] / w[1] - s[2] / w[2]);
195KOKKOS_INLINE_FUNCTION
void vofPlicCentroid(
const double m[3],
double alpha,
double p[3]) {
197 const int nv =
plicPolygon(m[0], m[1], m[2], alpha, v);
204 const double nn = m[0] * m[0] + m[1] * m[1] + m[2] * m[2];
205 const double t = nn > 0.0 ? (alpha - 0.5 * (m[0] + m[1] + m[2])) / nn : 0.0;
206 p[0] = 0.5 + t * m[0];
207 p[1] = 0.5 + t * m[1];
208 p[2] = 0.5 + t * m[2];
226KOKKOS_INLINE_FUNCTION
int vofWettingPlane(
const double mfIn[3],
double cf,
const double nwIn[3],
227 double cosT,
double sinT,
double sdfF,
int pivot,
228 double tEps,
double mth[3],
double& alphaTh,
241 double mh[3] = {mfIn[0], mfIn[1], mfIn[2]};
247 double nw[3] = {nwIn[0], nwIn[1], nwIn[2]};
257 cosApp = mh[0] * nw[0] + mh[1] * nw[1] + mh[2] * nw[2];
258 double t[3] = {mh[0] - cosApp * nw[0], mh[1] - cosApp * nw[1], mh[2] - cosApp * nw[2]};
259 const double tn = Kokkos::sqrt(t[0] * t[0] + t[1] * t[1] + t[2] * t[2]);
267 for (
int d = 0; d < 3; ++d)
268 mth[d] = cosT * nw[d] + sinT * t[d] / tn;
276 alphaTh =
plicAlpha(mth[0], mth[1], mth[2], cf);
281 double mfl[3] = {mfIn[0], mfIn[1], mfIn[2]};
285 double c0[3] = {pf[0], pf[1], pf[2]};
291 const double dpi[3] = {pf[0] - 0.5, pf[1] - 0.5, pf[2] - 0.5};
294 const double sp = sdfF + nw[0] * dpp[0] + nw[1] * dpp[1] + nw[2] * dpp[2];
298 for (
int d = 0; d < 3; ++d)
299 c0[d] = pf[d] - sp * nw[d] / g.
h[d];
300 }
else if (tn >= tEps) {
302 double q[3] = {nw[0] - cosApp * mh[0], nw[1] - cosApp * mh[1], nw[2] - cosApp * mh[2]};
303 const double qn = Kokkos::sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2]);
305 for (
int d = 0; d < 3; ++d)
306 c0[d] = pf[d] - (sp / qn) * (q[d] / qn) / g.
h[d];
309 alphaTh = mth[0] * c0[0] + mth[1] * c0[1] + mth[2] * c0[2];
314KOKKOS_INLINE_FUNCTION
int vofWettingPlane(
const double mfIn[3],
double cf,
const double nwIn[3],
315 double cosT,
double sinT,
double sdfF,
int pivot,
316 double tEps,
double mth[3],
double& alphaTh,
318 return vofWettingPlane(mfIn, cf, nwIn, cosT, sinT, sdfF, pivot, tEps, mth, alphaTh, cosApp,
326 const double a = alphaTh - (mth[0] * ds[0] + mth[1] * ds[1] + mth[2] * ds[2]);
327 const double v =
plicVolume(mth[0], mth[1], mth[2], a);
328 return v < 0.0 ? 0.0 : (v > 1.0 ? 1.0 : v);
core — VoF rung V3 (WO-O): interface curvature from volume fractions, as the Popinet (2009) height-fu...
VofWettingBranch
Which rule produced a band cell's colour, for contact_angle_diagnostics().
@ kVofWetPure
pure-phase continuation (C_f is 0 or 1, no interface in reach)
@ kVofWetNeutral
fell back to WO-Q's neutral mean (no usable n_w/f/m_f)
@ kVofWetTheta
the theta-plane of this column's own anchor cell
@ kVofWetNone
not written by pass 1
@ kVofWetNeighbour
the mean of the theta-planes of the anchor's MIXED neighbours, used where the anchor itself is pure p...
@ kVofWetParallel
interface parallel to the wall (|t| < tEps): m_f kept unrotated
void vofPlicCentroid(const double m[3], double alpha, double p[3])
The centroid of the PLIC polygon of cell f in the cell's own unit-cube frame, for the plane m .
void vofIndexNormal(const double n[3], const VofMetric &g, double m[3])
The INDEX-space normal of a physical normal n (any scale): m = H n, returned unnormalized (plicAlpha ...
VofWettingPivot
How the theta-plane is anchored in the fluid cell.
@ kVofPivotInterface
through p_f (Afkhami-Bussmann / Basilisk). Idempotent.
@ kVofPivotContactLine
the point of the fluid plane on the wall nearest p_f. Idempotent.
@ kVofPivotWallNormal
WO-S as written: c = p_f - sdf(p_f) n_w. NOT idempotent.
@ kVofPivotVolume
plicAlpha(m_theta, C_f): volume-consistent. DEFAULT, idempotent.
double vofPhysNormal(const double m[3], const VofMetric &g, double n[3])
The PHYSICAL unit normal of an index-space normal m (any scale), i.e.
int vofWettingPlane(const double mfIn[3], double cf, const double nwIn[3], double cosT, double sinT, double sdfF, int pivot, double tEps, double mth[3], double &alphaTh, double &cosApp, const VofMetric &g)
Build the theta-plane in the FLUID cell's own unit-cube frame.
double plicAlpha(double mx, double my, double mz, double v)
Plane offset alpha such that plicVolume(mx,my,mz,alpha) == V, exactly (analytic inverse).
double plicNormalizeL1(double m[3])
L1-normalize a normal in place. Returns the L1 norm before normalization (0 => untouched).
int plicPolygon(double mx, double my, double mz, double alpha, double v[8][3])
Vertices of the polygon {x in [0,1]^3 : m .
double plicVolume(double mx, double my, double mz, double alpha)
Volume fraction of the unit cell [0,1]^3 lying on the fluid side m .
double vofWettingFraction(const double mth[3], double alphaTh, const int ds[3])
The liquid fraction of the solid cell at integer offset ds from the fluid cell, under the theta-plane...
void polygonAreaCentroid(const double v[8][3], int nv, double ctr[3], double &area)
Area and centroid of a planar polygon in 3-D (fan triangulation from v[0]).
bool youngsNormalFluidOnly(const double c[27], const unsigned char fluid[27], double m[3])
Youngs' 27-point weighted gradient restricted to non-solid cells.
core — PLIC (piecewise-linear interface construction) geometric toolbox: the analytic plane<->volume ...
The per-axis cell size, in the solver's reference length (hRef), of the cell these kernels map to the...
void toPhys(const double X[3], double out[3]) const
Index displacement -> physical displacement (in hRef): X'_a = h[a] X_a.