30 PetscInt i,PetscInt j,PetscInt k,
31 PetscReal xi,PetscReal eta,PetscReal zta,
48 PetscInt i,PetscInt j,PetscInt k,
70 PetscInt i,PetscInt j,PetscInt k,
71 PetscReal xi,PetscReal eta,PetscReal zta,
72 PetscReal J[3][3],PetscReal *detJ);
88 const PetscReal u[3],PetscReal uc[3]);
101 const PetscReal area_sq = metric.
x * metric.
x + metric.
y * metric.
y + metric.
z * metric.
z;
102 const PetscReal normal = (area_sq > 0.0)
103 ? (velocity.
x * metric.
x + velocity.
y * metric.
y + velocity.
z * metric.
z) / area_sq : 0.0;
106 tangential.
x = velocity.
x - normal * metric.
x;
107 tangential.
y = velocity.
y - normal * metric.
y;
108 tangential.
z = velocity.
z - normal * metric.
z;
205 double *l_xi,
double *l_eta,
double *l_zeta);
579 const PetscInt di = i - info->gxs, dj = j - info->gys, dk = k - info->gzs;
580 return (dk * info->gym + dj) * info->gxm + di;
PetscErrorCode ComputeCellEdgeVectors(PetscReal ajc, Cmpnts csi, Cmpnts eta, Cmpnts zet, Cmpnts edges[3])
Computes a cell's edge vectors along its three grid directions.
PetscErrorCode MetricRestoreFacePlaneArrays(UserCtx *user, FacePlaneArrays *arrays)
Closes arrays opened by MetricGetFacePlaneArrays().
PetscErrorCode CalculateAllGridMetrics(SimCtx *simCtx)
Orchestrates the calculation of all grid metrics.
static Cmpnts RemoveFaceNormalComponent(Cmpnts velocity, Cmpnts metric)
velocity less its component along the face metric metric, which leaves it tangent to the face.
PetscErrorCode MetricJacobian(UserCtx *user, const Cmpnts ***X, PetscInt i, PetscInt j, PetscInt k, PetscReal xi, PetscReal eta, PetscReal zta, PetscReal J[3][3], PetscReal *detJ)
Evaluates the trilinear mapping Jacobian and its determinant in one cell.
PetscErrorCode ComputeCellCenters(UserCtx *user)
Computes the physical location of each cell's center from the nodal coordinates.
PetscBool MetricFacePlane(const Cmpnts v1, const Cmpnts v2, const Cmpnts v3, const Cmpnts v4, const Cmpnts cell_centroid, FacePlane *plane, PetscBool *degenerate)
Builds one face plane: the unit outward normal of (v2 - v1) x (v4 - v1) and the vertex mean.
PetscErrorCode InvertCovariantMetricTensor(double covariantTensor[3][3], double contravariantTensor[3][3])
Inverts the 3x3 matrix of face-area vectors to obtain the covariant directions.
PetscErrorCode ComputeMetricNorms(UserCtx *user)
Computes the max-min values of the grid metrics.
PetscErrorCode CheckAndFixGridOrientation(UserCtx *user)
Verify and, when consistently inverted, repair the right-handed metric basis (Csi,...
PetscErrorCode MetricGetCellVertices(UserCtx *user, const Cmpnts ***X, PetscInt i, PetscInt j, PetscInt k, Cmpnts V[8])
Collects the eight node coordinates of one logical hexahedral cell.
void MetricGatherCellFacePlanes(const FacePlaneArrays *arrays, const DMDALocalInfo *info, PetscInt i, PetscInt j, PetscInt k, CellFacePlanes *planes)
Assembles one cell's six outward face planes from the shared per-face planes.
PetscErrorCode ComputeJFaceMetrics(UserCtx *user)
Computes metrics centered on constant-j faces (j-faces).
PetscErrorCode MetricDestroyFacePlanes(UserCtx *user)
Frees the face-plane fields MetricComputeFacePlanes() built, if any.
PetscErrorCode ComputeMetricsDivergence(UserCtx *user)
Performs a diagnostic check on the divergence of the face area metric vectors.
PetscErrorCode MetricComputeFacePlanes(UserCtx *user)
Builds the block's particle face planes once, as catalogued per-face fields.
PetscErrorCode MetricGetFacePlaneArrays(UserCtx *user, PetscBool dual, FacePlaneArrays *arrays)
Opens a family's face-plane arrays for reading; MetricComputeFacePlanes() must have run.
const Cmpnts * normal[3]
Unit normals toward +i, +j, +k; zero where there is no plane.
const Cmpnts * centroid[3]
Face vertex means.
PetscErrorCode ComputeGridLineFractions(UserCtx *user, Vec fraction, Vec length)
Arc-length position of every owned cell centre along its three grid lines.
PetscErrorCode ComputeFaceMetrics(UserCtx *user)
Computes the primary face metric components (Csi, Eta, Zet), including boundary extrapolation,...
static PetscInt MetricCellFacePlanesIndex(const DMDALocalInfo *info, PetscInt i, PetscInt j, PetscInt k)
Index of point (i, j, k) in a block's ghosted local arrays (coordinates, lCent, planes).
PetscErrorCode ComputeCellCharacteristicLengthScale(PetscReal ajc, Cmpnts csi, Cmpnts eta, Cmpnts zet, double *dx, double *dy, double *dz)
Computes characteristic length scales (dx, dy, dz) for a curvilinear cell.
PetscErrorCode CalculateFaceNormalAndArea(Cmpnts csi, Cmpnts eta, Cmpnts zet, double ni[3], double nj[3], double nk[3], double *Ai, double *Aj, double *Ak)
Computes the unit normal vectors and areas of the three faces of a computational cell.
PetscErrorCode ApplyPeriodicCorrectionsToIFaceCenter(UserCtx *user)
Builds translated periodic images for i-face centers (Centx).
void MetricBuildCellFacePlanes(const Cell *cell, CellFacePlanes *planes)
Builds the six face planes of a hexahedron, as the particle search tests them.
const PetscReal * size
Grid-cell sizes; NULL for dual cells.
PetscErrorCode ComputeCellCenteredJacobianInverse(UserCtx *user)
Calculates the cell-centered inverse Jacobian determinant (1/J) for INTERIOR cells and stores it in u...
PetscErrorCode ComputeKFaceMetrics(UserCtx *user)
Computes metrics centered on constant-k faces (k-faces).
PetscErrorCode ApplyPeriodicCorrectionsToJFaceCenter(UserCtx *user)
Builds translated periodic images for j-face centers (Centy).
PetscBool dual
Dual-cell planes (from lCent) rather than grid-cell planes.
PetscErrorCode ComputeCellDirectionalExtents(PetscReal ajc, Cmpnts csi, Cmpnts eta, Cmpnts zet, double *l_xi, double *l_eta, double *l_zeta)
Computes a cell's extent along each of its own grid directions.
PetscErrorCode MetricLogicalToPhysical(UserCtx *user, const Cmpnts ***X, PetscInt i, PetscInt j, PetscInt k, PetscReal xi, PetscReal eta, PetscReal zta, Cmpnts *Xp)
Maps a logical point inside one hexahedral cell to physical space.
PetscErrorCode ComputeIFaceMetrics(UserCtx *user)
Computes metrics centered on constant-i faces (i-faces).
PetscErrorCode ApplyPeriodicCorrectionsToCellCenters(UserCtx *user)
Builds translated periodic images for the dummy cell centers of periodic axes.
PetscErrorCode ApplyPeriodicCorrectionsToKFaceCenter(UserCtx *user)
Builds translated periodic images for k-face centers (Centz).
PetscErrorCode MetricVelocityContravariant(const PetscReal J[3][3], PetscReal detJ, const PetscReal u[3], PetscReal uc[3])
Converts a Cartesian velocity vector to contravariant logical components.
Read-only flat arrays of one family of face planes (grid cells or dual cells).
Public interface for data input/output routines.
Logging utilities and macros for PETSc-based applications.
Main header file for a complex fluid dynamics solver.
Defines the vertices of a single hexahedral grid cell.
The six face planes of one hexahedron, indexed by Face, and its characteristic size.
A 3D point or vector with PetscScalar components.
One cell face as the particle search tests against it: a plane through the vertex mean.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.