SimulatorState.hpp
Go to the documentation of this file.
1 // Copyright (C) 2013 Uni Research AS
2 // Copyright (C) 2015 IRIS AS
3 // This file is licensed under the GNU General Public License v3.0
4 
5 #ifndef OPM_SIMULATORSTATE_HEADER_INCLUDED
6 #define OPM_SIMULATORSTATE_HEADER_INCLUDED
7 
8 #include <vector>
9 #include <string>
10 
11 // forward declaration
12 struct UnstructuredGrid;
13 
14 namespace Opm
15 {
17  {
18  public:
19 
20  virtual void init(const UnstructuredGrid& g, int num_phases);
21 
22  virtual void init(int number_of_cells, int number_of_faces, int num_phases);
23 
25 
26  protected:
28  static const int pressureId_ = 0;
30  static const int temperatureId_ = 1;
32  static const int saturationId_ = 2;
33 
35  static const int facePressureId_ = 0;
37  static const int faceFluxId_ = 1;
38 
47  template <typename Props>
48  void setFirstSat(const std::vector<int>& cells,
49  const Props& props,
50  ExtremalSat es);
51  public:
52  int numPhases() const { return num_phases_; }
53  int numCells () const { return num_cells_; }
54  int numFaces () const { return num_faces_; }
55 
56  std::vector<double>& pressure () { return cellData_[ pressureId_ ]; }
57  std::vector<double>& temperature () { return cellData_[ temperatureId_ ]; }
58  std::vector<double>& facepressure() { return faceData_[ facePressureId_]; }
59  std::vector<double>& faceflux () { return faceData_[ faceFluxId_ ]; }
60  std::vector<double>& saturation () { return cellData_[ saturationId_ ]; }
61 
62  const std::vector<double>& pressure () const { return cellData_[ pressureId_ ]; }
63  const std::vector<double>& temperature () const { return cellData_[ temperatureId_ ]; }
64  const std::vector<double>& facepressure() const { return faceData_[ facePressureId_]; }
65  const std::vector<double>& faceflux () const { return faceData_[ faceFluxId_ ]; }
66  const std::vector<double>& saturation () const { return cellData_[ saturationId_ ]; }
67 
72  virtual bool equals(const SimulatorState& other,
73  double epsilon = 1e-8) const;
74 
75  std::vector< std::vector<double> >& cellData() { return cellData_; }
76  const std::vector< std::vector<double> >& cellData() const { return cellData_; }
77 
78  std::vector< std::vector<double> >& faceData() { return faceData_; }
79  const std::vector< std::vector<double> >& faceData() const { return faceData_; }
80 
81  const std::vector< std::string >& cellDataNames() const { return cellDataNames_; }
82  const std::vector< std::string >& faceDataNames() const { return faceDataNames_; }
83 
84  size_t registerCellData( const std::string& name, const int components, const double initialValue = 0.0 );
85  size_t registerFaceData( const std::string& name, const int components, const double initialValue = 0.0 );
86  private:
87  int num_cells_;
88  int num_faces_;
89  int num_phases_;
90 
92  std::vector< std::vector< double > > cellData_;
94  std::vector< std::vector< double > > faceData_;
95 
97  std::vector< std::string > cellDataNames_;
99  std::vector< std::string > faceDataNames_;
100 
101  protected:
111  static bool vectorApproxEqual(const std::vector<double>& v1,
112  const std::vector<double>& v2,
113  double epsilon);
114  };
115 
116 } // namespace Opm
117 
118 #endif // OPM_SIMULATORSTATE_HEADER_INCLUDED
void setFirstSat(const std::vector< int > &cells, const Props &props, ExtremalSat es)
int numFaces() const
Definition: SimulatorState.hpp:54
Definition: grid.h:98
std::vector< double > & facepressure()
Definition: SimulatorState.hpp:58
const std::vector< double > & facepressure() const
Definition: SimulatorState.hpp:64
Definition: AnisotropicEikonal.hpp:43
Definition: SimulatorState.hpp:24
std::vector< double > & saturation()
Definition: SimulatorState.hpp:60
static bool vectorApproxEqual(const std::vector< double > &v1, const std::vector< double > &v2, double epsilon)
std::vector< std::vector< double > > & faceData()
Definition: SimulatorState.hpp:78
Definition: SimulatorState.hpp:16
static const int facePressureId_
pressure per face.
Definition: SimulatorState.hpp:35
virtual void init(const UnstructuredGrid &g, int num_phases)
const std::vector< std::vector< double > > & faceData() const
Definition: SimulatorState.hpp:79
const std::vector< double > & saturation() const
Definition: SimulatorState.hpp:66
static const int temperatureId_
temperature per cell.
Definition: SimulatorState.hpp:30
int numPhases() const
Definition: SimulatorState.hpp:52
static const int faceFluxId_
The fluxes at the faces.
Definition: SimulatorState.hpp:37
const std::vector< double > & temperature() const
Definition: SimulatorState.hpp:63
const std::vector< std::string > & faceDataNames() const
Definition: SimulatorState.hpp:82
std::vector< double > & temperature()
Definition: SimulatorState.hpp:57
std::vector< double > & faceflux()
Definition: SimulatorState.hpp:59
virtual bool equals(const SimulatorState &other, double epsilon=1e-8) const
std::vector< std::vector< double > > & cellData()
Definition: SimulatorState.hpp:75
Definition: SimulatorState.hpp:24
int numCells() const
Definition: SimulatorState.hpp:53
const std::vector< double > & faceflux() const
Definition: SimulatorState.hpp:65
const std::vector< double > & pressure() const
Definition: SimulatorState.hpp:62
size_t registerFaceData(const std::string &name, const int components, const double initialValue=0.0)
static const int saturationId_
The saturation of each phase per cell.
Definition: SimulatorState.hpp:32
static const int pressureId_
pressure per cell.
Definition: SimulatorState.hpp:28
std::vector< double > & pressure()
Definition: SimulatorState.hpp:56
size_t registerCellData(const std::string &name, const int components, const double initialValue=0.0)
const std::vector< std::vector< double > > & cellData() const
Definition: SimulatorState.hpp:76
ExtremalSat
Definition: SimulatorState.hpp:24
const std::vector< std::string > & cellDataNames() const
Definition: SimulatorState.hpp:81