[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
dipole_wall_collision_unsteady_quantity_check.cpp
1 #include "dipole_wall_collision_unsteady_quantity_check.h"
2 #include "flow_solver/flow_solver_factory.h"
3 #include "flow_solver/flow_solver_cases/dipole_wall_collision.h"
4 
5 namespace PHiLiP {
6 namespace Tests {
7 
8 template <int dim, int nspecies, 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  , enstrophy_expected(parameters_input->flow_solver_param.expected_enstrophy_at_final_time)
16  , palinstrophy_expected(parameters_input->flow_solver_param.expected_palinstrophy_at_final_time)
17 {}
18 
19 template <int dim, int nspecies, int nstate>
21 {
22  // Integrate to final time
23  std::unique_ptr<FlowSolver::FlowSolver<dim,nspecies,nstate>> flow_solver = FlowSolver::FlowSolverFactory<dim,nspecies,nstate>::select_flow_case(this->all_parameters, parameter_handler);
24  static_cast<void>(flow_solver->run());
25 
26  // Compute kinetic energy, enstrophy, and palinstrophy
27  std::unique_ptr<FlowSolver::DipoleWallCollision<dim, nspecies, nstate>> flow_solver_case = std::make_unique<FlowSolver::DipoleWallCollision<dim,nspecies,nstate>>(this->all_parameters);
28  flow_solver_case->compute_and_update_integrated_quantities(*(flow_solver->dg));
29  const double kinetic_energy_computed = flow_solver_case->get_integrated_incompressible_kinetic_energy();
30  const double enstrophy_computed = flow_solver_case->get_integrated_incompressible_enstrophy();
31  const double palinstrophy_computed = flow_solver_case->get_integrated_incompressible_palinstrophy();
32 
33  const double relative_error_kinetic_energy = abs(kinetic_energy_computed - kinetic_energy_expected)/kinetic_energy_expected;
34  const double relative_error_enstrophy = abs(enstrophy_computed - enstrophy_expected)/enstrophy_expected;
35  const double relative_error_palinstrophy = abs(palinstrophy_computed - palinstrophy_expected)/palinstrophy_expected;
36  if (relative_error_kinetic_energy > 1.0e-10) {
37  pcout << "Computed kinetic energy is not within specified tolerance with respect to expected value." << std::endl;
38  return 1;
39  }
40  if (relative_error_enstrophy > 1.0e-10) {
41  pcout << "Computed enstrophy is not within specified tolerance with respect to expected value." << std::endl;
42  return 1;
43  }
44  if (relative_error_palinstrophy > 1.0e-10) {
45  pcout << "Computed palinstrophy is not within specified tolerance with respect to expected value." << std::endl;
46  return 1;
47  }
48  pcout << " Test passed, computed kinetic energy, enstrophy, and palinstrophy are within specified tolerance." << std::endl;
49  return 0;
50 }
51 
52 #if PHILIP_DIM==2
54 #endif
55 } // Tests namespace
56 } // PHiLiP namespace
const double kinetic_energy_expected
Expected kinetic energy at final time.
Files for the baseline physics.
Definition: ADTypes.hpp:10
static std::unique_ptr< FlowSolver< dim, nspecies, 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.
Main parameter class that contains the various other sub-parameter classes.
const dealii::ParameterHandler & parameter_handler
Parameter handler for storing the .prm file being ran.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
Definition: tests.h:20
DipoleWallCollisionUnsteadyQuantityCheck(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler &parameter_handler_input)
Constructor.
dealii::ConditionalOStream pcout
ConditionalOStream.
Definition: tests.h:45
Base class of all the tests.
Definition: tests.h:17