[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
khi_robustness.cpp
1 #include "khi_robustness.h"
2 #include "flow_solver/flow_solver_factory.h"
3 #include "flow_solver/flow_solver_cases/periodic_entropy_tests.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 {
20 
21  parameters.flow_solver_param.atwood_number = atwood_number;
22  parameters.flow_solver_param.unsteady_data_table_filename+=std::to_string(atwood_number);
23 
24  return parameters;
25 }
26 
27 template <int dim, int nstate>
29 {
30  const unsigned int n_runs = 2;
31  // Range of Atwood numbers to test
32  const double A_range[n_runs] = {0.8,0.9};
33  double end_times[n_runs] = {0};
34 
35  for (unsigned int i_run = 0; i_run < n_runs; ++i_run){
36  this->pcout << "--------------------------------------------------------------------" << std::endl
37  << " Starting run for A = " << A_range[i_run] << std::endl
38  << "--------------------------------------------------------------------" << std::endl;
39  //Define new parameters according to Atwood number
40  const Parameters::AllParameters params = reinit_params(A_range[i_run]);
41 
42  // Initialize flow_solver
43  std::unique_ptr<FlowSolver::FlowSolver<dim,nstate>> flow_solver = FlowSolver::FlowSolverFactory<dim,nstate>::select_flow_case(&params, parameter_handler);
44 
45  // Solve flow case
46  try{
47  static_cast<void>(flow_solver->run());
48  }
49  catch (double end) {
50  this->pcout << "WARNING: Flow simulation did not reach end_time. Crash at t = " << end << std::endl;
51  }
52 
53  end_times[i_run] = flow_solver->ode_solver->current_time;
54 
55  this->pcout << "End times for all runs so far:" << std::endl;
56  for (unsigned int j = 0; j < i_run+1; ++j){
57  this->pcout << " A = " << A_range[j] << " end_time = " << end_times[j] << std::endl;
58  }
59  this->pcout << std::endl << std::endl;
60 
61  if (mpi_rank==0){
62  std::ofstream current_end_times;
63  current_end_times.open("khi_end_times.txt");
64  for (unsigned int j = 0; j < i_run+1; ++j){
65  current_end_times << A_range[j] << " " << end_times[j] << std::endl;
66  }
67  current_end_times.close();
68  }
69  }
70 
71  return 0; //Always pass as the flow_solver runs are expected to crash
72 }
73 
74 #if PHILIP_DIM==2
76 #endif
77 } // Tests namespace
78 } // PHiLiP namespace
const dealii::ParameterHandler & parameter_handler
Parameter handler for storing the .prm file being ran.
KHIRobustness(const Parameters::AllParameters *const parameters_input, const dealii::ParameterHandler &parameter_handler_input)
Constructor.
FlowSolverParam flow_solver_param
Contains the parameters for simulation cases (flow solver test)
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.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
Definition: tests.h:20
const int mpi_rank
MPI rank.
Definition: tests.h:40
double atwood_number
For KHI, the atwood number.
dealii::ConditionalOStream pcout
ConditionalOStream.
Definition: tests.h:45
KHI Robustness test.
Parameters::AllParameters reinit_params(double atwood_number) const
Reinit parameters based on a specified Atwood number.
Base class of all the tests.
Definition: tests.h:17
int run_test() const override
Run test.