|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
#include "momentumsolvers.h"Go to the source code of this file.
Data Structures | |
| struct | MomentumNewtonJacobian |
| struct | MomentumPreconditionerDescription |
| struct | MomentumPreconditionerModelOps |
| struct | MomentumPreconditionerEngine |
| struct | MomentumNewtonKrylovContext |
Macros | |
| #define | __FUNCT__ "MomentumNewtonKrylov_Validate" |
| #define | __FUNCT__ "MomentumNewtonKrylov_ReadLinearizationConfig" |
| #define | __FUNCT__ "FrozenMomentumJacobian_DescribePointBlock" |
| #define | __FUNCT__ "FrozenMomentumJacobian_AssemblePointBlocks" |
| #define | __FUNCT__ "MomentumPreconditionerEngine_ApplyConstraintRows" |
| #define | __FUNCT__ "MomentumNewtonJacobian_Create" |
| #define | __FUNCT__ "MomentumPreconditionerEngine_Create" |
| #define | __FUNCT__ "MomentumPreconditionerEngine_Assemble" |
| #define | __FUNCT__ "MomentumNewtonKrylov_FormJacobian" |
| #define | __FUNCT__ "MomentumNewtonKrylov_ClassifyRow" |
| #define | __FUNCT__ "MomentumPreconditionerEngine_CreateExactPointBlockMatrix" |
| #define | __FUNCT__ "MomentumNewtonKrylov_ApplyConstraints" |
| #define | __FUNCT__ "MomentumNewtonKrylov_FormResidual" |
| #define | __FUNCT__ "MomentumSolver_NewtonKrylov" |
Functions | |
| static PetscErrorCode | MomentumNewtonKrylov_Validate (UserCtx *user) |
| Rejects configurations outside the audited version-one feature set. | |
| static PetscErrorCode | MomentumNewtonKrylov_FormResidual (SNES snes, Vec X, Vec F, void *vctx) |
| Adapts a PETSc trial vector to the existing momentum residual path. | |
| static PetscErrorCode | MomentumNewtonKrylov_Monitor (SNES snes, PetscInt iteration, PetscReal norm, void *vctx) |
| Captures SNES iteration norms and optionally writes PICurv history rows. | |
| static void | MomentumNewtonKrylov_OpenHistory (MomentumNewtonKrylovContext *ctx) |
| Opens the optional rank-zero Newton iteration-history file. | |
| static void | MomentumNewtonKrylov_WriteSummary (const MomentumNewtonKrylovContext *ctx, SNESConvergedReason reason, PetscInt nonlinear_its, PetscInt function_evals, PetscInt linear_its, PetscReal final_norm, PetscBool committed) |
| Appends one rank-zero structured Newton result for a physical step. | |
| static PetscErrorCode | MomentumNewtonKrylov_ApplyConstraints (MomentumNewtonKrylovContext *ctx, Vec X, Vec F) |
| Replaces every non-independent residual row with an explicit equation. | |
| static MomentumNewtonKrylovRowType | MomentumNewtonKrylov_ClassifyRow (UserCtx *user, PetscInt i, PetscInt j, PetscInt k, PetscInt component, PetscInt *ri, PetscInt *rj, PetscInt *rk) |
| Classifies one stored staggered component row and its periodic representative. | |
| static PetscErrorCode | MomentumNewtonKrylov_ReadLinearizationConfig (MomentumNewtonJacobian *jacobian, MomentumPreconditionerDescription *description) |
| Reads application-owned Jacobian and preconditioner mathematics. | |
| static PetscErrorCode | MomentumNewtonKrylov_FormJacobian (SNES snes, Vec current_solution, Mat jacobian_operator, Mat preconditioning_matrix, void *vctx) |
| Updates the Jacobian and then assembles any separate preconditioning matrix. | |
| static PetscErrorCode | FrozenMomentumJacobian_AssemblePointBlocks (UserCtx *user, Vec current_solution, Mat preconditioning_matrix) |
| Inserts only the audited interior frozen-momentum point blocks. | |
| static PetscErrorCode | MomentumPreconditionerEngine_CreateExactPointBlockMatrix (UserCtx *user, Mat *preconditioning_matrix) |
| Creates the frozen point-block P matrix with its exact scalar pattern. | |
| static PetscReal | FrozenMomentumJacobian_MetricNormSquared (Cmpnts metric) |
| Returns the squared Euclidean norm of one metric vector. | |
| static void | FrozenMomentumJacobian_PointBlock (const SimCtx *simCtx, const Cmpnts ***ucont, const Cmpnts ***csi, const Cmpnts ***eta, const Cmpnts ***zet, const PetscReal ***aj, PetscInt i, PetscInt j, PetscInt k, PetscScalar block[9]) |
| Returns the audited frozen-momentum point block in modern residual sign. | |
| static PetscErrorCode | FrozenMomentumJacobian_DescribePointBlock (UserCtx *user, MomentumPreconditionerDescription *description) |
| Describes the audited frozen-coefficient point-block model. | |
| static PetscErrorCode | MomentumPreconditionerEngine_ApplyConstraintRows (UserCtx *user, Mat preconditioning_matrix) |
| Inserts all common fixed, homogeneous, and periodic-duplicate rows. | |
| static PetscErrorCode | MomentumNewtonJacobian_Create (SNES snes, MomentumNewtonJacobian *jacobian) |
| Creates the selected Jacobian operator; currently PETSc MFFD only. | |
| static PetscErrorCode | MomentumNewtonJacobian_Update (SNES snes, Vec current_solution, MomentumNewtonJacobian *jacobian) |
| Updates the matrix-free finite-difference operator base. | |
| static PetscErrorCode | MomentumNewtonJacobian_Register (SNES snes, MomentumNewtonJacobian *jacobian, MomentumPreconditionerEngine *engine, MomentumNewtonKrylovContext *ctx) |
| Registers the application orchestration callback and both SNES matrices. | |
| static PetscErrorCode | MomentumNewtonJacobian_Destroy (MomentumNewtonJacobian *jacobian) |
| Destroys a partially or fully created Jacobian operator. | |
| static PetscErrorCode | MomentumPreconditionerEngine_Create (UserCtx *user, Mat jacobian_operator, const MomentumPreconditionerDescription *requested, MomentumPreconditionerEngine *engine) |
| Validates a model/structure and creates or aliases its matrix. | |
| static PetscErrorCode | MomentumPreconditionerEngine_Assemble (MomentumPreconditionerEngine *engine, UserCtx *user, Vec current_solution) |
| Runs model insertion, common row handling, and final assembly. | |
| static PetscErrorCode | MomentumPreconditionerEngine_ConfigurePetscPC (MomentumPreconditionerEngine *engine, PC pc) |
| Applies the validated model/structure-to-PETSc-PC mapping. | |
| static PetscErrorCode | MomentumPreconditionerEngine_ValidatePetscPC (MomentumPreconditionerEngine *engine, PC pc) |
| Rejects raw options that select an unvalidated PETSc PC backend. | |
| static PetscErrorCode | MomentumPreconditionerEngine_Destroy (MomentumPreconditionerEngine *engine) |
| Destroys only a separately owned preconditioning matrix. | |
| PetscErrorCode | MomentumSolver_NewtonKrylov (UserCtx *user, IBMNodes *ibm, FSInfo *fsi) |
| Solves one physical momentum step with matrix-free Newton–Krylov. | |
Variables | |
| static const MomentumPreconditionerModelOps | frozen_momentum_point_block_ops |
| struct MomentumNewtonJacobian |
Definition at line 11 of file momentum_newton_krylov.c.
| Data Fields | ||
|---|---|---|
| MomentumNewtonJacobianType | type | |
| MomentumNewtonFiniteDifferenceMode | finite_difference_mode | |
| Mat | jacobian_operator | |
| struct MomentumPreconditionerDescription |
Definition at line 27 of file momentum_newton_krylov.c.
| Data Fields | ||
|---|---|---|
| MomentumPreconditionerModel | model | |
| MomentumPreconditionerStructure | structure | |
| PetscInt | block_size | |
| PetscInt | stencil_width | |
| struct MomentumPreconditionerEngine |
Definition at line 39 of file momentum_newton_krylov.c.
| Data Fields | ||
|---|---|---|
| MomentumPreconditionerDescription | description | |
| const MomentumPreconditionerModelOps * | model_ops | |
| Mat | preconditioning_matrix | |
| PetscBool | aliases_jacobian_operator | |
| PetscBool | owns_preconditioning_matrix | |
| const char * | petsc_pc_type | |
| struct MomentumNewtonKrylovContext |
Definition at line 48 of file momentum_newton_krylov.c.
| Data Fields | ||
|---|---|---|
| UserCtx * | user | |
| FILE * | history_file | |
| PetscBool | have_initial_norm | |
| PetscReal | initial_norm | |
| MomentumNewtonJacobian | jacobian | |
| MomentumPreconditionerEngine | preconditioning_engine | |
| #define __FUNCT__ "MomentumNewtonKrylov_Validate" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumNewtonKrylov_ReadLinearizationConfig" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "FrozenMomentumJacobian_DescribePointBlock" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "FrozenMomentumJacobian_AssemblePointBlocks" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumPreconditionerEngine_ApplyConstraintRows" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumNewtonJacobian_Create" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumPreconditionerEngine_Create" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumPreconditionerEngine_Assemble" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumNewtonKrylov_FormJacobian" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumNewtonKrylov_ClassifyRow" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumPreconditionerEngine_CreateExactPointBlockMatrix" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumNewtonKrylov_ApplyConstraints" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumNewtonKrylov_FormResidual" |
Definition at line 203 of file momentum_newton_krylov.c.
| #define __FUNCT__ "MomentumSolver_NewtonKrylov" |
Definition at line 203 of file momentum_newton_krylov.c.
| Enumerator | |
|---|---|
| MOM_NK_JACOBIAN_FINITE_DIFFERENCE | |
Definition at line 3 of file momentum_newton_krylov.c.
| Enumerator | |
|---|---|
| MOM_NK_FD_MODE_MATRIX_FREE | |
Definition at line 7 of file momentum_newton_krylov.c.
| Enumerator | |
|---|---|
| MOM_NK_PC_MODEL_NONE | |
| MOM_NK_PC_MODEL_FROZEN_MOMENTUM_JACOBIAN | |
Definition at line 17 of file momentum_newton_krylov.c.
| Enumerator | |
|---|---|
| MOM_NK_PC_STRUCTURE_NONE | |
| MOM_NK_PC_STRUCTURE_POINT_BLOCK | |
Definition at line 22 of file momentum_newton_krylov.c.
| Enumerator | |
|---|---|
| MOM_NK_ROW_PHYSICAL | |
| MOM_NK_ROW_FIXED_CONDITIONED | |
| MOM_NK_ROW_FIXED_HOMOGENEOUS | |
| MOM_NK_ROW_PERIODIC_DUPLICATE | |
Definition at line 59 of file momentum_newton_krylov.c.
|
static |
Rejects configurations outside the audited version-one feature set.
| user | Single-block momentum context to validate. |
Definition at line 209 of file momentum_newton_krylov.c.
|
static |
Adapts a PETSc trial vector to the existing momentum residual path.
A matrix-free SNES residual must be a deterministic function of the trial vector X alone: F(X) may not depend on any state left by a previous residual or MFFD evaluation, or finite-difference Jacobian actions become inconsistent. To honor that contract this callback fully derives the Cartesian velocity state (Ucat/lUcat) from X before the first boundary sweep – see the inline comment below for why ApplyBoundaryConditions()'s own internal reconstruction is not sufficient for the first outlet pass.
State invariants:
Side effects: overwrites user->Ucont/lUcont, user->Ucat/lUcat, user->Rhs, the boundary Ubcs targets, and boundary flux/area diagnostics; writes F.
| snes | Calling nonlinear solver. |
| X | Trial solution (read-only). |
| F | Residual output. |
| vctx | Pointer to MomentumNewtonKrylovContext. |
Definition at line 1066 of file momentum_newton_krylov.c.
|
static |
Captures SNES iteration norms and optionally writes PICurv history rows.
SNES supplies the already-computed norm, so this monitor never causes an additional nonlinear residual evaluation. PETSc monitors selected through -mom_nk_snes_monitor remain independent and may run alongside this callback.
Definition at line 98 of file momentum_newton_krylov.c.
|
static |
Opens the optional rank-zero Newton iteration-history file.
Definition at line 121 of file momentum_newton_krylov.c.
|
static |
Appends one rank-zero structured Newton result for a physical step.
File failures are deliberately diagnostic-only: rollback and PETSc cleanup must retain their original error behavior.
Definition at line 150 of file momentum_newton_krylov.c.
|
static |
Replaces every non-independent residual row with an explicit equation.
Conditioned face-normal rows use F=X-Uconditioned, unconditioned legacy dummy/tangential rows use F=X, and periodic duplicates use Fdup=Xdup-Xrep. These equations prevent the zero Jacobian rows produced by simply retaining EnforceRHSBoundaryConditions() zeros in a matrix-free Newton operator. Immersed, masked, TwoD, and interface rows are rejected before this callback is installed.
| ctx | Active solve context. |
| X | Unconditioned PETSc trial state. |
| F | Residual vector to update in place. |
Definition at line 986 of file momentum_newton_krylov.c.
|
static |
Classifies one stored staggered component row and its periodic representative.
Negative nonperiodic planes and positive dummy planes are zeroed by the legacy residual treatment. Only a face-normal row actually written by its boundary handler is conditioned; the remaining zeroed rows use F=X. Periodic endpoint rows use the same wrapped representatives as SynchronizePeriodicStaggeredFields(). At periodic/nonperiodic intersections the periodic equation owns rows that a shrunken boundary-handler loop does not condition.
| user | Block context containing boundary metadata and global dimensions. |
| i | Global i index. |
| j | Global j index. |
| k | Global k index. |
| component | Stored component, 0=x, 1=y, 2=z. |
| ri | Returned periodic representative i index. |
| rj | Returned periodic representative j index. |
| rk | Returned periodic representative k index. |
Definition at line 769 of file momentum_newton_krylov.c.
|
static |
Reads application-owned Jacobian and preconditioner mathematics.
Definition at line 295 of file momentum_newton_krylov.c.
|
static |
Updates the Jacobian and then assembles any separate preconditioning matrix.
Definition at line 734 of file momentum_newton_krylov.c.
|
static |
Inserts only the audited interior frozen-momentum point blocks.
Definition at line 485 of file momentum_newton_krylov.c.
|
static |
Creates the frozen point-block P matrix with its exact scalar pattern.
Row and column ownership follows the velocity DMDA global vector. Physical rows reserve the three same-point components, fixed rows reserve only their diagonal, and periodic duplicate rows additionally reserve their wrapped representative. DMDA AO, local mapping, and stencil metadata are retained so the existing insertion paths keep their exact ordering.
Definition at line 830 of file momentum_newton_krylov.c.
|
static |
Returns the squared Euclidean norm of one metric vector.
Definition at line 355 of file momentum_newton_krylov.c.
|
static |
Returns the audited frozen-momentum point block in modern residual sign.
Definition at line 361 of file momentum_newton_krylov.c.
|
static |
Describes the audited frozen-coefficient point-block model.
Definition at line 468 of file momentum_newton_krylov.c.
|
static |
Inserts all common fixed, homogeneous, and periodic-duplicate rows.
Definition at line 553 of file momentum_newton_krylov.c.
|
static |
Creates the selected Jacobian operator; currently PETSc MFFD only.
Definition at line 595 of file momentum_newton_krylov.c.
|
static |
Updates the matrix-free finite-difference operator base.
Definition at line 611 of file momentum_newton_krylov.c.
|
static |
Registers the application orchestration callback and both SNES matrices.
Definition at line 621 of file momentum_newton_krylov.c.
|
static |
Destroys a partially or fully created Jacobian operator.
Definition at line 633 of file momentum_newton_krylov.c.
|
static |
Validates a model/structure and creates or aliases its matrix.
Definition at line 643 of file momentum_newton_krylov.c.
|
static |
Runs model insertion, common row handling, and final assembly.
Definition at line 678 of file momentum_newton_krylov.c.
|
static |
Applies the validated model/structure-to-PETSc-PC mapping.
Definition at line 694 of file momentum_newton_krylov.c.
|
static |
Rejects raw options that select an unvalidated PETSc PC backend.
Definition at line 703 of file momentum_newton_krylov.c.
|
static |
Destroys only a separately owned preconditioning matrix.
Definition at line 720 of file momentum_newton_krylov.c.
Solves one physical momentum step with matrix-free Newton–Krylov.
The Jacobian operator is the finite-difference, matrix-free operator of the complete deterministic residual. With no mathematical preconditioner its matrix is also passed to PETSc's preconditioning slot and PCNONE is derived. The optional provisional frozen-momentum, point-block model approximates same-cell frozen coupling, owns a separate matrix, and derives a block-Jacobi PETSc backend. It does not relax the version-one physics or boundary-condition restrictions. All PETSc solver objects are local to this call. Rows removed by legacy boundary residual enforcement are made explicit: conditioned normal rows use X-Uconditioned, untouched dummy/tangential rows use X, and periodic duplicates use Xdup-Xrepresentative. Unsupported masked, interface, and component-disabled rows are rejected before setup.
| user | Single-block momentum context. |
| ibm | Must be NULL; immersed boundaries are not supported in version one. |
| fsi | Must be NULL; moving-body coupling is not supported in version one. |
Definition at line 1131 of file momentum_newton_krylov.c.
|
static |
Definition at line 587 of file momentum_newton_krylov.c.