|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
Go to the source code of this file.
Macros | |
| #define | __FUNCT__ "CanRankServiceInletFace" |
| #define | __FUNCT__ "CanRankServiceFace" |
| #define | __FUNCT__ "GetDeterministicFaceGridLocation" |
| #define | __FUNCT__ "GetRandomFCellAndLogicOnInletFace" |
| #define | __FUNCT__ "TranslateModernBCsToLegacy" |
| #define | __FUNCT__ "EnforceRHSBoundaryConditions" |
| #define | __FUNCT__ "BoundaryCondition_Create" |
| #define | __FUNCT__ "BoundarySystem_Validate" |
| #define | __FUNCT__ "BoundarySystem_Initialize" |
| #define | __FUNCT__ "PropagateBoundaryConfigToCoarserLevels" |
| #define | __FUNCT__ "BoundarySystem_ExecuteStep" |
| #define | __FUNCT__ "BoundarySystem_RefreshUbcs" |
| #define | __FUNCT__ "BoundarySystem_Destroy" |
| #define | __FUNCT__ "TransferPeriodicFieldByDirection" |
| #define | __FUNCT__ "TransferPeriodicField" |
| #define | __FUNCT__ "TransferPeriodicFaceField" |
| #define | __FUNCT__ "ApplyMetricsPeriodicBCs" |
| #define | __FUNCT__ "ApplyPeriodicBCs" |
| #define | __FUNCT__ "ApplyUcontPeriodicBCs" |
| #define | __FUNCT__ "EnforceUcontPeriodicity" |
| #define | __FUNCT__ "UpdateDummyCells" |
| #define | __FUNCT__ "UpdateCornerNodes" |
| #define | __FUNCT__ "UpdatePeriodicCornerNodes" |
| #define | __FUNCT__ "ApplyWallFunction" |
| #define | __FUNCT__ "RefreshBoundaryGhostCells" |
| #define | __FUNCT__ "ApplyBoundaryConditions" |
Functions | |
| 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 | TranslateModernBCsToLegacy (UserCtx *user) |
| PetscErrorCode | EnforceRHSBoundaryConditions (UserCtx *user) |
| Enforces boundary conditions on the momentum equation's Right-Hand-Side (RHS) vector. | |
| PetscErrorCode | BoundaryCondition_Create (BCHandlerType handler_type, BoundaryCondition **new_bc_ptr) |
| (Private) Creates and configures a specific BoundaryCondition handler object. | |
| PetscErrorCode | BoundarySystem_Validate (UserCtx *user) |
| (Public) Validates the consistency and compatibility of the parsed boundary condition system. | |
| PetscErrorCode | BoundarySystem_Initialize (UserCtx *user, const char *bcs_filename) |
| Initializes the entire boundary system based on a configuration file. | |
| PetscErrorCode | PropagateBoundaryConfigToCoarserLevels (SimCtx *simCtx) |
| Propagates boundary condition configuration from finest to all coarser multigrid levels. | |
| PetscErrorCode | BoundarySystem_ExecuteStep (UserCtx *user) |
| Executes all boundary condition handlers in priority order. | |
| 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 resources allocated by the boundary system. | |
| PetscErrorCode | TransferPeriodicFieldByDirection (UserCtx *user, const char *field_name, char direction) |
| (Private Worker) Copies periodic data for a SINGLE field in a SINGLE direction. | |
| PetscErrorCode | TransferPeriodicField (UserCtx *user, const char *field_name) |
| (Private) A generic routine to copy data for a single, named field across periodic boundaries. | |
| 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 | ApplyUcontPeriodicBCs (UserCtx *user) |
| (Orchestrator) Updates the contravariant velocity field in the local ghost cell regions for periodic boundaries. | |
| PetscErrorCode | EnforceUcontPeriodicity (UserCtx *user) |
| Enforces strict periodicity on the interior contravariant velocity field. | |
| 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[]) |
| (Orchestrator) Performs a sequential, deterministic periodic update for a list of fields. | |
| PetscErrorCode | ApplyWallFunction (UserCtx *user) |
| Applies wall function modeling to near-wall velocities for all wall-type boundaries. | |
| PetscErrorCode | RefreshBoundaryGhostCells (UserCtx *user) |
| (Public) Orchestrates the "light" refresh of all boundary ghost cells after the projection step. | |
| PetscErrorCode | ApplyBoundaryConditions (UserCtx *user) |
| Main master function to apply all boundary conditions for a time step. | |
| #define __FUNCT__ "CanRankServiceInletFace" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "CanRankServiceFace" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "GetDeterministicFaceGridLocation" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "GetRandomFCellAndLogicOnInletFace" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "TranslateModernBCsToLegacy" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "EnforceRHSBoundaryConditions" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "BoundaryCondition_Create" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "BoundarySystem_Validate" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "BoundarySystem_Initialize" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "PropagateBoundaryConfigToCoarserLevels" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "BoundarySystem_ExecuteStep" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "BoundarySystem_RefreshUbcs" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "BoundarySystem_Destroy" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "TransferPeriodicFieldByDirection" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "TransferPeriodicField" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "TransferPeriodicFaceField" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "ApplyMetricsPeriodicBCs" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "ApplyPeriodicBCs" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "ApplyUcontPeriodicBCs" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "EnforceUcontPeriodicity" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "UpdateDummyCells" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "UpdateCornerNodes" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "UpdatePeriodicCornerNodes" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "ApplyWallFunction" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "RefreshBoundaryGhostCells" |
Definition at line 6 of file Boundaries.c.
| #define __FUNCT__ "ApplyBoundaryConditions" |
Definition at line 6 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. |
Definition at line 25 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. |
Definition at line 151 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:
The particle's final position is set just inside the target cell face to ensure it is correctly located. The total number of particles (simCtx->np) is distributed as evenly as possible among all generated lines.
The function includes extensive validation to stop with an error if the requested grid placement is geometrically impossible (e.g., in a 2D domain or if layers would overlap). It also issues warnings for non-fatal but potentially unintended configurations.
| user | Pointer to UserCtx, which must contain a valid identifiedInletBCFace. | |
| info | Pointer to DMDALocalInfo for the current rank's grid layout. | |
| xs_gnode_rank,ys_gnode_rank,zs_gnode_rank | Local starting node indices (incl. ghosts) for the rank's DA. | |
| IM_cells_global,JM_cells_global,KM_cells_global | Global cell counts. | |
| particle_global_id | The unique global ID of the particle being placed (from 0 to np-1). | |
| [out] | ci_metric_lnode_out | Local I-node index of the selected cell's origin. |
| [out] | cj_metric_lnode_out | Local J-node index of the selected cell's origin. |
| [out] | ck_metric_lnode_out | Local K-node index of the selected cell's origin. |
| [out] | xi_metric_logic_out | Logical xi-coordinate [0,1] within the cell. |
| [out] | eta_metric_logic_out | Logical eta-coordinate [0,1] within the cell. |
| [out] | zta_metric_logic_out | Logical zta-coordinate [0,1] within the cell. |
| [out] | placement_successful_out | PETSC_TRUE if the point belongs to this rank, PETSC_FALSE otherwise. |
Definition at line 268 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,ys_gnode,zs_gnode | Local starting node indices (incl. ghosts) for the rank's DA. | |
| IM_nodes_global,JM_nodes_global,KM_nodes_global | Global node counts. | |
| rand_logic_i_ptr,rand_logic_j_ptr,rand_logic_k_ptr | Pointers to RNGs for logical coords. | |
| [out] | ci_metric_lnode_out,cj_metric_lnode_out,ck_metric_lnode_out | Local node indices of the selected cell's origin (these are local to the rank's DA including ghosts). |
| [out] | xi_metric_logic_out,eta_metric_logic_out,zta_metric_logic_out | Logical coords [0,1] within the cell. |
Definition at line 467 of file Boundaries.c.
| PetscErrorCode TranslateModernBCsToLegacy | ( | UserCtx * | user | ) |
Definition at line 656 of file Boundaries.c.
| PetscErrorCode EnforceRHSBoundaryConditions | ( | UserCtx * | user | ) |
Enforces boundary conditions on the momentum equation's Right-Hand-Side (RHS) vector.
(Private) A generic routine to copy data for a single, named field across periodic boundaries.
This function is a faithful and structured replication of the boundary logic from the legacy CalcRHS routine. It accounts for the specific staggered grid architecture where a dimension of size mx has mx-1 nodes (0 to mx-2) and mx-2 cells. The face-centered RHS vector is allocated to size mx.
This results in the following indexing for the x-component of the RHS:
This function performs two distinct roles based on this layout:
| user | The UserCtx for the specific block being computed. |
Definition at line 705 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. |
Definition at line 866 of file Boundaries.c.
| 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. |
Definition at line 958 of file Boundaries.c.
| PetscErrorCode BoundarySystem_Initialize | ( | UserCtx * | user, |
| const char * | bcs_filename | ||
| ) |
Initializes the entire boundary system based on a configuration file.
Initializes the entire boundary system.
Definition at line 987 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 |
Definition at line 1118 of file Boundaries.c.
| PetscErrorCode BoundarySystem_ExecuteStep | ( | UserCtx * | user | ) |
Executes all boundary condition handlers in priority order.
Executes one full boundary condition update cycle for a time step.
This function orchestrates the application of boundary conditions across all faces using a priority-based system. Each priority group is executed atomically: handlers at a given priority complete their PreStep, Apply, and PostStep phases, with MPI communication between phases as needed. This ensures proper data flow for boundary conditions that depend on results from other boundaries.
Priority execution order (matches legacy): 0 (BC_PRIORITY_INLET): Inlets - Set inflow, measure flux 1 (BC_PRIORITY_FARFIELD): Farfield - Bidirectional flow, measure flux
2 (BC_PRIORITY_WALL): Walls/Symmetry - Set velocity/gradients 3 (BC_PRIORITY_OUTLET): Outlets - Apply conservation correction
NOTE: This function is called INSIDE the ApplyBoundaryConditions iteration loop. It does NOT handle:
| user | The UserCtx containing boundary configuration and state |
Definition at line 1207 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. |
Definition at line 1644 of file Boundaries.c.
| PetscErrorCode BoundarySystem_Destroy | ( | UserCtx * | user | ) |
Cleans up and destroys all resources allocated by the boundary system.
Cleans up and destroys all boundary system resources.
This function should be called once at the end of the simulation. It iterates through all created handlers and calls their respective Destroy methods to free any privately allocated data (like parameter lists or handler-specific data), and then frees the handler object itself. This prevents memory leaks.
| user | The main UserCtx struct containing the boundary system to be destroyed. |
Definition at line 1699 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. |
Definition at line 1754 of file Boundaries.c.
| PetscErrorCode TransferPeriodicField | ( | UserCtx * | user, |
| const char * | field_name | ||
| ) |
(Private) A generic routine to copy data for a single, named field across periodic boundaries.
This function encapsulates all logic for a periodic transfer. Given a field name (e.g., "P", "Ucat"), it determines the field's data type (scalar/vector), retrieves the correct DMDA and Vecs from the UserCtx, and then performs the memory copy from the local ghost array to the global array.
This must be called AFTER the corresponding local ghost vector has been updated via DMGlobalToLocal.
| user | The main UserCtx struct, containing all grid info and field data. |
| field_name | A string identifier for the field to transfer. |
Definition at line 1847 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"). |
Definition at line 1959 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 calls the TransferPeriodicFaceField primitive for each of the 16 metric fields that require a 2-cell deep periodic ghost cell update. This is a direct replacement for the legacy Update_Metrics_PBC function.
| user | The main UserCtx struct. |
Definition at line 2099 of file Boundaries.c.
| PetscErrorCode ApplyPeriodicBCs | ( | UserCtx * | user | ) |
Applies periodic boundary conditions by copying data across domain boundaries for all relevant fields.
This function orchestrates the periodic update. It first performs a single, collective ghost-cell exchange for all fields. Then, it calls a generic helper routine to perform the memory copy for each individual field by name.
| user | The main UserCtx struct. |
Definition at line 2132 of file Boundaries.c.
| PetscErrorCode ApplyUcontPeriodicBCs | ( | UserCtx * | user | ) |
(Orchestrator) Updates the contravariant velocity field in the local ghost cell regions for periodic boundaries.
This function calls the TransferPeriodicFaceField primitive for the Ucont field. This is a direct replacement for the legacy Update_U_Cont_PBC function.
| user | The main UserCtx struct. |
Definition at line 2189 of file Boundaries.c.
| PetscErrorCode EnforceUcontPeriodicity | ( | UserCtx * | user | ) |
Enforces strict periodicity on the interior contravariant velocity field.
This function is a "fix-up" routine for staggered grids. After a solver step, numerical inaccuracies can lead to small discrepancies between fluxes on opposing periodic boundaries. This function manually corrects this by copying the flux value from the first boundary face (retrieved from a ghost cell) to the last interior face.
This routine involves MPI communication to synchronize the grid before and after the copy.
| user | The main UserCtx struct. |
Definition at line 2216 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 function.
| user | The main UserCtx struct containing all necessary data. |
Definition at line 2283 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. |
Definition at line 2386 of file Boundaries.c.
| PetscErrorCode UpdatePeriodicCornerNodes | ( | UserCtx * | user, |
| PetscInt | num_fields, | ||
| const char * | field_names[] | ||
| ) |
(Orchestrator) Performs a sequential, deterministic periodic update for a list of fields.
This function orchestrates the resolution of ambiguous periodic corners and edges. It takes an array of field names and updates them in a strict i-sync-j-sync-k order by calling the low-level worker TransferPeriodicFieldByDirection and the communication routine UpdateLocalGhosts.
| 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"]). |
Definition at line 2539 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 |
Definition at line 2624 of file Boundaries.c.
| PetscErrorCode RefreshBoundaryGhostCells | ( | UserCtx * | user | ) |
(Public) Orchestrates the "light" refresh of all boundary ghost cells after the projection step.
This function is the correct and complete replacement for the role that GhostNodeVelocity played when called from within the Projection function. Its purpose is to ensure that all ghost cells for ucat and p are made consistent with the final, divergence-free interior velocity field computed by the projection step.
This function is fundamentally different from ApplyBoundaryConditions because it does NOT modify the physical flux field (ucont) and does NOT apply physical models like the wall function. It is a purely geometric and data-consistency operation.
WORKFLOW:
BoundarySystem_RefreshUbcs() engine. This re-calculates the ubcs target values ONLY for flow-dependent boundary conditions (like Symmetry or Outlets) using the newly updated interior ucat field.ApplyPeriodicBCs, UpdateDummyCells, UpdateCornerNodes) in the correct, dependency-aware order to fill in all ghost cell values based on the now fully-refreshed ubcs targets.| user | The main UserCtx struct, containing all simulation state. |
Definition at line 3106 of file Boundaries.c.
| PetscErrorCode ApplyBoundaryConditions | ( | UserCtx * | user | ) |
Main master function to apply all boundary conditions for a time step.
This function orchestrates the entire boundary condition workflow in a specific, dependency-aware order:
BoundarySystem_ExecuteStep calculates fluxes and sets boundary values (ubcs).UpdateDummyCells uses these values to update the ghost cells.UpdateCornerNodes is called to resolve the values at ghost cell edges and corners, using the now-final values from both the periodic and non-periodic faces.| user | The main UserCtx struct containing the complete simulation state. |
Definition at line 3192 of file Boundaries.c.