13.1 SolverCore Filters

SolverCore filters observe a running equation system and produce diagnostics or field output without participating in the time integration itself. Examples include point histories, domain averages, time-averaged fields and checkpoints. The redesigned interface makes the data available to a filter explicit: filters no longer retain a pointer to the whole equation system, but instead receive a short-lived context for each phase of the solve.

Figure 13.1 shows the main data flow: equation-system fields and expansions are published through a FieldRegistry, which a FilterContext carries with the time, the step, the phase, the output services and the derived data to the filters. HistoryPoints and Mean evaluate the fields at one instant in an operator and write one table row per due step on rank zero; Checkpoint and AverageFields write field files. A solver may add filters of its own on the same interface; they are described in the solver’s chapter.


oInniopetie paralisacetkeords:C Soemmr:ia:l,R AeVdXu,ceD teov riacnek 0
mfumvEFDFtFHMDCAFvF_r__qieiiiieihviieAifitfiGeuelrltmeltsaaeeelwpnaehetadie,etongRcrdspllerlFtRvr srrnokalyisddiieeOtCyootpgoesfiseogdueoPsToeuel_lniDtpnotaiFtdcdSsap,tiicbnipsoRyttu ienlteueesratnxtteldtffgityCSitsabWssemaet,lr(.tcri peifrhvalestelyei,rrd(c f(r))eipaosnhnnaak rlsae0n)k 0
uofuvrovwHMww,nr_lelrierrv, ttGeeoitstanititwhhts,ceoOee,eerO eitFrpFOiru.yiyiusc ocotg. geP→etaweprlolplanffiusoadi.durctldsnastseiFuie,tv →Fxeietn wsOgiepnlitrplatsdo ∇it.cdnVnue→hssii,,Okoe vu.→nweothsslnpi(occeus)ittpFyeierlds
Wppg_rhheaityatMvgesisee.Oc;tfualalt gddprauottuaFp,ies sl,ed ntMsoe(nt)- oavdearltaapping
cooepffiercaiteonrt a gnrdou sptso,ra ogne kreeqpute fstor the
run

Figure 13.1 Data flow of the SolverCore filters. The equation system publishes views of its fields; UnsteadySystem::RunFilters gathers them with the shared derived data and output services into a FilterContext, which every configured filter receives in each phase.


The unsteady system creates a new registry, and marks the data in its derived-data cache out of date, during initialisation, after each completed time-integration step, and during finalisation. All filters invoked in one of these phases see the same registry and cache. Derived data can therefore be shared between filters on the same step, but is never reused after the solution changes.

13.1.1 State-specific field views

Physical and coefficient fields use the same view representation, specialised by the state of the field:

1struct FieldComponent 
2{ 
3    std::string name; 
4    unsigned int index; 
5}; 
6 
7template <FieldState State> 
8struct StateFieldView 
9{ 
10    std::reference_wrapper<LibUtilities::Field<double, State>> field; 
11    MultiRegions::ExpListSharedPtr expansion; 
12    unsigned int spaceDimension; 
13    std::vector<FieldComponent> components; 
14}; 
15 
16using PhysicalFieldView = StateFieldView<FieldState::Phys>; 
17using CoefficientFieldView = StateFieldView<FieldState::Coeff>;

The members have the following ownership and interpretation.

The component indices are particularly important when passive scalars share a field with velocity. If the stored components are

u, v, w, temperature, concentration,

then a three-dimensional velocity view contains only (u,0), (v,1) and (w,2). A solution view can still contain all five components. A consumer of the velocity role uses the indices in the velocity view and therefore excludes the passive scalars.

The view does not own the referenced field. It is valid while the publishing equation system and its field storage remain alive. Filters should not retain a reference to a per-phase registry or context beyond the corresponding filter call.

13.1.2 The field registry

FieldRegistry is the catalogue through which an equation system publishes fields to filters. It supports three access patterns.

Semantic roles. Role lookup is used when a filter requires a field with a particular meaning:

1auto velocity = context.fields.GetRole(FieldRoles::Velocity); 
2auto pressure = context.fields.GetRole(FieldRoles::Pressure);

The standard roles are solution, velocity and pressure. Role views may overlap: velocity is normally a subset of the solution storage.

Physical groups.

GetPhysicalGroups() returns canonical, non-overlapping groups for operations that must visit every physical variable exactly once. HistoryPoints and Mean use these groups.

Coefficient groups.

GetCoefficientGroups() returns canonical, non-overlapping coefficient views for field output. These views are supplied by a callback and are obtained lazily, since a continuous Galerkin equation system may need to perform a forward transform before coefficients are current. AverageFields consumes these groups.

13.1.3 The filter context

Each filter lifecycle method receives a FilterContext:

1struct FilterContext 
2{ 
3    double time; 
4    unsigned int step; 
5    bool initial; 
6    bool final; 
7    FilterOutputServices &output; 
8    const FieldRegistry &fields; 
9    DerivedDataCache &derived; 
10};

Here, step is the actual global step reported by the time-integration operator, not a filter-local invocation count. The initial and final flags distinguish explicit initialisation and finalisation phases. The remaining members provide controlled access to field state, derived data and output services.

The context is assembled on the stack by UnsteadySystem. Its registry, output services and cache are valid only for the current phase. A filter may retain its own configuration and persistent accumulators, but must not store a pointer or reference to the context itself.

The base interface is consequently

1void Initialise(FilterContext &context); 
2void Apply(FilterContext &context); 
3void Finalise(FilterContext &context);

The factory constructs filters using the session and parameter map only. The filter base class retains the session for static configuration and communicator access, but it does not retain an equation-system pointer.

13.1.4 Output services

FilterOutputServices contains callbacks supplied by the equation system:

Checkpoint uses writeFields, while AverageFields uses writeOutputFields for its own accumulator fields. The equation system remains responsible for converting views into field definitions. In particular, each coefficient view uses its own expansion when field definitions are produced, so fields on different expansions may have different layouts. A view whose field definitions match those of the preceding view in shape, elements, basis and modes adds its variables to the preceding definitions, so that, as in files written by FieldConvert, each block of the file holds every such variable. FieldConvert modules that take the variable list from the first block, such as interppoints, rely on this.

This interface gives filters the output capabilities they require without exposing the entire equation system.

13.1.5 Derived data

DerivedDataCache stores expensive data derived from the current physical fields. Its first service is

1LibUtilities::Field<double, FieldState::Phys> &GetGradient( 
2    const PhysicalFieldView &view, 
3    const std::string &executionSpace);

A gradient is keyed by the underlying field, expansion, component selection and execution space. The first request constructs a physical derivative operator and the gradient field, which the cache keeps for the rest of the solve. The first request in each phase applies the operator; later requests in the same phase receive the cached field. Filters requesting the same gradient on the same step therefore share one calculation, and none constructs an operator or allocates a field per step.

The cached gradient currently has storage for the full component count of the underlying field, each with one derivative per coordinate direction, or three for a 3DH1 field with more than one local plane, whose z derivative the physical derivative operator adds. Downstream operators consume only the component indices in the view, so passive scalars outside it do not enter their calculations, although their derivatives may be present in the cached field.

The cache uses an implementation object so that the public filter interface does not expose physical-derivative operator implementation details.

13.1.6 Shared filter utilities

Several small types provide consistent policy across filters.

Filter parameters.

FilterParameters evaluates expression-valued parameters and tracks which entries have been consumed. It provides finite floating-point values, strict true/false booleans, required strings and strictly positive integral frequencies. Unknown parameters are rejected. The standard start-time parameter is StartTime; OutputStartTime remains a deprecated alias and produces a warning.

Strict frequency parsing is important because converting a negative evaluated value directly to an unsigned integer can otherwise create a very large output interval.

Step schedules.

StepSchedule is stateless. An event is due when its start-time rule is satisfied and the actual integration step is divisible by its frequency. A schedule also states whether the initial phase is included. Mean, HistoryPoints and Checkpoint include step zero; AverageFields begins sampling after the first completed step. Figure 13.2 shows the phases and three schedules.


HistoryCPhoeinctks,MpeoOuaintntputFrequency 5
s01234567891pInSSSSSSSSSSFOOSte0hiteteteteteteteteteteinuuStdpatippppppppppatttarusealppartelututtTFFTirrimeeemqqeuu beeemnntuccwlyyeti 5 2epnle stoepfs the3 afrnedqu4ency before StartTime, not due

Figure 13.2 Filter phases and step schedules. RunFilters runs every filter at initialisation, after each completed step and at finalisation. A StepSchedule is due when the global step is a multiple of the frequency and the time has reached StartTime; the schedules shown include the initial phase.


Output series and tables.

OutputSeries creates zero-based numbered paths. Both numbered paths and backup paths preserve their parent directory; for example, results/run.avg is backed up as results/run.bak0.avg. RootTableWriter provides root-only, RAII-managed whitespace tables with comment metadata, an uncommented column row, scientific formatting and 16-digit precision. A line is ended with EndRow(), which flushes it, so each row reaches the file as soon as it is complete and a run that terminates abnormally keeps every completed row. HistoryPoints, which writes a row per point at each output step, ends those rows with a newline and calls Flush() once after the last.

Point sets.

PointSet parses explicit points, lines, planes and boxes for point filters. It validates exact arity, finite coordinates, integral point counts and multiplication overflow before allocating a generated point set.

13.1.7 Filter interactions

Mean

Mean obtains the registry’s physical groups, so that every canonical variable, including one held in a separate field, is averaged exactly once. For each group it constructs a MeanOp on the group’s own expansion. The operator reuses the MeanRemoval block operators to accumulate, in the selected execution space, the integral of every component together with the domain volume, packs them into one MemoryRegion and reduces them once over the spatial ranks to the writer rank, the filter requesting a root-only reduction. There MeanOp::GetMeans() returns the instantaneous averages ∫ Ωf dΩ∕∫ ΩdΩ in component order, and GetVolume() the volume. The volume is recorded at initialisation and written to the header. The .avg table keeps the legacy layout,

# Time <variables...> volume <V>,

with area in place of volume in two dimensions and one row per due step, including step zero. A 3DH1 expansion is averaged over its planes with their z quadrature weights, its volume being the plane area times the homogeneous length. One-dimensional, embedded-manifold and other homogeneous expansions are rejected.

HistoryPoints

HistoryPoints obtains the registry’s physical groups so every canonical variable is sampled once. At initialisation, an interpolation operator for each registered layout determines containing elements and interpolation weights. Point ownership is resolved with a maximum-rank reduction over the ranks sharing the planes, which hold one copy of the mesh, giving deterministic highest-rank ownership when a point lies on a partition boundary. For a 3DH1 expansion a point is located in the two-dimensional mesh by its x and y, and its value is the trigonometric interpolation at its z of its values on the planes, through one weight per local plane computed at initialisation. A point that cannot be found on any rank produces an explicit diagnostic.

At each output step each group is evaluated locally, block by block on the blocks’ streams, one point per thread. The storage offset of the element holding each point is built the first time a field is read at an interleave width, one or the width of the execution space, which is a template parameter of the kernel, and the points of a block are sorted by element, so that at the execution space’s width neighbouring threads read neighbouring lanes. The values are then collected on the writer rank by one sum over the spatial ranks: each point is owned by one rank, or for a 3DH1 expansion by the ranks holding its element, each adding the share of its own planes, and every other rank contributes zero. On the writer rank HistoryPointsOp::GetValues() returns each group’s values point-major, with component comp of point point at point * nComp + comp, and the groups are interleaved into one point-major table, whose schema is

Time Point <variables...>.

Single-file histories and zero-based numbered snapshots use the same scheduling and output-series utilities.

AverageFields

AverageFields obtains coefficient groups and allocates a matching accumulator for each group, with the source block attributes and interleave width. Accumulation is performed by the backend-selected mathematical operator, which adds the two fields entry by entry, so an accumulator block at another interleave width than its source is first reshaped to the source’s. Coefficients remain unscaled while samples are collected; scaling is applied only when a file is written.

The filter takes the parameters OutputFile (default: the session name), OutputFrequency (default: NumSteps), SampleFrequency (default: one), StartTime, RestartFile, and PhaseAverage with PhaseAveragePeriod and PhaseAveragePhase; the command-line argument –set-filter-averagefield-start-number sets the first file number. Sampling and periodic output use separate schedules, both based on the actual global step, both excluding the initial phase and both starting at StartTime. This means a sample frequency of two selects steps 2, 4, 6 and so on. Phase averaging adds a time-phase condition to the sampling schedule: a step due for sampling adds a sample only when its time lies within half a sampling interval of the requested phase.

A numbered file <OutputFile>_<k>_avg.fld, from a zero-based series k = 0,1,…, is written on a step that is due for both sampling and output, once at least one sample has been taken; with phase averaging such a step need not itself add a sample. Finalisation always writes the unnumbered _avg.fld file. If no samples were collected, a zero-valued final field is written with a warning.

When an earlier average is loaded, AverageFields validates sample and file number metadata, finite time metadata, required variables, element identifiers, bases, modes and expansion layouts. The stored average is multiplied by its previous sample count to reconstruct the unscaled accumulated sum before new samples are added.

Checkpoint

Checkpoint does not need to inspect a field view. When its schedule is due, it updates FilterFileNum through the metadata service, obtains the next zero-based filename from OutputSeries, and calls writeFields. This establishes the same step and numbering semantics as the other output filters.

13.1.8 Integration with redesigned equation systems

The registry is the compatibility boundary between the filters and the equation systems. An equation system should publish mathematical meaning, rather than relying on a filter to interpret the ordering of its stored variables. The chapter of each solver in Part V describes what its equation systems publish and which filters of its own it adds.

Generic output filters. The default EquationSystem::v_GetFieldRegistry() publishes m_fields as the solution role and as one non-overlapping physical group, and installs v_GetOutputFieldViews() as the lazy coefficient provider. An equation system that keeps this default therefore provides the data contract required by Checkpoint, AverageFields, HistoryPoints and Mean, and their files contain its canonical variables.

The equation system’s output path must be retained when overriding this provider. Continuous fields use the global forward transform, whereas discontinuous fields use the element-local L2 projection, IProductWRTBaseOp followed by MultiplyByElmtInvMassOp, that makes DG restarts exact. Returning stale m_fields_coeff storage would make both checkpoints and averages incorrect even though the files themselves are structurally valid.

Capability validation and tests. Filters validate their required roles during initialisation: the generic filters require solution, physical or coefficient groups, and a filter that needs a semantic role such as velocity or pressure requires that role. Missing capabilities are configuration errors with the equation-system and filter names in the diagnostic.

The regression tests of every solver should exercise Checkpoint, AverageFields, HistoryPoints and Mean, including numerical restart and average contents for both CG and DG layouts.

13.1.9 Differences from the legacy filter interface

The principal changes relative to the SolverUtils filters, and to the Checkpoint filter SolverCore had before this interface, are as follows.

The resulting boundary is intentionally narrow: equation systems publish meaningful state and controlled services, while filters own only their static configuration and persistent diagnostic state. High-level filter logic remains independent of Serial, SIMD, CUDA and HIP backends; backend-specific evaluation continues to live in the operator layer.