29.6 Filters

The solver runs the SolverCore filters (Chapter 13) and three filters of its own: Energy, AeroForces and ReynoldsStresses, in Filters, with their operators EnergyOp, AeroForcesOp and ReynoldsStressOp in Utilities. They implement diagnostics of constant-density flow and read the velocity and pressure roles that this solver publishes. They use the SolverCore filter interface and register with its filter factory, so a session selects them as it does any other filter. Energy and AeroForces include step zero in their schedules; ReynoldsStresses begins sampling after the first completed step.

29.6.1 Published fields

VelocityCorrectionScheme overrides the registry because pressure is a separate variable group, with its own field and expansion list, and may have a different expansion. It publishes velocity as the first spaceDimension components of the solution field, publishes pressure as a separate role, and retains passive scalars only in the canonical solution group. The physical groups are therefore the complete solution field, including passive scalars, and the separate pressure field:

1PhysicalFieldView solution{ 
2    m_phys[m_velocityIndex], m_expansionLists[m_velocityIndex], m_coordim, 
3    MakeFieldComponents(m_variables[m_velocityIndex])}; 
4 
5PhysicalFieldView velocity{ 
6    m_phys[m_velocityIndex], m_expansionLists[m_velocityIndex], m_coordim, 
7    MakeFieldComponents(m_variables[m_velocityIndex], 0, m_coordim)}; 
8 
9PhysicalFieldView pressure{ 
10    m_phys[m_pressureIndex], m_expansionLists[m_pressureIndex], m_coordim, 
11    MakeFieldComponents(m_variables[m_pressureIndex])}; 
12 
13registry.SetRole(std::string(FieldRoles::Solution), solution); 
14registry.SetRole(std::string(FieldRoles::Velocity), velocity); 
15registry.SetRole(std::string(FieldRoles::Pressure), pressure); 
16registry.SetPhysicalGroups({solution, pressure});

This arrangement lets semantic consumers request velocity or pressure while generic output consumers operate on complete, non-overlapping groups. Energy and AeroForces use the component indices of the velocity view and therefore exclude the passive scalars. Both request the velocity gradient from the derived-data cache, so when both are due on the same step they share one gradient calculation.

29.6.2 Energy

Energy obtains the velocity role and constructs EnergyOp with its component indices. On a due step it requests the velocity gradient from the shared derived-data cache and passes the underlying velocity field and the cached gradient to the operator.

The operator supports two- and three-dimensional velocity fields, and 3DH1 fields, whose local planes it weights with their z quadrature weights in the same sums, every entry of every plane one term; the z derivatives the curl needs require more than one plane on each rank. The quadrature metric of each block, the quadrature weight times the Jacobian of every point, is fetched from the data warehouse through LocalRegions::QuadratureMetricKey the first time a velocity is read at a given interleave width, laid out as the velocity, so that one storage index addresses the same point of the velocity, its gradient and the metric at either width, with no reshape. Each block is integrated by one parallel_reduce_sum over its storage, on the block’s stream, neighbouring threads reading neighbouring entries. It packs ∫ Ω|u|2 dΩ, ∫ Ω|ω|2 dΩ and the volume into one MemoryRegion and performs a single reduction over the spatial ranks, to the writer rank alone, which the filter requests through SetRootOnly(true). On the writer rank the filter reads the three values through EnergyOp::GetKineticEnergy(), GetEnstrophy() and GetVolume(), and writes half of each integral divided by the volume. Passive scalars are not included.

29.6.3 AeroForces

AeroForces obtains both velocity and pressure role views and uses the same cached velocity gradient as Energy. Its operator retains the velocity and pressure expansions separately, with the component indices of velocity and pressure in their fields.

During configuration, the operator constructs independent oriented volume-to-boundary restrictions for pressure and velocity gradient data, so pressure and velocity expansions do not need identical quadrature. Each boundary quadrature point has one sparse row per restriction, with a single entry of weight one where the restriction is a gather. The pressure shares the blocks of the velocity, as the incompressible solver requires, and the points on the elements of one block are integrated by one parallel_reduce_sum of the twelve sums on the block’s stream, whatever the shapes of its faces. The rows are gathered on the host at configuration. The first time the gradient is read at an interleave width, one or the width of the execution space, the rows of each block are copied to the operator’s memory space for that width: the restriction sources are converted to storage offsets, those of the pressure at both widths, and the points are ordered by the offset of their first gradient source, so that neighbouring threads read neighbouring entries where the boundary allows; the normals and moment arms are stored point-minor for the same reason. Apply() then reads the pressure and the gradient where they are stored, at either width. The operator integrates pressure and viscous forces and moments into twelve packed values and reduces them to the writer rank, the filter requesting a root-only reduction. There the filter reads the four Cartesian 3-vectors through AeroForcesOp::GetPressureForce(), GetViscousForce(), GetPressureMoment() and GetViscousMoment(); in two dimensions the z force components and the x and y moment components are zero.

A 3DH1 expansion is integrated as its two-dimensional planes are: the boundary restrictions, normals and moment arms are built once from its first plane, each local plane gives the forces and moments per unit span from the in-plane velocity gradient, and the result is their average over all the planes, one boundary point of one plane per thread. The table therefore keeps the two-dimensional columns.

The filter validates that the boundary selection is non-empty and contains no duplicates, and that every selected boundary identifier exists on some rank. Directions and pivot points require exactly three finite values; directions are normalised but are not required to be mutually orthogonal. Output retains separate pressure, viscous and total columns. Unlike the SolverUtils filter, AeroForces supports pressure and velocity expansions with different volume quadrature, through independent restriction maps, and validates its boundary identifiers rather than silently ignoring unknown ones.

29.6.4 ReynoldsStresses

ReynoldsStresses obtains the coefficient groups and the velocity role. Like AverageFields, it keeps an unscaled coefficient accumulator for every group, so the averages of all solver variables, pressure included, are written. The velocity is the leading components of the first coefficient group, on the velocity expansion, as VelocityCorrectionScheme publishes it. In addition the filter keeps one physical-space field Sab with a component for every pair a ≤b of velocity components, d(d + 1)∕2 in d dimensions, to which each sample adds the pointwise products uaub at the quadrature points. The products are formed by ReynoldsStressOp, which is created on the velocity expansion and configured with the velocity component indices. It adds suaub for a scale s set with SetScale immediately before each application, reads only the selected velocity components of a field that may also hold passive scalars, and runs block b on stream b + 1. The product field has the block attributes of the velocity, and a product block at another interleave width than the velocity’s is first reshaped to it on the block’s stream, keeping its content, so one storage index addresses the same point in both. Each block is one parallel_for over its storage, neighbouring threads reading and writing neighbouring entries with no index arithmetic, and the same kernel serves the Serial, AVX and device execution spaces at any interleave width. The padding of the velocity is zero, so that of the products stays zero.

When a file is written, the summed velocity coefficients are transformed back to Ua = ∑ nua at the quadrature points, and the operator is applied to them with s = -1∕N on a copy of S, giving Sab -UaUb∕N. This is projected element by element onto the velocity expansion with IProductWRTBaseOp followed by MultiplyByElmtInvMassOp. FwdTransOp is not used: its continuous path imposes the Dirichlet and Robin conditions of the solver variables, which do not exist for the product variables, and it would perform a global rather than an elementwise projection. All written fields share the scale 1∕N, so the file holds the averages followed by the covariances

-----    (           )
u′au′=  1-  Sab - UaUb  ,
   b   N          N

named uu, uv, uw, vv, vw, ww (uu, uv, vv in two dimensions). The two-moment form needs no mean in physical space during sampling. Its rounding error is of order ϵuaub in absolute terms, which for wall-bounded turbulence, where u2 exceeds u′2 by at most a few hundred, is far below the sampling error.

Sampling excludes the initial phase and follows SampleFrequency. A numbered file <OutputFile>_<k>_stress.fld, from the shared zero-based series k = 0,1,…, is written on sampled steps that are also multiples of OutputFrequency, and finalisation always writes <OutputFile>_stress.fld. The metadata records InitialTime, FinalTime, Time, NumberOfFieldDumps and, once a numbered file has been written, FilterFileNum. Moving averages, phase averaging, scaled expansions, FieldConvert modules and restarting from an earlier file are rejected with an explicit error, as are homogeneous and embedded-manifold expansions. Besides the coefficient accumulators and the d(d + 1)∕2 physical-space products, the filter holds an output workspace: the summed velocity at the quadrature points, a copy of the products and two coefficient fields of d(d + 1)∕2 components. It is allocated at initialisation and refilled at each output, so that writing a file neither allocates nor frees memory.