35#ifndef PECLET_CORE_SCHEME_CUT_CELL_GEOMETRY_HPP
36#define PECLET_CORE_SCHEME_CUT_CELL_GEOMETRY_HPP
75#ifdef KOKKOS_INLINE_FUNCTION
76 return Kokkos::sqrt(x);
83 return x < 0.0 ? -x : x;
99 const double den = (x - y) * (x - z);
101 return (x * x) /
den;
107 return (x * x) / ((x - y) * (x - z));
112 const double den = ((a -
b1) * (a -
b2)) * (a -
b3);
114 return (a * a * a) /
den;
120 return (a * a * a) / (((a -
b1) * (a -
b2)) * (a -
b3));
135 const double p =
a1 *
a2;
146 const bool pa = a > 0.0,
pb = b > 0.0,
pc = c > 0.0;
147 const int np = (
pa ? 1 : 0) + (
pb ? 1 : 0) + (
pc ? 1 : 0);
171 const double v[4] = {
v0,
v1,
v2,
v3};
174 for (
int k = 0;
k < 4; ++
k) {
213 return a == 0 ? h[1] * h[2] : (a == 1 ? h[0] * h[2] : h[0] * h[1]);
220 for (
int a = 0; a < 3; ++a)
228 for (
int a = 0; a < 3; ++a)
229 x[a] = (((c >> a) & 1) ? 0.5 : -0.5) * h[a];
234 t1 = (a == 0) ? 1 : 0;
235 t2 = (a == 2) ? 1 : 2;
240 const int a =
f >> 1,
side =
f & 1;
243 const int u = (
k == 1 ||
k == 2) ? 1 : 0;
244 const int w = (
k >= 2) ? 1 : 0;
245 return (
side << a) | (u << t1) | (w <<
t2);
251 double centre,
const double h[3],
double val[4],
260 const int a =
f >> 1;
261 for (
int d = 0;
d < 3; ++
d) {
265 pos[2][a] = ((
f & 1) ? 0.5 : -0.5) * h[a];
271 const double t =
vp / (
vp -
vn);
272 for (
int d = 0;
d < 3; ++
d)
277 w[0] = u[1] * v[2] - u[2] * v[1];
278 w[1] = u[2] * v[0] - u[0] * v[2];
279 w[2] = u[0] * v[1] - u[1] * v[0];
283 return ccgSqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
290 double&
area,
double cen[3]) {
293 for (
int k = 0;
k < 4; ++
k) {
299 if (
np == 0 ||
np == 4)
310 for (
int d = 0;
d < 3; ++
d) {
315 for (
int d = 0;
d < 3; ++
d)
319 for (
int d = 0;
d < 3; ++
d) {
326 const double wS =
wA +
wB;
327 for (
int d = 0;
d < 3; ++
d) {
328 const double cA = (
X[0][
d] +
X[1][
d] +
X[2][
d]) / 3.0;
329 const double cB = (
X[0][
d] +
X[2][
d] +
X[3][
d]) / 3.0;
335 for (
int k = 0;
k < 3; ++
k) {
336 const int p = (
np == 1) ?
ip[0] :
ip[
k];
337 const int n = (
np == 1) ?
in[
k] :
in[0];
341 for (
int d = 0;
d < 3; ++
d) {
346 for (
int d = 0;
d < 3; ++
d) {
348 cen[
d] = (
X[0][
d] +
X[1][
d] +
X[2][
d]) / 3.0;
355 for (
int d = 0;
d < 3; ++
d)
374 const double face[6],
double centre,
381 for (
int d = 0;
d < 3; ++
d) {
389 for (
int f = 0;
f < 6; ++
f) {
401 for (
int c = 0; c < 8; ++c) {
405 for (
int f = 0;
f < 6; ++
f) {
421 double wc[3] = {0.0, 0.0, 0.0};
422 double refVec[3] = {0.0, 0.0, 0.0};
424 for (
int f = 0;
f < 6; ++
f) {
425 for (
int k = 0;
k < 4; ++
k) {
432 for (
int d = 0;
d < 3; ++
d) {
439 for (
int d = 0;
d < 3; ++
d)
451 double vA[3] = {0.0, 0.0, 0.0},
vB[3] = {0.0, 0.0, 0.0};
452 double cA[3] = {0.0, 0.0, 0.0},
cB[3] = {0.0, 0.0, 0.0};
453 double sA = 0.0,
sB = 0.0;
454 for (
int f = 0;
f < 6; ++
f) {
455 for (
int k = 0;
k < 4; ++
k) {
462 double* v =
dot >= 0.0 ?
vA :
vB;
463 double* c =
dot >= 0.0 ?
cA :
cB;
464 for (
int d = 0;
d < 3; ++
d) {
471 if (
sA > 0.0 &&
sB > 0.0) {
472 for (
int d = 0;
d < 3; ++
d) {
488 for (
int d = 0;
d < 3; ++
d) {
core — the shared cut-cell IBM boundary-distance closure polynomials (flow <-> amr).
#define PECLET_CORE_CC_HD
PECLET_CORE_CC_HD double triOnePositive(double x, double y, double z)
PECLET_CORE_CC_HD void ccgFanTet(int f, int k, const double corner[8], const double face[6], double centre, const double h[3], double val[4], double pos[4][3])
PECLET_CORE_CC_HD void ccgCrossProd(const double u[3], const double v[3], double w[3])
PECLET_CORE_CC_HD double ccgSqrt(double x)
PECLET_CORE_CC_HD void ccgTangents(int a, int &t1, int &t2)
PECLET_CORE_CC_HD double ccgMaxAbs4(double a, double b, double c, double d)
PECLET_CORE_CC_HD double ccgAbs(double x)
PECLET_CORE_CC_HD double tetOnePositive(double a, double b1, double b2, double b3)
PECLET_CORE_CC_HD void ccgCornerPos(int c, const double h[3], double x[3])
PECLET_CORE_CC_HD bool ccgTetPiece(const double val[4], const double pos[4][3], double vec[3], double &area, double cen[3])
PECLET_CORE_CC_HD double ccgNorm(const double v[3])
PECLET_CORE_CC_HD void ccgCross(double vp, double vn, const double xp[3], const double xn[3], double x[3])
PECLET_CORE_CC_HD int ccgFanCorner(int f, int k)
PECLET_CORE_CC_HD double ccgMaxAbs3(double a, double b, double c)
PECLET_CORE_CC_HD double tetTwoPositive(double a1, double a2, double b1, double b2)
PECLET_CORE_CC_HD CutCellGeometry cutCellGeometryFanTet(const double corner[8], const double face[6], double centre, const double h[3])
The cut-cell record of one cell from its 15 PL samples (§2.2): corner[8] (index bx+2by+4bz),...
constexpr double kSingleFacetRho
ρ = |areaPL| / areaSum at or above which the cell carries ONE facet (§2.2).
PECLET_CORE_CC_HD double fanFaceAperture(double v00, double v10, double v11, double v01, double cc)
PL aperture of one face from its fan (§2.2): the corner values in loop order c00, c10,...
PECLET_CORE_CC_HD double cutCellFaceArea(int a, const double h[3])
Face area of axis a for cell size h: the product of the two other spacings.
CutCellKind
Facet classification of a cut cell (§2.2).
@ none
no facet (uncut, or every piece below the drop threshold)
@ thinSolid
two facets, solid between two fluids (a counted resolution error)
@ single
one facet (ρ ≥ 0.5, or the two-group split left a group empty)
@ gap
two facets, fluid between two walls
PECLET_CORE_CC_HD double triPositiveFraction(double a, double b, double c)
Fraction of a triangle on which the linear interpolant of its vertex values (a, b,...
constexpr double kApertureSnap
Aperture snap threshold at BOTH ends (§2.3): a < 1e-3 → 0, a > 1 − 1e-3 → 1.
constexpr double kPieceDropRel
A facet piece with area < kPieceDropRel · min_a A_a is dropped (§2.2).
PECLET_CORE_CC_HD double snapAperture(double a)
Snap a face aperture at both ends (§2.3): a < 1e-3 → 0, a > 1 − 1e-3 → 1, else a.
PECLET_CORE_CC_HD void facetAreaVector(const double ap[6], const double h[3], double out[3])
The area vector the apertures imply through the divergence theorem (§2.3): out_a = A_a (ap[2a+1] − ap...
PECLET_CORE_CC_HD double tetPositiveFraction(double v0, double v1, double v2, double v3)
Fraction of a tetrahedron on which the linear interpolant of its vertex values is strictly positive (...
PECLET_HD Real dot(Vec3< Real > a, Vec3< Real > b)
Kokkos::View< T *, MemSpace > View
1D device array.
The geometric record of one cell (§2.1). Double, cell-centred frame, internal lengths.
double facetCentroid[2][3]
per facet: centroid relative to the cell centre; unused 0
double areaPL[3]
net PL facet area vector (into the fluid)
double kappa
fluid volume fraction ∈ [0, 1]
double aperture[6]
open fraction of each face, −x,+x,−y,+y,−z,+z, UNSNAPPED
double facetArea[2][3]
per facet: area vector (into the fluid); unused slots 0