xref: /honee/include/spanstats.h (revision c0d10d1ddfa51fc3c0a8079706784eb95f3ed88f)
1 // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors.
2 // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
3 #include <ceed.h>
4 #include <honee.h>
5 #include <petsc_ops.h>
6 #include <petscsys.h>
7 
8 typedef struct {
9   DM                    dm;
10   PetscSF               sf;  // For communicating child data to parents
11   OperatorApplyContext  op_stats_collect_ctx, op_proj_rhs_ctx;
12   PetscInt              num_comp_stats;
13   Vec                   Child_Stats_loc, Parent_Stats_loc;
14   KSP                   ksp;         // For the L^2 projection solve
15   CeedScalar            span_width;  // spanwise width of the child domain
16   PetscBool             do_mms_test;
17   OperatorApplyContext  mms_error_ctx;
18   CeedContextFieldLabel solution_time_label, previous_time_label, timestep_label;
19   PetscReal             initial_solution_time;
20   PetscInt              initial_solution_step;
21   PetscInt              collect_interval;
22   char                 *prefix;
23 } *SpanStatsCtx;
24 
25 PetscErrorCode SpanStatsCtxDestroy(SpanStatsCtx *spanstats);
26 
27 typedef struct {
28   CeedElemRestriction elem_restr_parent_x, elem_restr_parent_stats, elem_restr_parent_colloc, elem_restr_child_colloc;
29   CeedBasis           basis_x, basis_stats;
30   CeedVector          x_coord;
31 } *SpanStatsSetupData;
32 
33 PetscErrorCode SpanwiseStatisticsSetupInitialize(Honee honee, PetscInt degree, PetscInt num_comps, const char *prefix,
34                                                  SpanStatsSetupData *stats_setup_data, SpanStatsCtx *spanstats_new);
35 PetscErrorCode SpanwiseStatisticsSetupFinalize(TS ts, Honee honee, SpanStatsCtx spanstats, PetscViewerAndFormat *ctx,
36                                                SpanStatsSetupData *stats_setup_data);
37 
38 PetscErrorCode SpanwiseStatisticsCollect(Honee honee, SpanStatsCtx spanstats, PetscScalar solution_time, Vec Q);
39 PetscErrorCode SpanwiseStatisticsProcess(Honee honee, SpanStatsCtx spanstats, Vec stats);
40 
41 PetscErrorCode SpanwiseStatisticsSetup_Turbulence(TS ts, PetscViewerAndFormat *ctx);
42 PetscErrorCode TSMonitor_SpanwiseStatisticsTurbulence(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, PetscViewerAndFormat *ctx);
43 
44 PetscErrorCode SpanwiseStatisticsSetup_CflPe(TS ts, PetscViewerAndFormat *ctx);
45 PetscErrorCode TSMonitor_SpanwiseStatisticsCflPe(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, PetscViewerAndFormat *ctx);
46