Implements the Large Eddy Simulation (LES) subgrid-scale closure. More...
Go to the source code of this file.
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 first cells beside a modelled wall, so the procedure skips them. | |
| 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(). | |
| 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 65 of file les.c.
|
static |
Marks the first cells beside a modelled wall, so the procedure skips them.
A wall model exists because the grid does not resolve the wall layer, and the first cell sits inside it, with its wall flux supplied by the model's stress rather than by a resolved gradient. The Germano identity evaluated there measures an under-resolved wall layer, not the inertial-range motions the procedure assumes, so the cell is excluded from both contraction sums; 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; a wall-resolved run resolves that layer and every cell takes part.
Definition at line 91 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 132 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 151 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 170 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 181 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 197 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 210 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 225 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 252 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 313 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 326 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 360 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 419 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 448 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 469 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 506 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 544 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 573 of file les.c.
|
static |
Fills the strain-rate scratch fields across the computed range and its halo.
Definition at line 583 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 664 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 899 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 991 of file les.c.