|
PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
Momentum source terms added to the contravariant RHS. More...
Go to the source code of this file.
Functions | |
| PetscErrorCode | ComputeDrivenChannelFlowSource (UserCtx *user, Vec Rct) |
| Applies a momentum source term to drive flow in a periodic channel or pipe. | |
Momentum source terms added to the contravariant RHS.
Every body force here is invoked from ComputeBodyForces() (src/rhs.c), which is the single extension point. A new force should:
(UserCtx *user, Vec Rct),Rct with +=, never assign.ComputeBodyForces() is called from ComputeRHS(), which runs once per residual evaluation - that is, once per Jameson RK stage under the Picard solver and once per Newton residual evaluation (including every finite difference probe) under Newton-Krylov. It is emphatically NOT called once per physical timestep.
Any force that carries state across calls - a filter, a ramp, a moving average, an integral controller term - must therefore gate its update on simCtx->step and reuse the resolved value for the rest of that step:
Advancing it unconditionally makes the applied force depend on how many residual evaluations preceded it. That is history dependence, and it breaks two things at once: MomentumNewtonKrylov_FormResidual() requires F(X) to be a deterministic function of the trial vector alone, and the Picard shadow-Jacobian estimate assumes body forces are a constant forcing with zero velocity Jacobian.
This is not hypothetical. The driven-flow smoothing EMA in ComputeDrivenChannelFlowSource() had exactly this defect: the applied force walked 0.5, 0.75, 0.875 ... of the way toward its target across evaluations within a single timestep. tests/smoke/run_driven_periodic_regression.sh asserts the force is piecewise constant per step; extend it when adding a stateful force.
Definition in file BodyForces.h.
| PetscErrorCode ComputeDrivenChannelFlowSource | ( | UserCtx * | user, |
| Vec | Rct | ||
| ) |
Applies a momentum source term to drive flow in a periodic channel or pipe.
This function is the "engine" of the driven flow control system. It operates by:
DRIVEN_ flow handler is active on any face. This determines if a driven flow is enabled and in which direction ('X', 'Y', or 'Z').bulkVelocityCorrection value that was computed by the handler's PreStep method and stored in the SimCtx.Rct) for all fluid cells in the domain.If no driven flow handler is found, this function does nothing.
| user | The UserCtx containing the simulation state for a single block. |
| Rct | The PETSc Vec for the contravariant RHS, which will be modified in-place. |
Applies a momentum source term to drive flow in a periodic channel or pipe.
Local to this translation unit.
Definition at line 14 of file BodyForces.c.