|
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 "field_catalog.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.
Enumerations | |
| enum | MomentumRowType { MOM_ROW_PHYSICAL = 0 , MOM_ROW_FIXED_CONDITIONED , MOM_ROW_FIXED_HOMOGENEOUS , MOM_ROW_PERIODIC_DUPLICATE } |
| Classification of one staggered momentum row (location + component). More... | |
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. | |
| MomentumRowType | ClassifyMomentumRow (UserCtx *user, PetscInt i, PetscInt j, PetscInt k, PetscInt component, PetscInt *ri, PetscInt *rj, PetscInt *rk) |
| Single source of truth for "which staggered momentum rows are unknowns". | |
| PetscErrorCode | EnforceRHSBoundaryConditions (UserCtx *user) |
| Zeroes every momentum RHS row that does not carry an independent unknown. | |
| PetscErrorCode | SynchronizePeriodicCellFields (UserCtx *user, PetscInt num_fields, const FieldId field_ids[]) |
| Synchronizes periodic endpoint cells for a list of cell-centered fields. | |
| PetscErrorCode | SynchronizePeriodicFaceFields (UserCtx *user, char face_direction, PetscInt num_fields, const FieldId field_ids[]) |
| Synchronizes persistent fields belonging to one face family. | |
| PetscErrorCode | SynchronizePeriodicStaggeredFields (UserCtx *user, PetscInt num_fields, const FieldId field_ids[]) |
| 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 | 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 | 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. | |
| enum MomentumRowType |
Classification of one staggered momentum row (location + component).
| Enumerator | |
|---|---|
| MOM_ROW_PHYSICAL | Independent unknown governed by the momentum equation. |
| MOM_ROW_FIXED_CONDITIONED | Strong Dirichlet row; the value comes from ApplyBoundaryConditions(). |
| MOM_ROW_FIXED_HOMOGENEOUS | Dummy/tangential row carrying no unknown at all. |
| MOM_ROW_PERIODIC_DUPLICATE | Duplicate of a wrapped representative row (see |
Definition at line 252 of file Boundaries.h.
| 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 789 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 703 of file Boundaries.c.
| PetscErrorCode BoundarySystem_Initialize | ( | UserCtx * | user, |
| const char * | bcs_filename | ||
| ) |
Initializes the entire boundary system.
| [in,out] | user | Finest-level block context receiving parsed face configuration. |
| bcs_filename | Path to the generated boundary-condition definition file. |
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 850 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 947 of file Boundaries.c.
| PetscErrorCode BoundarySystem_ExecuteStep | ( | UserCtx * | user | ) |
Executes one full boundary condition update cycle for a time step.
| [in,out] | user | Block context whose boundary handlers update target values and fluxes. |
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 1018 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 1440 of file Boundaries.c.
| PetscErrorCode BoundarySystem_Destroy | ( | UserCtx * | user | ) |
Cleans up and destroys all boundary system resources.
| [in,out] | user | Block context whose boundary handlers and temporary state are released. |
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 1490 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 127 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 | Inlet-boundary context that defines the target face and grid layers. | |
| info | Local ownership and ghost-range information. | |
| xs_gnode_rank | Global xi node index at this rank's owned lower corner. | |
| ys_gnode_rank | Global eta node index at this rank's owned lower corner. | |
| zs_gnode_rank | Global zeta node index at this rank's owned lower corner. | |
| IM_cells_global | Global number of xi cells. | |
| JM_cells_global | Global number of eta cells. | |
| KM_cells_global | Global number of zeta cells. | |
| particle_global_id | Global particle ordinal used for deterministic placement. | |
| [out] | ci_metric_lnode_out | Local xi metric-node index of the chosen cell. |
| [out] | cj_metric_lnode_out | Local eta metric-node index of the chosen cell. |
| [out] | ck_metric_lnode_out | Local zeta metric-node index of the chosen cell. |
| [out] | xi_metric_logic_out | Logical xi coordinate within the chosen cell. |
| [out] | eta_metric_logic_out | Logical eta coordinate within the chosen cell. |
| [out] | zta_metric_logic_out | Logical zeta coordinate within the chosen cell. |
| [out] | placement_successful_out | PETSC_TRUE when this rank owns a valid placement. |
Places particles in a deterministic grid/raster pattern on a specified domain face.
Local to this translation unit.
Definition at line 213 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 400 of file Boundaries.c.
| MomentumRowType ClassifyMomentumRow | ( | UserCtx * | user, |
| PetscInt | i, | ||
| PetscInt | j, | ||
| PetscInt | k, | ||
| PetscInt | component, | ||
| PetscInt * | ri, | ||
| PetscInt * | rj, | ||
| PetscInt * | rk | ||
| ) |
Single source of truth for "which staggered momentum rows are unknowns".
Every consumer of the momentum system must agree on which rows the solver is responsible for, and every consumer must derive that answer from this function rather than restating the index arithmetic locally. Three independent restatements previously disagreed, and the disagreement was silent: the residual assembly skipped the periodic duplicate column at index 0 while nothing zeroed it, so ComputeTotalResidual()'s BDF term accumulated there without bound and the reported residual norm stopped describing the state.
The classification depends only on user->info, the configured boundary types, and the queried index; it reads no field data and performs no communication, so it is safe to call inside assembly loops.
Periodicity of an axis is taken from that axis's NEGATIVE face, matching ComputeRHS() and TransferPeriodicStaggeredFieldByDirection(). A periodic axis is expected to carry PERIODIC on both of its faces.
Callers act on the classification differently, and both actions are correct:
EnforceRHSBoundaryConditions()) zero every non-physical row, because the value there is imposed immediately afterwards by the boundary sweep or the periodic synchronisation;F = X - U_conditioned, F = X, F = X_dup - X_rep), because a zeroed row would leave a zero Jacobian row.| [in] | user | Block context supplying info and boundary_faces. |
| [in] | i | Location index along xi. |
| [in] | j | Location index along eta. |
| [in] | k | Location index along zeta. |
| [in] | component | Staggered component of the row (0 = xi, 1 = eta, 2 = zeta). |
| [out] | ri | Representative xi index; equals i unless the row wraps. |
| [out] | rj | Representative eta index; equals j unless the row wraps. |
| [out] | rk | Representative zeta index; equals k unless the row wraps. |
Single source of truth for "which staggered momentum rows are unknowns".
Pure index/boundary-type arithmetic: no field reads, no communication. Precedence matters. A conditioned row is reported first because its explicit Dirichlet value is more specific than the homogeneous fallback, and a periodic duplicate is reported before the homogeneous case because the Newton path needs its representative index to build F = X_dup - X_rep.
Definition at line 597 of file Boundaries.c.
| PetscErrorCode EnforceRHSBoundaryConditions | ( | UserCtx * | user | ) |
Zeroes every momentum RHS row that does not carry an independent unknown.
The set of such rows is not restated here: each owned location and component is asked of ClassifyMomentumRow(), and anything other than MOM_ROW_PHYSICAL is zeroed. That covers, without enumerating them,
ApplyBoundaryConditions() has just set;SynchronizePeriodicStaggeredFields() copies from the wrapped master.The last case is the one that must not be skipped. ComputeRHS() leaves the transverse components of a periodic duplicate column untouched, so a row left unzeroed here retains its previous contents while ComputeTotalResidual() adds the BDF term on top of them on every call. The residual norm then grows by |dU|/dt per evaluation regardless of the state, and no pseudo-time iteration can reduce it.
Call 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. |
Zeroes every momentum RHS row that does not carry an independent unknown.
The sweep is deliberately expressed over every owned location rather than over the six boundary slabs: restating "which indices can be non-physical" here is exactly the duplication that let the periodic duplicate column go unzeroed. ClassifyMomentumRow() is a handful of integer comparisons and the walk is a single pass with no stencil access, which is negligible next to the several ghosted stencil passes ComputeRHS() has already made over the same range. MomentumNewtonKrylov_ApplyConstraints() walks the same range the same way.
Definition at line 660 of file Boundaries.c.
| PetscErrorCode SynchronizePeriodicCellFields | ( | UserCtx * | user, |
| PetscInt | num_fields, | ||
| const FieldId | field_ids[] | ||
| ) |
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 selected by FIELD_CAPABILITY_PERIODIC_CELL_SYNC in the field catalog.
| user | The main UserCtx struct. |
| num_fields | The number of entries in field_ids. |
| field_ids | 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 1621 of file Boundaries.c.
| PetscErrorCode SynchronizePeriodicFaceFields | ( | UserCtx * | user, |
| char | face_direction, | ||
| PetscInt | num_fields, | ||
| const FieldId | field_ids[] | ||
| ) |
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'`). | |
| [in] | num_fields | Count of registered face fields. |
| field_ids | Registered persistent face-field identities. |
Definition at line 1855 of file Boundaries.c.
| PetscErrorCode SynchronizePeriodicStaggeredFields | ( | UserCtx * | user, |
| PetscInt | num_fields, | ||
| const FieldId | field_ids[] | ||
| ) |
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_ids. |
| field_ids | Registered component-staggered field identities. |
Synchronizes persistent component-staggered vector fields.
Definition at line 1989 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 2034 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 2100 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 2140 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 2169 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 2222 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 2314 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 2458 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 2918 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 2958 of file Boundaries.c.