simple_cfl_1d.cpp
1 #include "simple_cfl_1d.hpp"
2 
3 using std::max;
4 
5 SimpleCFL1D::SimpleCFL1D(double cfl): cfl_(cfl)
6 {
7  assert(cfl>0);
8  assert(cfl<1);
9 }
10 
11 double SimpleCFL1D::operator()
12  (const SimulationState1D& ss,
13  const EquationOfState& eos) const
14 {
15  double idt = 0;
16  for(size_t i=0;i<ss.getCells().size();++i){
17  const ComputationalCell& cell = ss.getCells().at(i);
18  const double c = eos.dp2c(cell.density, cell.pressure);
19  const double dx = ss.getVertices().at(i+1) - ss.getVertices().at(i);
20  const double idt_candidate = (c+abs(cell.velocity))/dx;
21  idt = max(idt, idt_candidate);
22  }
23  assert(idt>0);
24  return cfl_/idt;
25 }
Simple CFL time step calculator.
const vector< double > & getVertices(void) const
Access to vertices.
double max(vector< double > const &v)
returns the maximal term in a vector
Definition: utils.cpp:52
SimpleCFL1D(double cfl)
Class constructor.
double pressure
Pressure.
const vector< ComputationalCell > & getCells(void) const
Access to hydro cells.
Base class for equation of state.
double abs(Vector3D const &v)
Norm of a vector.
Definition: Vector3D.cpp:44
Vector2D velocity
Velocity.
Package for computational domain and hydro cells.
Computational cell.