FluidStateSaturationModules.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  Copyright (C) 2011-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
26 #ifndef OPM_FLUID_STATE_SATURATION_MODULES_HPP
27 #define OPM_FLUID_STATE_SATURATION_MODULES_HPP
28 
29 #include <opm/common/ErrorMacros.hpp>
30 #include <opm/common/Exceptions.hpp>
31 
34 
35 #include <algorithm>
36 
37 namespace Opm {
38 
43 template <class Scalar,
44  int numPhases,
45  class Implementation>
47 {
48 public:
51 
55  const Scalar& saturation(unsigned phaseIdx) const
56  { return saturation_[phaseIdx]; }
57 
61  void setSaturation(unsigned phaseIdx, const Scalar& value)
62  { saturation_[phaseIdx] = value; }
63 
68  template <class FluidState>
69  void assign(const FluidState& fs)
70  {
71  typedef typename FluidState::Scalar FsScalar;
72  typedef Opm::MathToolbox<FsScalar> FsToolbox;
73  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
74  saturation_[phaseIdx] = FsToolbox::template toLhs<Scalar>(fs.saturation(phaseIdx));
75  }
76  }
77 
86  void checkDefined() const
87  {
89  }
90 
91 protected:
92  Scalar saturation_[numPhases];
93 };
94 
99 template <class Scalar>
101 {
102 public:
104  { }
105 
109  const Scalar& saturation(int /* phaseIdx */) const
110  { OPM_THROW(std::runtime_error, "Saturation is not provided by this fluid state"); }
111 
116  template <class FluidState>
117  void assign(const FluidState& /* fs */)
118  { }
119 
128  void checkDefined() const
129  { }
130 };
131 
132 } // namespace Opm
133 
134 #endif
void SetUndefined(const T &value OPM_UNUSED)
Make the memory on which an object resides undefined in valgrind runs.
Definition: Valgrind.hpp:138
bool CheckDefined(const T &value OPM_UNUSED)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition: Valgrind.hpp:74
FluidStateNullSaturationModule()
Definition: FluidStateSaturationModules.hpp:103
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
Some templates to wrap the valgrind client request macros.
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateSaturationModules.hpp:86
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateSaturationModules.hpp:117
void setSaturation(unsigned phaseIdx, const Scalar &value)
Set the saturation of a phase [-].
Definition: FluidStateSaturationModules.hpp:61
const Scalar & saturation(unsigned phaseIdx) const
The saturation of a fluid phase [-].
Definition: FluidStateSaturationModules.hpp:55
Module for the modular fluid state which does not the saturations but throws std::logic_error instead...
Definition: FluidStateSaturationModules.hpp:100
const Scalar & saturation(int) const
The saturation of a fluid phase [-].
Definition: FluidStateSaturationModules.hpp:109
Scalar saturation_[numPhases]
Definition: FluidStateSaturationModules.hpp:92
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateSaturationModules.hpp:69
FluidStateExplicitSaturationModule()
Definition: FluidStateSaturationModules.hpp:49
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateSaturationModules.hpp:128
Module for the modular fluid state which stores the saturations explicitly.
Definition: FluidStateSaturationModules.hpp:46
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...