xref: /honee/include/navierstokes.h (revision 354560d100c3151a85e6abf4f71c41dd4f95bc3d)
1ae2b091fSJames Wright // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors.
2ae2b091fSJames Wright // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
3149fb536SJames Wright #pragma once
4149fb536SJames Wright 
5149fb536SJames Wright #include <ceed.h>
6149fb536SJames Wright #include <bc_definition.h>
793ca29b6SJames Wright #include <honee-file.h>
8149fb536SJames Wright #include <log_events.h>
9149fb536SJames Wright #include <mat-ceed.h>
10149fb536SJames Wright #include <petsc-ceed-utils.h>
11149fb536SJames Wright #include <petscts.h>
12149fb536SJames Wright #include <stdbool.h>
13*354560d1SJames Wright #include <time.h>
14149fb536SJames Wright 
15149fb536SJames Wright #include <petsc_ops.h>
16149fb536SJames Wright #include "../qfunctions/newtonian_types.h"
17149fb536SJames Wright 
18214d311dSJeremy L Thompson #if PETSC_VERSION_LT(3, 22, 0)
19214d311dSJeremy L Thompson #error "PETSc v3.22 or later is required"
20149fb536SJames Wright #endif
21149fb536SJames Wright 
22149fb536SJames Wright // -----------------------------------------------------------------------------
23149fb536SJames Wright // Enums
24149fb536SJames Wright // -----------------------------------------------------------------------------
25149fb536SJames Wright 
26149fb536SJames Wright // Euler - test cases
27149fb536SJames Wright typedef enum {
28149fb536SJames Wright   EULER_TEST_ISENTROPIC_VORTEX = 0,
29149fb536SJames Wright   EULER_TEST_1                 = 1,
30149fb536SJames Wright   EULER_TEST_2                 = 2,
31149fb536SJames Wright   EULER_TEST_3                 = 3,
32149fb536SJames Wright   EULER_TEST_4                 = 4,
33149fb536SJames Wright   EULER_TEST_5                 = 5,
34149fb536SJames Wright } EulerTestType;
35149fb536SJames Wright static const char *const EulerTestTypes[] = {"ISENTROPIC_VORTEX", "1", "2", "3", "4", "5", "EulerTestType", "EULER_TEST_", NULL};
36149fb536SJames Wright 
37149fb536SJames Wright // Advection - Wind types
383d1afcc1SJames Wright static const char *const AdvDifWindTypes[] = {"ROTATION", "TRANSLATION", "BOUNDARY_LAYER", "WindType", "ADVDIF_WIND_", NULL};
39149fb536SJames Wright 
40149fb536SJames Wright // Advection - Initial Condition Types
413d1afcc1SJames Wright static const char *const AdvDifICTypes[] = {"SPHERE",         "CYLINDER",        "COSINE_HILL", "SKEW", "WAVE",
423d1afcc1SJames Wright                                             "BOUNDARY_LAYER", "AdvectionICType", "ADVDIF_IC_",  NULL};
43a62be6baSJames Wright 
44a62be6baSJames Wright // Advection - Wave Types
45a62be6baSJames Wright static const char *const AdvDifWaveTypes[] = {"SINE", "SQUARE", "AdvDifWaveType", "ADVDIF_WAVE_", NULL};
46149fb536SJames Wright 
47149fb536SJames Wright // Advection - Bubble Continuity Types
485f636aeaSJames Wright static const char *const AdvDifBubbleContinuityTypes[] = {
495f636aeaSJames Wright     "SMOOTH", "BACK_SHARP", "THICK", "COSINE", "BubbleContinuityType", "ADVDIF_BUBBLE_CONTINUITY_", NULL};
50149fb536SJames Wright 
51149fb536SJames Wright // Stabilization methods
52149fb536SJames Wright static const char *const StabilizationTypes[] = {"NONE", "SU", "SUPG", "StabilizationType", "STAB_", NULL};
53149fb536SJames Wright 
54149fb536SJames Wright // Stabilization tau constants
553a9e4118SJames Wright static const char *const StabilizationTauTypes[] = {"CTAU", "ADVDIFF_SHAKIB", "StabilizationTauType", "STAB_TAU_", NULL};
56149fb536SJames Wright 
57149fb536SJames Wright // Test mode type
58149fb536SJames Wright typedef enum {
59149fb536SJames Wright   TESTTYPE_NONE           = 0,
60149fb536SJames Wright   TESTTYPE_SOLVER         = 1,
61149fb536SJames Wright   TESTTYPE_TURB_SPANSTATS = 2,
62149fb536SJames Wright   TESTTYPE_DIFF_FILTER    = 3,
63149fb536SJames Wright } TestType;
64149fb536SJames Wright static const char *const TestTypes[] = {"NONE", "SOLVER", "TURB_SPANSTATS", "DIFF_FILTER", "TestType", "TESTTYPE_", NULL};
65149fb536SJames Wright 
66149fb536SJames Wright // Subgrid-Stress mode type
67149fb536SJames Wright typedef enum {
68149fb536SJames Wright   SGS_MODEL_NONE        = 0,
69149fb536SJames Wright   SGS_MODEL_DATA_DRIVEN = 1,
70149fb536SJames Wright } SGSModelType;
71149fb536SJames Wright static const char *const SGSModelTypes[] = {"NONE", "DATA_DRIVEN", "SGSModelType", "SGS_MODEL_", NULL};
72149fb536SJames Wright 
73149fb536SJames Wright // Subgrid-Stress mode type
74149fb536SJames Wright typedef enum {
75149fb536SJames Wright   SGS_MODEL_DD_FUSED           = 0,
76149fb536SJames Wright   SGS_MODEL_DD_SEQENTIAL_CEED  = 1,
77149fb536SJames Wright   SGS_MODEL_DD_SEQENTIAL_TORCH = 2,
78149fb536SJames Wright } SGSModelDDImplementation;
79149fb536SJames Wright static const char *const SGSModelDDImplementations[] = {"FUSED", "SEQUENTIAL_CEED", "SEQUENTIAL_TORCH", "SGSModelDDImplementation", "SGS_MODEL_DD_",
80149fb536SJames Wright                                                         NULL};
81149fb536SJames Wright 
82149fb536SJames Wright // Mesh transformation type
83149fb536SJames Wright typedef enum {
84149fb536SJames Wright   MESH_TRANSFORM_NONE      = 0,
85149fb536SJames Wright   MESH_TRANSFORM_PLATEMESH = 1,
86149fb536SJames Wright } MeshTransformType;
87149fb536SJames Wright static const char *const MeshTransformTypes[] = {"NONE", "PLATEMESH", "MeshTransformType", "MESH_TRANSFORM_", NULL};
88149fb536SJames Wright 
89149fb536SJames Wright static const char *const DifferentialFilterDampingFunctions[] = {
90149fb536SJames Wright     "NONE", "VAN_DRIEST", "MMS", "DifferentialFilterDampingFunction", "DIFF_FILTER_DAMP_", NULL};
91149fb536SJames Wright 
928c85b835SJames Wright static const char *const DivDiffFluxProjectionMethods[] = {"NONE", "DIRECT", "INDIRECT", "DivDiffFluxProjectionMethod", "DIV_DIFF_FLUX_PROJ_", NULL};
938c85b835SJames Wright 
94149fb536SJames Wright // -----------------------------------------------------------------------------
95149fb536SJames Wright // Structs
96149fb536SJames Wright // -----------------------------------------------------------------------------
97149fb536SJames Wright // Structs declarations
98149fb536SJames Wright typedef struct AppCtx_private      *AppCtx;
990c373b74SJames Wright typedef struct Honee_private       *Honee;
100149fb536SJames Wright typedef struct Units_private       *Units;
101149fb536SJames Wright typedef struct SimpleBC_private    *SimpleBC;
102149fb536SJames Wright typedef struct Physics_private     *Physics;
103149fb536SJames Wright typedef struct ProblemData_private *ProblemData;
104149fb536SJames Wright 
105149fb536SJames Wright // Application context from user command line options
106149fb536SJames Wright struct AppCtx_private {
107149fb536SJames Wright   // libCEED arguments
108149fb536SJames Wright   char     ceed_resource[PETSC_MAX_PATH_LEN];  // libCEED backend
109149fb536SJames Wright   PetscInt degree;
110149fb536SJames Wright   PetscInt q_extra;
111149fb536SJames Wright   // Solver arguments
112149fb536SJames Wright   MatType amat_type;
113149fb536SJames Wright   // Post-processing arguments
114149fb536SJames Wright   PetscInt  checkpoint_interval;
115149fb536SJames Wright   PetscInt  viz_refine;
116481d14cbSJames Wright   PetscBool use_continue_file;
117149fb536SJames Wright   PetscInt  cont_steps;
118149fb536SJames Wright   PetscReal cont_time;
119149fb536SJames Wright   char      cont_file[PETSC_MAX_PATH_LEN];
120149fb536SJames Wright   char      output_dir[PETSC_MAX_PATH_LEN];
121149fb536SJames Wright   PetscBool add_stepnum2bin;
122149fb536SJames Wright   PetscBool checkpoint_vtk;
123149fb536SJames Wright   // Problem type arguments
124149fb536SJames Wright   PetscFunctionList problems;
125149fb536SJames Wright   char              problem_name[PETSC_MAX_PATH_LEN];
126149fb536SJames Wright   // Test mode arguments
127149fb536SJames Wright   TestType    test_type;
128149fb536SJames Wright   PetscScalar test_tol;
129149fb536SJames Wright   char        test_file_path[PETSC_MAX_PATH_LEN];
130149fb536SJames Wright   // Turbulent spanwise statistics
131149fb536SJames Wright   PetscBool         turb_spanstats_enable;
132149fb536SJames Wright   PetscInt          turb_spanstats_collect_interval;
133149fb536SJames Wright   PetscInt          turb_spanstats_viewer_interval;
134149fb536SJames Wright   PetscViewer       turb_spanstats_viewer;
135149fb536SJames Wright   PetscViewerFormat turb_spanstats_viewer_format;
136149fb536SJames Wright   // Wall forces
137149fb536SJames Wright   struct {
138149fb536SJames Wright     PetscInt          num_wall;
139149fb536SJames Wright     PetscInt         *walls;
140149fb536SJames Wright     PetscViewer       viewer;
141149fb536SJames Wright     PetscViewerFormat viewer_format;
142149fb536SJames Wright     PetscBool         header_written;
143149fb536SJames Wright   } wall_forces;
144149fb536SJames Wright   // Subgrid Stress Model
145149fb536SJames Wright   SGSModelType sgs_model_type;
146149fb536SJames Wright   PetscBool    sgs_train_enable;
147149fb536SJames Wright   // Differential Filtering
148149fb536SJames Wright   PetscBool         diff_filter_monitor;
149149fb536SJames Wright   MeshTransformType mesh_transform_type;
1508c85b835SJames Wright   // Divergence of Diffusive Flux Projection
1518c85b835SJames Wright   DivDiffFluxProjectionMethod divFdiffproj_method;
1528b774af8SJames Wright 
1538b774af8SJames Wright   PetscInt check_step_interval;
154149fb536SJames Wright };
155149fb536SJames Wright 
156149fb536SJames Wright typedef struct {
157149fb536SJames Wright   DM                    dm;
158149fb536SJames Wright   PetscSF               sf;  // For communicating child data to parents
159149fb536SJames Wright   OperatorApplyContext  op_stats_collect_ctx, op_proj_rhs_ctx;
160149fb536SJames Wright   PetscInt              num_comp_stats;
161149fb536SJames Wright   Vec                   Child_Stats_loc, Parent_Stats_loc;
162149fb536SJames Wright   KSP                   ksp;         // For the L^2 projection solve
163149fb536SJames Wright   CeedScalar            span_width;  // spanwise width of the child domain
164149fb536SJames Wright   PetscBool             do_mms_test;
165149fb536SJames Wright   OperatorApplyContext  mms_error_ctx;
166149fb536SJames Wright   CeedContextFieldLabel solution_time_label, previous_time_label;
167149fb536SJames Wright } SpanStatsData;
168149fb536SJames Wright 
169149fb536SJames Wright typedef struct {
170149fb536SJames Wright   DM                   dm;
171149fb536SJames Wright   PetscInt             num_comp;
172149fb536SJames Wright   OperatorApplyContext l2_rhs_ctx;
173149fb536SJames Wright   KSP                  ksp;
174149fb536SJames Wright } *NodalProjectionData;
175149fb536SJames Wright 
17636038bbcSJames Wright typedef struct DivDiffFluxProjectionData_private *DivDiffFluxProjectionData;
17736038bbcSJames Wright 
17836038bbcSJames Wright struct DivDiffFluxProjectionData_private {
1798c85b835SJames Wright   PetscInt                    num_diff_flux_comps;
1808c85b835SJames Wright   DivDiffFluxProjectionMethod method;
1818c85b835SJames Wright   NodalProjectionData         projection;
18236038bbcSJames Wright 
18336038bbcSJames Wright   // CeedOperator Objects
18436038bbcSJames Wright   CeedElemRestriction elem_restr_div_diff_flux;
18536038bbcSJames Wright   CeedBasis           basis_div_diff_flux;
18636038bbcSJames Wright   CeedEvalMode        eval_mode_div_diff_flux;
1878c85b835SJames Wright   CeedVector          div_diff_flux_ceed;
18836038bbcSJames Wright 
18936038bbcSJames Wright   // Problem specific setup functions
190e3663b90SJames Wright   PetscErrorCode (*CreateRHSOperator_Direct)(Honee, DivDiffFluxProjectionData, CeedOperator *);
191e3663b90SJames Wright   PetscErrorCode (*CreateRHSOperator_Indirect)(Honee, DivDiffFluxProjectionData, CeedOperator *);
19236038bbcSJames Wright 
1938c85b835SJames Wright   // Only used for direct method:
1948c85b835SJames Wright   Vec          DivDiffFlux_loc;
1958c85b835SJames Wright   PetscMemType DivDiffFlux_memtype;
1968c85b835SJames Wright   PetscBool    ceed_vec_has_array;
19736038bbcSJames Wright 
19836038bbcSJames Wright   // Only used for indirect method:
19936038bbcSJames Wright   OperatorApplyContext calc_div_diff_flux;
20036038bbcSJames Wright };
2018c85b835SJames Wright 
2020c373b74SJames Wright typedef PetscErrorCode (*SgsDDNodalStressEval)(Honee honee, Vec Q_loc, Vec VelocityGradient, Vec SGSNodal_loc);
203149fb536SJames Wright typedef PetscErrorCode (*SgsDDNodalStressInference)(Vec DD_Inputs_loc, Vec DD_Outputs_loc, void *ctx);
204149fb536SJames Wright typedef struct {
205149fb536SJames Wright   DM                        dm_sgs, dm_dd_inputs, dm_dd_outputs;
206149fb536SJames Wright   PetscInt                  num_comp_sgs, num_comp_inputs, num_comp_outputs;
207149fb536SJames Wright   OperatorApplyContext      op_nodal_evaluation_ctx, op_nodal_dd_inputs_ctx, op_nodal_dd_outputs_ctx, op_sgs_apply_ctx;
208149fb536SJames Wright   CeedVector                sgs_nodal_ceed, grad_velo_ceed;
209149fb536SJames Wright   SgsDDNodalStressEval      sgs_nodal_eval;
210149fb536SJames Wright   SgsDDNodalStressInference sgs_nodal_inference;
211149fb536SJames Wright   void                     *sgs_nodal_inference_ctx;
212149fb536SJames Wright   PetscErrorCode (*sgs_nodal_inference_ctx_destroy)(void *ctx);
213149fb536SJames Wright } *SgsDDData;
214149fb536SJames Wright 
215149fb536SJames Wright typedef struct {
216149fb536SJames Wright   DM                   dm_dd_training;
217149fb536SJames Wright   PetscInt             num_comp_dd_inputs, write_data_interval, num_filter_widths;
218149fb536SJames Wright   PetscScalar          filter_widths[16];
219149fb536SJames Wright   OperatorApplyContext op_training_data_calc_ctx;
220149fb536SJames Wright   NodalProjectionData  filtered_grad_velo_proj;
221149fb536SJames Wright   size_t               training_data_array_dims[2];
222149fb536SJames Wright   PetscBool            overwrite_training_data;
223149fb536SJames Wright } *SGS_DD_TrainingData;
224149fb536SJames Wright 
225149fb536SJames Wright typedef struct {
226149fb536SJames Wright   DM                    dm_filter;
227149fb536SJames Wright   PetscInt              num_filtered_fields;
228149fb536SJames Wright   CeedInt              *num_field_components;
229149fb536SJames Wright   PetscInt              field_prim_state, field_velo_prod;
230149fb536SJames Wright   OperatorApplyContext  op_rhs_ctx;
231149fb536SJames Wright   KSP                   ksp;
232149fb536SJames Wright   PetscObjectState      X_loc_state;
233149fb536SJames Wright   PetscBool             do_mms_test;
234149fb536SJames Wright   CeedContextFieldLabel filter_width_scaling_label;
235149fb536SJames Wright } *DiffFilterData;
236149fb536SJames Wright 
237149fb536SJames Wright typedef struct {
238149fb536SJames Wright   void    *client;
239149fb536SJames Wright   char     rank_id_name[16];
240149fb536SJames Wright   PetscInt collocated_database_num_ranks;
241149fb536SJames Wright } *SmartSimData;
242149fb536SJames Wright 
243149fb536SJames Wright // PETSc user data
2440c373b74SJames Wright struct Honee_private {
245149fb536SJames Wright   MPI_Comm                  comm;
246149fb536SJames Wright   DM                        dm;
247149fb536SJames Wright   DM                        dm_viz;
248149fb536SJames Wright   Mat                       interp_viz;
249149fb536SJames Wright   Ceed                      ceed;
250149fb536SJames Wright   Units                     units;
251149fb536SJames Wright   Vec                       Q_loc, Q_dot_loc;
252149fb536SJames Wright   Physics                   phys;
253149fb536SJames Wright   AppCtx                    app_ctx;
254149fb536SJames Wright   CeedVector                q_ceed, q_dot_ceed, g_ceed, x_ceed;
255149fb536SJames Wright   CeedOperator              op_ifunction;
256149fb536SJames Wright   Mat                       mat_ijacobian;
257149fb536SJames Wright   KSP                       mass_ksp;
258149fb536SJames Wright   OperatorApplyContext      op_rhs_ctx, op_strong_bc_ctx;
259149fb536SJames Wright   CeedScalar                time_bc_set;
260149fb536SJames Wright   SpanStatsData             spanstats;
261149fb536SJames Wright   NodalProjectionData       grad_velo_proj;
262149fb536SJames Wright   SgsDDData                 sgs_dd_data;
263149fb536SJames Wright   DiffFilterData            diff_filter;
264149fb536SJames Wright   SmartSimData              smartsim;
265149fb536SJames Wright   SGS_DD_TrainingData       sgs_dd_train;
2668c85b835SJames Wright   DivDiffFluxProjectionData diff_flux_proj;
267e3663b90SJames Wright 
268e3663b90SJames Wright   // old CeedData
269e3663b90SJames Wright   CeedVector           x_coord;
270e3663b90SJames Wright   CeedBasis            basis_x, basis_q;
271e3663b90SJames Wright   CeedElemRestriction  elem_restr_x, elem_restr_q;
272e3663b90SJames Wright   OperatorApplyContext op_ics_ctx;
273*354560d1SJames Wright 
274*354560d1SJames Wright   time_t   start_time;
275*354560d1SJames Wright   time_t   max_wall_time;
276*354560d1SJames Wright   PetscInt max_wall_time_interval;
277149fb536SJames Wright };
278149fb536SJames Wright 
279149fb536SJames Wright // Units
280149fb536SJames Wright struct Units_private {
281149fb536SJames Wright   // fundamental units
282149fb536SJames Wright   PetscScalar meter;
283149fb536SJames Wright   PetscScalar kilogram;
284149fb536SJames Wright   PetscScalar second;
285149fb536SJames Wright   PetscScalar Kelvin;
286149fb536SJames Wright   // derived units
287149fb536SJames Wright   PetscScalar Pascal;
288149fb536SJames Wright   PetscScalar J_per_kg_K;
289149fb536SJames Wright   PetscScalar m_per_squared_s;
290149fb536SJames Wright   PetscScalar W_per_m_K;
291149fb536SJames Wright   PetscScalar Joule;
292149fb536SJames Wright };
293149fb536SJames Wright 
294149fb536SJames Wright // Boundary conditions
295149fb536SJames Wright struct SimpleBC_private {
296149fb536SJames Wright   PetscInt num_inflow, num_outflow, num_freestream, num_slip;
297149fb536SJames Wright   PetscInt inflows[16], outflows[16], freestreams[16], slips[16];
298149fb536SJames Wright };
299149fb536SJames Wright 
300149fb536SJames Wright // Struct that contains all enums and structs used for the physics of all problems
301149fb536SJames Wright struct Physics_private {
302149fb536SJames Wright   PetscBool             implicit;
303149fb536SJames Wright   StateVariable         state_var;
304149fb536SJames Wright   CeedContextFieldLabel solution_time_label;
305149fb536SJames Wright   CeedContextFieldLabel stg_solution_time_label;
306149fb536SJames Wright   CeedContextFieldLabel timestep_size_label;
307149fb536SJames Wright   CeedContextFieldLabel ics_time_label;
308149fb536SJames Wright };
309149fb536SJames Wright 
3100c373b74SJames Wright PetscErrorCode BoundaryConditionSetUp(Honee honee, ProblemData problem, AppCtx app_ctx, SimpleBC bc);
311149fb536SJames Wright 
312149fb536SJames Wright typedef struct {
313e07531f7SJames Wright   CeedQFunctionUser    qf_func_ptr;  // !< QFunction function pointer
314e07531f7SJames Wright   const char          *qf_loc;       // !< Absolute path to QFunction source file
315e07531f7SJames Wright   CeedQFunctionContext qfctx;        // !< QFunctionContext to attach to QFunction
316149fb536SJames Wright } ProblemQFunctionSpec;
317149fb536SJames Wright 
318149fb536SJames Wright // Problem specific data
319149fb536SJames Wright struct ProblemData_private {
32028160fc2SJames Wright   CeedInt              jac_data_size_vol, jac_data_size_sur;
321149fb536SJames Wright   ProblemQFunctionSpec ics, apply_vol_rhs, apply_vol_ifunction, apply_vol_ijacobian, apply_inflow, apply_outflow, apply_freestream, apply_slip,
322149fb536SJames Wright       apply_inflow_jacobian, apply_outflow_jacobian, apply_freestream_jacobian, apply_slip_jacobian;
323149fb536SJames Wright   bool          compute_exact_solution_error;
32428160fc2SJames Wright   PetscBool     set_bc_from_ics, use_strong_bc_ceed;
325ddb7a641SJames Wright   PetscCount    num_bc_defs;
326149fb536SJames Wright   BCDefinition *bc_defs;
3270c373b74SJames Wright   PetscErrorCode (*print_info)(Honee, ProblemData, AppCtx);
3280c373b74SJames Wright   PetscErrorCode (*create_mass_operator)(Honee, CeedOperator *);
329149fb536SJames Wright };
330149fb536SJames Wright 
331149fb536SJames Wright extern int FreeContextPetsc(void *);
332149fb536SJames Wright 
333149fb536SJames Wright // -----------------------------------------------------------------------------
334149fb536SJames Wright // Set up problems
335149fb536SJames Wright // -----------------------------------------------------------------------------
336149fb536SJames Wright // Set up function for each problem
337149fb536SJames Wright extern PetscErrorCode NS_TAYLOR_GREEN(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
338149fb536SJames Wright extern PetscErrorCode NS_GAUSSIAN_WAVE(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
339149fb536SJames Wright extern PetscErrorCode NS_CHANNEL(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
340149fb536SJames Wright extern PetscErrorCode NS_BLASIUS(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
341149fb536SJames Wright extern PetscErrorCode NS_NEWTONIAN_IG(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
342149fb536SJames Wright extern PetscErrorCode NS_DENSITY_CURRENT(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
343149fb536SJames Wright extern PetscErrorCode NS_EULER_VORTEX(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
344149fb536SJames Wright extern PetscErrorCode NS_SHOCKTUBE(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
345149fb536SJames Wright extern PetscErrorCode NS_ADVECTION(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
346149fb536SJames Wright extern PetscErrorCode NS_ADVECTION2D(ProblemData problem, DM dm, void *ctx, SimpleBC bc);
347149fb536SJames Wright 
348149fb536SJames Wright // Print function for each problem
3490c373b74SJames Wright extern PetscErrorCode PRINT_NEWTONIAN(Honee honee, ProblemData problem, AppCtx app_ctx);
3500c373b74SJames Wright extern PetscErrorCode PRINT_EULER_VORTEX(Honee honee, ProblemData problem, AppCtx app_ctx);
3510c373b74SJames Wright extern PetscErrorCode PRINT_SHOCKTUBE(Honee honee, ProblemData problem, AppCtx app_ctx);
3520c373b74SJames Wright extern PetscErrorCode PRINT_ADVECTION(Honee honee, ProblemData problem, AppCtx app_ctx);
3530c373b74SJames Wright extern PetscErrorCode PRINT_ADVECTION2D(Honee honee, ProblemData problem, AppCtx app_ctx);
354149fb536SJames Wright 
3550c373b74SJames Wright PetscErrorCode PrintRunInfo(Honee honee, Physics phys_ctx, ProblemData problem, TS ts);
356149fb536SJames Wright 
357149fb536SJames Wright // -----------------------------------------------------------------------------
358149fb536SJames Wright // libCEED functions
359149fb536SJames Wright // -----------------------------------------------------------------------------
360149fb536SJames Wright PetscErrorCode DMPlexCeedElemRestrictionCreate(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height, PetscInt dm_field,
361149fb536SJames Wright                                                CeedElemRestriction *restriction);
362149fb536SJames Wright PetscErrorCode DMPlexCeedElemRestrictionCoordinateCreate(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height,
363149fb536SJames Wright                                                          CeedElemRestriction *restriction);
364149fb536SJames Wright PetscErrorCode DMPlexCeedElemRestrictionQDataCreate(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height,
365149fb536SJames Wright                                                     PetscInt q_data_size, CeedElemRestriction *restriction);
366149fb536SJames Wright PetscErrorCode DMPlexCeedElemRestrictionCollocatedCreate(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height,
367149fb536SJames Wright                                                          PetscInt q_data_size, CeedElemRestriction *restriction);
368149fb536SJames Wright 
369149fb536SJames Wright PetscErrorCode CreateBasisFromPlex(Ceed ceed, DM dm, DMLabel domain_label, CeedInt label_value, CeedInt height, CeedInt dm_field, CeedBasis *basis);
3708c85b835SJames Wright PetscErrorCode CreateCoordinateBasisFromPlex(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height, CeedBasis *basis);
37121ba7ba4SJames Wright PetscErrorCode DMPlexCeedBasisCellToFaceCoordinateCreate(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt face,
37221ba7ba4SJames Wright                                                          CeedBasis *basis);
37321ba7ba4SJames Wright PetscErrorCode DMPlexCeedBasisCellToFaceCreate(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt face, PetscInt dm_field,
37421ba7ba4SJames Wright                                                CeedBasis *basis);
3755f65e1a7SJames Wright PetscErrorCode DMPlexCreateFaceLabel(DM dm, PetscInt dm_face, char **face_label_name);
3765f65e1a7SJames Wright PetscErrorCode DMLabelCreateGlobalValueArray(DM dm, DMLabel label, PetscInt *num_values, PetscInt **value_array);
377149fb536SJames Wright 
378e3663b90SJames Wright PetscErrorCode SetupLibceed(Ceed ceed, DM dm, Honee honee, AppCtx app_ctx, ProblemData problem, SimpleBC bc);
379149fb536SJames Wright 
380149fb536SJames Wright PetscErrorCode QDataGet(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, CeedElemRestriction elem_restr_x, CeedBasis basis_x,
381149fb536SJames Wright                         CeedVector x_coord, CeedElemRestriction *elem_restr_qd, CeedVector *q_data, CeedInt *q_data_size);
382149fb536SJames Wright PetscErrorCode QDataGetNumComponents(DM dm, CeedInt *q_data_size);
383149fb536SJames Wright PetscErrorCode QDataBoundaryGet(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, CeedElemRestriction elem_restr_x, CeedBasis basis_x,
384149fb536SJames Wright                                 CeedVector x_coord, CeedElemRestriction *elem_restr_qd, CeedVector *q_data, CeedInt *q_data_size);
385149fb536SJames Wright PetscErrorCode QDataBoundaryGetNumComponents(DM dm, CeedInt *q_data_size);
3868c85b835SJames Wright PetscErrorCode QDataBoundaryGradientGetNumComponents(DM dm, CeedInt *q_data_size);
3878c85b835SJames Wright PetscErrorCode QDataBoundaryGradientGet(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, CeedVector x_coord,
38800dbc7b1SJames Wright                                         CeedElemRestriction *elem_restr_qd, CeedVector *q_data, CeedInt *q_data_size);
389e816a7e4SJames Wright PetscErrorCode QDataClearStoredData();
390149fb536SJames Wright // -----------------------------------------------------------------------------
391149fb536SJames Wright // Time-stepping functions
392149fb536SJames Wright // -----------------------------------------------------------------------------
393149fb536SJames Wright PetscErrorCode RHS_NS(TS ts, PetscReal t, Vec Q, Vec G, void *user_data);
394149fb536SJames Wright PetscErrorCode IFunction_NS(TS ts, PetscReal t, Vec Q, Vec Q_dot, Vec G, void *user_data);
395149fb536SJames Wright PetscErrorCode TSMonitor_NS(TS ts, PetscInt step_no, PetscReal time, Vec Q, void *ctx);
3960c373b74SJames Wright PetscErrorCode TSSolve_NS(DM dm, Honee honee, AppCtx app_ctx, Physics phys, ProblemData problem, Vec *Q, PetscScalar *f_time, TS *ts);
3970c373b74SJames Wright PetscErrorCode UpdateBoundaryValues(Honee honee, Vec Q_loc, PetscReal t);
398149fb536SJames Wright 
399149fb536SJames Wright // -----------------------------------------------------------------------------
400149fb536SJames Wright // Setup DM
401149fb536SJames Wright // -----------------------------------------------------------------------------
402149fb536SJames Wright PetscErrorCode CreateDM(MPI_Comm comm, ProblemData problem, MatType, VecType, DM *dm);
403149fb536SJames Wright PetscErrorCode SetUpDM(DM dm, ProblemData problem, PetscInt degree, PetscInt q_extra, SimpleBC bc, Physics phys);
4040c373b74SJames Wright PetscErrorCode VizRefineDM(DM dm, Honee honee, ProblemData problem, SimpleBC bc, Physics phys);
4054cb09fddSJames Wright 
406149fb536SJames Wright PetscErrorCode DMSetupByOrderBegin_FEM(PetscBool setup_faces, PetscBool setup_coords, PetscInt degree, PetscInt coord_order, PetscInt q_extra,
407149fb536SJames Wright                                        PetscInt num_fields, const PetscInt *field_sizes, DM dm);
408149fb536SJames Wright PetscErrorCode DMSetupByOrderEnd_FEM(PetscBool setup_coords, DM dm);
409149fb536SJames Wright PetscErrorCode DMSetupByOrder_FEM(PetscBool setup_faces, PetscBool setup_coords, PetscInt degree, PetscInt coord_order, PetscInt q_extra,
410149fb536SJames Wright                                   PetscInt num_fields, const PetscInt *field_sizes, DM dm);
411149fb536SJames Wright 
412149fb536SJames Wright // -----------------------------------------------------------------------------
413149fb536SJames Wright // Process command line options
414149fb536SJames Wright // -----------------------------------------------------------------------------
41573170398SJames Wright PetscErrorCode ProcessCommandLineOptions(Honee honee, SimpleBC bc);
41659572072SJames Wright PetscErrorCode HoneeOptionsSetValueDefault(PetscOptions options, const char name[], const char value[]);
417149fb536SJames Wright 
418149fb536SJames Wright // -----------------------------------------------------------------------------
419149fb536SJames Wright // Miscellaneous utility functions
420149fb536SJames Wright // -----------------------------------------------------------------------------
421149fb536SJames Wright PetscErrorCode GetInverseMultiplicity(Ceed ceed, DM dm, DMLabel domain_label, PetscInt label_value, PetscInt height, PetscInt dm_field,
422149fb536SJames Wright                                       PetscBool get_global_multiplicity, CeedElemRestriction *elem_restr_inv_multiplicity,
423149fb536SJames Wright                                       CeedVector *inv_multiplicity);
424e3663b90SJames Wright PetscErrorCode ICs_FixMultiplicity(DM dm, Honee honee, Vec Q_loc, Vec Q, CeedScalar time);
425149fb536SJames Wright 
426149fb536SJames Wright PetscErrorCode DMPlexInsertBoundaryValues_FromICs(DM dm, PetscBool insert_essential, Vec Q_loc, PetscReal time, Vec face_geom_FVM, Vec cell_geom_FVM,
427149fb536SJames Wright                                                   Vec grad_FVM);
428149fb536SJames Wright 
429149fb536SJames Wright PetscErrorCode RegressionTest(AppCtx app_ctx, Vec Q);
430e3663b90SJames Wright PetscErrorCode PrintError(DM dm, Honee honee, Vec Q, PetscScalar final_time);
431e3663b90SJames Wright PetscErrorCode PostProcess(TS ts, DM dm, ProblemData problem, Honee honee, Vec Q, PetscScalar final_time);
432149fb536SJames Wright PetscErrorCode SetBCsFromICs(DM dm, Vec Q, Vec Q_loc);
43364dd23feSJames Wright PetscErrorCode HoneeMassQFunctionCreate(Ceed ceed, CeedInt N, CeedInt q_data_size, CeedQFunction *qf);
43425125139SJames Wright PetscErrorCode HoneeCalculateDomainSize(Honee honee, PetscScalar *volume);
435149fb536SJames Wright PetscErrorCode NodalProjectionDataDestroy(NodalProjectionData context);
436149fb536SJames Wright 
437149fb536SJames Wright // -----------------------------------------------------------------------------
438149fb536SJames Wright // Turbulence Statistics Collection Functions
439149fb536SJames Wright // -----------------------------------------------------------------------------
440e3663b90SJames Wright PetscErrorCode TurbulenceStatisticsSetup(Ceed ceed, Honee honee, ProblemData problem);
441149fb536SJames Wright PetscErrorCode TSMonitor_TurbulenceStatistics(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, void *ctx);
442e3663b90SJames Wright PetscErrorCode TurbulenceStatisticsDestroy(Honee honee);
443149fb536SJames Wright 
444149fb536SJames Wright // -----------------------------------------------------------------------------
445149fb536SJames Wright // Data-Driven Subgrid Stress (DD-SGS) Modeling Functions
446149fb536SJames Wright // -----------------------------------------------------------------------------
447e3663b90SJames Wright PetscErrorCode SgsDDSetup(Ceed ceed, Honee honee, ProblemData problem);
448149fb536SJames Wright PetscErrorCode SgsDDDataDestroy(SgsDDData sgs_dd_data);
4490c373b74SJames Wright PetscErrorCode SgsDDApplyIFunction(Honee honee, const Vec Q_loc, Vec G_loc);
450e3663b90SJames Wright PetscErrorCode VelocityGradientProjectionSetup(Ceed ceed, Honee honee, ProblemData problem, StateVariable state_var_input,
451149fb536SJames Wright                                                CeedElemRestriction elem_restr_input, CeedBasis basis_input, NodalProjectionData *pgrad_velo_proj);
452149fb536SJames Wright PetscErrorCode VelocityGradientProjectionApply(NodalProjectionData grad_velo_proj, Vec Q_loc, Vec VelocityGradient);
453e3663b90SJames Wright PetscErrorCode GridAnisotropyTensorProjectionSetupApply(Ceed ceed, Honee honee, CeedElemRestriction *elem_restr_grid_aniso,
454149fb536SJames Wright                                                         CeedVector *grid_aniso_vector);
455e3663b90SJames Wright PetscErrorCode GridAnisotropyTensorCalculateCollocatedVector(Ceed ceed, Honee honee, CeedElemRestriction *elem_restr_grid_aniso,
456149fb536SJames Wright                                                              CeedVector *aniso_colloc_ceed, PetscInt *num_comp_aniso);
457149fb536SJames Wright 
458149fb536SJames Wright // -----------------------------------------------------------------------------
459149fb536SJames Wright // Boundary Condition Related Functions
460149fb536SJames Wright // -----------------------------------------------------------------------------
461e3663b90SJames Wright PetscErrorCode SetupStrongBC_Ceed(Ceed ceed, DM dm, Honee honee, ProblemData problem, SimpleBC bc);
462149fb536SJames Wright PetscErrorCode FreestreamBCSetup(ProblemData problem, DM dm, void *ctx, NewtonianIdealGasContext newtonian_ig_ctx, const StatePrimitive *reference);
463149fb536SJames Wright PetscErrorCode OutflowBCSetup(ProblemData problem, DM dm, void *ctx, NewtonianIdealGasContext newtonian_ig_ctx, const StatePrimitive *reference);
464149fb536SJames Wright PetscErrorCode SlipBCSetup(ProblemData problem, DM dm, void *ctx, CeedQFunctionContext newtonian_ig_qfctx);
465149fb536SJames Wright 
466149fb536SJames Wright // -----------------------------------------------------------------------------
467149fb536SJames Wright // Differential Filtering Functions
468149fb536SJames Wright // -----------------------------------------------------------------------------
469e3663b90SJames Wright PetscErrorCode DifferentialFilterSetup(Ceed ceed, Honee honee, ProblemData problem);
470149fb536SJames Wright PetscErrorCode DifferentialFilterDataDestroy(DiffFilterData diff_filter);
471149fb536SJames Wright PetscErrorCode TSMonitor_DifferentialFilter(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, void *ctx);
4720c373b74SJames Wright PetscErrorCode DifferentialFilterApply(Honee honee, const PetscReal solution_time, const Vec Q, Vec Filtered_Solution);
473149fb536SJames Wright PetscErrorCode DifferentialFilterMmsICSetup(ProblemData problem);
474149fb536SJames Wright 
475149fb536SJames Wright // -----------------------------------------------------------------------------
476149fb536SJames Wright // SGS Data-Driven Training via SmartSim
477149fb536SJames Wright // -----------------------------------------------------------------------------
4780c373b74SJames Wright PetscErrorCode SmartSimSetup(Honee honee);
479149fb536SJames Wright PetscErrorCode SmartSimDataDestroy(SmartSimData smartsim);
480e3663b90SJames Wright PetscErrorCode SGS_DD_TrainingSetup(Ceed ceed, Honee honee, ProblemData problem);
481149fb536SJames Wright PetscErrorCode TSMonitor_SGS_DD_Training(TS ts, PetscInt step_num, PetscReal solution_time, Vec Q, void *ctx);
482149fb536SJames Wright PetscErrorCode TSPostStep_SGS_DD_Training(TS ts);
483149fb536SJames Wright PetscErrorCode SGS_DD_TrainingDataDestroy(SGS_DD_TrainingData sgs_dd_train);
4848c85b835SJames Wright 
4858c85b835SJames Wright // -----------------------------------------------------------------------------
4868c85b835SJames Wright // Divergence of Diffusive Flux Projection
4878c85b835SJames Wright // -----------------------------------------------------------------------------
4880c373b74SJames Wright PetscErrorCode DivDiffFluxProjectionCreate(Honee honee, PetscInt num_diff_flux_comps, DivDiffFluxProjectionData *pdiff_flux_proj);
4890880fbb6SJames Wright PetscErrorCode DivDiffFluxProjectionGetOperatorFieldData(DivDiffFluxProjectionData diff_flux_proj, CeedElemRestriction *elem_restr, CeedBasis *basis,
4900880fbb6SJames Wright                                                          CeedVector *vector, CeedEvalMode *eval_mode);
491e3663b90SJames Wright PetscErrorCode DivDiffFluxProjectionSetup(Honee honee, DivDiffFluxProjectionData diff_flux_proj);
49236038bbcSJames Wright PetscErrorCode DivDiffFluxProjectionApply(DivDiffFluxProjectionData diff_flux_proj, Vec Q_loc);
4938c85b835SJames Wright PetscErrorCode DivDiffFluxProjectionDataDestroy(DivDiffFluxProjectionData diff_flux_proj);
49425125139SJames Wright 
49525125139SJames Wright PetscErrorCode SetupMontiorTotalKineticEnergy(TS ts, PetscViewerAndFormat *ctx);
49625125139SJames Wright PetscErrorCode TSMonitor_TotalKineticEnergy(TS ts, PetscInt steps, PetscReal solution_time, Vec Q, PetscViewerAndFormat *ctx);
497