xref: /honee/include/spanstats.h (revision f0d618ea4257fb2becf67b1c197b60af5714c53d)
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.h>
600e32f70SJames Wright #include <petsc_ops.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 
2578c5b8e5SJames Wright typedef struct {
2600e32f70SJames Wright   CeedElemRestriction elem_restr_parent_x, elem_restr_parent_stats, elem_restr_parent_colloc, elem_restr_child_colloc;
2700e32f70SJames Wright   CeedBasis           basis_x, basis_stats;
2800e32f70SJames Wright   CeedVector          x_coord;
2900e32f70SJames Wright } *SpanStatsSetupData;
3000e32f70SJames Wright 
3178c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsSetupInitialize(Honee honee, PetscInt degree, PetscInt num_comps, const char *prefix,
3278c5b8e5SJames Wright                                                  SpanStatsSetupData *stats_setup_data, SpanStatsCtx *spanstats_new);
3378c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsSetupFinalize(TS ts, Honee honee, SpanStatsCtx spanstats, PetscViewerAndFormat *ctx,
3478c5b8e5SJames Wright                                                SpanStatsSetupData *stats_setup_data);
3500e32f70SJames Wright 
3678c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsCollect(Honee honee, SpanStatsCtx spanstats, PetscScalar solution_time, Vec Q);
3778c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsProcess(Honee honee, SpanStatsCtx spanstats, Vec stats);
3878c5b8e5SJames Wright 
3978c5b8e5SJames Wright PetscErrorCode SpanStatsCtxDestroy(void **ctx);
40*f0d618eaSJames Wright 
41*f0d618eaSJames Wright PetscErrorCode SpanwiseStatisticsSetup_Turbulence(TS ts, PetscViewerAndFormat *ctx);
42*f0d618eaSJames Wright PetscErrorCode TSMonitor_SpanwiseStatisticsTurbulence(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, PetscViewerAndFormat *ctx);
43*f0d618eaSJames Wright 
44*f0d618eaSJames Wright PetscErrorCode SpanwiseStatisticsSetup_CflPe(TS ts, PetscViewerAndFormat *ctx);
45*f0d618eaSJames Wright PetscErrorCode TSMonitor_SpanwiseStatisticsCflPe(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, PetscViewerAndFormat *ctx);
46