CourantFriedrichsLewy.cpp
2 #include "../../misc/utils.hpp"
3 #include "../../misc/lazy_list.hpp"
4 
6 cfl_(cfl)
7 {
8  assert(cfl_<1 && "cfl number must be smaller than 1");
9 }
10 
11 namespace
12 {
13  class TimeStepBoundCalculator: public LazyList<double>
14  {
15  public:
16 
17  TimeStepBoundCalculator(const Tessellation3D& tess,
18  const vector<ComputationalCell>& cells,
19  const EquationOfState& eos):
20  tess_(tess), cells_(cells), eos_(eos) {}
21 
22  size_t size(void) const
23  {
24  return cells_.size();
25  }
26 
27  double operator[](size_t i) const
28  {
29  return tess_.GetWidth(i)/
30  (abs(cells_[i].velocity)+
31  eos_.dp2c(cells_[i].density,cells_[i].pressure));
32  }
33 
34  private:
35  const Tessellation3D& tess_;
36  const vector<ComputationalCell>& cells_;
37  const EquationOfState& eos_;
38  };
39 }
40 
41 double CourantFriedrichsLewy::operator()
42  (const Tessellation3D& tess,
43  const vector<ComputationalCell>& cells,
44  const EquationOfState& eos) const
45 {
46  return cfl_*lazy_min(TimeStepBoundCalculator(tess,cells,eos));
47 }
T lazy_min(const LazyList< T > &i2m)
Finds the minimum of a lazy list.
Definition: lazy_list.hpp:186
Abstract class for tessellation in 3D.
Ordered list whose terms are evaluated lazily.
Definition: lazy_list.hpp:17
virtual double operator[](const size_t i) const=0
Returns a single member of the list.
Base class for equation of state.
CourantFriedrichsLewy(double cfl)
Class constructor.
Calculates the time step according to the CFL criterion.
double abs(Vector3D const &v)
Norm of a vector.
Definition: Vector3D.cpp:44
virtual size_t size(void) const=0
Returns the length of the list.