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.h> 6 #include <petsc_ops.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 typedef struct { 26 CeedElemRestriction elem_restr_parent_x, elem_restr_parent_stats, elem_restr_parent_colloc, elem_restr_child_colloc; 27 CeedBasis basis_x, basis_stats; 28 CeedVector x_coord; 29 } *SpanStatsSetupData; 30 31 PetscErrorCode SpanwiseStatisticsSetupInitialize(Honee honee, PetscInt degree, PetscInt num_comps, const char *prefix, 32 SpanStatsSetupData *stats_setup_data, SpanStatsCtx *spanstats_new); 33 PetscErrorCode SpanwiseStatisticsSetupFinalize(TS ts, Honee honee, SpanStatsCtx spanstats, PetscViewerAndFormat *ctx, 34 SpanStatsSetupData *stats_setup_data); 35 36 PetscErrorCode SpanwiseStatisticsCollect(Honee honee, SpanStatsCtx spanstats, PetscScalar solution_time, Vec Q); 37 PetscErrorCode SpanwiseStatisticsProcess(Honee honee, SpanStatsCtx spanstats, Vec stats); 38 39 PetscErrorCode SpanStatsCtxDestroy(void **ctx); 40