27 const nlohmann::json &runtime,
28 std::shared_ptr<mfem::ParFiniteElementSpace> vfes,
29 std::shared_ptr<mfem::ParFiniteElementSpace> fes0,
30 std::shared_ptr<mfem::ParMesh> pmesh,
31 std::shared_ptr<mfem::ParGridFunction> eta,
32 std::shared_ptr<mfem::ParGridFunction> alpha,
33 std::vector<std::shared_ptr<mfem::ParGridFunction> > &grad_u,
34 std::shared_ptr<Prandtl::PerssonPeraireIndicator> indicator,
35 mfem::real_t alpha_max,
36 std::shared_ptr<const GasModelT> gas_,
37 const std::string &gasModelName,
38 const std::string &numFluxName)
42 return std::make_unique<Theseus::EulerOperator<Physics>>(vfes, fes0, pmesh, eta, alpha,
49 return std::make_unique<Theseus::NSOperator<Physics>>(vfes, fes0, pmesh, eta, alpha, grad_u,
60 std::shared_ptr<mfem::ParFiniteElementSpace> vfes,
61 std::shared_ptr<mfem::ParFiniteElementSpace> fes0,
62 std::shared_ptr<mfem::ParMesh> pmesh,
63 std::shared_ptr<mfem::ParGridFunction> eta,
64 std::shared_ptr<mfem::ParGridFunction> alpha,
65 std::vector<std::shared_ptr<mfem::ParGridFunction> > &grad_u,
66 std::shared_ptr<Prandtl::PerssonPeraireIndicator> indicator,
67 mfem::real_t alpha_max)
70 std::string gas_model_string =
71 to_lower(runtime.value(
"gas_model", std::string{}));
73 std::string inv_flux_string =
74 to_lower(runtime.value(
"numerical_flux", std::string{}));
76 std::string flow_model_string =
77 to_lower(runtime.value(
"flow_model", std::string{}));
80 gas_model_string.empty() ||
81 gas_model_string ==
"cpg" ||
82 gas_model_string ==
"ideal" ||
83 gas_model_string ==
"ideal_gas";
86 gas_model_string ==
"lte";
89 inv_flux_string.empty() ||
90 inv_flux_string ==
"chandrashekar" ||
94 inv_flux_string ==
"hll";
97 inv_flux_string ==
"llf" ||
98 inv_flux_string ==
"lfr" ||
99 inv_flux_string ==
"laxfriedrichs" ||
100 inv_flux_string ==
"lax_friedrichs" ||
108 const bool inviscid = !viscous;
110 const int dim = pmesh->Dimension();
111 const int num_dofs_scalar = vfes->GetNDofs();
114 runtime.value(
"Pr", 0.72),
115 runtime.value(
"R_gas", 287.05),
116 runtime.value(
"mu", 0.02));
123 std::make_shared<Theseus::IdealGasModel>(physics_constants, layout);
124 std::string gasModelName(
"CPG1");
127 std::string numFluxName(
"Chandrashekar");
131 return MakeTypedRHSOperator<Physics, Theseus::IdealGasModel>(inviscid, runtime,
132 vfes, fes0, pmesh, eta, alpha, grad_u,
133 indicator, alpha_max, gas_model,
134 gasModelName, numFluxName);
138 std::string numFluxName(
"HLL");
143 return MakeTypedRHSOperator<Physics, Theseus::IdealGasModel>(inviscid, runtime,
144 vfes, fes0, pmesh, eta, alpha, grad_u,
145 indicator, alpha_max, gas_model,
146 gasModelName, numFluxName);
150 std::string numFluxName(
"LLF");
155 return MakeTypedRHSOperator<Physics, Theseus::IdealGasModel>(inviscid, runtime,
156 vfes, fes0, pmesh, eta, alpha, grad_u,
157 indicator, alpha_max, gas_model,
158 gasModelName, numFluxName);
161 std::cerr <<
"Error: Invalid Numerical Flux Type specified: "
162 << inv_flux_string <<
"\n"
163 <<
"Supported: Chandrashekar, LLF/LFR, HLL"
168 std::string mixture(runtime.value(
"gas_mixture",
"air5"));
169 std::string solver(runtime.value(
"plato_solver",
"LTE_table_rhoT_(air5)"));
170 std::string path(runtime.value(
"database_path", std::string(Theseus::BuildConfig::PlatoDBPath)));
171 std::string rho_dist(runtime.value(
"rho_dist",
"log"));
172 std::string T_dist(runtime.value(
"T_dist",
"log"));
173 int N_rho = runtime.value(
"N_rho", 101);
174 int N_T = runtime.value(
"N_T", 101);
175 mfem::real_t rho_min = runtime.value(
"rho_min", 0.1);
176 mfem::real_t rho_max = runtime.value(
"rho_max", 1.1);
177 mfem::real_t T_min = runtime.value(
"T_min", 250.0);
178 mfem::real_t T_max = runtime.value(
"T_max", 35.0);
179 int num_properties = 9;
180 auto lteData = std::make_unique<Theseus::LTETable::Data>();
181 auto <eTableData = *lteData;
183 lteTableData.lte_table.SetSize(N_rho * N_T * num_properties);
184 lteTableData.inv_table.SetSize(N_rho * N_T);
185 if(rho_dist ==
"log")
202 lteTableData.e_grid.SetSize(N_T);
203 lteTables.
L.
setup(N_rho, N_T);
205 if(mfem::Mpi::Root())
207 std::cout <<
"Constructing LTE table for " << mixture
208 <<
" with solver " << solver << std::endl
209 <<
"LTE Database: " << path << std::endl;
210 if(Theseus::LTETable::check_plato_database_path(path)){
211 std::cerr <<
"Plato Database (" << path <<
") not found." << std::endl;
214 mfem::real_t e_min, e_max;
215 std::string empty_str(
"empty");
216 plato_initialize(solver.c_str(), mixture.c_str(), empty_str.c_str(), empty_str.c_str(), path.c_str());
218 lteTableData.lte_table.GetData(), e_min, e_max);
219 std::cout <<
"Constructing inverse table T = T(rho, e)" << std::endl;
222 lteTableData.T_grid.GetData(), lteTableData.inv_table.GetData());
227 if(mfem::Mpi::Root()){
228 std::cerr <<
"LTE runs *must* have Theseus build with PLATO support (-DTHESEUS_WITH_PLATO)" << std::endl;
232 MPI_Bcast(lteTableData.lte_table.GetData(), N_rho * N_T * num_properties, MPI_DOUBLE, 0, pmesh->GetComm());
233 MPI_Bcast(lteTableData.inv_table.GetData(), N_rho * N_T, MPI_DOUBLE, 0, pmesh->GetComm());
234 MPI_Bcast(lteTableData.e_grid.GetData(), N_T, MPI_DOUBLE, 0, pmesh->GetComm());
236 lteTableData.
lte_table.HostRead(), lteTableData.inv_table.HostRead(),
237 lteTableData.rho_grid.HostRead(), lteTableData.T_grid.HostRead(),
238 lteTableData.e_grid.HostRead()
240 auto gas_model = std::make_shared<Theseus::LTEGas>(physics_constants, layout, lteTables);
241 std::string gasModelName(
"LTE:"+mixture);
244 std::string numFluxName(
"Chandrashekar");
252 std::cerr <<
"Error: Cannot use Chandrashekar flux with LTE" << std::endl;
257 std::string numFluxName(
"HLL");
262 auto rhsOp = MakeTypedRHSOperator<Physics, Theseus::LTEGas>(inviscid, runtime,
263 vfes, fes0, pmesh, eta, alpha, grad_u,
264 indicator, alpha_max, gas_model,
265 gasModelName, numFluxName);
268 operator_cache.lteTableData = std::move(lteData);
273 std::string numFluxName(
"LFR");
278 auto rhsOp = MakeTypedRHSOperator<Physics, Theseus::LTEGas>
279 (inviscid, runtime,vfes, fes0, pmesh, eta, alpha, grad_u,
280 indicator, alpha_max, gas_model,
281 gasModelName, numFluxName);
285 operator_cache.lteTableData = std::move(lteData);
289 std::cerr <<
"Error: Invalid Numerical Flux Type specified: "
290 << inv_flux_string <<
"\n"
291 <<
"Supported: Chandrashekar, LLF/LFR, HLL"
297 std::cerr <<
"Error: Invalid Gas Model specified: "
298 << gas_model_string <<
"\n"
299 <<
"Supported: CPG, LTE"