PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Metric.h
Go to the documentation of this file.
1#ifndef METRIC_H
2#define METRIC_H
3
4// Include necessary headers
5#include <petsc.h>
6#include "variables.h" // Common type definitions
7#include "logging.h" // Logging macros and definitions
8#include <stdlib.h>
9#include "io.h"
10#include "setup.h" // For SetDMDAProcLayout
11
12/**
13 * @brief Maps a logical point inside one hexahedral cell to physical space.
14 *
15 * Uses trilinear interpolation of the eight cell vertices. Logical coordinates
16 * are measured from the cell's lower logical corner and normally lie in [0, 1].
17 *
18 * @param user Grid context used for cell indexing.
19 * @param X Ghosted node-coordinate array for the block.
20 * @param i Cell index in the xi direction.
21 * @param j Cell index in the eta direction.
22 * @param k Cell index in the zeta direction.
23 * @param xi Local xi coordinate within the cell.
24 * @param eta Local eta coordinate within the cell.
25 * @param zta Local zeta coordinate within the cell.
26 * @param[out] Xp Physical Cartesian position evaluated at the logical point.
27 * @return PetscErrorCode 0 on success.
28 */
29PetscErrorCode MetricLogicalToPhysical(UserCtx *user, const Cmpnts ***X,
30 PetscInt i,PetscInt j,PetscInt k,
31 PetscReal xi,PetscReal eta,PetscReal zta,
32 Cmpnts *Xp);
33
34/**
35 * @brief Collects the eight node coordinates of one logical hexahedral cell.
36 *
37 * Vertex ordering matches the trilinear metric kernels in this module.
38 *
39 * @param user Grid context used for cell indexing.
40 * @param X Ghosted node-coordinate array for the block.
41 * @param i Cell index in the xi direction.
42 * @param j Cell index in the eta direction.
43 * @param k Cell index in the zeta direction.
44 * @param[out] V Eight physical vertex coordinates in metric-kernel order.
45 * @return PetscErrorCode 0 on success.
46 */
47PetscErrorCode MetricGetCellVertices(UserCtx *user,const Cmpnts ***X,
48 PetscInt i,PetscInt j,PetscInt k,
49 Cmpnts V[8]);
50
51/**
52 * @brief Evaluates the trilinear mapping Jacobian and its determinant in one cell.
53 *
54 * The returned matrix is \f$\partial(x,y,z)/\partial(\xi,\eta,\zeta)\f$;
55 * callers use its determinant to reject degenerate or inverted cells.
56 *
57 * @param user Grid context used for cell indexing.
58 * @param X Ghosted node-coordinate array for the block.
59 * @param i Cell index in the xi direction.
60 * @param j Cell index in the eta direction.
61 * @param k Cell index in the zeta direction.
62 * @param xi Local xi coordinate within the cell.
63 * @param eta Local eta coordinate within the cell.
64 * @param zta Local zeta coordinate within the cell.
65 * @param[out] J Mapping Jacobian in row-major Cartesian/logical form.
66 * @param[out] detJ Determinant of J.
67 * @return PetscErrorCode 0 on success.
68 */
69PetscErrorCode MetricJacobian(UserCtx *user,const Cmpnts ***X,
70 PetscInt i,PetscInt j,PetscInt k,
71 PetscReal xi,PetscReal eta,PetscReal zta,
72 PetscReal J[3][3],PetscReal *detJ);
73
74/**
75 * @brief Converts a Cartesian velocity vector to contravariant logical components.
76 *
77 * Uses the inverse of the physical-to-logical Jacobian; `detJ` must describe
78 * the same mapping as `J` and must be nonzero.
79 *
80 * @param J Mapping Jacobian at the evaluation point.
81 * @param detJ Determinant of J.
82 * @param u Cartesian velocity components.
83 * @param[out] uc Contravariant xi/eta/zeta velocity components.
84 * @return PetscErrorCode 0 on success.
85 */
86PetscErrorCode MetricVelocityContravariant(const PetscReal J[3][3],
87 PetscReal detJ,
88 const PetscReal u[3],PetscReal uc[3]);
89
90/**
91 * @brief Computes the unit normal vectors and areas of the three faces of a computational cell.
92 *
93 * Given the metric vectors (csi, eta, zet), this function calculates the geometric
94 * properties of the cell faces aligned with the i, j, and k directions.
95 *
96 * @param csi Covariant xi metric vector.
97 * @param eta Covariant eta metric vector.
98 * @param zet Covariant zeta metric vector.
99 * @param[out] ni Unit normal of the xi-normal face.
100 * @param[out] nj Unit normal of the eta-normal face.
101 * @param[out] nk Unit normal of the zeta-normal face.
102 * @param[out] Ai Area of the xi-normal face.
103 * @param[out] Aj Area of the eta-normal face.
104 * @param[out] Ak Area of the zeta-normal face.
105 * @deprecated Unreachable from any executable: its only caller is
106 * @ref ComputeCellCharacteristicLengthScale, which has none. Kept for now with
107 * its unit tests; do not add new callers - use @ref ComputeCellDirectionalExtents or
108 * @ref ComputeCellEdgeVectors, which do not depend on the cell's orientation.
109 * @return PetscErrorCode 0 on success.
110 */
111PetscErrorCode CalculateFaceNormalAndArea(Cmpnts csi, Cmpnts eta, Cmpnts zet, double ni[3], double nj[3], double nk[3], double *Ai, double *Aj, double *Ak);
112
113/**
114 * @brief Inverts the 3x3 matrix of face-area vectors to obtain the covariant directions.
115 *
116 * The caller fills the rows with `csi`, `eta` and `zet` - the face-area vectors, which
117 * are the contravariant basis scaled by the cell Jacobian. The inverse's columns are the
118 * covariant (tangent) directions `dx/dxi`, `dx/deta`, `dx/dzeta` divided by that
119 * Jacobian, which is what `CalculateFaceNormalAndArea()` normalizes.
120 *
121 * Degeneracy is judged relative to the rows' own magnitude, because the determinant of
122 * area vectors scales as the square of the cell volume: an absolute floor would reject a
123 * well-formed cell purely for being small.
124 *
125 * @param covariantTensor Input: rows are the three face-area vectors.
126 * @param[out] contravariantTensor Inverse written in place.
127 * @deprecated Unreachable from any executable: its only caller is
128 * @ref CalculateFaceNormalAndArea, which is reached only from the deprecated
129 * @ref ComputeCellCharacteristicLengthScale. Kept for now with its unit tests;
130 * do not add new callers - use @ref ComputeCellDirectionalExtents or
131 * @ref ComputeCellEdgeVectors, which do not depend on the cell's orientation.
132 * @return PetscErrorCode 0 on success; `PETSC_ERR_MAT_LU_ZRPVT` when the rows are
133 * coplanar or one of them vanishes.
134 */
135PetscErrorCode InvertCovariantMetricTensor(double covariantTensor[3][3], double contravariantTensor[3][3]);
136
137/**
138 * @brief Computes characteristic length scales (dx, dy, dz) for a curvilinear cell.
139 *
140 * For a non-uniform, non-orthogonal cell, there is no single "dx". This function
141 * computes an effective length scale in each Cartesian direction based on the cell
142 * volume and the areas of its faces: the three outputs are the Cartesian components of
143 * the cell diagonal, so they change when an otherwise identical cell is rotated. Use
144 * @ref ComputeCellDirectionalExtents for a measure of the cell itself.
145 *
146 * @param ajc Cell Jacobian/volume metric at the cell center.
147 * @param csi Covariant xi metric vector.
148 * @param eta Covariant eta metric vector.
149 * @param zet Covariant zeta metric vector.
150 * @param[out] dx Effective physical length associated with xi variation.
151 * @param[out] dy Effective physical length associated with eta variation.
152 * @param[out] dz Effective physical length associated with zeta variation.
153 * @deprecated No production caller. Its outputs are Cartesian projections of the cell
154 * diagonal, so they change when an identical cell is rotated; the LES filter
155 * widths and the Clark term stopped using it for that reason. Kept for now
156 * with its unit tests; do not add new callers - use @ref ComputeCellDirectionalExtents or
157 * @ref ComputeCellEdgeVectors, which do not depend on the cell's orientation.
158 * @return PetscErrorCode 0 on success.
159 */
160PetscErrorCode ComputeCellCharacteristicLengthScale(PetscReal ajc, Cmpnts csi, Cmpnts eta, Cmpnts zet, double *dx, double *dy, double *dz);
161
162/**
163 * @brief Computes a cell's extent along each of its own grid directions.
164 *
165 * Each extent is the cell volume divided by the area of the face pair it crosses, which
166 * is the distance between those two faces. Unlike
167 * @ref ComputeCellCharacteristicLengthScale, whose outputs are the Cartesian components
168 * of the cell diagonal and so change when the same cell is rotated, these depend on the
169 * cell alone: a filter width built from them is the same for a cell in a straight
170 * section and for an identical cell turned by a bend.
171 *
172 * @param ajc Inverse cell volume at the cell center.
173 * @param csi Face-area vector of the xi faces.
174 * @param eta Face-area vector of the eta faces.
175 * @param zet Face-area vector of the zeta faces.
176 * @param[out] l_xi Extent across the xi faces.
177 * @param[out] l_eta Extent across the eta faces.
178 * @param[out] l_zeta Extent across the zeta faces.
179 * @return PetscErrorCode 0 on success; `PETSC_ERR_ARG_OUTOFRANGE` for a non-positive
180 * Jacobian or a face of zero area.
181 */
182PetscErrorCode ComputeCellDirectionalExtents(PetscReal ajc, Cmpnts csi, Cmpnts eta, Cmpnts zet,
183 double *l_xi, double *l_eta, double *l_zeta);
184
185/**
186 * @brief Computes a cell's edge vectors along its three grid directions.
187 *
188 * Each is the covariant basis vector `dx/dxi_k` over one index step: the physical
189 * displacement from one cell to the next along that grid line, with both its direction
190 * and its length. Projecting a velocity gradient onto it gives the change in velocity
191 * across the cell in that direction, which is what a direction-resolved subgrid model
192 * needs and what does not depend on how the grid is oriented.
193 *
194 * @param ajc Inverse cell volume at the cell center.
195 * @param csi Face-area vector of the xi faces.
196 * @param eta Face-area vector of the eta faces.
197 * @param zet Face-area vector of the zeta faces.
198 * @param[out] edges Edge vectors along xi, eta and zeta, in that order.
199 * @return PetscErrorCode 0 on success; `PETSC_ERR_ARG_OUTOFRANGE` for a non-positive Jacobian.
200 */
201PetscErrorCode ComputeCellEdgeVectors(PetscReal ajc, Cmpnts csi, Cmpnts eta, Cmpnts zet,
202 Cmpnts edges[3]);
203
204/**
205 * @brief Builds translated periodic images for cell centers and grid spacing.
206 *
207 * PETSc wraps field indices but does not translate coordinates. This routine
208 * applies the validated per-axis geometric translation to wrapped center
209 * coordinates and refreshes the associated local grid spacing.
210 *
211 * @param user The UserCtx containing grid and field data.
212 * @return PetscErrorCode 0 on success.
213 */
215
216/**
217 * @brief Builds translated periodic images for i-face centers (Centx).
218 *
219 * Every active periodic axis can affect the ghost images of Centx. This must
220 * be called after Centx is computed and before it is used for metric calculations.
221 *
222 * @param user The UserCtx containing grid and field data.
223 * @return PetscErrorCode 0 on success.
224 */
226
227/**
228 * @brief Builds translated periodic images for j-face centers (Centy).
229 *
230 * Every active periodic axis can affect the ghost images of Centy. This must
231 * be called after Centy is computed and before it is used for metric calculations.
232 *
233 * @param user The UserCtx containing grid and field data.
234 * @return PetscErrorCode 0 on success.
235 */
237
238/**
239 * @brief Builds translated periodic images for k-face centers (Centz).
240 *
241 * Every active periodic axis can affect the ghost images of Centz. This must
242 * be called after Centz is computed and before it is used for metric calculations.
243 *
244 * @param user The UserCtx containing grid and field data.
245 * @return PetscErrorCode 0 on success.
246 */
248
249/**
250 * @brief Computes the primary face metric components (Csi, Eta, Zet), including
251 * boundary extrapolation, and stores them in the corresponding global Vec
252 * members of the UserCtx structure (user->Csi, user->Eta, user->Zet).
253 *
254 * This is a self-contained routine that performs the following steps:
255 * 1. Obtains local ghosted nodal coordinates using DMGetCoordinatesLocal.
256 * 2. Calculates metrics for INTERIOR faces where finite difference stencils are valid.
257 * 3. EXTRAPOLATES metrics for faces on the physical domain boundaries by copying
258 * from the nearest computed interior face.
259 * 4. Assembles the global `user->Csi`, `user->Eta`, `user->Zet` Vecs.
260 * 5. Updates the local ghosted `user->lCsi`, `user->lEta`, `user->lZet` Vecs.
261 *
262 * @param[in,out] user Pointer to the UserCtx structure.
263 *
264 * @return PetscErrorCode 0 on success.
265 *
266 * @note
267 * - This function is a complete "compute and make ready" unit for Csi, Eta, and Zet.
268 * - It's recommended to call `VecZeroEntries` on user->Csi, Eta, Zet before this
269 * if they might contain old data.
270 */
271PetscErrorCode ComputeFaceMetrics(UserCtx *user);
272
273/**
274 * @brief Calculates the cell-centered inverse Jacobian determinant (1/J) for INTERIOR cells
275 * and stores it in `user->Aj`. This version includes boundary extrapolation.
276 *
277 * Nodal coordinates are obtained internally.
278 * Refer to previous Doxygen comments for details on physical locations and
279 * storage convention (`aj_arr[k_n][j_n][i_n]` for cell `C(i_n-1,j_n-1,k_n-1)`).
280 *
281 * @param[in,out] user Pointer to the UserCtx structure.
282 *
283 * @return PetscErrorCode 0 on success.
284 */
285PetscErrorCode ComputeCellCenteredJacobianInverse(UserCtx *user);
286
287/**
288 * @brief Verify and, when consistently inverted, repair the **right-handed** metric basis (`Csi`, `Eta`, `Zet`) and a
289 * **positive Jacobian** (`Aj`) over the whole domain.
290 *
291 * The metric-generation kernels are completely algebraic, so they will happily
292 * deliver a *left-handed* basis if the mesh file enumerates nodes in the
293 * opposite ζ-direction.
294 * This routine makes the orientation explicit and—if needed—repairs it
295 * **once per run**:
296 *
297 * | Step | Action |
298 * |------|--------|
299 * | 1 | Compute global `Aj_min`, `Aj_max`. |
300 * | 2 | **Mixed signs** (`Aj_min < 0 && Aj_max > 0`) &rarr; abort: the mesh is topologically inconsistent. |
301 * | 3 | **All negative** (`Aj_max < 0`) &rarr; abort: the grid is left-handed. Negating the metric vectors is not a valid repair (a mirrored duct solved that way was wrong by a factor of forty), so the grid must be renumbered along one logical axis instead. |
302 * | 4 | Store `user->GridOrientation = +1`, the only orientation the solver accepts. |
303 *
304 * @param[in,out] user Fully initialised #UserCtx that already contains
305 * `Csi`, `Eta`, `Zet`, `Aj`, their **local** ghosts, and
306 * valid distributed DMs.
307 *
308 * @return `0` on success or a PETSc error code on failure.
309 *
310 * @note Call **immediately after** `ComputeCellCenteredJacobianInverse()` and
311 * before any routine that differentiates or applies BCs.
312 *
313 * @note Author metadata intentionally omitted in API docs.
314 */
315PetscErrorCode CheckAndFixGridOrientation(UserCtx *user);
316
317/**
318 * @brief Computes the physical location of cell centers and the spacing between them.
319 *
320 * This function calculates two key geometric properties from the nodal coordinates:
321 * 1. `Cent`: A vector field storing the (x,y,z) coordinates of the center of each grid cell.
322 * 2. `GridSpace`: A vector field storing the physical distance between adjacent
323 * cell centers in the i, j, and k computational directions.
324 *
325 * It is a direct adaptation of the corresponding logic from the legacy `FormMetrics`.
326 *
327 * @param user The UserCtx for a specific grid level. The function populates `user->Cent` and `user->GridSpace`.
328 * @return PetscErrorCode 0 on success, or a PETSc error code on failure.
329 */
330PetscErrorCode ComputeCellCentersAndSpacing(UserCtx *user);
331
332/**
333 * @brief Computes metrics centered on constant-i faces (i-faces).
334 *
335 * This function calculates the metric terms (ICsi, IEta, IZet) and the inverse
336 * Jacobian (IAj) located at the center of each i-face. The stencils use
337 * i-face-centered coordinates (`Centx`) which must be computed first.
338 * The logic is a direct adaptation of the legacy FormMetrics function.
339 *
340 * @param user The UserCtx for a specific grid level. Populates user->ICsi, etc.
341 * @return PetscErrorCode 0 on success, or a PETSc error code on failure.
342 */
343PetscErrorCode ComputeIFaceMetrics(UserCtx *user);
344
345/**
346 * @brief Computes metrics centered on constant-j faces (j-faces).
347 *
348 * This function calculates the metric terms (`JCsi`, `JEta`, `JZet`) and the
349 * inverse Jacobian (`JAj`) located at the geometric center of each constant-j
350 * face. This is a critical step for staggered-grid finite difference schemes.
351 *
352 * The process is a direct and faithful refactoring of the corresponding logic
353 * from the legacy `FormMetrics` function:
354 * 1. It first calculates the physical (x,y,z) coordinates of the center of
355 * each i-face and stores them in the `user->Centy` vector.
356 * 2. It then uses a boundary-aware, second-order finite difference stencil on
357 * the `Centy` field to compute the derivatives (e.g., d(x)/d(csi)).
358 * - Central differences are used in the grid interior.
359 * - One-sided differences are used at the physical domain boundaries.
360 * 3. Finally, these derivatives are used to compute the final metric terms and
361 * the inverse Jacobian, which are stored in their respective `Vec` objects.
362 *
363 * @param user The UserCtx for a specific grid level. This function populates
364 * the `user->JCsi`, `user->JEta`, `user->JZet`, and `user->JAj` vectors.
365 * @return PetscErrorCode 0 on success, or a PETSc error code on failure.
366 */
367PetscErrorCode ComputeJFaceMetrics(UserCtx *user);
368
369/**
370 * @brief Computes metrics centered on constant-k faces (k-faces).
371 *
372 * This function calculates the metric terms (`KCsi`, `KEta`, `KZet`) and the
373 * inverse Jacobian (`KAj`) located at the geometric center of each constant-j
374 * face. This is a critical step for staggered-grid finite difference schemes.
375 *
376 * The process is a direct and faithful refactoring of the corresponding logic
377 * from the legacy `FormMetrics` function:
378 * 1. It first calculates the physical (x,y,z) coordinates of the center of
379 * each i-face and stores them in the `user->Centz` vector.
380 * 2. It then uses a boundary-aware, second-order finite difference stencil on
381 * the `Centz` field to compute the derivatives (e.g., d(x)/d(csi)).
382 * - Central differences are used in the grid interior.
383 * - One-sided differences are used at the physical domain boundaries.
384 * 3. Finally, these derivatives are used to compute the final metric terms and
385 * the inverse Jacobian, which are stored in their respective `Vec` objects.
386 *
387 * @param user The UserCtx for a specific grid level. This function populates
388 * the `user->KCsi`, `user->KEta`, `user->KZet`, and `user->KAj` vectors.
389 * @return PetscErrorCode 0 on success, or a PETSc error code on failure.
390 */
391PetscErrorCode ComputeKFaceMetrics(UserCtx *user);
392
393/**
394 * @brief Performs a diagnostic check on the divergence of the face area metric vectors.
395 *
396 * For a closed cell, the sum of the face area vectors should be zero (Gauss's
397 * divergence theorem). This function computes a measure of this divergence and
398 * reports the maximum value over the domain. A small value indicates a
399 * well-formed grid. This is a direct adaptation of the legacy function.
400 *
401 * @param user The UserCtx for a specific grid level (typically the finest).
402 * @return PetscErrorCode 0 on success, or a PETSc error code on failure.
403 */
404PetscErrorCode ComputeMetricsDivergence(UserCtx *user);
405
406/**
407 * @brief Computes the max-min values of the grid metrics.
408 *
409 * This function serves as a diagnostic tool to assess the quality of the grid
410 * metrics. It calculates the bounds of the face metrics (Csi, Eta, Zet).
411 *
412 * @param user The UserCtx, containing all necessary grid data.
413 * @return PetscErrorCode
414 */
415PetscErrorCode ComputeMetricNorms(UserCtx *user);
416
417/**
418 * @brief Orchestrates the calculation of all grid metrics.
419 *
420 * This function iterates through every UserCtx in the multigrid and multi-block
421 * hierarchy. For each context, it calls a series of modern, modular helper
422 * functions to compute the face metrics (Csi, Eta, Zet), the cell-centered
423 * inverse Jacobian (Aj), and to validate the grid's orientation.
424 *
425 * @param simCtx The master SimCtx, containing the configured UserCtx hierarchy.
426 * @return PetscErrorCode
427 */
428PetscErrorCode CalculateAllGridMetrics(SimCtx *simCtx);
429#endif /* METRIC_H */
PetscErrorCode ComputeCellEdgeVectors(PetscReal ajc, Cmpnts csi, Cmpnts eta, Cmpnts zet, Cmpnts edges[3])
Computes a cell's edge vectors along its three grid directions.
Definition Metric.c:360
PetscErrorCode CalculateAllGridMetrics(SimCtx *simCtx)
Orchestrates the calculation of all grid metrics.
Definition Metric.c:1993
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.
Definition Metric.c:105
PetscErrorCode InvertCovariantMetricTensor(double covariantTensor[3][3], double contravariantTensor[3][3])
Inverts the 3x3 matrix of face-area vectors to obtain the covariant directions.
Definition Metric.c:202
PetscErrorCode ComputeMetricNorms(UserCtx *user)
Computes the max-min values of the grid metrics.
Definition Metric.c:1861
PetscErrorCode ApplyPeriodicCorrectionsToCellCentersAndSpacing(UserCtx *user)
Builds translated periodic images for cell centers and grid spacing.
Definition Metric.c:444
PetscErrorCode CheckAndFixGridOrientation(UserCtx *user)
Verify and, when consistently inverted, repair the right-handed metric basis (Csi,...
Definition Metric.c:389
PetscErrorCode ComputeCellCentersAndSpacing(UserCtx *user)
Computes the physical location of cell centers and the spacing between them.
Definition Metric.c:1046
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.
Definition Metric.c:26
PetscErrorCode ComputeJFaceMetrics(UserCtx *user)
Computes metrics centered on constant-j faces (j-faces).
Definition Metric.c:1360
PetscErrorCode ComputeMetricsDivergence(UserCtx *user)
Performs a diagnostic check on the divergence of the face area metric vectors.
Definition Metric.c:1769
PetscErrorCode ComputeFaceMetrics(UserCtx *user)
Computes the primary face metric components (Csi, Eta, Zet), including boundary extrapolation,...
Definition Metric.c:690
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.
Definition Metric.c:297
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.
Definition Metric.c:251
PetscErrorCode ApplyPeriodicCorrectionsToIFaceCenter(UserCtx *user)
Builds translated periodic images for i-face centers (Centx).
Definition Metric.c:643
PetscErrorCode ComputeCellCenteredJacobianInverse(UserCtx *user)
Calculates the cell-centered inverse Jacobian determinant (1/J) for INTERIOR cells and stores it in u...
Definition Metric.c:902
PetscErrorCode ComputeKFaceMetrics(UserCtx *user)
Computes metrics centered on constant-k faces (k-faces).
Definition Metric.c:1555
PetscErrorCode ApplyPeriodicCorrectionsToJFaceCenter(UserCtx *user)
Builds translated periodic images for j-face centers (Centy).
Definition Metric.c:659
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.
Definition Metric.c:328
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.
Definition Metric.c:76
PetscErrorCode ComputeIFaceMetrics(UserCtx *user)
Computes metrics centered on constant-i faces (i-faces).
Definition Metric.c:1149
PetscErrorCode ApplyPeriodicCorrectionsToKFaceCenter(UserCtx *user)
Builds translated periodic images for k-face centers (Centz).
Definition Metric.c:675
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.
Definition Metric.c:165
Public interface for data input/output routines.
Logging utilities and macros for PETSc-based applications.
Main header file for a complex fluid dynamics solver.
A 3D point or vector with PetscScalar components.
Definition variables.h:121
The master context for the entire simulation.
Definition variables.h:859
User-defined context containing data specific to a single computational grid level.
Definition variables.h:1074