opm-common
Loading...
Searching...
No Matches
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 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 2 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 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef OPM_FLUID_STATE_SATURATION_MODULES_HPP
29#define OPM_FLUID_STATE_SATURATION_MODULES_HPP
30
33
34#include <array>
35
36namespace Opm {
37
42template <class ValueType,
43 unsigned numPhases,
44 class Implementation>
45class FluidStateExplicitSaturationModule
46{
47public:
48 FluidStateExplicitSaturationModule()
49 { Valgrind::SetUndefined(saturation_); }
50
54 const ValueType& saturation(unsigned phaseIdx) const
55 { return saturation_[phaseIdx]; }
56
60 void setSaturation(unsigned phaseIdx, const ValueType& value)
61 { saturation_[phaseIdx] = value; }
62
67 template <class FluidState>
68 void assign(const FluidState& fs)
69 {
70 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
71 saturation_[phaseIdx] = decay<ValueType>(fs.saturation(phaseIdx));
72 }
73 }
74
83 void checkDefined() const
84 {
85 Valgrind::CheckDefined(saturation_);
86 }
87
88protected:
89 std::array<ValueType, numPhases> saturation_{};
90};
91
96template <class ValueT>
97class FluidStateNullSaturationModule
98{
99public:
100 FluidStateNullSaturationModule()
101 { }
102
106 const ValueT& saturation(unsigned /* phaseIdx */) const
107 { throw std::runtime_error("Saturation is not provided by this fluid state"); }
108
113 template <class FluidState>
114 void assign(const FluidState& /* fs */)
115 { }
116
125 void checkDefined() const
126 { }
127};
128
129} // namespace Opm
130
131#endif
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE void SetUndefined(const T &value)
Make the memory on which an object resides undefined in valgrind runs.
Definition Valgrind.hpp:174
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateSaturationModules.hpp:68
void setSaturation(unsigned phaseIdx, const ValueType &value)
Set the saturation of a phase [-].
Definition FluidStateSaturationModules.hpp:60
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateSaturationModules.hpp:83
const ValueType & saturation(unsigned phaseIdx) const
The saturation of a fluid phase [-].
Definition FluidStateSaturationModules.hpp:54
const ValueT & saturation(unsigned) const
The saturation of a fluid phase [-].
Definition FluidStateSaturationModules.hpp:106
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateSaturationModules.hpp:114
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateSaturationModules.hpp:125
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30