[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
euler_entropy_conserving_split_forms_check.cpp
1 #include "euler_entropy_conserving_split_forms_check.h"
2 #include "flow_solver/flow_solver_factory.h"
3 #include "flow_solver/flow_solver_cases/periodic_turbulence.h"
4 
5 namespace PHiLiP {
6 namespace Tests {
7 
8 template <int dim, int nstate>
10  const PHiLiP::Parameters::AllParameters *const parameters_input,
11  const dealii::ParameterHandler &parameter_handler_input)
12  : TestsBase::TestsBase(parameters_input)
13  , parameter_handler(parameter_handler_input)
14 {}
15 
16 template <int dim, int nstate>
18 {
19  int testfail = 0;
20  const unsigned int n_fluxes = 4;
21 
23  const std::array<TwoPtFluxEnum, n_fluxes> two_point_fluxes{{TwoPtFluxEnum::IR, TwoPtFluxEnum::CH, TwoPtFluxEnum::Ra, TwoPtFluxEnum::KG}};
24  const std::array<double, n_fluxes> tols{{5E-15, 5E-15, 5E-15, 1E-10}};
25  const std::array<std::string, n_fluxes> flux_names{{"Ismail-Roe", "Chandrashekar", "Ranocha", "Kennedy-Gruber"}};
26 
27  for (unsigned int i = 0; i < n_fluxes; ++i){
28  pcout << "-----------------------------------------------------------------------" << std::endl;
29  pcout << " Using " << flux_names[i] << " two-point flux" << std::endl;
30  pcout << "-----------------------------------------------------------------------" << std::endl;
31 
32  const TwoPtFluxEnum flux = two_point_fluxes[i];
33  const double tol = tols[i];
34 
35  // Copying parameters and modifying flux type
37  parameters.two_point_num_flux_type = flux;
38 
39  // Initialize flow_solver
40  std::unique_ptr<FlowSolver::FlowSolver<dim,nstate>> flow_solver = FlowSolver::FlowSolverFactory<dim,nstate>::select_flow_case(&parameters, parameter_handler);
41 
42  // Compute initial and final entropy
43  std::shared_ptr<FlowSolver::PeriodicTurbulence<dim, nstate>> flow_solver_case = std::dynamic_pointer_cast<FlowSolver::PeriodicTurbulence<dim, nstate>>(flow_solver->flow_solver_case);
44  flow_solver_case->compute_and_update_integrated_quantities(*flow_solver->dg);
45  const double initial_KE = flow_solver_case->get_integrated_kinetic_energy();
46 
47  static_cast<void>(flow_solver->run());
48  const double final_entropy = flow_solver_case->get_numerical_entropy(flow_solver->dg);
49  flow_solver_case->compute_and_update_integrated_quantities(*flow_solver->dg);
50  const double final_KE = flow_solver_case->get_integrated_kinetic_energy();
51 
52  //Compare initial and final entropy to confirm entropy preservation
53 
54  pcout << "Final numerical entropy: " << final_entropy << std::endl;
55  pcout << "Initial kinetic energy: " << std::setprecision(16) << initial_KE << std::endl
56  << "Final: " << final_KE << std::endl
57  << "Scaled difference: " << abs((initial_KE-final_KE)/initial_KE)
58  << std::endl << std::endl;
59 
60 
61  if (abs(final_entropy) > tol){
62  pcout << "Entropy change is not within allowable tolerance. Test failing." << std::endl;
63  testfail = 1;
64  } else pcout << "Entropy change is allowable." << std::endl;
65  }
66 
67  return testfail;
68 }
69 
70 #if PHILIP_DIM==3
72 #endif
73 } // Tests namespace
74 } // PHiLiP namespace
TwoPointNumericalFlux two_point_num_flux_type
Store selected TwoPointNumericalFlux from the input file.
Files for the baseline physics.
Definition: ADTypes.hpp:10
Main parameter class that contains the various other sub-parameter classes.
static std::unique_ptr< FlowSolver< dim, nstate > > select_flow_case(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler &parameter_handler_input)
Factory to return the correct flow solver given input file.
TwoPointNumericalFlux
Two point numerical flux type for split form.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
Definition: tests.h:20
EulerSplitEntropyCheck(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler &parameter_handler_input)
Constructor.
void compute_and_update_integrated_quantities(DGBase< dim, double > &dg)
dealii::ConditionalOStream pcout
ConditionalOStream.
Definition: tests.h:45
Base class of all the tests.
Definition: tests.h:17
const dealii::ParameterHandler & parameter_handler
Parameter handler for storing the .prm file being ran.