|
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 | TransferPeriodicField (UserCtx *user, const char *field_name) |
| (Orchestrator) Applies periodic transfer for one field across all i/j/k directions. | |
| 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 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 825 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 857 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 982 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 1053 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 1475 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 1525 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 1572 of file Boundaries.c.
| PetscErrorCode TransferPeriodicField | ( | UserCtx * | user, |
| const char * | field_name | ||
| ) |
(Orchestrator) Applies periodic transfer for one field across all i/j/k directions.
This wrapper executes directional periodic transfers in the prescribed order with intermediate ghost synchronization where needed, so callers can request a complete periodic update for a single field without handling the directional details.
| user | The main UserCtx struct. |
| field_name | The string identifier for the field to transfer. |
(Orchestrator) Applies periodic transfer for one field across all i/j/k directions.
Local to this translation unit.
Definition at line 1656 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 1759 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. |
(Orchestrator) Updates all metric-related fields in the local ghost cell regions for periodic boundaries.
Local to this translation unit.
Definition at line 1895 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 field transfer helper and also updates staggered Ucont periodicity via ApplyUcontPeriodicBCs() and EnforceUcontPeriodicity().
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 1922 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. |
(Orchestrator) Updates the contravariant velocity field in the local ghost cell regions for periodic boundaries.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Boundaries.h.
Definition at line 1983 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. |
Enforces strict periodicity on the interior contravariant velocity field.
Local to this translation unit.
Definition at line 2007 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 2059 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 2151 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"]). |
(Orchestrator) Performs a sequential, deterministic periodic update for a list of fields.
Local to this translation unit.
Definition at line 2295 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 2338 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. |
(Public) Orchestrates the "light" refresh of all boundary ghost cells after the projection step.
Local to this translation unit.
Definition at line 2797 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 2862 of file Boundaries.c.