Theseus
Compressible flow solver
Loading...
Searching...
No Matches
Simulation.hpp
Go to the documentation of this file.
1// Copyright (c) 2025-2026 Board of Trustees of the University of Illinois
2//
3// This file is part of Theseus.
4//
5// SPDX-License-Identifier: BSD-3-Clause
6#pragma once
7
8#include "Theseus.hpp"
10#include "RHSOperator.hpp"
11#include "RunControl.hpp"
13
14namespace Theseus
15{
16
18 {
19 private:
20 int numProcs, myRank;
21 int order;
22 int dim;
23 int num_equations;
24 int ref_levels;
25 int vis_steps;
26 int nancheck_steps;
27 int precision;
28 int num_dofs_scalar;
29 int num_dofs_system;
30 int print_interval;
31 int cfl_check_interval;
32 int ti;
33 int nsteps_max;
34
35 bool done = false;
36 bool variable_dt = false;
37 bool clock_simulation = true;
38 bool nancheck = false;
39 bool visualize = true;
40 bool visit = false;
41 bool paraview = true;
42 CheckpointConfig checkpoint_config;
43 VisualizationConfig visualization_config;
44
45 std::string output_file_path;
46 std::string paraview_folder;
47
48 mfem::real_t t, t_final, dt, dt_real;
49 mfem::real_t dt_fixed;
50 mfem::real_t cfl;
51 mfem::real_t max_dt_growth;
52 mfem::real_t Re, Ma;
53 mfem::real_t next_save_t;
54 mfem::real_t save_dt1;
55 mfem::real_t save_dt2;
56 mfem::real_t trigger_t;
57 mfem::real_t save_dt;
58 mfem::real_t next_checkpoint_t;
59
60 mfem::real_t V_sq;
61
62 mfem::real_t alpha_max;
63
64 mfem::Array<int> mesh_ordering;
65 std::shared_ptr<mfem::ParMesh> pmesh;
66
67 int btype = mfem::BasisType::GaussLobatto;
68 int ordering = mfem::Ordering::byNODES;
69
70 std::shared_ptr<mfem::DG_FECollection> fec;
71 std::shared_ptr<mfem::DG_FECollection> fec0;
72 std::shared_ptr<mfem::ParFiniteElementSpace> vfes;
73 std::shared_ptr<mfem::ParFiniteElementSpace> fes0;
74 std::unique_ptr<mfem::ParFiniteElementSpace> fes;
75 std::unique_ptr<mfem::ParFiniteElementSpace> dfes;
76
77 std::unique_ptr<mfem::VectorFunctionCoefficient> u0;
78 std::unique_ptr<mfem::VectorFunctionCoefficient> exact_solution;
79
80 std::shared_ptr<mfem::ParGridFunction> sol;
81 std::shared_ptr<mfem::ParGridFunction> dudx;
82 std::shared_ptr<mfem::ParGridFunction> dudy;
83 std::shared_ptr<mfem::ParGridFunction> dudz;
84
85 // Subcell blending : nullptr if OFF
86 std::shared_ptr<mfem::ParGridFunction> eta;
87 std::shared_ptr<mfem::ParGridFunction> alpha;
88 std::shared_ptr<Prandtl::PerssonPeraireIndicator> indicator;
89
90 std::vector<std::shared_ptr<mfem::VectorFunctionCoefficient>> BC_coeff;
91
92 mfem::ParGridFunction rho, mom, energy;
93
94 std::unique_ptr<mfem::ParGridFunction> velocity;
95 std::unique_ptr<mfem::ParGridFunction> p;
96
97 std::unique_ptr<mfem::ParaViewDataCollection> pd;
98 std::unique_ptr<mfem::VisItDataCollection> vd;
99
100 std::shared_ptr<mfem::ODESolver> ode_solver;
101 std::unique_ptr<Theseus::RHSOperatorBase> rhsOp;
102
103 int signature;
104
105 std::vector<mfem::Array<int>> bdr_marker_vector;
106 mfem::Array<int> set_marker;
107 int max_bdr_attr;
108 void InitDevice(std::string);
109 std::unique_ptr<mfem::Device> device_;
110
111 void UpdateVisualizationFields();
112 void SaveVisualization();
113 CheckpointCompatibility CurrentCheckpointCompatibility() const;
114 void LoadCheckpoint();
115 void SaveCheckpoint();
116 void PrintFacePartitionDiagnostics() const;
117
118 Simulation(std::string);
119
120 public:
121 static Simulation& SimulationCreate(std::string);
122 int LoadConfig(const std::string &config_file_path);
123
124 ~Simulation();
125
126 void Run();
127
128 Simulation(const Simulation&) = delete;
130 };
131
132}
Definition CheckpointConfig.hpp:32
Definition Simulation.hpp:18
~Simulation()
Definition Simulation.cpp:89
Simulation(const Simulation &)=delete
static Simulation & SimulationCreate(std::string)
Definition Simulation.cpp:40
int LoadConfig(const std::string &config_file_path)
Definition Simulation.cpp:101
void Run()
Definition Simulation.cpp:1110
Simulation & operator=(const Simulation &)=delete
Definition VisualizationConfig.hpp:40
Definition AxisymmetricGeometry.hpp:15
Definition CheckpointConfig.hpp:20