[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
taylor_green_vortex_energy_check.cpp
1 #include "taylor_green_vortex_energy_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  , kinetic_energy_expected(parameters_input->flow_solver_param.expected_kinetic_energy_at_final_time)
15  , theoretical_dissipation_rate_expected(parameters_input->flow_solver_param.expected_theoretical_dissipation_rate_at_final_time)
16 {}
17 
18 template <int dim, int nstate>
20 {
21  // Integrate to final time
22  std::unique_ptr<FlowSolver::FlowSolver<dim,nstate>> flow_solver = FlowSolver::FlowSolverFactory<dim,nstate>::select_flow_case(this->all_parameters, parameter_handler);
23  static_cast<void>(flow_solver->run());
24 
25  // Compute kinetic energy and theoretical dissipation rate
26  std::unique_ptr<FlowSolver::PeriodicTurbulence<dim, nstate>> flow_solver_case = std::make_unique<FlowSolver::PeriodicTurbulence<dim,nstate>>(this->all_parameters);
27  flow_solver_case->compute_and_update_integrated_quantities(*(flow_solver->dg));
28  const double kinetic_energy_computed = flow_solver_case->get_integrated_kinetic_energy();
29  const double theoretical_dissipation_rate_computed = flow_solver_case->get_vorticity_based_dissipation_rate();
30 
31  const double relative_error_kinetic_energy = abs(kinetic_energy_computed - kinetic_energy_expected)/kinetic_energy_expected;
32  const double relative_error_theoretical_dissipation_rate = abs(theoretical_dissipation_rate_computed - theoretical_dissipation_rate_expected)/theoretical_dissipation_rate_expected;
33  if (relative_error_kinetic_energy > 1.0e-10) {
34  pcout << "Computed kinetic energy is not within specified tolerance with respect to expected value." << std::endl;
35  return 1;
36  }
37  if (relative_error_theoretical_dissipation_rate > 1.0e-10) {
38  pcout << "Computed theoretical dissipation rate is not within specified tolerance with respect to expected value." << std::endl;
39  return 1;
40  }
41  pcout << " Test passed, computed kinetic energy and theoretical dissipation rate are within specified tolerance." << std::endl;
42  return 0;
43 }
44 
45 #if PHILIP_DIM==3
47 #endif
48 } // Tests namespace
49 } // PHiLiP namespace
Files for the baseline physics.
Definition: ADTypes.hpp:10
Main parameter class that contains the various other sub-parameter classes.
TaylorGreenVortexEnergyCheck(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler &parameter_handler_input)
Constructor.
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.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
Definition: tests.h:20
const dealii::ParameterHandler & parameter_handler
Parameter handler for storing the .prm file being ran.
const double theoretical_dissipation_rate_expected
Expected theoretical dissipation rate at final time.
dealii::ConditionalOStream pcout
ConditionalOStream.
Definition: tests.h:45
const double kinetic_energy_expected
Expected kinetic energy at final time.
Base class of all the tests.
Definition: tests.h:17