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> 4*78c5b8e5SJames Wright #include <honee.h> 500e32f70SJames Wright #include <petsc.h> 600e32f70SJames Wright #include <petsc_ops.h> 700e32f70SJames Wright 800e32f70SJames Wright typedef struct { 9*78c5b8e5SJames Wright DM dm; 10*78c5b8e5SJames Wright PetscSF sf; // For communicating child data to parents 11*78c5b8e5SJames Wright OperatorApplyContext op_stats_collect_ctx, op_proj_rhs_ctx; 12*78c5b8e5SJames Wright PetscInt num_comp_stats; 13*78c5b8e5SJames Wright Vec Child_Stats_loc, Parent_Stats_loc; 14*78c5b8e5SJames Wright KSP ksp; // For the L^2 projection solve 15*78c5b8e5SJames Wright CeedScalar span_width; // spanwise width of the child domain 16*78c5b8e5SJames Wright PetscBool do_mms_test; 17*78c5b8e5SJames Wright OperatorApplyContext mms_error_ctx; 18*78c5b8e5SJames Wright CeedContextFieldLabel solution_time_label, previous_time_label; 19*78c5b8e5SJames Wright PetscReal initial_solution_time; 20*78c5b8e5SJames Wright PetscInt initial_solution_step; 21*78c5b8e5SJames Wright PetscInt collect_interval; 22*78c5b8e5SJames Wright char *prefix; 23*78c5b8e5SJames Wright } *SpanStatsCtx; 24*78c5b8e5SJames Wright 25*78c5b8e5SJames 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 31*78c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsSetupInitialize(Honee honee, PetscInt degree, PetscInt num_comps, const char *prefix, 32*78c5b8e5SJames Wright SpanStatsSetupData *stats_setup_data, SpanStatsCtx *spanstats_new); 33*78c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsSetupFinalize(TS ts, Honee honee, SpanStatsCtx spanstats, PetscViewerAndFormat *ctx, 34*78c5b8e5SJames Wright SpanStatsSetupData *stats_setup_data); 3500e32f70SJames Wright 36*78c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsCollect(Honee honee, SpanStatsCtx spanstats, PetscScalar solution_time, Vec Q); 37*78c5b8e5SJames Wright PetscErrorCode SpanwiseStatisticsProcess(Honee honee, SpanStatsCtx spanstats, Vec stats); 38*78c5b8e5SJames Wright 39*78c5b8e5SJames Wright PetscErrorCode SpanStatsCtxDestroy(void **ctx); 40