[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
ode_solver_base.h
1 #ifndef __ODE_SOLVER_BASE__
2 #define __ODE_SOLVER_BASE__
3 
4 #include <deal.II/base/conditional_ostream.h>
5 #include <deal.II/base/table_handler.h>
6 #include <deal.II/lac/vector.h>
7 #include "parameters/all_parameters.h"
8 #include "limiter/bound_preserving_limiter_factory.hpp"
9 #include <iostream>
10 #include <stdexcept>
11 
12 #include "dg/dg_base.hpp"
13 #include "parameters/all_parameters.h"
14 #include "reduced_order/pod_basis_base.h"
15 
16 namespace PHiLiP {
17 namespace ODE {
18 
20 
21 #if PHILIP_DIM==1
22 template <int dim, typename real, typename MeshType = dealii::Triangulation<dim>>
23 #else
24 template <int dim, typename real, typename MeshType = dealii::parallel::distributed::Triangulation<dim>>
25 #endif
27 {
28 public:
30  explicit ODESolverBase(std::shared_ptr< DGBase<dim, real, MeshType> > dg_input,
32 
34  ODESolverBase(std::shared_ptr< DGBase<dim, real, MeshType> > dg_input);
35 
36  virtual ~ODESolverBase() = default;
37 
39  dealii::TableHandler solutions_table;
40 
43  const unsigned int current_iteration,
44  const double current_residual,
45  const std::shared_ptr <dealii::TableHandler> data_table) const;
46 
48  virtual int steady_state ();
49 
50 
52 
58  void initialize_steady_polynomial_ramping (const unsigned int global_final_poly_degree);
59 
60 
62 
64  void valid_initial_conditions () const;
65 
67  int advance_solution_time (double time_advance);
68 
70  virtual void step_in_time(real dt, const bool pseudotime) = 0;
71 
73  virtual double get_automatic_error_adaptive_step_size (real dt, const bool pseudotime);
74 
76  virtual double get_automatic_initial_step_size (real dt, const bool pseudotime);
77 
79  virtual void allocate_ode_system () = 0;
80 
81  double residual_norm;
83 
84 protected:
86 
90  double CFL_factor;
91 
92  double update_norm;
94 
96  dealii::LinearAlgebra::distributed::Vector<double> solution_update;
97 
98 public:
100  std::shared_ptr<DGBase<dim,real,MeshType>> dg;
101 
103  std::shared_ptr<ProperOrthogonalDecomposition::PODBase<dim>> pod;
104 
106  std::unique_ptr<BoundPreservingLimiter<dim,real>> limiter;
107 
108 protected:
111 
114 
115 public:
117 
118  double current_time;
119 
121 
122  unsigned int current_iteration;
123 
125 
128 
130  double get_original_time_step() const;
131 
133  double get_modified_time_step() const;
134 
135 protected:
138 public:
139 
141 
144 
146 
149 
150 protected:
151  const MPI_Comm mpi_communicator;
152  const int mpi_rank;
153  dealii::ConditionalOStream pcout;
154 };
155 } // ODE namespace
156 } // PHiLiP namespace
157 
158 #endif
virtual void step_in_time(real dt, const bool pseudotime)=0
Virtual function to evaluate solution update.
double FR_entropy_contribution_RRK_solver
Entropy FR correction at the current timestep.
std::shared_ptr< ProperOrthogonalDecomposition::PODBase< dim > > pod
Smart pointer to PODBasis.
const MPI_Comm mpi_communicator
MPI communicator.
virtual int steady_state()
Evaluate steady state solution.
double CFL_factor
CFL factor for (un)successful linesearches.
const int mpi_rank
MPI rank.
int advance_solution_time(double time_advance)
Function to advance solution to time+dt.
double modified_time_step
Modified time step after calling step_in_time.
virtual ~ODESolverBase()=default
Destructor.
dealii::LinearAlgebra::distributed::Vector< double > solution_update
Solution update given by the ODE solver.
void write_ode_solver_steady_state_convergence_data_to_table(const unsigned int current_iteration, const double current_residual, const std::shared_ptr< dealii::TableHandler > data_table) const
Writes the ode solver steady state convergence data to a file.
unsigned int current_iteration
Current iteration.
void initialize_steady_polynomial_ramping(const unsigned int global_final_poly_degree)
Ramps up the solution from p0 all the way up to the given global_final_poly_degree.
double current_desired_time_for_output_solution_every_dt_time_intervals
Current desired time for output solution every dt time intervals.
Files for the baseline physics.
Definition: ADTypes.hpp:10
Base class ODE solver.
double residual_norm_decrease
Current residual norm normalized by initial residual. Only makes sense for steady state...
double initial_residual_norm
Initial residual norm.
double original_time_step
Original time step before calling step_in_time.
double get_modified_time_step() const
Getter for modified_time_step.
Main parameter class that contains the various other sub-parameter classes.
ODESolverBase(std::shared_ptr< DGBase< dim, real, MeshType > > dg_input, std::shared_ptr< ProperOrthogonalDecomposition::PODBase< dim >> pod)
Default constructor that will set the constants.
double current_time
Useful for accurate time-stepping.
const Parameters::AllParameters *const all_parameters
Input parameters.
double relaxation_parameter_RRK_solver
Relaxation parameter.
double residual_norm
Current residual norm. Only makes sense for steady state.
const Parameters::ODESolverParam ode_param
Input ODE solver parameters.
void valid_initial_conditions() const
Checks whether the DG vector has valid values.
dealii::ConditionalOStream pcout
Parallel std::cout that only outputs on mpi_rank==0.
double get_original_time_step() const
Getter for original_time_step.
virtual double get_automatic_initial_step_size(real dt, const bool pseudotime)
Virtual function to evaluate initial automatic error adaptive time step.
virtual void allocate_ode_system()=0
Virtual function to allocate the ODE system.
Parameters related to the ODE solver.
std::unique_ptr< BoundPreservingLimiter< dim, real > > limiter
Pointer to BoundPreservingLimiter.
virtual double get_automatic_error_adaptive_step_size(real dt, const bool pseudotime)
Virtual function to evaluate automatic error adaptive time step.
double update_norm
Norm of the solution update.
DGBase is independent of the number of state variables.
Definition: dg_base.hpp:82
dealii::TableHandler solutions_table
Table used to output solution vector at each time step.
std::shared_ptr< DGBase< dim, real, MeshType > > dg
Smart pointer to DGBase.