ExplicitArraysFluidState.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2015 Andreas Lauser
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_EXPLICIT_ARRAYS_FLUID_STATE_HEADER_INCLUDED
21 #define OPM_EXPLICIT_ARRAYS_FLUID_STATE_HEADER_INCLUDED
22 
24 
25 #include <array>
26 
27 namespace Opm
28 {
29 
37 {
38 public:
39  typedef double Scalar;
41 
42  explicit ExplicitArraysFluidState(const PhaseUsage& phaseUsage)
43  : phaseUsage_(phaseUsage)
44  {}
45 
52  void setIndex(unsigned arrayIdx)
53  {
54  int np = phaseUsage_.num_phases;
55  for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
56  if (!phaseUsage_.phase_used[phaseIdx]) {
57  sats_[phaseIdx] = 0.0;
58  }
59  else {
60  sats_[phaseIdx] = saturations_[np*arrayIdx + phaseUsage_.phase_pos[phaseIdx]];
61  }
62  }
63  }
64 
73  void setSaturationArray(const double* saturations)
74  { saturations_ = saturations; }
75 
79  Scalar saturation(int phaseIdx) const
80  { return sats_[phaseIdx]; }
81 
82  // TODO (?) temperature, pressure, composition, etc
83 
84 private:
85  const PhaseUsage phaseUsage_;
86  const double* saturations_;
87  std::array<Scalar, BlackoilPhases::MaxNumPhases> sats_;
88 };
89 
90 } // namespace Opm
91 
92 #endif // OPM_SIMULATORTIMER_HEADER_INCLUDED
Definition: AnisotropicEikonal.hpp:43
int phase_used[MaxNumPhases]
Definition: BlackoilPhases.hpp:39
int phase_pos[MaxNumPhases]
Definition: BlackoilPhases.hpp:40
void setIndex(unsigned arrayIdx)
Sets the currently used array index.
Definition: ExplicitArraysFluidState.hpp:52
int num_phases
Definition: BlackoilPhases.hpp:38
double Scalar
Definition: ExplicitArraysFluidState.hpp:39
This is a fluid state which translates global arrays and translates them to a subset of the fluid sta...
Definition: ExplicitArraysFluidState.hpp:36
ExplicitArraysFluidState(const PhaseUsage &phaseUsage)
Definition: ExplicitArraysFluidState.hpp:42
Scalar saturation(int phaseIdx) const
Returns the saturation of a phase for the current cell index.
Definition: ExplicitArraysFluidState.hpp:79
void setSaturationArray(const double *saturations)
Set the array containing the phase saturations.
Definition: ExplicitArraysFluidState.hpp:73
Definition: ExplicitArraysFluidState.hpp:40
static const int MaxNumPhases
Definition: BlackoilPhases.hpp:30
Definition: BlackoilPhases.hpp:36