Implements the Large Eddy Simulation (LES) subgrid-scale closure. More...
Go to the source code of this file.
Macros | |
| #define | __FUNCT__ "SymTensorSelfOuter" |
| #define | __FUNCT__ "SymTensorCombine" |
| #define | __FUNCT__ "SymTensorTrace" |
| #define | __FUNCT__ "SymTensorDeviator" |
| #define | __FUNCT__ "SymTensorContract" |
| #define | __FUNCT__ "SymTensorTimesVector" |
| #define | __FUNCT__ "SymTensorNormSq" |
| #define | __FUNCT__ "StrainRateFromGradients" |
| #define | __FUNCT__ "ComputeCellFilterWidth" |
| #define | __FUNCT__ "LeonardStress" |
| #define | __FUNCT__ "GermanoModelTensor" |
| #define | __FUNCT__ "ResolveLESAveragingDirections" |
| #define | __FUNCT__ "ClipModelCoefficient" |
| #define | __FUNCT__ "EddyViscosityFromCoefficient" |
| #define | __FUNCT__ "WALEEddyViscosity" |
| #define | __FUNCT__ "VremanEddyViscosity" |
| #define | __FUNCT__ "SubgridKineticEnergy" |
| #define | __FUNCT__ "ComputeSmagorinskyConstant" |
| #define | __FUNCT__ "ComputeEddyViscosityLES" |
| #define | __FUNCT__ "LogLESDiagnostics" |
Functions | |
| static PetscErrorCode | FinalizeSmagorinskyConstantField (UserCtx *user) |
| Synchronizes the completed Smagorinsky coefficient field. | |
| static PetscErrorCode | LESResolveDomain (UserCtx *user, SpatialTargetPlan *plan) |
| Resolves the iteration domain the closure computes over. | |
| static PetscErrorCode | BuildWallModelExclusionMask (UserCtx *user, Vec inclusion) |
| Marks the near-wall cells a wall model overwrites, so the procedure skips them. | |
| static void | LESPeriodicAxes (const SimCtx *simCtx, PetscBool periodic[3]) |
Reports the block's per-axis periodicity in (xi, eta, zeta) order. | |
| SymTensor | SymTensorSelfOuter (Cmpnts v) |
| Implementation of SymTensorSelfOuter(). | |
| SymTensor | SymTensorCombine (PetscReal a, SymTensor x, PetscReal b, SymTensor y) |
| Implementation of SymTensorCombine(). | |
| PetscReal | SymTensorTrace (SymTensor t) |
| Implementation of SymTensorTrace(). | |
| SymTensor | SymTensorDeviator (SymTensor t) |
| Implementation of SymTensorDeviator(). | |
| PetscReal | SymTensorContract (SymTensor a, SymTensor b) |
| Implementation of SymTensorContract(). | |
| Cmpnts | SymTensorTimesVector (SymTensor t, Cmpnts v) |
| Implementation of SymTensorTimesVector(). | |
| PetscReal | SymTensorNormSq (SymTensor t) |
| Implementation of SymTensorNormSq(). | |
| PetscErrorCode | StrainRateFromGradients (Cmpnts dudx, Cmpnts dvdx, Cmpnts dwdx, SymTensor *strain, PetscReal *magnitude) |
| Implementation of StrainRateFromGradients(). | |
| PetscErrorCode | ComputeCellFilterWidth (LESFilterWidthModel model, PetscReal aj, Cmpnts csi, Cmpnts eta, Cmpnts zet, PetscReal *delta) |
| Implementation of ComputeCellFilterWidth(). | |
| SymTensor | LeonardStress (Cmpnts velocity_filtered, SymTensor velocity_product_filtered) |
| Implementation of LeonardStress(). | |
| SymTensor | GermanoModelTensor (PetscReal delta, PetscReal alpha, PetscReal strain_magnitude_filtered, SymTensor strain_filtered, SymTensor strain_product_filtered) |
| Implementation of GermanoModelTensor(). | |
| PetscErrorCode | ResolveLESAveragingDirections (UserCtx *user, PetscBool direction[3]) |
| Implementation of ResolveLESAveragingDirections(). | |
| PetscReal | ClipModelCoefficient (PetscReal coefficient, const LESConfig *config, PetscBool *limited) |
| Implementation of ClipModelCoefficient(). | |
| PetscReal | EddyViscosityFromCoefficient (PetscReal coefficient, PetscReal delta, PetscReal strain_magnitude, PetscReal molecular_viscosity, PetscReal min_viscosity_ratio) |
| Implementation of EddyViscosityFromCoefficient(). | |
| PetscReal | WALEEddyViscosity (Cmpnts dudx, Cmpnts dvdx, Cmpnts dwdx, PetscReal delta, PetscReal coefficient) |
| Implementation of WALEEddyViscosity(). | |
| PetscReal | VremanEddyViscosity (Cmpnts dudx, Cmpnts dvdx, Cmpnts dwdx, const Cmpnts edges[3], PetscReal coefficient) |
| Implementation of VremanEddyViscosity(). | |
| PetscReal | SubgridKineticEnergy (PetscReal yoshizawa_ci, PetscReal delta, PetscReal strain_magnitude) |
| Implementation of SubgridKineticEnergy(). | |
| static PetscInt | LESStrainSampleIndex (PetscInt index, PetscInt extent, PetscBool periodic) |
| Maps a cell index to the index whose strain rate represents it. | |
| static PetscErrorCode | ComputeStrainRateField (UserCtx *user, Cmpnts ***ucat, Vec strain_diagonal, Vec strain_offdiagonal, Vec strain_magnitude) |
| Fills the strain-rate scratch fields across the computed range and its halo. | |
| static SymTensor | LESStrainAt (Cmpnts diagonal, Cmpnts offdiagonal) |
| Rebuilds a symmetric strain tensor from its two scratch storage vectors. | |
| PetscErrorCode | ComputeSmagorinskyConstant (UserCtx *user) |
| Implementation of ComputeSmagorinskyConstant(). | |
| PetscErrorCode | ComputeEddyViscosityLES (UserCtx *user) |
| Implementation of ComputeEddyViscosityLES(). | |
| PetscErrorCode | LogLESDiagnostics (UserCtx *user) |
| Implementation of LogLESDiagnostics(). | |
Variables | |
| static const double | LES_EPSILON = 1.0e-12 |
Implements the Large Eddy Simulation (LES) subgrid-scale closure.
The closure is built from small kernels that each do one thing, so the physics is readable at the call sites and testable without a running solve:
SymTensor*), which knows nothing about turbulence;LeonardStress() and GermanoModelTensor();PicurvSpatialRatioAverage() from the shared spatial-target module: it turns the local dynamic model into the plane- or volume-averaged one without a separate code path per mode;Two routines drive them. ComputeSmagorinskyConstant() runs the Germano-Lilly procedure for the dynamic model, and ComputeEddyViscosityLES() turns whichever coefficient is in force into the eddy viscosity the momentum equations add to the molecular one. LogLESDiagnostics() reports the coefficient's time history.
The coefficient stored in UserCtx::CS is C, the factor multiplying Delta^2 |S|, which is Cs^2 in the classical notation and is signed when backscatter is admitted. Conversion to the familiar Cs happens only where a human reads the number.
Definition in file les.c.
|
static |
Synchronizes the completed Smagorinsky coefficient field.
Definition at line 40 of file les.c.
|
static |
Resolves the iteration domain the closure computes over.
Delegates to the shared spatial target so the closure, the statistics pipeline, and anything else looping over cell-centred data agree on which indices are physical. The domain excludes PETSc halo storage and the solver's boundary, dummy, and duplicate-periodic indices; the last of those matters here, because counting a duplicate plane in a spatial average would weight a real cell twice.
The plan is resolved for CS as a representative cell-centred field. The bounds depend on the layout and the block's periodicity, not on which field is being iterated, so the scratch vectors this module allocates share them.
Definition at line 63 of file les.c.
|
static |
Marks the near-wall cells a wall model overwrites, so the procedure skips them.
A wall model replaces the first interior cell's velocity with an analytic profile. The Germano identity evaluated there measures that imposed profile rather than resolved turbulence, so the cell is excluded from both contraction sums. This is not a modelling preference: the data at those cells is not a measurement, and averaging it in biases whatever set it belongs to. Under global averaging that set is the whole domain; under homogeneous averaging retaining the wall-normal direction it is the wall plane, whose value would otherwise be entirely imposed.
A cell left with no data receives a zero coefficient, which is the right answer where a wall model is already supplying the stress.
Only meaningful while a wall model is active; with none, nothing is imposed and every cell carries a real measurement.
Definition at line 87 of file les.c.
|
static |
Reports the block's per-axis periodicity in (xi, eta, zeta) order.
Reads the resolved global flags rather than the boundary face configuration. The two cannot disagree: the flags are derived from the boundary files, and the loader rejects a case whose opposite faces or whose blocks do not agree on periodicity. The flags are also what the DMDA itself was built from, and what the shared spatial target consults, so taking them here keeps one source of truth.
Definition at line 129 of file les.c.
Implementation of SymTensorSelfOuter().
Forms a symmetric tensor from a vector's outer product with itself.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 144 of file les.c.
Implementation of SymTensorCombine().
Forms the linear combination a*x + b*y.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 165 of file les.c.
| PetscReal SymTensorTrace | ( | SymTensor | t | ) |
Implementation of SymTensorTrace().
Returns the trace t_kk.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 186 of file les.c.
Implementation of SymTensorDeviator().
Removes the isotropic part, returning t_ij - (1/3) delta_ij t_kk.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 199 of file les.c.
Implementation of SymTensorContract().
Contracts two symmetric tensors as a_ij b_ij.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 217 of file les.c.
Implementation of SymTensorTimesVector().
Applies a symmetric tensor to a vector, returning t_ij v_j.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 232 of file les.c.
| PetscReal SymTensorNormSq | ( | SymTensor | t | ) |
Implementation of SymTensorNormSq().
Returns the squared Frobenius norm t_ij t_ij.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 250 of file les.c.
| PetscErrorCode StrainRateFromGradients | ( | Cmpnts | dudx, |
| Cmpnts | dvdx, | ||
| Cmpnts | dwdx, | ||
| SymTensor * | strain, | ||
| PetscReal * | magnitude | ||
| ) |
Implementation of StrainRateFromGradients().
Builds the strain-rate tensor and its magnitude from a velocity gradient.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 267 of file les.c.
| PetscErrorCode ComputeCellFilterWidth | ( | LESFilterWidthModel | model, |
| PetscReal | aj, | ||
| Cmpnts | csi, | ||
| Cmpnts | eta, | ||
| Cmpnts | zet, | ||
| PetscReal * | delta | ||
| ) |
Implementation of ComputeCellFilterWidth().
Computes one cell's grid filter width under the selected width model.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 296 of file les.c.
Implementation of LeonardStress().
Forms the Leonard stress L_ij = (u_i u_j)^ - u^_i u^_j.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 359 of file les.c.
| SymTensor GermanoModelTensor | ( | PetscReal | delta, |
| PetscReal | alpha, | ||
| PetscReal | strain_magnitude_filtered, | ||
| SymTensor | strain_filtered, | ||
| SymTensor | strain_product_filtered | ||
| ) |
Implementation of GermanoModelTensor().
Forms the deviatoric Germano model tensor M_ij.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 374 of file les.c.
| PetscErrorCode ResolveLESAveragingDirections | ( | UserCtx * | user, |
| PetscBool | direction[3] | ||
| ) |
Implementation of ResolveLESAveragingDirections().
Resolves which logical directions the dynamic coefficient is averaged over.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 410 of file les.c.
| PetscReal ClipModelCoefficient | ( | PetscReal | coefficient, |
| const LESConfig * | config, | ||
| PetscBool * | limited | ||
| ) |
Implementation of ClipModelCoefficient().
Applies the configured admissible range to one model coefficient.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 466 of file les.c.
| PetscReal EddyViscosityFromCoefficient | ( | PetscReal | coefficient, |
| PetscReal | delta, | ||
| PetscReal | strain_magnitude, | ||
| PetscReal | molecular_viscosity, | ||
| PetscReal | min_viscosity_ratio | ||
| ) |
Implementation of EddyViscosityFromCoefficient().
Builds the eddy viscosity from a model coefficient.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 497 of file les.c.
| PetscReal WALEEddyViscosity | ( | Cmpnts | dudx, |
| Cmpnts | dvdx, | ||
| Cmpnts | dwdx, | ||
| PetscReal | delta, | ||
| PetscReal | coefficient | ||
| ) |
Implementation of WALEEddyViscosity().
WALE eddy viscosity (Nicoud & Ducros 1999) from the resolved velocity gradient.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 520 of file les.c.
| PetscReal VremanEddyViscosity | ( | Cmpnts | dudx, |
| Cmpnts | dvdx, | ||
| Cmpnts | dwdx, | ||
| const Cmpnts | edges[3], | ||
| PetscReal | coefficient | ||
| ) |
Implementation of VremanEddyViscosity().
Vreman eddy viscosity (Vreman 2004), weighting each grid direction by its own spacing.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 557 of file les.c.
| PetscReal SubgridKineticEnergy | ( | PetscReal | yoshizawa_ci, |
| PetscReal | delta, | ||
| PetscReal | strain_magnitude | ||
| ) |
Implementation of SubgridKineticEnergy().
Returns the modelled subgrid kinetic energy at a cell.
Full API contract is documented with the header declaration in include/les.h.
Definition at line 595 of file les.c.
|
static |
Maps a cell index to the index whose strain rate represents it.
The strain rate must be known one cell beyond the computed range, because the test-filter stencil reaches there. At an interior index the answer is the index itself. At the two layout-boundary planes it is not, and for opposite reasons.
On a periodic axis, index 0 and index m-1 are duplicates of the last and first interior cells. A central difference evaluated at index 0 straddles the wrap and returns nonsense, so the strain is evaluated instead at ghost index -2, which addresses the same physical cell from the interior side. Index m+1 plays the same role at the other end. These are the ghost indices the periodic cell synchronization itself copies from, and the DMDA carries the three ghost layers they need whenever any axis is periodic.
On a non-periodic axis the two planes are the solver's boundary layer, where a central difference would reach outside the domain. The nearest interior cell's strain is used instead, which is a zeroth-order extrapolation into a layer that only ever contributes to a filter average.
Definition at line 624 of file les.c.
|
static |
Fills the strain-rate scratch fields across the computed range and its halo.
Definition at line 634 of file les.c.
| PetscErrorCode ComputeSmagorinskyConstant | ( | UserCtx * | user | ) |
Implementation of ComputeSmagorinskyConstant().
Computes the dynamic Smagorinsky coefficient field for one block.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/les.h.
Definition at line 715 of file les.c.
| PetscErrorCode ComputeEddyViscosityLES | ( | UserCtx * | user | ) |
Implementation of ComputeEddyViscosityLES().
Computes the turbulent eddy viscosity for one block.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/les.h.
Definition at line 952 of file les.c.
| PetscErrorCode LogLESDiagnostics | ( | UserCtx * | user | ) |
Implementation of LogLESDiagnostics().
Appends one row of LES coefficient statistics to the run's log directory.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/les.h.
Definition at line 1045 of file les.c.