// Setup code for running any simulation More...
#include <ctype.h>#include <errno.h>#include "setup.h"#include "statistics_config.h"#include "statistics_accumulator.h"#include "ParticleInitialConditions.h"#include "verification_sources.h"#include <unistd.h>#include <limits.h>#include <stdlib.h>Go to the source code of this file.
Macros | |
| #define | PICURV_STRINGIZE_(x) #x |
| #define | PICURV_STRINGIZE(x) PICURV_STRINGIZE_(x) |
| #define | PICURV_PETSC_MODE "optimized" |
| #define | PETSC_ARCH "" |
| #define | PETSC_DIR "" |
| #define | PICURV_PETSC_STAMP_MARKER "PICURV_PETSC_BUILD:" |
| #define | __FUNCT__ "LESConfigSetDefaults" |
| #define | __FUNCT__ "ParseLESConfiguration" |
| #define | __FUNCT__ "CreateSimulationContext" |
| #define | __FUNCT__ "PetscMkdirRecursive" |
| #define | __FUNCT__ "SetupSimulationEnvironment" |
| #define | __FUNCT__ "AllocateContextHeirarchy" |
| #define | __FUNCT__ "SetupGridAndSolvers" |
| #define | __FUNCT__ "CreateAndInitializeAllVectors" |
| #define | __FUNCT__ "RepairPeriodicNormalFaceGhosts" |
| #define | __FUNCT__ "UpdateLocalGhosts" |
| #define | __FUNCT__ "SetupBoundaryConditions" |
| #define | __FUNCT__ "GetOwnedCellRange" |
| #define | __FUNCT__ "ComputeAndStoreNeighborRanks" |
| #define | __FUNCT__ "SetDMDAProcLayout" |
| #define | __FUNCT__ "SetupDomainRankInfo" |
| #define | __FUNCT__ "Contra2Cart" |
| #define | __FUNCT__ "Cart2Contra" |
| #define | __FUNCT__ "UniformCart2Contra" |
| #define | __FUNCT__ "SetupDomainCellDecompositionMap" |
| #define | __FUNCT__ "BinarySearchInt64" |
| #define | __FUNCT__ "ComputeDivergence" |
| #define | __FUNCT__ "InitializeRandomGenerators" |
| #define | __FUNCT__ "InitializeLogicalSpaceRNGs" |
| #define | __FUNCT__ "InitializeBrownianRNG" |
| #define | __FUNCT__ "TransformScalarDerivativesToPhysical" |
| #define | __FUNCT__ "TransformDerivativesToPhysical" |
| #define | __FUNCT__ "ComputeScalarFieldDerivatives" |
| #define | __FUNCT__ "ComputeVectorFieldDerivatives" |
| #define | __FUNCT__ "DestroyUserVectors" |
| #define | __FUNCT__ "DestroyUserContext" |
| #define | __FUNCT__ "FinalizeSimulation" |
Functions | |
| int | PicurvHandleVersionArgument (int argc, char **argv, const char *executable_name) |
| Implementation of PicurvHandleVersionArgument(). | |
| PetscBool | RuntimeWalltimeGuardParsePositiveSeconds (const char *text, PetscReal *seconds_out) |
| Implementation of RuntimeWalltimeGuardParsePositiveSeconds(). | |
| PetscErrorCode | InitializeSolutionConvergenceState (SimCtx *simCtx) |
| Implementation of InitializeSolutionConvergenceState(). | |
| PetscErrorCode | DestroySolutionConvergenceState (SimCtx *simCtx) |
| Implementation of DestroySolutionConvergenceState(). | |
| PetscErrorCode | LESConfigSetDefaults (LESConfig *config) |
| Implementation of LESConfigSetDefaults(). | |
| static PetscErrorCode | ParseLESConfiguration (SimCtx *simCtx) |
| Reads every LES closure parameter from the generated control file. | |
| PetscErrorCode | CreateSimulationContext (int argc, char **argv, SimCtx **p_simCtx) |
| Implementation of CreateSimulationContext(). | |
| static PetscErrorCode | PetscMkdirRecursive (const char *path) |
| Create a directory path recursively using PETSc-compatible error handling. | |
| static PetscBool | DirectoriesOverlap (const char *first, const char *second) |
| Whether two configured directories denote the same location or nest. | |
| static PetscBool | DirectoryValueIsWellFormed (const char *value) |
| Whether a configured directory name is safe to write to a PETSc options line. | |
| static PetscBool | DirectoryHitsReservedName (const char *value) |
| Whether a directory's first path segment collides with a reserved run directory. | |
| static PetscBool | NormalizePathLexically (const char *value, char *out, size_t size, char *stack) |
| Lexically normalize a path, resolving "." and ".." textually. | |
| static PetscBool | ResolveDirectoryPhysically (const char *value, const char *cwd, char *out, size_t size, char *scratch) |
| Resolve a directory that may not exist yet to an absolute physical path. | |
| static PetscBool | PathContainsOrEquals (const char *ancestor, const char *path) |
Whether ancestor is the same directory as path, or contains it. | |
| static DirectoryVerdict | ClassifyLogDirectory (const char *log_dir, const char *output_dir, const char **reason) |
| Classify a configured log directory against the working directory. | |
| static PetscBool | LogDirectoryIsSafeToWipe (const char *log_dir, const char *output_dir, PetscBool authorized, const char **reason) |
| Final safety guard before the runtime deletes its log directory. | |
| PetscErrorCode | SetupSimulationEnvironment (SimCtx *simCtx) |
Internal helper implementation: SetupSimulationEnvironment(). | |
| static PetscErrorCode | AllocateContextHierarchy (SimCtx *simCtx) |
| Allocate the user-context objects required by every multigrid level. | |
| PetscErrorCode | SetupGridAndSolvers (SimCtx *simCtx) |
| Implementation of SetupGridAndSolvers(). | |
| PetscErrorCode | CreateAndInitializeAllVectors (SimCtx *simCtx) |
Internal helper implementation: CreateAndInitializeAllVectors(). | |
| static PetscErrorCode | RepairPeriodicNormalFaceGhosts (UserCtx *user, DM dm, Vec local_vec, PetscInt dof, char face_direction, PetscBool component_staggered) |
| Repairs the adjacent normal ghost layer for periodic face-staggered data. | |
| PetscErrorCode | UpdateLocalGhosts (UserCtx *user, FieldId field_id) |
| Updates a catalogued field's local ghost representation. | |
| PetscErrorCode | SetupBoundaryConditions (SimCtx *simCtx) |
Internal helper implementation: SetupBoundaryConditions(). | |
| PetscErrorCode | Allocate3DArrayScalar (PetscReal ****array, PetscInt nz, PetscInt ny, PetscInt nx) |
Internal helper implementation: Allocate3DArrayScalar(). | |
| PetscErrorCode | Deallocate3DArrayScalar (PetscReal ***array, PetscInt nz, PetscInt ny) |
Internal helper implementation: Deallocate3DArrayScalar(). | |
| PetscErrorCode | Allocate3DArrayVector (Cmpnts ****array, PetscInt nz, PetscInt ny, PetscInt nx) |
| Implementation of Allocate3DArrayVector(). | |
| PetscErrorCode | Deallocate3DArrayVector (Cmpnts ***array, PetscInt nz, PetscInt ny) |
| Implementation of Deallocate3DArrayVector(). | |
| PetscErrorCode | GetOwnedCellRange (const DMDALocalInfo *info_nodes, PetscInt dim, PetscInt *xs_cell_global_out, PetscInt *xm_cell_local_out) |
Internal helper implementation: GetOwnedCellRange(). | |
| PetscErrorCode | ComputeAndStoreNeighborRanks (UserCtx *user) |
Internal helper implementation: ComputeAndStoreNeighborRanks(). | |
| PetscErrorCode | SetDMDAProcLayout (DM dm, UserCtx *user) |
Internal helper implementation: SetDMDAProcLayout(). | |
| PetscErrorCode | SetupDomainRankInfo (SimCtx *simCtx) |
| Implementation of SetupDomainRankInfo(). | |
| PetscErrorCode | Contra2Cart (UserCtx *user) |
Internal helper implementation: Contra2Cart(). | |
| PetscErrorCode | Cart2Contra (UserCtx *user) |
| Convert a spatially varying Cartesian velocity field to contravariant fluxes. | |
| PetscErrorCode | UniformCart2Contra (UserCtx *user, PetscReal u, PetscReal v, PetscReal w) |
| Populate contravariant fluxes from one uniform Cartesian velocity. | |
| PetscErrorCode | SetupDomainCellDecompositionMap (UserCtx *user) |
Internal helper implementation: SetupDomainCellDecompositionMap(). | |
| PetscErrorCode | BinarySearchInt64 (PetscInt n, const PetscInt64 arr[], PetscInt64 key, PetscBool *found) |
| Implementation of BinarySearchInt64(). | |
| static PetscInt | Gidx (PetscInt i, PetscInt j, PetscInt k, UserCtx *user) |
| Convert logical indices into the flattened global index used by setup helpers. | |
| PetscErrorCode | ComputeDivergence (UserCtx *user) |
| Implementation of ComputeDivergence(). | |
| PetscErrorCode | InitializeRandomGenerators (UserCtx *user, PetscRandom *randx, PetscRandom *randy, PetscRandom *randz) |
| Implementation of InitializeRandomGenerators(). | |
| PetscErrorCode | InitializeLogicalSpaceRNGs (PetscInt base_seed, PetscRandom *rand_logic_i, PetscRandom *rand_logic_j, PetscRandom *rand_logic_k) |
Internal helper implementation: InitializeLogicalSpaceRNGs(). | |
| PetscErrorCode | InitializeBrownianRNG (SimCtx *simCtx) |
Internal helper implementation: InitializeBrownianRNG(). | |
| void | TransformScalarDerivativesToPhysical (PetscReal jacobian, Cmpnts csi_metrics, Cmpnts eta_metrics, Cmpnts zet_metrics, PetscReal dPhi_dcsi, PetscReal dPhi_deta, PetscReal dPhi_dzet, Cmpnts *gradPhi) |
| Implementation of TransformScalarDerivativesToPhysical(). | |
| static void | TransformDerivativesToPhysical (PetscReal jacobian, Cmpnts csi_metrics, Cmpnts eta_metrics, Cmpnts zet_metrics, Cmpnts deriv_csi, Cmpnts deriv_eta, Cmpnts deriv_zet, Cmpnts *dudx, Cmpnts *dvdx, Cmpnts *dwdx) |
| Transform contravariant vector derivatives into physical Cartesian derivatives. | |
| PetscErrorCode | ComputeScalarFieldDerivatives (UserCtx *user, PetscInt i, PetscInt j, PetscInt k, PetscReal ***field_data, Cmpnts *grad) |
Internal helper implementation: ComputeScalarFieldDerivatives(). | |
| PetscErrorCode | ComputeVectorFieldDerivatives (UserCtx *user, PetscInt i, PetscInt j, PetscInt k, Cmpnts ***field_data, Cmpnts *dudx, Cmpnts *dvdx, Cmpnts *dwdx) |
Internal helper implementation: ComputeVectorFieldDerivatives(). | |
| PetscErrorCode | DestroyUserVectors (UserCtx *user) |
Internal helper implementation: DestroyUserVectors(). | |
| PetscErrorCode | DestroyUserContext (UserCtx *user) |
Internal helper implementation: DestroyUserContext(). | |
| PetscErrorCode | FinalizeSimulation (SimCtx *simCtx) |
| Implementation of FinalizeSimulation(). | |
Variables | |
| static const char | picurv_petsc_build_stamp [] |
| static const char * | kReservedRunDirectories [] = {"config", "scheduler", "checkpoints", "visualization", NULL} |
| Directory names the run tree owns; a log directory must never target one. | |
// Setup code for running any simulation
Test program for DMSwarm interpolation using the fdf-curvIB method. Provides the setup to start any simulation with DMSwarm and DMDAs.
Definition in file setup.c.
| #define PICURV_STRINGIZE | ( | x | ) | PICURV_STRINGIZE_(x) |
| enum DirectoryVerdict |
Definition at line 1387 of file setup.c.
| int PicurvHandleVersionArgument | ( | int | argc, |
| char ** | argv, | ||
| const char * | executable_name | ||
| ) |
Implementation of PicurvHandleVersionArgument().
Print the shared native build identity when a version flag is present.
The public argument and return contract is documented in include/setup.h.
Definition at line 47 of file setup.c.
| PetscBool RuntimeWalltimeGuardParsePositiveSeconds | ( | const char * | text, |
| PetscReal * | seconds_out | ||
| ) |
Implementation of RuntimeWalltimeGuardParsePositiveSeconds().
Parse a positive floating-point seconds value from runtime metadata.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 67 of file setup.c.
| PetscErrorCode InitializeSolutionConvergenceState | ( | SimCtx * | simCtx | ) |
Implementation of InitializeSolutionConvergenceState().
Allocates any runtime storage required by solution-convergence logging.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 96 of file setup.c.
| PetscErrorCode DestroySolutionConvergenceState | ( | SimCtx * | simCtx | ) |
Implementation of DestroySolutionConvergenceState().
Frees any runtime storage allocated for solution-convergence logging.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 148 of file setup.c.
| PetscErrorCode LESConfigSetDefaults | ( | LESConfig * | config | ) |
Implementation of LESConfigSetDefaults().
Installs the shipped defaults for every LES closure parameter.
Full API contract is documented with the header declaration in include/setup.h.
Definition at line 206 of file setup.c.
|
static |
Reads every LES closure parameter from the generated control file.
Grouped into one routine because the parameters constrain one another: the averaging directions only mean something under homogeneous averaging, and the clip ceiling only under clamping. Selectors arrive as integers that the Python layer has already normalized from their user-facing names, which is the same contract -les, -pinit, and -interpolation_method follow.
Values that would make the closure ill-defined are rejected here as well as in Python, so a hand-written control file fails with a reason rather than producing a plausible-looking coefficient.
| [in,out] | simCtx | Simulation context whose les_config is populated. |
PETSC_ERR_ARG_OUTOFRANGE for a value outside its admissible range. Definition at line 259 of file setup.c.
| PetscErrorCode CreateSimulationContext | ( | int | argc, |
| char ** | argv, | ||
| SimCtx ** | p_simCtx | ||
| ) |
Implementation of CreateSimulationContext().
Allocates and populates the master SimulationContext object.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 371 of file setup.c.
|
static |
Create a directory path recursively using PETSc-compatible error handling.
Definition at line 1232 of file setup.c.
|
static |
Whether two configured directories denote the same location or nest.
A bare strcmp accepted "output/" against "output", and missed "output/sub" entirely. Comparison is done on normalized segment sequences so trailing slashes, "./" prefixes and repeated separators cannot defeat it.
| [in] | first | First directory value. |
| [in] | second | Second directory value. |
Definition at line 1289 of file setup.c.
|
static |
Whether a configured directory name is safe to write to a PETSc options line.
Whitespace, quotes, and comment markers change how the options file is tokenized, so a value carrying them would be misread rather than merely unsafe. This is never waivable: the user cannot consent to ambiguity.
| [in] | value | Configured directory value. |
Definition at line 1340 of file setup.c.
|
static |
Whether a directory's first path segment collides with a reserved run directory.
| [in] | value | Configured directory value. |
Definition at line 1358 of file setup.c.
|
static |
Lexically normalize a path, resolving "." and ".." textually.
Used only when the target does not exist yet, so realpath cannot resolve it. Resolving ".." textually is correct here precisely because there is no file to be a symlink; the existing prefix is resolved separately with realpath, which does follow symlinks.
| [in] | value | Path to normalize. |
| [out] | out | Buffer receiving the normalized path. |
| [in] | size | Size of the output buffer. |
| [out] | stack | Caller-provided scratch of at least PETSC_MAX_PATH_LEN bytes. |
Definition at line 1414 of file setup.c.
|
static |
Resolve a directory that may not exist yet to an absolute physical path.
realpath fails on a path whose final components have not been created, which is the normal case for a log directory. The longest existing prefix is resolved with realpath, so symlinked ancestors are followed, and the remainder is appended lexically.
| [in] | value | Configured directory value. |
| [in] | cwd | Current working directory, for relative values. |
| [out] | out | Buffer receiving the resolved absolute path. |
| [in] | size | Size of the output buffer. |
| [out] | scratch | Caller-provided scratch of at least 5*PETSC_MAX_PATH_LEN bytes. |
Definition at line 1474 of file setup.c.
|
static |
Whether ancestor is the same directory as path, or contains it.
| [in] | ancestor | Candidate containing directory, absolute and normalized. |
| [in] | path | Candidate contained directory, absolute and normalized. |
ancestor equals or contains path. Definition at line 1525 of file setup.c.
|
static |
Classify a configured log directory against the working directory.
Every non-waivable check - lexical and physical alike - runs before the caller is allowed to consider an authorization. An earlier version returned safe as soon as it saw an absolute path with authorization set, which let an authorized run delete its own run directory, an ancestor of it, or the filesystem root. Classification is now total and the waiver is applied once, to exactly one verdict.
| [in] | log_dir | Configured log directory. |
| [in] | output_dir | Configured output directory, for the overlap check. |
| [out] | reason | Set to a short explanation of the verdict. |
Definition at line 1549 of file setup.c.
|
static |
Final safety guard before the runtime deletes its log directory.
picurv validates run directories and re-checks them at submission, but the solver can be launched directly on a hand-written control file, and a directory can be replaced with a symlink between validation and launch. This is the last check before an irreversible recursive delete, so it is deliberately independent of anything the launcher did, which is what eliminates the validation-to-execution race.
An explicit -allow_unsafe_log_dir authorization waives exactly one verdict: an absolute location outside the working directory that neither is nor contains it. It never waives the working directory itself, an ancestor of it, a reserved run directory, an overlap with the output directory, a relative traversal, a relative symlink escape, or a malformed value. Those destroy the run itself or corrupt the options file, and no user consent makes them correct.
| [in] | log_dir | Configured log directory. |
| [in] | output_dir | Configured output directory, for the overlap check. |
| [in] | authorized | Whether an explicit unsafe-path authorization was supplied. |
| [out] | reason | Set to a short explanation when the directory is refused. |
Definition at line 1669 of file setup.c.
| PetscErrorCode SetupSimulationEnvironment | ( | SimCtx * | simCtx | ) |
Internal helper implementation: SetupSimulationEnvironment().
Verifies and prepares the complete I/O environment for a simulation run.
Local to this translation unit.
Definition at line 1685 of file setup.c.
|
static |
Allocate the user-context objects required by every multigrid level.
Definition at line 1897 of file setup.c.
| PetscErrorCode SetupGridAndSolvers | ( | SimCtx * | simCtx | ) |
Implementation of SetupGridAndSolvers().
The main orchestrator for setting up all grid-related components.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 2001 of file setup.c.
| PetscErrorCode CreateAndInitializeAllVectors | ( | SimCtx * | simCtx | ) |
Internal helper implementation: CreateAndInitializeAllVectors().
Creates and initializes all PETSc Vec objects for all fields.
Local to this translation unit.
Definition at line 2036 of file setup.c.
|
static |
Repairs the adjacent normal ghost layer for periodic face-staggered data.
PETSc wraps every component with cell-style indexing. A face family instead needs its adjacent normal ghost shifted by one additional physical face. With the width-three periodic DMDA, the required value is available in the deeper PETSc ghost at -3 or n+2. Tangential ghosts retain PETSc's native wraparound.
Definition at line 2319 of file setup.c.
Updates a catalogued field's local ghost representation.
Updates the local vector (including ghost points) from its corresponding global vector.
Resolves the typed field view, performs the existing PETSc scatter, and applies the established periodic normal-face repair when needed.
Definition at line 2489 of file setup.c.
| PetscErrorCode SetupBoundaryConditions | ( | SimCtx * | simCtx | ) |
Internal helper implementation: SetupBoundaryConditions().
(Orchestrator) Sets up all boundary conditions for the simulation.
Local to this translation unit.
Definition at line 2678 of file setup.c.
| PetscErrorCode Allocate3DArrayScalar | ( | PetscReal **** | array, |
| PetscInt | nz, | ||
| PetscInt | ny, | ||
| PetscInt | nx | ||
| ) |
Internal helper implementation: Allocate3DArrayScalar().
Allocates a 3D array of PetscReal values using PetscCalloc.
Local to this translation unit.
Definition at line 2742 of file setup.c.
| PetscErrorCode Deallocate3DArrayScalar | ( | PetscReal *** | array, |
| PetscInt | nz, | ||
| PetscInt | ny | ||
| ) |
Internal helper implementation: Deallocate3DArrayScalar().
Deallocates a 3D array of PetscReal values allocated by Allocate3DArrayScalar.
Local to this translation unit.
Definition at line 2777 of file setup.c.
| PetscErrorCode Allocate3DArrayVector | ( | Cmpnts **** | array, |
| PetscInt | nz, | ||
| PetscInt | ny, | ||
| PetscInt | nx | ||
| ) |
Implementation of Allocate3DArrayVector().
Allocates a contiguous 3D array of Cmpnts values.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 2820 of file setup.c.
| PetscErrorCode Deallocate3DArrayVector | ( | Cmpnts *** | array, |
| PetscInt | nz, | ||
| PetscInt | ny | ||
| ) |
Implementation of Deallocate3DArrayVector().
Deallocates a 3D array of Cmpnts structures allocated by Allocate3DArrayVector.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 2870 of file setup.c.
| PetscErrorCode GetOwnedCellRange | ( | const DMDALocalInfo * | info_nodes, |
| PetscInt | dim, | ||
| PetscInt * | xs_cell_global_out, | ||
| PetscInt * | xm_cell_local_out | ||
| ) |
Internal helper implementation: GetOwnedCellRange().
Determines the global starting index and number of CELLS owned by the current processor in a specified dimension.
Local to this translation unit.
Definition at line 2936 of file setup.c.
| PetscErrorCode ComputeAndStoreNeighborRanks | ( | UserCtx * | user | ) |
Internal helper implementation: ComputeAndStoreNeighborRanks().
Computes and stores the Cartesian neighbor ranks for the DMDA decomposition.
Local to this translation unit.
Definition at line 3033 of file setup.c.
| PetscErrorCode SetDMDAProcLayout | ( | DM | dm, |
| UserCtx * | user | ||
| ) |
Internal helper implementation: SetDMDAProcLayout().
Sets the processor layout for a given DMDA based on PETSc options.
Local to this translation unit.
Definition at line 3149 of file setup.c.
| PetscErrorCode SetupDomainRankInfo | ( | SimCtx * | simCtx | ) |
Implementation of SetupDomainRankInfo().
Sets up the full rank communication infrastructure, including neighbor ranks and bounding box exchange.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 3227 of file setup.c.
| PetscErrorCode Contra2Cart | ( | UserCtx * | user | ) |
Internal helper implementation: Contra2Cart().
Reconstructs Cartesian velocity (Ucat) at cell centers from contravariant velocity (Ucont) defined on cell faces.
Local to this translation unit.
Definition at line 3300 of file setup.c.
| PetscErrorCode Cart2Contra | ( | UserCtx * | user | ) |
Convert a spatially varying Cartesian velocity field to contravariant fluxes.
Convert the ghosted Cartesian velocity field to contravariant face fluxes.
Definition at line 3435 of file setup.c.
| PetscErrorCode UniformCart2Contra | ( | UserCtx * | user, |
| PetscReal | u, | ||
| PetscReal | v, | ||
| PetscReal | w | ||
| ) |
Populate contravariant fluxes from one uniform Cartesian velocity.
| [in,out] | user | UserCtx for the block; Ucont is written in place. |
| [in] | u | Physical x-velocity component. |
| [in] | v | Physical y-velocity component. |
| [in] | w | Physical z-velocity component. |
Definition at line 3504 of file setup.c.
| PetscErrorCode SetupDomainCellDecompositionMap | ( | UserCtx * | user | ) |
Internal helper implementation: SetupDomainCellDecompositionMap().
Creates and distributes a map of the domain's cell decomposition to all ranks.
Local to this translation unit.
Definition at line 3551 of file setup.c.
| PetscErrorCode BinarySearchInt64 | ( | PetscInt | n, |
| const PetscInt64 | arr[], | ||
| PetscInt64 | key, | ||
| PetscBool * | found | ||
| ) |
Implementation of BinarySearchInt64().
Performs a binary search for a key in a sorted array of PetscInt64.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 3616 of file setup.c.
|
static |
Convert logical indices into the flattened global index used by setup helpers.
Definition at line 3659 of file setup.c.
| PetscErrorCode ComputeDivergence | ( | UserCtx * | user | ) |
Implementation of ComputeDivergence().
Computes the discrete divergence of the contravariant velocity field.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 3685 of file setup.c.
| PetscErrorCode InitializeRandomGenerators | ( | UserCtx * | user, |
| PetscRandom * | randx, | ||
| PetscRandom * | randy, | ||
| PetscRandom * | randz | ||
| ) |
Implementation of InitializeRandomGenerators().
Initializes random number generators for assigning particle properties.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 3851 of file setup.c.
| PetscErrorCode InitializeLogicalSpaceRNGs | ( | PetscInt | base_seed, |
| PetscRandom * | rand_logic_i, | ||
| PetscRandom * | rand_logic_j, | ||
| PetscRandom * | rand_logic_k | ||
| ) |
Internal helper implementation: InitializeLogicalSpaceRNGs().
Initializes random number generators for logical space operations [0.0, 1.0).
Local to this translation unit.
Definition at line 3895 of file setup.c.
| PetscErrorCode InitializeBrownianRNG | ( | SimCtx * | simCtx | ) |
Internal helper implementation: InitializeBrownianRNG().
Initializes a single master RNG for time-stepping physics (Brownian motion).
Local to this translation unit.
Definition at line 3940 of file setup.c.
| void TransformScalarDerivativesToPhysical | ( | PetscReal | jacobian, |
| Cmpnts | csi_metrics, | ||
| Cmpnts | eta_metrics, | ||
| Cmpnts | zet_metrics, | ||
| PetscReal | dPhi_dcsi, | ||
| PetscReal | dPhi_deta, | ||
| PetscReal | dPhi_dzet, | ||
| Cmpnts * | gradPhi | ||
| ) |
Implementation of TransformScalarDerivativesToPhysical().
Transforms scalar derivatives from computational space to physical space.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 3983 of file setup.c.
|
static |
Transform contravariant vector derivatives into physical Cartesian derivatives.
Definition at line 4007 of file setup.c.
| PetscErrorCode ComputeScalarFieldDerivatives | ( | UserCtx * | user, |
| PetscInt | i, | ||
| PetscInt | j, | ||
| PetscInt | k, | ||
| PetscReal *** | field_data, | ||
| Cmpnts * | grad | ||
| ) |
Internal helper implementation: ComputeScalarFieldDerivatives().
Computes the gradient of a cell-centered SCALAR field at a specific grid point.
Local to this translation unit.
Definition at line 4031 of file setup.c.
| PetscErrorCode ComputeVectorFieldDerivatives | ( | UserCtx * | user, |
| PetscInt | i, | ||
| PetscInt | j, | ||
| PetscInt | k, | ||
| Cmpnts *** | field_data, | ||
| Cmpnts * | dudx, | ||
| Cmpnts * | dvdx, | ||
| Cmpnts * | dwdx | ||
| ) |
Internal helper implementation: ComputeVectorFieldDerivatives().
Computes the derivatives of a cell-centered vector field at a specific grid point.
Local to this translation unit.
Definition at line 4074 of file setup.c.
| PetscErrorCode DestroyUserVectors | ( | UserCtx * | user | ) |
Internal helper implementation: DestroyUserVectors().
Destroys all PETSc Vec objects within a single UserCtx structure.
Local to this translation unit.
Definition at line 4128 of file setup.c.
| PetscErrorCode DestroyUserContext | ( | UserCtx * | user | ) |
Internal helper implementation: DestroyUserContext().
Destroys all resources allocated within a single UserCtx structure.
Local to this translation unit.
Definition at line 4278 of file setup.c.
| PetscErrorCode FinalizeSimulation | ( | SimCtx * | simCtx | ) |
Implementation of FinalizeSimulation().
Main cleanup function for the entire simulation context.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/setup.h.
Definition at line 4368 of file setup.c.
|
static |