13#ifndef CD_MIRRORDEPOSITIONIMPLEM_H
14#define CD_MIRRORDEPOSITIONIMPLEM_H
21#include <CD_NamespaceHeader.H>
30 const int lo = (a_i < a_j) ? a_i : a_j;
31 const int hi = (a_i < a_j) ? a_j : a_i;
33 return lo * SpaceDim - (lo * (lo - 1)) / 2 + (hi - lo);
43 for (
int i = 0; i < SpaceDim; i++) {
44 for (
int j = i; j < SpaceDim; j++) {
49 sum += a_tangents[a][i] * a_S[a][b] * a_tangents[b][j];
59shapeEntry(
const Real* a_shape,
const int a_i,
const int a_j)
noexcept
67 RealVect ret = RealVect::Zero;
69 for (
int i = 0; i < SpaceDim; i++) {
72 for (
int j = 0; j < SpaceDim; j++) {
87 for (
int i = 0; i < SpaceDim; i++) {
102 for (
int i = 0; i < SpaceDim; i++) {
103 for (
int j = 0; j < SpaceDim; j++) {
110 return 0.5 * (tr * tr - trSq);
114jacobian(
const Real a_twoH,
const Real a_K,
const Real a_d, Real& a_denominator)
noexcept
116 const Real dSq = a_d * a_d;
118 a_denominator = 1.0 + a_twoH * a_d + a_K * dSq;
120 return (1.0 - a_twoH * a_d + a_K * dSq) / a_denominator;
125 const Real* a_surfaceData,
126 const Real a_maxJacobian,
127 const Real a_minDenominator,
130 Real& a_signedDistance,
136 for (
int dir = 0; dir < SpaceDim; dir++) {
138 normal[dir] = a_surfaceData[
compNormal + dir];
141 const Real* shape = a_surfaceData +
compShape;
144 const RealVect w = a_pos - centroid;
146 const Real eta = normal.dotProduct(w);
147 const Real d = eta + 0.5 * w.dotProduct(Sw);
151 RealVect nhat = normal + Sw;
152 const Real len = nhat.vectorLength();
161 a_image = a_pos - 2.0 * d * nhat;
162 a_signedDistance = d;
164 Real denominator = 0.0;
169 if (std::abs(denominator) < a_minDenominator) {
172 else if (!(J > 0.0)) {
175 else if (J > a_maxJacobian) {
188#include <CD_NamespaceFooter.H>
Namespace containing the geometry used by mirrored cut-cell deposition.
Geometry for mirrored cut-cell deposition, i.e. the even extension of the density about an embedded b...
Definition CD_MirrorDeposition.H:38
constexpr int compCentroid
First of the SpaceDim components holding the boundary centroid, as a PHYSICAL position.
Definition CD_MirrorDeposition.H:58
constexpr int numTangents
Number of tangent directions on the surface. One in 2-D, two in 3-D.
Definition CD_MirrorDeposition.H:43
int shapeIndex(const int a_i, const int a_j) noexcept
Index into the stored upper triangle of a symmetric SpaceDim x SpaceDim tensor.
Definition CD_MirrorDepositionImplem.H:26
Refusal
Why reflect() refused to trust its Jacobian.
Definition CD_MirrorDeposition.H:108
@ NonPositiveJacobian
The Jacobian came out non-positive, i.e. the reflection is past the surface's centre of curvature.
@ SmallDenominator
The Jacobian's denominator came too close to zero.
@ LargeJacobian
The Jacobian exceeded the permitted magnitude.
@ None
No refusal; the Jacobian was accepted.
constexpr int compShape
First of the numShapeComp components holding the world-frame shape operator's upper triangle.
Definition CD_MirrorDeposition.H:68
Real shapeEntry(const Real *a_shape, const int a_i, const int a_j) noexcept
Read one entry of a world-frame shape operator stored as an upper triangle.
Definition CD_MirrorDepositionImplem.H:59
constexpr int compNormal
First of the SpaceDim components holding the unit normal, pointing INTO the fluid.
Definition CD_MirrorDeposition.H:63
constexpr int numShapeComp
Number of independent entries in a symmetric SpaceDim x SpaceDim tensor. Three in 2-D,...
Definition CD_MirrorDeposition.H:48
Real meanCurvatureTimesTwo(const Real *a_shape) noexcept
Twice the mean curvature, i.e. the first invariant of the shape operator.
Definition CD_MirrorDepositionImplem.H:83
bool reflect(const RealVect &a_pos, const Real *a_surfaceData, const Real a_maxJacobian, const Real a_minDenominator, RealVect &a_image, Real &a_jacobian, Real &a_signedDistance, Refusal &a_refusal) noexcept
Reflect a position across the quadratic surface patch stored for its cell, and weight the image.
Definition CD_MirrorDepositionImplem.H:124
Real jacobian(const Real a_twoH, const Real a_K, const Real a_d, Real &a_denominator) noexcept
The exact area/volume Jacobian of the reflection across a curved surface.
Definition CD_MirrorDepositionImplem.H:114
RealVect applyShapeOperator(const Real *a_shape, const RealVect &a_vec) noexcept
Apply a world-frame shape operator to a vector.
Definition CD_MirrorDepositionImplem.H:65
Real gaussianCurvature(const Real *a_shape) noexcept
Gaussian curvature, i.e. the second invariant of the shape operator.
Definition CD_MirrorDepositionImplem.H:95
void liftShapeOperator(const RealVect(&a_tangents)[numTangents], const Real(&a_S)[numTangents][numTangents], Real(&a_shape)[numShapeComp]) noexcept
Lift a shape operator from the tangent frame into world coordinates.
Definition CD_MirrorDepositionImplem.H:37