PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Functions
Filter.h File Reference
#include "variables.h"
#include "logging.h"
Include dependency graph for Filter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

double ApplyLESTestFilter (LESTestFilterKernel kernel, double values[3][3][3], double weights[3][3][3])
 Applies a numerical "test filter" to a 3x3x3 stencil of data points.
 
PetscErrorCode ApplyLESTestFilterSymTensor (LESTestFilterKernel kernel, SymTensor values[3][3][3], double weights[3][3][3], SymTensor *filtered)
 Applies the test filter to all six components of a symmetric tensor.
 

Function Documentation

◆ ApplyLESTestFilter()

double ApplyLESTestFilter ( LESTestFilterKernel  kernel,
double  values[3][3][3],
double  weights[3][3][3] 
)

Applies a numerical "test filter" to a 3x3x3 stencil of data points.

EXPLANATION of "Test Filter": In the dynamic Smagorinsky LES model the model coefficient is not prescribed. It is calculated dynamically by sampling the turbulent energy cascade at two different scales. The first scale is the grid filter itself, implicit in the discretization. The second, larger scale is this explicit "test filter". By comparing how the resolved flow behaves at the two scales, the model determines how much dissipation the unresolved motions require.

The kernel is selected by the caller rather than read from the simulation context, so a filter can be exercised on 27 numbers without a live run.

Parameters
[in]kernelDiscrete stencil to apply.
[in]valuesThe 3x3x3 array of scalar values at the stencil points, indexed [k][j][i] in the DMDA convention.
[in]weightsThe 3x3x3 array of cell volume weights. Ignored by LES_TEST_FILTER_SIMPSON_IK, which assumes uniform spacing in its homogeneous plane.
Returns
The filtered value, or zero when every weight vanishes because the stencil lies entirely inside a solid body.

Applies a numerical "test filter" to a 3x3x3 stencil of data points.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Filter.h.

See also
ApplyLESTestFilter()

Definition at line 123 of file Filter.c.

124{
125 // This function acts as a dispatcher over the configured stencil.
126 switch (kernel) {
128 // The caller has declared the i and k directions homogeneous, so the more
129 // accurate Simpson stencil applies. Volume weights are irrelevant there.
132 default:
133 // Default for general, non-uniform, curvilinear grids. The volume-weighted
134 // box filter keeps the average correct when neighbouring cells differ in size.
135 return ApplyVolumeWeightedBoxFilter(values, weights);
136 }
137}
static double ApplyVolumeWeightedBoxFilter(double values[3][3][3], double weights[3][3][3])
Average a 3x3x3 stencil with cell-volume weights while excluding solid cells.
Definition Filter.c:37
static double ApplySimpsonRuleHomogeneousFilter(double values[3][3][3])
Apply the two-dimensional Simpson stencil on the central homogeneous-plane samples.
Definition Filter.c:21
@ LES_TEST_FILTER_SIMPSON_IK
Definition variables.h:593
@ LES_TEST_FILTER_VOLUME_WEIGHTED_BOX
Definition variables.h:592
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ApplyLESTestFilterSymTensor()

PetscErrorCode ApplyLESTestFilterSymTensor ( LESTestFilterKernel  kernel,
SymTensor  values[3][3][3],
double  weights[3][3][3],
SymTensor *  filtered 
)

Applies the test filter to all six components of a symmetric tensor.

Filtering is linear, so applying it componentwise is exact; this wrapper exists so callers state the intent once instead of repeating six near-identical calls whose only difference is easy to mistype.

Parameters
[in]kernelDiscrete stencil to apply.
[in]valuesPer-stencil-point tensors, indexed [k][j][i].
[in]weightsCell volume weights over the same stencil.
[out]filteredComponentwise filtered tensor.
Returns
PetscErrorCode 0 on success.

Applies the test filter to all six components of a symmetric tensor.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/Filter.h.

See also
ApplyLESTestFilterSymTensor()

Definition at line 147 of file Filter.c.

149{
150 // One scratch plane per component keeps the scalar filter unaware of tensors.
151 double component[6][3][3][3];
152
153 PetscFunctionBeginUser;
154 PetscCheck(filtered != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
155 "Filtered tensor destination cannot be NULL.");
156
157 for (PetscInt r = 0; r < 3; r++)
158 for (PetscInt q = 0; q < 3; q++)
159 for (PetscInt p = 0; p < 3; p++) {
160 component[0][r][q][p] = values[r][q][p].xx;
161 component[1][r][q][p] = values[r][q][p].xy;
162 component[2][r][q][p] = values[r][q][p].xz;
163 component[3][r][q][p] = values[r][q][p].yy;
164 component[4][r][q][p] = values[r][q][p].yz;
165 component[5][r][q][p] = values[r][q][p].zz;
166 }
167
168 filtered->xx = ApplyLESTestFilter(kernel, component[0], weights);
169 filtered->xy = ApplyLESTestFilter(kernel, component[1], weights);
170 filtered->xz = ApplyLESTestFilter(kernel, component[2], weights);
171 filtered->yy = ApplyLESTestFilter(kernel, component[3], weights);
172 filtered->yz = ApplyLESTestFilter(kernel, component[4], weights);
173 filtered->zz = ApplyLESTestFilter(kernel, component[5], weights);
174
175 PetscFunctionReturn(0);
176}
double ApplyLESTestFilter(LESTestFilterKernel kernel, double values[3][3][3], double weights[3][3][3])
Implementation of ApplyLESTestFilter().
Definition Filter.c:123
PetscReal yy
Definition variables.h:139
PetscReal xx
Definition variables.h:139
PetscReal yz
Definition variables.h:139
PetscReal zz
Definition variables.h:139
PetscReal xz
Definition variables.h:139
PetscReal xy
Definition variables.h:139
Here is the call graph for this function:
Here is the caller graph for this function: