|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
#include <petscpf.h>#include <petscdmswarm.h>#include <stdlib.h>#include <time.h>#include <math.h>#include <petsctime.h>#include <petscsys.h>#include <petscdmcomposite.h>#include <petscsystypes.h>#include "variables.h"#include "ParticleSwarm.h"#include "walkingsearch.h"#include "grid.h"#include "logging.h"#include "io.h"#include "interpolation.h"#include "ParticleMotion.h"#include "BC_Handlers.h"#include "wallfunction.h"Go to the source code of this file.
Functions | |
| PetscErrorCode | BoundarySystem_Validate (UserCtx *user) |
| (Public) Validates the consistency and compatibility of the parsed boundary condition system. | |
| PetscErrorCode | BoundaryCondition_Create (BCHandlerType handler_type, BoundaryCondition **new_bc_ptr) |
| (Private) Creates and configures a specific BoundaryCondition handler object. | |
| PetscErrorCode | BoundarySystem_Initialize (UserCtx *user, const char *bcs_filename) |
| Initializes the entire boundary system. | |
| PetscErrorCode | PropagateBoundaryConfigToCoarserLevels (SimCtx *simCtx) |
| Propagates boundary condition configuration from finest to all coarser multigrid levels. | |
| PetscErrorCode | BoundarySystem_ExecuteStep (UserCtx *user) |
| Executes one full boundary condition update cycle for a time step. | |
| PetscErrorCode | BoundarySystem_RefreshUbcs (UserCtx *user) |
| (Private) A lightweight execution engine that calls the UpdateUbcs() method on all relevant handlers. | |
| PetscErrorCode | BoundarySystem_Destroy (UserCtx *user) |
| Cleans up and destroys all boundary system resources. | |
| PetscErrorCode | CanRankServiceInletFace (UserCtx *user, const DMDALocalInfo *info, PetscInt IM_nodes_global, PetscInt JM_nodes_global, PetscInt KM_nodes_global, PetscBool *can_service_inlet_out) |
| Determines if the current MPI rank owns any part of the globally defined inlet face, making it responsible for placing particles on that portion of the surface. | |
| PetscErrorCode | CanRankServiceFace (const DMDALocalInfo *info, PetscInt IM_nodes_global, PetscInt JM_nodes_global, PetscInt KM_nodes_global, BCFace face_id, PetscBool *can_service_out) |
| Determines if the current MPI rank owns any part of a specified global face. | |
| PetscErrorCode | GetDeterministicFaceGridLocation (UserCtx *user, const DMDALocalInfo *info, PetscInt xs_gnode_rank, PetscInt ys_gnode_rank, PetscInt zs_gnode_rank, PetscInt IM_cells_global, PetscInt JM_cells_global, PetscInt KM_cells_global, PetscInt64 particle_global_id, PetscInt *ci_metric_lnode_out, PetscInt *cj_metric_lnode_out, PetscInt *ck_metric_lnode_out, PetscReal *xi_metric_logic_out, PetscReal *eta_metric_logic_out, PetscReal *zta_metric_logic_out, PetscBool *placement_successful_out) |
| Places particles in a deterministic grid/raster pattern on a specified domain face. | |
| PetscErrorCode | GetRandomCellAndLogicalCoordsOnInletFace (UserCtx *user, const DMDALocalInfo *info, PetscInt xs_gnode_rank, PetscInt ys_gnode_rank, PetscInt zs_gnode_rank, PetscInt IM_nodes_global, PetscInt JM_nodes_global, PetscInt KM_nodes_global, PetscRandom *rand_logic_i_ptr, PetscRandom *rand_logic_j_ptr, PetscRandom *rand_logic_k_ptr, PetscInt *ci_metric_lnode_out, PetscInt *cj_metric_lnode_out, PetscInt *ck_metric_lnode_out, PetscReal *xi_metric_logic_out, PetscReal *eta_metric_logic_out, PetscReal *zta_metric_logic_out) |
| Assuming the current rank services the inlet face, this function selects a random cell (owned by this rank on that face) and random logical coordinates within that cell, suitable for placing a particle on the inlet surface. | |
| PetscErrorCode | EnforceRHSBoundaryConditions (UserCtx *user) |
| Enforces boundary conditions on the momentum equation's Right-Hand-Side (RHS) vector. | |
| PetscErrorCode | TransferPeriodicFieldByDirection (UserCtx *user, const char *field_name, char direction) |
| (Private Worker) Copies periodic data for a SINGLE field in a SINGLE direction. | |
| PetscErrorCode | SynchronizePeriodicCellFields (UserCtx *user, PetscInt num_fields, const char *field_names[]) |
| Synchronizes periodic endpoint cells for a list of cell-centered fields. | |
| PetscErrorCode | TransferPeriodicFaceFieldByDirection (UserCtx *user, const char *field_name, char face_direction, char periodic_direction) |
| Transfers one persistent single-face-family field in one periodic direction. | |
| PetscErrorCode | SynchronizePeriodicFaceFields (UserCtx *user, char face_direction, PetscInt num_fields, const char *field_names[]) |
| Synchronizes persistent fields belonging to one face family. | |
| PetscErrorCode | TransferPeriodicStaggeredFieldByDirection (UserCtx *user, const char *field_name, char periodic_direction) |
| Transfers one persistent component-staggered field in one periodic direction. | |
| PetscErrorCode | SynchronizePeriodicStaggeredFields (UserCtx *user, PetscInt num_fields, const char *field_names[]) |
| Synchronizes persistent component-staggered vector fields. | |
| PetscErrorCode | PreparePeriodicQuickStencilFields (UserCtx *user, Vec local_vector_field, Vec local_scalar_field) |
| Repairs the outer adjacent periodic ghosts used by QUICK cell stencils. | |
| PetscErrorCode | SynchronizePeriodicLocalStaggeredField (UserCtx *user, Vec local_field) |
| Synchronizes one local-only component-staggered periodic work field. | |
| PetscErrorCode | TransferPeriodicField (UserCtx *user, const char *field_name) |
| Legacy monolithic periodic endpoint transfer for one cell-centered field. | |
| PetscErrorCode | TransferPeriodicFaceField (UserCtx *user, const char *field_name) |
| (Primitive) Copies periodic data from the interior to the local ghost cell region for a single field. | |
| PetscErrorCode | ApplyMetricsPeriodicBCs (UserCtx *user) |
| (Orchestrator) Updates all metric-related fields in the local ghost cell regions for periodic boundaries. | |
| PetscErrorCode | ApplyPeriodicBCs (UserCtx *user) |
| Applies periodic boundary conditions by copying data across domain boundaries for all relevant fields. | |
| PetscErrorCode | UpdateDummyCells (UserCtx *user) |
| Updates the dummy cells (ghost nodes) on the faces of the local domain for NON-PERIODIC boundaries. | |
| PetscErrorCode | UpdateCornerNodes (UserCtx *user) |
| Updates the corner and edge ghost nodes of the local domain by averaging. | |
| PetscErrorCode | UpdatePeriodicCornerNodes (UserCtx *user, PetscInt num_fields, const char *field_names[]) |
| Legacy sequential periodic-corner update for a list of fields. | |
| PetscErrorCode | ApplyWallFunction (UserCtx *user) |
| Applies wall function modeling to near-wall velocities for all wall-type boundaries. | |
| PetscErrorCode | FinalizePostProjectionCellFields (UserCtx *user) |
| Finalizes cell-centered fields after the projection step. | |
| PetscErrorCode | ApplyBoundaryConditions (UserCtx *user) |
| Main boundary-condition orchestrator executed during solver timestepping. | |
| PetscErrorCode BoundarySystem_Validate | ( | UserCtx * | user | ) |
(Public) Validates the consistency and compatibility of the parsed boundary condition system.
This function is the main entry point for all boundary condition validation. It should be called from the main setup sequence AFTER the configuration file has been parsed by ParseAllBoundaryConditions but BEFORE any BoundaryCondition handler objects are created.
It acts as a dispatcher, calling specialized private sub-validators for different complex BC setups (like driven flow) to ensure the combination of mathematical_type and handler_type across all six faces is physically and numerically valid. This provides a "fail-fast" mechanism to prevent users from running improperly configured simulations.
| user | The UserCtx for a single block, containing the populated boundary_faces configuration. |
(Public) Validates the consistency and compatibility of the parsed boundary condition system.
Local to this translation unit.
Definition at line 830 of file Boundaries.c.
| PetscErrorCode BoundaryCondition_Create | ( | BCHandlerType | handler_type, |
| BoundaryCondition ** | new_bc_ptr | ||
| ) |
(Private) Creates and configures a specific BoundaryCondition handler object.
This function acts as a factory. Based on the requested handler_type, it allocates a BoundaryCondition object and populates it with the correct set of function pointers corresponding to that specific behavior.
| handler_type | The specific handler to create (e.g., BC_HANDLER_WALL_NOSLIP). | |
| [out] | new_bc_ptr | A pointer to where the newly created BoundaryCondition object's address will be stored. |
(Private) Creates and configures a specific BoundaryCondition handler object.
Local to this translation unit.
Definition at line 744 of file Boundaries.c.
| PetscErrorCode BoundarySystem_Initialize | ( | UserCtx * | user, |
| const char * | bcs_filename | ||
| ) |
Initializes the entire boundary system.
| user | The |
| bcs_filename | The |
Initializes the entire boundary system.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Boundaries.h.
Definition at line 891 of file Boundaries.c.
| PetscErrorCode PropagateBoundaryConfigToCoarserLevels | ( | SimCtx * | simCtx | ) |
Propagates boundary condition configuration from finest to all coarser multigrid levels.
Coarser levels need BC type information for geometric operations (e.g., periodic corrections) but do NOT need full handler objects since timestepping only occurs at the finest level. This function copies the boundary_faces configuration down the hierarchy.
| simCtx | The master SimCtx containing the multigrid hierarchy |
Propagates boundary condition configuration from finest to all coarser multigrid levels.
Local to this translation unit.
Definition at line 988 of file Boundaries.c.
| PetscErrorCode BoundarySystem_ExecuteStep | ( | UserCtx * | user | ) |
Executes one full boundary condition update cycle for a time step.
| user | The |
Executes one full boundary condition update cycle for a time step.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Boundaries.h.
Definition at line 1059 of file Boundaries.c.
| PetscErrorCode BoundarySystem_RefreshUbcs | ( | UserCtx * | user | ) |
(Private) A lightweight execution engine that calls the UpdateUbcs() method on all relevant handlers.
This function's sole purpose is to re-evaluate the target boundary values (ubcs) for flow-dependent boundary conditions (e.g., Symmetry, Outlets) after the interior velocity field has changed, such as after the projection step.
It operates based on a "pull" model: it iterates through all boundary handlers and executes their UpdateUbcs method only if the handler has provided one. This makes the system extensible, as new flow-dependent handlers can be added without changing this engine. Handlers for fixed boundary conditions (e.g., a wall with a constant velocity) will have their UpdateUbcs pointer set to NULL and will be skipped automatically.
ucont and does NOT perform flux balancing.| user | The main UserCtx struct. |
(Private) A lightweight execution engine that calls the UpdateUbcs() method on all relevant handlers.
Local to this translation unit.
Definition at line 1481 of file Boundaries.c.
| PetscErrorCode BoundarySystem_Destroy | ( | UserCtx * | user | ) |
Cleans up and destroys all boundary system resources.
| user | The |
Cleans up and destroys all boundary system resources.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Boundaries.h.
Definition at line 1531 of file Boundaries.c.
| PetscErrorCode CanRankServiceInletFace | ( | UserCtx * | user, |
| const DMDALocalInfo * | info, | ||
| PetscInt | IM_nodes_global, | ||
| PetscInt | JM_nodes_global, | ||
| PetscInt | KM_nodes_global, | ||
| PetscBool * | can_service_inlet_out | ||
| ) |
Determines if the current MPI rank owns any part of the globally defined inlet face, making it responsible for placing particles on that portion of the surface.
The determination is based on the rank's owned nodes (from DMDALocalInfo) and the global node counts, in conjunction with the user->identifiedInletBCFace. A rank can service an inlet face if it owns the cells adjacent to that global boundary and has a non-zero extent (owns cells) in the tangential dimensions of that face.
| user | Pointer to the UserCtx structure, containing identifiedInletBCFace. | |
| info | Pointer to the DMDALocalInfo for the current rank's DA (node-based). | |
| IM_nodes_global | Global number of nodes in the I-direction (e.g., user->IM + 1 if user->IM is cell count). | |
| JM_nodes_global | Global number of nodes in the J-direction. | |
| KM_nodes_global | Global number of nodes in the K-direction. | |
| [out] | can_service_inlet_out | Pointer to a PetscBool; set to PETSC_TRUE if the rank services (part of) the inlet, PETSC_FALSE otherwise. |
Determines if the current MPI rank owns any part of the globally defined inlet face, making it responsible for placing particles on that portion of the surface.
Local to this translation unit.
Definition at line 11 of file Boundaries.c.
| PetscErrorCode CanRankServiceFace | ( | const DMDALocalInfo * | info, |
| PetscInt | IM_nodes_global, | ||
| PetscInt | JM_nodes_global, | ||
| PetscInt | KM_nodes_global, | ||
| BCFace | face_id, | ||
| PetscBool * | can_service_out | ||
| ) |
Determines if the current MPI rank owns any part of a specified global face.
This function is a general utility for parallel boundary operations. It checks if the local domain of the current MPI rank is adjacent to a specified global boundary face. A rank "services" a face if it owns the cells adjacent to that global boundary and has a non-zero extent (i.e., owns at least one cell) in the tangential dimensions of that face.
| info | Pointer to the DMDALocalInfo for the current rank's DA. | |
| IM_nodes_global | Global number of nodes in the I-direction (e.g., user->IM + 1 if user->IM is cell count). | |
| JM_nodes_global | Global number of nodes in the J-direction. | |
| KM_nodes_global | Global number of nodes in the K-direction. | |
| face_id | The specific global face (e.g., BC_FACE_NEG_Z) to check. | |
| [out] | can_service_out | Pointer to a PetscBool; set to PETSC_TRUE if the rank services the face, PETSC_FALSE otherwise. |
Determines if the current MPI rank owns any part of a specified global face.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Boundaries.h.
Definition at line 126 of file Boundaries.c.
| PetscErrorCode GetDeterministicFaceGridLocation | ( | UserCtx * | user, |
| const DMDALocalInfo * | info, | ||
| PetscInt | xs_gnode_rank, | ||
| PetscInt | ys_gnode_rank, | ||
| PetscInt | zs_gnode_rank, | ||
| PetscInt | IM_cells_global, | ||
| PetscInt | JM_cells_global, | ||
| PetscInt | KM_cells_global, | ||
| PetscInt64 | particle_global_id, | ||
| PetscInt * | ci_metric_lnode_out, | ||
| PetscInt * | cj_metric_lnode_out, | ||
| PetscInt * | ck_metric_lnode_out, | ||
| PetscReal * | xi_metric_logic_out, | ||
| PetscReal * | eta_metric_logic_out, | ||
| PetscReal * | zta_metric_logic_out, | ||
| PetscBool * | placement_successful_out | ||
| ) |
Places particles in a deterministic grid/raster pattern on a specified domain face.
This function creates a set of equidistant, parallel lines of particles near the four edges of the face specified by user->identifiedInletBCFace. The number of lines drawn from each edge is hardcoded within this function (default is 2). For example, if grid_layers=2 on face BC_FACE_NEG_X, the function will create particle lines at:
| user | Pointer |
| info | Pointer |
| xs_gnode_rank | Parameter xs_gnode_rank passed to GetDeterministicFaceGridLocation(). |
| ys_gnode_rank | Parameter ys_gnode_rank passed to GetDeterministicFaceGridLocation(). |
| zs_gnode_rank | Parameter zs_gnode_rank passed to GetDeterministicFaceGridLocation(). |
| IM_cells_global | Parameter IM_cells_global passed to GetDeterministicFaceGridLocation(). |
| JM_cells_global | Parameter JM_cells_global passed to GetDeterministicFaceGridLocation(). |
| KM_cells_global | Parameter KM_cells_global passed to GetDeterministicFaceGridLocation(). |
| particle_global_id | The |
| ci_metric_lnode_out | Local |
| cj_metric_lnode_out | Local |
| ck_metric_lnode_out | Local |
| xi_metric_logic_out | Logical |
| eta_metric_logic_out | Logical |
| zta_metric_logic_out | Logical |
| placement_successful_out | PETSC_TRUE |
Places particles in a deterministic grid/raster pattern on a specified domain face.
Local to this translation unit.
Definition at line 212 of file Boundaries.c.
| PetscErrorCode GetRandomCellAndLogicalCoordsOnInletFace | ( | UserCtx * | user, |
| const DMDALocalInfo * | info, | ||
| PetscInt | xs_gnode_rank, | ||
| PetscInt | ys_gnode_rank, | ||
| PetscInt | zs_gnode_rank, | ||
| PetscInt | IM_nodes_global, | ||
| PetscInt | JM_nodes_global, | ||
| PetscInt | KM_nodes_global, | ||
| PetscRandom * | rand_logic_i_ptr, | ||
| PetscRandom * | rand_logic_j_ptr, | ||
| PetscRandom * | rand_logic_k_ptr, | ||
| PetscInt * | ci_metric_lnode_out, | ||
| PetscInt * | cj_metric_lnode_out, | ||
| PetscInt * | ck_metric_lnode_out, | ||
| PetscReal * | xi_metric_logic_out, | ||
| PetscReal * | eta_metric_logic_out, | ||
| PetscReal * | zta_metric_logic_out | ||
| ) |
Assuming the current rank services the inlet face, this function selects a random cell (owned by this rank on that face) and random logical coordinates within that cell, suitable for placing a particle on the inlet surface.
It is the caller's responsibility to ensure CanRankServiceInletFace returned true.
| user | Pointer to UserCtx. | |
| info | Pointer to DMDALocalInfo for the current rank (node-based). | |
| xs_gnode_rank | Local i-start node index (including ghosts) for this rank. | |
| ys_gnode_rank | Local j-start node index (including ghosts) for this rank. | |
| zs_gnode_rank | Local k-start node index (including ghosts) for this rank. | |
| IM_nodes_global | Global node count in i. | |
| JM_nodes_global | Global node count in j. | |
| KM_nodes_global | Global node count in k. | |
| rand_logic_i_ptr | RNG handle for sampling local logical xi. | |
| rand_logic_j_ptr | RNG handle for sampling local logical eta. | |
| rand_logic_k_ptr | RNG handle for sampling local logical zta. | |
| [out] | ci_metric_lnode_out | Local i node index of selected cell origin. |
| [out] | cj_metric_lnode_out | Local j node index of selected cell origin. |
| [out] | ck_metric_lnode_out | Local k node index of selected cell origin. |
| [out] | xi_metric_logic_out | Logical xi coordinate in [0,1]. |
| [out] | eta_metric_logic_out | Logical eta coordinate in [0,1]. |
| [out] | zta_metric_logic_out | Logical zta coordinate in [0,1]. |
Assuming the current rank services the inlet face, this function selects a random cell (owned by this rank on that face) and random logical coordinates within that cell, suitable for placing a particle on the inlet surface.
Local to this translation unit.
Definition at line 399 of file Boundaries.c.
| PetscErrorCode EnforceRHSBoundaryConditions | ( | UserCtx * | user | ) |
Enforces boundary conditions on the momentum equation's Right-Hand-Side (RHS) vector.
This function performs two critical roles based on the legacy implementation:
ApplyBoundaryConditions.i=0, i=mx-1, etc.), it zeroes out all components of the RHS. Since the RHS is a cell-centered quantity in this architecture, these locations correspond to ghost cells. This step sanitizes these unused locations, ensuring they do not contain garbage data that could affect diagnostics or other routines. This sanitization is performed for ALL boundary types, including periodic ones.This function should be called immediately after the RHS vector is fully assembled (spatial + temporal terms) and before it is used in a time-stepping update.
| user | The UserCtx for the specific block being computed. |
Enforces boundary conditions on the momentum equation's Right-Hand-Side (RHS) vector.
Local to this translation unit.
Definition at line 591 of file Boundaries.c.
| PetscErrorCode TransferPeriodicFieldByDirection | ( | UserCtx * | user, |
| const char * | field_name, | ||
| char | direction | ||
| ) |
(Private Worker) Copies periodic data for a SINGLE field in a SINGLE direction.
This is a low-level helper that performs the memory copy from the local ghost array to the global array for a specified field and direction ('i', 'j', or 'k'). It contains NO communication logic; that is handled by the orchestrator.
| user | The main UserCtx struct. |
| field_name | The string identifier for the field to transfer (e.g., "Ucat"). |
| direction | The character 'i', 'j', or 'k' specifying the direction. |
(Private Worker) Copies periodic data for a SINGLE field in a SINGLE direction.
Local to this translation unit.
Definition at line 1578 of file Boundaries.c.
| PetscErrorCode SynchronizePeriodicCellFields | ( | UserCtx * | user, |
| PetscInt | num_fields, | ||
| const char * | field_names[] | ||
| ) |
Synchronizes periodic endpoint cells for a list of cell-centered fields.
The fields are first communicated from global to local storage. Each periodic direction is then transferred in i-j-k order, with an intermediate ghost refresh after every active direction so periodic edges and corners inherit the values established by earlier directions. Only global duplicate planes in active periodic directions are repaired; non-periodic directions are untouched. The routine is a no-op, including no local refresh, when every direction is nonperiodic. During active periodic synchronization it internally refreshes the local vectors, but it is not a general replacement for UpdateLocalGhosts().
Supported fields are Ucat, P, Phi, Nvert, Nu_t, CS, Diffusivity, and Aj (Eddy Viscosity and Cs are accepted as compatibility aliases for Nu_t and CS, respectively).
| user | The main UserCtx struct. |
| num_fields | The number of entries in field_names. |
| field_names | The cell-centered fields to synchronize. |
Synchronizes periodic endpoint cells for a list of cell-centered fields.
Full API contract is documented with the header declaration in include/Boundaries.h.
Definition at line 1673 of file Boundaries.c.
| PetscErrorCode TransferPeriodicFaceFieldByDirection | ( | UserCtx * | user, |
| const char * | field_name, | ||
| char | face_direction, | ||
| char | periodic_direction | ||
| ) |
Transfers one persistent single-face-family field in one periodic direction.
This lower-level helper updates owned global endpoint/dummy values from an up-to-date local ghosted vector. face_direction identifies the field's storage family (‘'i’,'j', or'k');periodic_direction` selects the direction transferred during this call.
| user | The main UserCtx struct. |
| field_name | Registered persistent I/J/K-face field name. |
| face_direction | Face family containing the field (‘'i’,'j', or'k'). @param periodic_direction Periodic direction to transfer ('i','j', or'k'`). |
Transfers one persistent single-face-family field in one periodic direction.
Definition at line 1841 of file Boundaries.c.
| PetscErrorCode SynchronizePeriodicFaceFields | ( | UserCtx * | user, |
| char | face_direction, | ||
| PetscInt | num_fields, | ||
| const char * | field_names[] | ||
| ) |
Synchronizes persistent fields belonging to one face family.
The function performs deterministic I/J/K directional passes with an intermediate ghost refresh after each active periodic direction. It updates persistent global seam/dummy values only; face-specific local stencil repair remains a separate operation.
| user | The main UserCtx struct. |
| face_direction | Face family shared by every field (‘'i’,'j', or'k'). @param num_fields Number of entries infield_names`. |
| field_names | Registered persistent face-field names. |
Synchronizes persistent fields belonging to one face family.
Definition at line 1916 of file Boundaries.c.
| PetscErrorCode TransferPeriodicStaggeredFieldByDirection | ( | UserCtx * | user, |
| const char * | field_name, | ||
| char | periodic_direction | ||
| ) |
Transfers one persistent component-staggered field in one periodic direction.
A component-staggered vector stores its x, y, and z components on I-, J-, and K-faces, respectively. Persistent endpoint synchronization uses the same endpoint copy for all components; component-specific behavior is required later when repairing local stencil ghosts.
| user | The main UserCtx struct. |
| field_name | Registered component-staggered field name. |
| periodic_direction | Periodic direction to transfer (‘'i’,'j', or'k'`). |
Transfers one persistent component-staggered field in one periodic direction.
Definition at line 1999 of file Boundaries.c.
| PetscErrorCode SynchronizePeriodicStaggeredFields | ( | UserCtx * | user, |
| PetscInt | num_fields, | ||
| const char * | field_names[] | ||
| ) |
Synchronizes persistent component-staggered vector fields.
The function performs deterministic I/J/K endpoint transfers with an intermediate ghost refresh after every active periodic direction. Currently Ucont is the only registered component-staggered field.
| user | The main UserCtx struct. |
| num_fields | Number of entries in field_names. |
| field_names | Registered component-staggered field names. |
Synchronizes persistent component-staggered vector fields.
Definition at line 2048 of file Boundaries.c.
| PetscErrorCode PreparePeriodicQuickStencilFields | ( | UserCtx * | user, |
| Vec | local_vector_field, | ||
| Vec | local_scalar_field | ||
| ) |
Repairs the outer adjacent periodic ghosts used by QUICK cell stencils.
The supplied local vectors must already contain a current PETSc periodic ghost exchange. The vector and scalar fields are repaired two logical cells across each active periodic seam so QUICK's i-1/i+2 equivalents are valid.
| user | Main block context containing periodic boundary metadata. |
| local_vector_field | Ghosted three-component cell-centered field. |
| local_scalar_field | Ghosted scalar cell-centered field. |
Repairs the outer adjacent periodic ghosts used by QUICK cell stencils.
Definition at line 2093 of file Boundaries.c.
| PetscErrorCode SynchronizePeriodicLocalStaggeredField | ( | UserCtx * | user, |
| Vec | local_field | ||
| ) |
Synchronizes one local-only component-staggered periodic work field.
This helper communicates locally computed owned entries, establishes the normal-component periodic endpoint values, and communicates once more.
| user | Main block context containing periodic boundary metadata. |
| local_field | Ghosted local component-staggered vector. |
Synchronizes one local-only component-staggered periodic work field.
Definition at line 2159 of file Boundaries.c.
| PetscErrorCode TransferPeriodicField | ( | UserCtx * | user, |
| const char * | field_name | ||
| ) |
Legacy monolithic periodic endpoint transfer for one cell-centered field.
Retained for compatibility with older callers. New code should use SynchronizePeriodicCellFields, which provides ordered directional transfers with the required intermediate ghost communication.
| user | The main UserCtx struct. |
| field_name | The string identifier for the field to transfer. |
Legacy monolithic periodic endpoint transfer for one cell-centered field.
Local to this translation unit.
Definition at line 2199 of file Boundaries.c.
| PetscErrorCode TransferPeriodicFaceField | ( | UserCtx * | user, |
| const char * | field_name | ||
| ) |
(Primitive) Copies periodic data from the interior to the local ghost cell region for a single field.
This primitive function performs a direct memory copy for a specified field, updating all periodic ghost faces (i, j, and k). It reads data from just inside the periodic boundary and writes it to the corresponding local ghost cells.
The copy is "two-cells deep" to support wider computational stencils.
This function does NOT involve any MPI communication; it operates entirely on local PETSc vectors.
| user | The main UserCtx struct. |
| field_name | The string identifier for the field to update (e.g., "Csi", "Ucont"). |
(Primitive) Copies periodic data from the interior to the local ghost cell region for a single field.
Local to this translation unit.
Definition at line 2303 of file Boundaries.c.
| PetscErrorCode ApplyMetricsPeriodicBCs | ( | UserCtx * | user | ) |
(Orchestrator) Updates all metric-related fields in the local ghost cell regions for periodic boundaries.
This function synchronizes cell-centered Aj and the persistent I/J/K metric face families through the canonical MPI-safe synchronizers.
| user | The main UserCtx struct. |
(Orchestrator) Updates all metric-related fields in the local ghost cell regions for periodic boundaries.
Local to this translation unit.
Definition at line 2439 of file Boundaries.c.
| PetscErrorCode ApplyPeriodicBCs | ( | UserCtx * | user | ) |
Applies periodic boundary conditions by copying data across domain boundaries for all relevant fields.
This is the canonical periodic orchestrator for geometric consistency. It updates Ucat, P, and Nvert through the generic cell synchronizer and updates staggered Ucont through the component-staggered synchronizer.
Future extension rule: add new periodic variables by extending the existing field string dispatchers and invoking them from this orchestrator.
| user | The main UserCtx struct. |
Applies periodic boundary conditions by copying data across domain boundaries for all relevant fields.
Local to this translation unit.
Definition at line 2465 of file Boundaries.c.
| PetscErrorCode UpdateDummyCells | ( | UserCtx * | user | ) |
Updates the dummy cells (ghost nodes) on the faces of the local domain for NON-PERIODIC boundaries.
This function's role is to apply a second-order extrapolation to set the ghost cell values based on the boundary condition value (stored in ubcs) and the first interior cell.
NOTE: This function deliberately IGNORES periodic boundaries. It is part of a larger workflow where ApplyPeriodicBCs handles periodic faces first.
CRITICAL DETAIL: This function uses shrunken loop ranges (lxs, lxe, etc.) to intentionally update only the flat part of the faces, avoiding the edges and
corners. The edges and corners are then handled separately by UpdateCornerNodes. This precisely replicates the logic of the original FormBCS function.
| user | The main UserCtx struct containing all necessary data. |
Updates the dummy cells (ghost nodes) on the faces of the local domain for NON-PERIODIC boundaries.
Local to this translation unit.
Definition at line 2518 of file Boundaries.c.
| PetscErrorCode UpdateCornerNodes | ( | UserCtx * | user | ) |
Updates the corner and edge ghost nodes of the local domain by averaging.
This function should be called AFTER the face ghost nodes are finalized by both ApplyPeriodicBCs and UpdateDummyCells. It resolves the values at shared edges and corners by averaging the values of adjacent, previously-computed ghost nodes.
The logic is generic and works correctly regardless of the boundary types on the adjacent faces (e.g., it will correctly average a periodic face neighbor with a wall face neighbor).
| user | The main UserCtx struct containing all necessary data. |
Updates the corner and edge ghost nodes of the local domain by averaging.
Local to this translation unit.
Definition at line 2610 of file Boundaries.c.
| PetscErrorCode UpdatePeriodicCornerNodes | ( | UserCtx * | user, |
| PetscInt | num_fields, | ||
| const char * | field_names[] | ||
| ) |
Legacy sequential periodic-corner update for a list of fields.
Retained for compatibility with older callers. New code should use SynchronizePeriodicCellFields, which additionally skips non-periodic directions and performs the initial ghost refresh.
| user | The main UserCtx struct. |
| num_fields | The number of fields in the field_names array. |
| field_names | An array of strings with the names of fields to update (e.g., ["Ucat", "P"]). |
Legacy sequential periodic-corner update for a list of fields.
Local to this translation unit.
Definition at line 2754 of file Boundaries.c.
| PetscErrorCode ApplyWallFunction | ( | UserCtx * | user | ) |
Applies wall function modeling to near-wall velocities for all wall-type boundaries.
This function implements log-law wall functions to model the near-wall velocity profile without fully resolving the viscous sublayer. It is applicable to ALL wall-type boundaries regardless of their specific boundary condition (no-slip, moving wall, slip, etc.), as determined by the mathematical_type being WALL.
MATHEMATICAL BACKGROUND: Wall functions bridge the gap between the wall (y=0) and the first computational cell center by using empirical log-law relationships:
IMPLEMENTATION DETAILS: Unlike standard boundary conditions that set ghost cell values, wall functions:
WORKFLOW:
GEOMETRIC QUANTITIES: sb = wall-normal distance from wall to first interior cell center sc = wall-normal distance from wall to second interior cell center
These are computed from cell Jacobians (aj) and face area vectors
APPLICABILITY:
| user | The UserCtx containing all simulation state and geometry |
Applies wall function modeling to near-wall velocities for all wall-type boundaries.
Local to this translation unit.
Definition at line 2797 of file Boundaries.c.
| PetscErrorCode FinalizePostProjectionCellFields | ( | UserCtx * | user | ) |
Finalizes cell-centered fields after the projection step.
This function completes the cell-centered state derived from the final, divergence-free Ucont produced by Projection. It fills non-periodic Ucat dummy faces, synchronizes periodic Ucat and P endpoints, resolves edges and corners, and refreshes the corresponding local vectors.
This function is fundamentally different from ApplyBoundaryConditions: it does NOT modify Ucont, reapply wall functions, or rerun the full physical boundary-condition workflow.
WORKFLOW:
Ucat and any flow-dependent Ubcs targets.Ucat and P.| user | The main UserCtx struct, containing all simulation state. |
Finalizes cell-centered fields after the projection step.
Full API contract is documented with the header declaration in include/Boundaries.h.
Definition at line 3257 of file Boundaries.c.
| PetscErrorCode ApplyBoundaryConditions | ( | UserCtx * | user | ) |
Main boundary-condition orchestrator executed during solver timestepping.
This routine performs the full BC workflow for the current block, including dynamic boundary refresh, periodic transfer, dummy/corner updates, and optional wall-function corrections in the same order expected by the runtime solver. It may iterate boundary updates to enforce coupled boundary dependencies.
| user | The main UserCtx struct containing field vectors and boundary system state. |
Main boundary-condition orchestrator executed during solver timestepping.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Boundaries.h.
Definition at line 3297 of file Boundaries.c.