xref: /honee/include/spanstats.h (revision c0d10d1ddfa51fc3c0a8079706784eb95f3ed88f)
100e32f70SJames Wright // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors.
200e32f70SJames Wright // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
300e32f70SJames Wright #include <ceed.h>
478c5b8e5SJames Wright #include <honee.h>
500e32f70SJames Wright #include <petsc_ops.h>
6*1c58d510SJames Wright #include <petscsys.h>
700e32f70SJames Wright 
800e32f70SJames Wright typedef struct {
978c5b8e5SJames Wright   DM                    dm;
1078c5b8e5SJames Wright   PetscSF               sf;  // For communicating child data to parents
1178c5b8e5SJames Wright   OperatorApplyContext  op_stats_collect_ctx, op_proj_rhs_ctx;
1278c5b8e5SJames Wright   PetscInt              num_comp_stats;
1378c5b8e5SJames Wright   Vec                   Child_Stats_loc, Parent_Stats_loc;
1478c5b8e5SJames Wright   KSP                   ksp;         // For the L^2 projection solve
1578c5b8e5SJames Wright   CeedScalar            span_width;  // spanwise width of the child domain
1678c5b8e5SJames Wright   PetscBool             do_mms_test;
1778c5b8e5SJames Wright   OperatorApplyContext  mms_error_ctx;
18b30619f6SJames Wright   CeedContextFieldLabel solution_time_label, previous_time_label, timestep_label;
1978c5b8e5SJames Wright   PetscReal             initial_solution_time;
2078c5b8e5SJames Wright   PetscInt              initial_solution_step;
2178c5b8e5SJames Wright   PetscInt              collect_interval;
2278c5b8e5SJames Wright   char                 *prefix;
2378c5b8e5SJames Wright } *SpanStatsCtx;
2478c5b8e5SJames Wright 
255206a5a0SJames Wright PetscErrorCode SpanStatsCtxDestroy(SpanStatsCtx *spanstats);
265206a5a0SJames Wright 
2778c5b8e5SJames Wright typedef struct {
2800e32f70SJames Wright   CeedElemRestriction elem_restr_parent_x, elem_restr_parent_stats, elem_restr_parent_colloc, elem_restr_child_colloc;
2900e32f70SJames Wright   CeedBasis           basis_x, basis_stats;
3000e32f70SJames Wright   CeedVector          x_coord;
3100e32f70SJames Wright } *SpanStatsSetupData;
3200e32f70SJames Wright 
3378c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsSetupInitialize(Honee honee, PetscInt degree, PetscInt num_comps, const char *prefix,
3478c5b8e5SJames Wright                                                  SpanStatsSetupData *stats_setup_data, SpanStatsCtx *spanstats_new);
3578c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsSetupFinalize(TS ts, Honee honee, SpanStatsCtx spanstats, PetscViewerAndFormat *ctx,
3678c5b8e5SJames Wright                                                SpanStatsSetupData *stats_setup_data);
3700e32f70SJames Wright 
3878c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsCollect(Honee honee, SpanStatsCtx spanstats, PetscScalar solution_time, Vec Q);
3978c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsProcess(Honee honee, SpanStatsCtx spanstats, Vec stats);
4078c5b8e5SJames Wright 
41f0d618eaSJames Wright PetscErrorCode SpanwiseStatisticsSetup_Turbulence(TS ts, PetscViewerAndFormat *ctx);
42f0d618eaSJames Wright PetscErrorCode TSMonitor_SpanwiseStatisticsTurbulence(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, PetscViewerAndFormat *ctx);
43f0d618eaSJames Wright 
44f0d618eaSJames Wright PetscErrorCode SpanwiseStatisticsSetup_CflPe(TS ts, PetscViewerAndFormat *ctx);
45f0d618eaSJames Wright PetscErrorCode TSMonitor_SpanwiseStatisticsCflPe(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, PetscViewerAndFormat *ctx);
46