PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
Public interface for grid, solver, and metric setup routines. More...
Go to the source code of this file.
Functions | |
PetscErrorCode | DefineAllGridDimensions (SimCtx *simCtx) |
Orchestrates the parsing and setting of grid dimensions for all blocks. | |
PetscErrorCode | InitializeAllGridDMs (SimCtx *simCtx) |
Orchestrates the creation of DMDA objects for every block and multigrid level. | |
PetscErrorCode | AssignAllGridCoordinates (SimCtx *simCtx) |
Orchestrates the assignment of physical coordinates to all DMDA objects. | |
PetscErrorCode | ComputeLocalBoundingBox (UserCtx *user, BoundingBox *localBBox) |
Computes the local bounding box of the grid on the current process. | |
PetscErrorCode | GatherAllBoundingBoxes (UserCtx *user, BoundingBox **allBBoxes) |
Gathers local bounding boxes from all MPI processes to rank 0. | |
PetscErrorCode | BroadcastAllBoundingBoxes (UserCtx *user, BoundingBox **bboxlist) |
Broadcasts the bounding box information collected on rank 0 to all other ranks. | |
Public interface for grid, solver, and metric setup routines.
Definition in file grid.h.
PetscErrorCode DefineAllGridDimensions | ( | SimCtx * | simCtx | ) |
Orchestrates the parsing and setting of grid dimensions for all blocks.
This function serves as the high-level entry point for defining the geometric properties of each grid block in the simulation. It iterates through every block defined by simCtx->block_number
.
For each block, it performs two key actions:
_this
) in the corresponding UserCtx
struct for the finest multigrid level. This makes the context "self-aware".ParseAndSetGridInputs
) to handle the detailed work of parsing options or files to populate the rest of the geometric properties for that specific block (e.g., IM
, Min_X
, rx
).simCtx | The master SimCtx, which contains the number of blocks and the UserCtx hierarchy to be configured. |
Definition at line 57 of file grid.c.
PetscErrorCode InitializeAllGridDMs | ( | SimCtx * | simCtx | ) |
Orchestrates the creation of DMDA objects for every block and multigrid level.
This function systematically builds the entire DMDA hierarchy. It first calculates the dimensions (IM, JM, KM) for all coarse grids based on the finest grid's dimensions and the semi-coarsening flags. It then iterates from the coarsest to the finest level, calling a powerful helper function (InitializeSingleGridDM
) to create the DMs for each block, ensuring that finer grids are properly aligned with their coarser parents for multigrid efficiency.
Definition at line 230 of file grid.c.
PetscErrorCode AssignAllGridCoordinates | ( | SimCtx * | simCtx | ) |
Orchestrates the assignment of physical coordinates to all DMDA objects.
This function manages the entire process of populating the coordinate vectors for every DMDA across all multigrid levels and blocks. It follows a two-part strategy that is essential for multigrid methods:
SetFinestLevelCoordinates
) to set the physical coordinates for the highest-resolution grid (the finest multigrid level).RestrictCoordinates
) to copy the coordinate values from the fine grid nodes to their corresponding parent nodes on the coarser grids. This ensures all levels represent the exact same geometry.Definition at line 317 of file grid.c.
PetscErrorCode ComputeLocalBoundingBox | ( | UserCtx * | user, |
BoundingBox * | localBBox | ||
) |
Computes the local bounding box of the grid on the current process.
This function calculates the minimum and maximum coordinates of the local grid points owned by the current MPI process and stores the computed bounding box in the provided structure.
[in] | user | Pointer to the user-defined context containing grid information. |
[out] | localBBox | Pointer to the BoundingBox structure to store the computed bounding box. |
This function calculates the minimum and maximum coordinates (x, y, z) of the local grid points owned by the current MPI process. It iterates over the local portion of the grid, examines each grid point's coordinates, and updates the minimum and maximum values accordingly.
The computed bounding box is stored in the provided localBBox
structure, and the user->bbox
field is also updated with this bounding box for consistency within the user context.
[in] | user | Pointer to the user-defined context containing grid information. This context must be properly initialized before calling this function. |
[out] | localBBox | Pointer to the BoundingBox structure where the computed local bounding box will be stored. The structure should be allocated by the caller. |
0
on success, non-zero on failure. Definition at line 702 of file grid.c.
PetscErrorCode GatherAllBoundingBoxes | ( | UserCtx * | user, |
BoundingBox ** | allBBoxes | ||
) |
Gathers local bounding boxes from all MPI processes to rank 0.
This function computes the local bounding box on each process, then collects all local bounding boxes on the root process (rank 0) using MPI. The result is stored in an array of BoundingBox structures on rank 0.
[in] | user | Pointer to the user-defined context containing grid information. |
[out] | allBBoxes | Pointer to a pointer where the array of gathered bounding boxes will be stored on rank 0. The caller on rank 0 must free this array. |
Each rank computes its local bounding box, then all ranks participate in an MPI_Gather to send their BoundingBox to rank 0. Rank 0 allocates the result array and returns it via allBBoxes.
[in] | user | Pointer to UserCtx (must be non-NULL). |
[out] | allBBoxes | On rank 0, receives malloc’d array of size size . On other ranks, set to NULL. |
Definition at line 837 of file grid.c.
PetscErrorCode BroadcastAllBoundingBoxes | ( | UserCtx * | user, |
BoundingBox ** | bboxlist | ||
) |
Broadcasts the bounding box information collected on rank 0 to all other ranks.
This function assumes that GatherAllBoundingBoxes()
was previously called, so bboxlist
is allocated and populated on rank 0. All other ranks will allocate memory for bboxlist
, and this function will use MPI_Bcast to distribute the bounding box data to them.
[in] | user | Pointer to the UserCtx structure. (Currently unused in this function, but kept for consistency.) |
[in,out] | bboxlist | Pointer to the array of BoundingBoxes. On rank 0, this should point to a valid array of size 'size' (where size is the number of MPI ranks). On non-root ranks, this function will allocate memory for bboxlist . |
Broadcasts the bounding box information collected on rank 0 to all other ranks.
After GatherAllBoundingBoxes, rank 0 has an array of size
boxes. This routine makes sure every rank ends up with its own malloc’d copy.
[in] | user | Pointer to UserCtx (unused here, but kept for signature). |
[in,out] | bboxlist | On entry: rank 0’s array; on exit: every rank’s array. |
Definition at line 896 of file grid.c.