|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
Public interface for data input/output routines. More...
Go to the source code of this file.
Functions | |
| PetscErrorCode | ReadGridGenerationInputs (UserCtx *user) |
| Parses command-line options for a programmatically generated grid for a SINGLE block. | |
| PetscErrorCode | PopulateFinestUserGridResolutionFromOptions (UserCtx *finest_users, PetscInt nblk) |
Parses grid resolution arrays (-im, -jm, -km) once and applies them to all finest-grid blocks. | |
| PetscErrorCode | ReadGridFile (UserCtx *user) |
| Sets grid dimensions from a file for a SINGLE block using a one-time read cache. | |
| PetscErrorCode | VerifyPathExistence (const char *path, PetscBool is_dir, PetscBool is_optional, const char *description, PetscBool *exists) |
| A parallel-safe helper to verify the existence of a generic file or directory path. | |
| PetscBool | ShouldWriteDataOutput (const SimCtx *simCtx, PetscInt completed_step) |
| Returns whether full field/restart output should be written for the. | |
| PetscErrorCode | ReadSimulationFields (UserCtx *user, PetscInt ti) |
| Reads binary field data for velocity, pressure, and other required vectors. | |
| PetscErrorCode | ReadFieldData (UserCtx *user, const char *field_name, Vec field_vec, PetscInt ti, const char *ext) |
| Reads data for a specific field from a file into the provided vector. | |
| PetscErrorCode | ReadStatisticalFields (UserCtx *user, PetscInt ti) |
| Reads statistical fields used for time-averaged simulations. | |
| PetscErrorCode | ReadLESFields (UserCtx *user, PetscInt ti) |
| Reads LES-related fields used in turbulence modeling. | |
| PetscErrorCode | ReadRANSFields (UserCtx *user, PetscInt ti) |
| Reads RANS-related fields for turbulence modeling. | |
| PetscErrorCode | WriteFieldData (UserCtx *user, const char *field_name, Vec field_vec, PetscInt ti, const char *ext) |
| Writes data from a specific PETSc vector to a file. | |
| PetscErrorCode | WriteSimulationFields (UserCtx *user) |
| Writes simulation fields to files. | |
| PetscErrorCode | WriteStatisticalFields (UserCtx *user) |
| Writes statistical fields for averaging purposes. | |
| PetscErrorCode | WriteLESFields (UserCtx *user) |
| Writes LES-related fields. | |
| PetscErrorCode | WriteRANSFields (UserCtx *user) |
| Writes RANS-related fields. | |
| PetscErrorCode | WriteSwarmField (UserCtx *user, const char *field_name, PetscInt ti, const char *ext) |
| Writes data from a specific field in a PETSc Swarm to a file. | |
| PetscErrorCode | WriteSwarmIntField (UserCtx *user, const char *field_name, PetscInt ti, const char *ext) |
| Writes integer data from a specific PETSc Swarm field to a file. | |
| PetscErrorCode | WriteAllSwarmFields (UserCtx *user) |
| Writes a predefined set of PETSc Swarm fields to files. | |
| PetscInt | ReadDataFileToArray (const char *filename, double **data_out, PetscInt *Nout, MPI_Comm comm) |
| Reads a simple ASCII data file containing one numeric value per line. | |
| PetscInt | CreateVTKFileFromMetadata (const char *filename, const VTKMetaData *meta, MPI_Comm comm) |
| Creates a VTK file from prepared metadata and field payloads. | |
| PetscErrorCode | VecToArrayOnRank0 (Vec inVec, PetscInt *N, double **arrayOut) |
| Gathers the contents of a distributed PETSc Vec into a single array on rank 0. | |
| PetscErrorCode | SwarmFieldToArrayOnRank0 (DM swarm, const char *field_name, PetscInt *n_total_particles, PetscInt *n_components, void **gathered_array) |
| Gathers any DMSwarm field from all ranks to a single, contiguous array on rank 0. | |
| PetscErrorCode | ReadSwarmField (UserCtx *user, const char *field_name, PetscInt ti, const char *ext) |
| Reads data from a file into a specified field of a PETSc DMSwarm. | |
| PetscErrorCode | ReadSwarmIntField (UserCtx *user, const char *field_name, PetscInt ti, const char *ext) |
| Reads integer swarm data by using ReadFieldData and casting the result. | |
| PetscErrorCode | ReadAllSwarmFields (UserCtx *user, PetscInt ti) |
| Reads multiple fields (positions, velocity, CellID, and weight) into a DMSwarm. | |
| PetscErrorCode | ReadPositionsFromFile (PetscInt timeIndex, UserCtx *user, double **coordsArray, PetscInt *Ncoords) |
| Reads coordinate data (for particles) from file into a PETSc Vec, then gathers it to rank 0. | |
| PetscErrorCode | ReadFieldDataToRank0 (PetscInt timeIndex, const char *fieldName, UserCtx *user, double **scalarArray, PetscInt *Nscalars) |
| Reads a named field from file into a PETSc Vec, then gathers it to rank 0. | |
| PetscErrorCode | DisplayBanner (SimCtx *simCtx) |
| Displays a structured banner summarizing the simulation configuration. | |
| PetscErrorCode | StringToBCFace (const char *str, BCFace *face_out) |
Converts a face-token string (e.g., "-Xi", "+Eta") to the internal BCFace enum. | |
| PetscErrorCode | StringToBCType (const char *str, BCType *type_out) |
Converts a mathematical BC type string (e.g., "PERIODIC", "WALL") to BCType. | |
| PetscErrorCode | StringToBCHandlerType (const char *str, BCHandlerType *handler_out) |
Converts a BC handler token (implementation strategy) to BCHandlerType. | |
| PetscErrorCode | ValidateBCHandlerForBCType (BCType type, BCHandlerType handler) |
| Validates that a selected handler is compatible with a mathematical BC type. | |
| void | FreeBC_ParamList (BC_Param *head) |
| Frees an entire linked list of boundary-condition parameters. | |
| PetscErrorCode | GetBCParamReal (BC_Param *params, const char *key, PetscReal *value_out, PetscBool *found) |
| Searches a BC_Param linked list for a key and returns its value as a double. | |
| PetscErrorCode | GetBCParamBool (BC_Param *params, const char *key, PetscBool *value_out, PetscBool *found) |
| Searches a BC_Param linked list for a key and returns its value as a bool. | |
| PetscErrorCode | ParseAllBoundaryConditions (UserCtx *user, const char *bcs_input_filename) |
| Parses the boundary conditions file to configure the type, handler, and any associated parameters for all 6 global faces of the domain. | |
| PetscErrorCode | DeterminePeriodicity (SimCtx *simCtx) |
| Scans all block-specific boundary condition files to determine a globally consistent periodicity for each dimension, reusing the core type parser. | |
| void | TrimWhitespace (char *str) |
| Helper function to trim leading/trailing whitespace from a string. | |
| PetscErrorCode | ParsePostProcessingSettings (SimCtx *simCtx) |
| Initializes post-processing settings from a config file and command-line overrides. | |
| PetscErrorCode | ParseScalingInformation (SimCtx *simCtx) |
| Parses physical scaling parameters from command-line options. | |
Public interface for data input/output routines.
This header declares functions responsible for parsing grid geometry information, either from command-line options for programmatically generated grids or by reading the header of a grid definition file.
Definition in file io.h.
| PetscErrorCode ReadGridGenerationInputs | ( | UserCtx * | user | ) |
Parses command-line options for a programmatically generated grid for a SINGLE block.
This function reads all per-block array options related to grid geometry, such as dimensions (-im), domain bounds (-xMins), and stretching ratios (-rxs). It then populates the fields of the provided UserCtx struct using its internal block index user->_this.
| user | Pointer to the UserCtx for a specific block. The function will populate the geometric fields (IM, Min_X, rx, etc.) within this struct. |
Parses command-line options for a programmatically generated grid for a SINGLE block.
Local to this translation unit.
Definition at line 85 of file io.c.
| PetscErrorCode PopulateFinestUserGridResolutionFromOptions | ( | UserCtx * | finest_users, |
| PetscInt | nblk | ||
| ) |
Parses grid resolution arrays (-im, -jm, -km) once and applies them to all finest-grid blocks.
This helper centralizes one-time resolution ingestion for analytical grid setup. It fills IM/JM/KM in each element of the finest-level UserCtx array.
| finest_users | Pointer to the finest-level UserCtx array (length nblk). |
| nblk | Number of blocks in the finest-level array. |
Parses grid resolution arrays (-im, -jm, -km) once and applies them to all finest-grid blocks.
Local to this translation unit.
Definition at line 170 of file io.c.
| PetscErrorCode ReadGridFile | ( | UserCtx * | user | ) |
Sets grid dimensions from a file for a SINGLE block using a one-time read cache.
This function uses a static-variable pattern to ensure the grid file header is read only once, collectively, by all processes on the first call. Subsequent calls simply retrieve the pre-loaded and broadcasted data for the specified block.
| user | Pointer to the UserCtx for a specific block. This function will populate the IM, JM, and KM fields. |
Sets grid dimensions from a file for a SINGLE block using a one-time read cache.
Local to this translation unit.
Definition at line 219 of file io.c.
| PetscErrorCode VerifyPathExistence | ( | const char * | path, |
| PetscBool | is_dir, | ||
| PetscBool | is_optional, | ||
| const char * | description, | ||
| PetscBool * | exists | ||
| ) |
A parallel-safe helper to verify the existence of a generic file or directory path.
This function centralizes the logic for checking arbitrary paths. Only Rank 0 performs the filesystem check, and the result is broadcast to all other processes. This ensures collective and synchronized decision-making across all ranks. It is intended for configuration files, source directories, etc., where the path is known completely.
| [in] | path | The full path to the file or directory to check. |
| [in] | is_dir | PETSC_TRUE if checking for a directory, PETSC_FALSE for a file. |
| [in] | is_optional | PETSC_TRUE if the path is optional (results in a warning), PETSC_FALSE if mandatory (results in an error). |
| [in] | description | A user-friendly description of the path for logging (e.g., "Grid file"). |
| [out] | exists | The result of the check (identical on all ranks). |
A parallel-safe helper to verify the existence of a generic file or directory path.
Local to this translation unit.
Definition at line 738 of file io.c.
| PetscBool ShouldWriteDataOutput | ( | const SimCtx * | simCtx, |
| PetscInt | completed_step | ||
| ) |
Returns whether full field/restart output should be written for the.
completed timestep.
| simCtx | Simulation context controlling the operation. |
| completed_step | Completed step index used by the decision helper. |
ShouldWriteDataOutput().Returns whether full field/restart output should be written for the.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 70 of file io.c.
| PetscErrorCode ReadSimulationFields | ( | UserCtx * | user, |
| PetscInt | ti | ||
| ) |
Reads binary field data for velocity, pressure, and other required vectors.
Reads contravariant velocity (Ucont) from vfield, Cartesian velocity (Ucat) from ufield, pressure (P), node state (Nvert_o), and optionally statistical quantities, LES, and RANS fields from binary files. Logs missing files but continues execution.
| [in,out] | user | Pointer to the UserCtx structure containing the simulation context. |
| [in] | ti | Timestep index used to construct restart file names. |
Reads binary field data for velocity, pressure, and other required vectors.
Local to this translation unit.
Definition at line 1126 of file io.c.
| PetscErrorCode ReadFieldData | ( | UserCtx * | user, |
| const char * | field_name, | ||
| Vec | field_vec, | ||
| PetscInt | ti, | ||
| const char * | ext | ||
| ) |
Reads data for a specific field from a file into the provided vector.
This function uses the field name to construct the file path and reads the data from the corresponding file into the provided PETSc vector.
| [in] | user | Pointer to the UserCtx structure containing simulation context. |
| [in] | field_name | Name of the field (e.g., "ufield", "vfield", "pfield"). |
| [out] | field_vec | PETSc vector to store the field data. |
| [in] | ti | Time index for constructing the file name. |
| [in] | ext | File extension (e.g., "dat"). |
Reads data for a specific field from a file into the provided vector.
Local to this translation unit.
Definition at line 898 of file io.c.
| PetscErrorCode ReadStatisticalFields | ( | UserCtx * | user, |
| PetscInt | ti | ||
| ) |
Reads statistical fields used for time-averaged simulations.
Reads statistical quantities such as velocity sums and pressure sums. Logs missing files and initializes fields to zero if files are unavailable.
| [in,out] | user | Pointer to the UserCtx structure containing the simulation context. |
| [in] | ti | Timestep index used to construct statistics file names. |
Reads statistical fields used for time-averaged simulations.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 1205 of file io.c.
| PetscErrorCode ReadLESFields | ( | UserCtx * | user, |
| PetscInt | ti | ||
| ) |
Reads LES-related fields used in turbulence modeling.
Reads the Smagorinsky constant (Cs) and transfers data to local vectors. Logs missing files and initializes fields to zero if files are unavailable.
| [in,out] | user | Pointer to the UserCtx structure containing the simulation context. |
| [in] | ti | Time index for constructing the file name. |
Reads LES-related fields used in turbulence modeling.
Local to this translation unit.
Definition at line 1229 of file io.c.
| PetscErrorCode ReadRANSFields | ( | UserCtx * | user, |
| PetscInt | ti | ||
| ) |
Reads RANS-related fields for turbulence modeling.
Reads K_Omega fields (used in RANS modeling) and initializes them if files are unavailable.
| [in,out] | user | Pointer to the UserCtx structure containing the simulation context. |
| [in] | ti | Time index for constructing the file name. |
Reads RANS-related fields for turbulence modeling.
Local to this translation unit.
Definition at line 1257 of file io.c.
| PetscErrorCode WriteFieldData | ( | UserCtx * | user, |
| const char * | field_name, | ||
| Vec | field_vec, | ||
| PetscInt | ti, | ||
| const char * | ext | ||
| ) |
Writes data from a specific PETSc vector to a file.
This function uses the field name to construct the file path and writes the data from the provided PETSc vector to the corresponding file.
| [in] | user | Pointer to the UserCtx structure containing simulation context. |
| [in] | field_name | Name of the field (e.g., "ufield", "vfield", "pfield"). |
| [in] | field_vec | PETSc vector containing the field data to write. |
| [in] | ti | Time index for constructing the file name. |
| [in] | ext | File extension (e.g., "dat"). |
Writes data from a specific PETSc vector to a file.
Local to this translation unit.
Definition at line 1448 of file io.c.
| PetscErrorCode WriteSimulationFields | ( | UserCtx * | user | ) |
Writes simulation fields to files.
This function writes contravariant velocity, Cartesian velocity, pressure, and node state fields to their respective binary files. It also conditionally writes LES, RANS, and statistical fields if they are enabled.
| [in] | user | Pointer to the UserCtx structure containing simulation context. |
Writes simulation fields to files.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 1568 of file io.c.
| PetscErrorCode WriteStatisticalFields | ( | UserCtx * | user | ) |
Writes statistical fields for averaging purposes.
This function writes data for fields such as Ucat_sum, Ucat_cross_sum, Ucat_square_sum, and P_sum to their respective binary files.
| [in] | user | Pointer to the UserCtx structure containing simulation context. |
Writes statistical fields for averaging purposes.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 1627 of file io.c.
| PetscErrorCode WriteLESFields | ( | UserCtx * | user | ) |
Writes LES-related fields.
This function writes LES-related fields such as Cs (Smagorinsky constant) to their respective binary files.
| [in] | user | Pointer to the UserCtx structure containing simulation context. |
Writes LES-related fields.
Local to this translation unit.
Definition at line 1649 of file io.c.
| PetscErrorCode WriteRANSFields | ( | UserCtx * | user | ) |
Writes RANS-related fields.
This function writes RANS-related fields such as K_Omega to their respective binary files.
| [in] | user | Pointer to the UserCtx structure containing simulation context. |
Writes RANS-related fields.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 1679 of file io.c.
| PetscErrorCode WriteSwarmField | ( | UserCtx * | user, |
| const char * | field_name, | ||
| PetscInt | ti, | ||
| const char * | ext | ||
| ) |
Writes data from a specific field in a PETSc Swarm to a file.
This function retrieves the Swarm from the UserCtx (i.e., user->swarm) and creates a global PETSc vector from the specified Swarm field. It then calls the existing WriteFieldData() function to handle the actual I/O operation. After writing the data, the function destroys the temporary global vector to avoid memory leaks.
| [in] | user | Pointer to the UserCtx structure containing simulation context and the PetscSwarm (as user->swarm). |
| [in] | field_name | Name of the Swarm field to be written (e.g., "my_field"). |
| [in] | ti | Time index used to construct the output file name. |
| [in] | ext | File extension (e.g., "dat", "bin"). |
Writes data from a specific field in a PETSc Swarm to a file.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 1700 of file io.c.
| PetscErrorCode WriteSwarmIntField | ( | UserCtx * | user, |
| const char * | field_name, | ||
| PetscInt | ti, | ||
| const char * | ext | ||
| ) |
Writes integer data from a specific PETSc Swarm field to a file.
This function is designed for swarm fields that store integer data (e.g., DMSwarm_CellID), which cannot be converted to a standard PETSc Vec of PetscScalars. It accesses the raw data pointer for the field on each rank using DMSwarmGetField(), writes the local data to a rank-specific binary file, and then restores the field access.
| [in] | user | Pointer to the UserCtx structure containing the PetscSwarm. |
| [in] | field_name | Name of the integer Swarm field to be written. |
| [in] | ti | Time index used to construct the output file name. |
| [in] | ext | File extension (e.g., "dat", "bin"). |
Writes integer data from a specific PETSc Swarm field to a file.
Local to this translation unit.
Definition at line 1755 of file io.c.
| PetscErrorCode WriteAllSwarmFields | ( | UserCtx * | user | ) |
Writes a predefined set of PETSc Swarm fields to files.
This function iterates through a hardcoded list of common swarm fields (position, velocity, etc.) and calls the WriteSwarmField() helper function for each one. This provides a straightforward way to output essential particle data at a given simulation step.
This function will only execute if particles are enabled in the simulation (i.e., user->simCtx->np > 0 and user->swarm is not NULL).
| [in] | user | Pointer to the UserCtx structure containing the simulation context and the PetscSwarm. |
Writes a predefined set of PETSc Swarm fields to files.
Local to this translation unit.
Definition at line 1815 of file io.c.
| PetscInt ReadDataFileToArray | ( | const char * | filename, |
| double ** | data_out, | ||
| PetscInt * | Nout, | ||
| MPI_Comm | comm | ||
| ) |
Reads a simple ASCII data file containing one numeric value per line.
This helper performs rank-0 file I/O, broadcasts the parsed result to the rest of the communicator, and returns a replicated array on every rank.
| filename | Path to the input data file. |
| data_out | Output pointer to the allocated scalar array. |
| Nout | Output pointer storing the number of values read. |
| comm | MPI communicator used for the coordinated read/broadcast sequence. |
ReadDataFileToArray().Reads a simple ASCII data file containing one numeric value per line.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 2401 of file io.c.
| PetscInt CreateVTKFileFromMetadata | ( | const char * | filename, |
| const VTKMetaData * | meta, | ||
| MPI_Comm | comm | ||
| ) |
Creates a VTK file from prepared metadata and field payloads.
This helper dispatches to the structured-grid or polydata writer based on the metadata contents and emits the assembled VTK file on the requested communicator.
| filename | Path to the output VTK file. |
| meta | VTK metadata describing the output geometry and field payloads. |
| comm | MPI communicator used by the write operation. |
CreateVTKFileFromMetadata().Creates a VTK file from prepared metadata and field payloads.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/vtk_io.h.
Definition at line 153 of file vtk_io.c.
| PetscErrorCode VecToArrayOnRank0 | ( | Vec | inVec, |
| PetscInt * | N, | ||
| double ** | arrayOut | ||
| ) |
Gathers the contents of a distributed PETSc Vec into a single array on rank 0.
| [in] | inVec | The input (possibly distributed) Vec. |
| [out] | N | The global size of the vector. |
| [out] | arrayOut | On rank 0, points to the newly allocated array holding all data. On other ranks, it is set to NULL. |
Gathers the contents of a distributed PETSc Vec into a single array on rank 0.
Local to this translation unit.
Definition at line 1868 of file io.c.
| PetscErrorCode SwarmFieldToArrayOnRank0 | ( | DM | swarm, |
| const char * | field_name, | ||
| PetscInt * | n_total_particles, | ||
| PetscInt * | n_components, | ||
| void ** | gathered_array | ||
| ) |
Gathers any DMSwarm field from all ranks to a single, contiguous array on rank 0.
This is a generic, type-aware version of SwarmFieldToArrayOnRank0. It is a COLLECTIVE operation.
| [in] | swarm | The DMSwarm to gather from. |
| [in] | field_name | The name of the field to gather. |
| [out] | n_total_particles | (Output on rank 0) Total number of particles in the global swarm. |
| [out] | n_components | (Output on rank 0) Number of components for the field. |
| [out] | gathered_array | (Output on rank 0) A newly allocated array containing the full, gathered data. The caller is responsible for freeing this memory and for casting it to the correct type. |
Gathers any DMSwarm field from all ranks to a single, contiguous array on rank 0.
Local to this translation unit.
Definition at line 1953 of file io.c.
| PetscErrorCode ReadSwarmField | ( | UserCtx * | user, |
| const char * | field_name, | ||
| PetscInt | ti, | ||
| const char * | ext | ||
| ) |
Reads data from a file into a specified field of a PETSc DMSwarm.
This function is the counterpart to WriteSwarmField(). It creates a global PETSc vector that references the specified DMSwarm field, uses ReadFieldData() to read the data from a file, and then destroys the global vector reference.
| [in] | user | Pointer to the UserCtx structure (containing user->swarm). |
| [in] | field_name | Name of the DMSwarm field to read into (must be previously declared/allocated). |
| [in] | ti | Time index used to construct the input file name. |
| [in] | ext | File extension (e.g., "dat" or "bin"). |
Reads data from a file into a specified field of a PETSc DMSwarm.
Local to this translation unit.
Definition at line 1291 of file io.c.
| PetscErrorCode ReadSwarmIntField | ( | UserCtx * | user, |
| const char * | field_name, | ||
| PetscInt | ti, | ||
| const char * | ext | ||
| ) |
Reads integer swarm data by using ReadFieldData and casting the result.
This function is the counterpart to WriteSwarmIntField. It reads a file containing floating-point data (that was originally integer) into a temporary Vec and then casts it back to the integer swarm field. It works by:
| [in] | user | Pointer to the UserCtx structure. |
| [in] | field_name | Name of the integer Swarm field to be read. |
| [in] | ti | Time index for the input file. |
| [in] | ext | File extension. |
Reads integer swarm data by using ReadFieldData and casting the result.
Local to this translation unit.
Definition at line 1321 of file io.c.
| PetscErrorCode ReadAllSwarmFields | ( | UserCtx * | user, |
| PetscInt | ti | ||
| ) |
Reads multiple fields (positions, velocity, CellID, and weight) into a DMSwarm.
This function is analogous to ReadSimulationFields() but targets a DMSwarm. Each Swarm field is read from a separate file using ReadSwarmField().
| [in,out] | user | Pointer to the UserCtx structure containing the DMSwarm (user->swarm). |
| [in] | ti | Time index for constructing the file name. |
Reads multiple fields (positions, velocity, CellID, and weight) into a DMSwarm.
Local to this translation unit.
Definition at line 1383 of file io.c.
| PetscErrorCode ReadPositionsFromFile | ( | PetscInt | timeIndex, |
| UserCtx * | user, | ||
| double ** | coordsArray, | ||
| PetscInt * | Ncoords | ||
| ) |
Reads coordinate data (for particles) from file into a PETSc Vec, then gathers it to rank 0.
This function uses ReadFieldData to fill a PETSc Vec with coordinate data, then leverages VecToArrayOnRank0 to gather that data into a contiguous array (valid on rank 0 only).
| [in] | timeIndex | The time index used to construct file names. |
| [in] | user | Pointer to the user context. |
| [out] | coordsArray | On rank 0, will point to a newly allocated array holding the coordinates. |
| [out] | Ncoords | On rank 0, the length of coordsArray. On other ranks, 0. |
Reads coordinate data (for particles) from file into a PETSc Vec, then gathers it to rank 0.
Local to this translation unit.
Definition at line 2533 of file io.c.
| PetscErrorCode ReadFieldDataToRank0 | ( | PetscInt | timeIndex, |
| const char * | fieldName, | ||
| UserCtx * | user, | ||
| double ** | scalarArray, | ||
| PetscInt * | Nscalars | ||
| ) |
Reads a named field from file into a PETSc Vec, then gathers it to rank 0.
This function wraps ReadFieldData and VecToArrayOnRank0 into a single step. The gathered data is stored in scalarArray on rank 0, with its length in Nscalars.
| [in] | timeIndex | The time index used to construct file names. |
| [in] | fieldName | Name of the field to be read (e.g., "velocity"). |
| [in] | user | Pointer to the user context. |
| [out] | scalarArray | On rank 0, a newly allocated array holding the field data. |
| [out] | Nscalars | On rank 0, length of scalarArray. On other ranks, 0. |
Reads a named field from file into a PETSc Vec, then gathers it to rank 0.
Local to this translation unit.
Definition at line 2571 of file io.c.
| PetscErrorCode DisplayBanner | ( | SimCtx * | simCtx | ) |
Displays a structured banner summarizing the simulation configuration.
This function prints key simulation parameters to standard output. It is intended to be called ONLY by MPI rank 0. It retrieves global domain bounds and block metadata from simCtx.
| [in] | simCtx | Pointer to the master simulation context. |
0 on success.Displays a structured banner summarizing the simulation configuration.
Local to this translation unit.
Definition at line 2031 of file io.c.
| PetscErrorCode StringToBCFace | ( | const char * | str, |
| BCFace * | face_out | ||
| ) |
Converts a face-token string (e.g., "-Xi", "+Eta") to the internal BCFace enum.
| [in] | str | Input token from configuration. |
| [out] | face_out | Parsed enum value on success. |
Converts a face-token string (e.g., "-Xi", "+Eta") to the internal BCFace enum.
Local to this translation unit.
Definition at line 317 of file io.c.
| PetscErrorCode StringToBCType | ( | const char * | str, |
| BCType * | type_out | ||
| ) |
Converts a mathematical BC type string (e.g., "PERIODIC", "WALL") to BCType.
| [in] | str | Input token from configuration. |
| [out] | type_out | Parsed enum value on success. |
Converts a mathematical BC type string (e.g., "PERIODIC", "WALL") to BCType.
Local to this translation unit.
Definition at line 332 of file io.c.
| PetscErrorCode StringToBCHandlerType | ( | const char * | str, |
| BCHandlerType * | handler_out | ||
| ) |
Converts a BC handler token (implementation strategy) to BCHandlerType.
| [in] | str | Input handler token from configuration. |
| [out] | handler_out | Parsed enum value on success. |
Converts a BC handler token (implementation strategy) to BCHandlerType.
Local to this translation unit.
Definition at line 347 of file io.c.
| PetscErrorCode ValidateBCHandlerForBCType | ( | BCType | type, |
| BCHandlerType | handler | ||
| ) |
Validates that a selected handler is compatible with a mathematical BC type.
| [in] | type | Mathematical BC type (e.g., WALL, PERIODIC). |
| [in] | handler | Selected handler implementation enum. |
Validates that a selected handler is compatible with a mathematical BC type.
Local to this translation unit.
Definition at line 364 of file io.c.
| void FreeBC_ParamList | ( | BC_Param * | head | ) |
Frees an entire linked list of boundary-condition parameters.
| [in,out] | head | Head pointer of the BC_Param list to destroy. |
Frees an entire linked list of boundary-condition parameters.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 302 of file io.c.
| PetscErrorCode GetBCParamReal | ( | BC_Param * | params, |
| const char * | key, | ||
| PetscReal * | value_out, | ||
| PetscBool * | found | ||
| ) |
Searches a BC_Param linked list for a key and returns its value as a double.
| params | The head of the BC_Param linked list. | |
| key | The key to search for (case-insensitive). | |
| [out] | value_out | The found value, converted to a PetscReal. |
| [out] | found | Set to PETSC_TRUE if the key was found, PETSC_FALSE otherwise. |
Searches a BC_Param linked list for a key and returns its value as a double.
Local to this translation unit.
Definition at line 387 of file io.c.
| PetscErrorCode GetBCParamBool | ( | BC_Param * | params, |
| const char * | key, | ||
| PetscBool * | value_out, | ||
| PetscBool * | found | ||
| ) |
Searches a BC_Param linked list for a key and returns its value as a bool.
| params | The head of the BC_Param linked list. | |
| key | The key to search for (case-insensitive). | |
| [out] | value_out | The found value, converted to a PetscBool. |
| [out] | found | Set to PETSC_TRUE if the key was found, PETSC_FALSE otherwise. |
Searches a BC_Param linked list for a key and returns its value as a bool.
Local to this translation unit.
Definition at line 408 of file io.c.
| PetscErrorCode ParseAllBoundaryConditions | ( | UserCtx * | user, |
| const char * | bcs_input_filename | ||
| ) |
Parses the boundary conditions file to configure the type, handler, and any associated parameters for all 6 global faces of the domain.
This function performs the following steps:
<Face> <Type> <Handler> [param=value]... format.user->boundary_faces array identically.UserCtx.| [in,out] | user | The main UserCtx struct where the final configuration for all ranks will be stored. |
| [in] | bcs_input_filename | The path to the boundary conditions configuration file. |
Parses the boundary conditions file to configure the type, handler, and any associated parameters for all 6 global faces of the domain.
Local to this translation unit.
Definition at line 447 of file io.c.
| PetscErrorCode DeterminePeriodicity | ( | SimCtx * | simCtx | ) |
Scans all block-specific boundary condition files to determine a globally consistent periodicity for each dimension, reusing the core type parser.
This is a lightweight pre-parser intended to be called before DMDA creation. It ensures that the periodicity setting is consistent across all blocks, which is a physical requirement for the domain.
StringToBCType helper.| [in,out] | simCtx | The master SimCtx struct, containing the bcs_files list and where the final periodicity flags will be stored. |
Scans all block-specific boundary condition files to determine a globally consistent periodicity for each dimension, reusing the core type parser.
Local to this translation unit.
Definition at line 634 of file io.c.
| void TrimWhitespace | ( | char * | str | ) |
Helper function to trim leading/trailing whitespace from a string.
| str | The string to trim in-place. |
Helper function to trim leading/trailing whitespace from a string.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 38 of file io.c.
| PetscErrorCode ParsePostProcessingSettings | ( | SimCtx * | simCtx | ) |
Initializes post-processing settings from a config file and command-line overrides.
This function establishes the configuration for a post-processing run by:
| simCtx | The pointer to the simulation context that contains the postprocessing file and struct. |
Initializes post-processing settings from a config file and command-line overrides.
Local to this translation unit.
Definition at line 2209 of file io.c.
| PetscErrorCode ParseScalingInformation | ( | SimCtx * | simCtx | ) |
Parses physical scaling parameters from command-line options.
This function reads the reference length, velocity, and density from the PETSc options database (provided via -scaling_L_ref, etc.). It populates the simCtx->scaling struct and calculates the derived reference pressure. It sets default values of 1.0 for a fully non-dimensional case if the options are not provided.
| [in,out] | simCtx | The simulation context whose 'scaling' member will be populated. |
Parses physical scaling parameters from command-line options.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/io.h.
Definition at line 2357 of file io.c.