opm-common
Loading...
Searching...
No Matches
FluidStateViscosityModules.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_VISCOSITY_MODULES_HPP
29#define OPM_FLUID_STATE_VISCOSITY_MODULES_HPP
30
33
34#include <array>
35
36namespace Opm {
41template <class ValueType,
42 unsigned numPhases,
43 class Implementation>
44class FluidStateExplicitViscosityModule
45{
46public:
47 FluidStateExplicitViscosityModule()
48 { Valgrind::SetUndefined(viscosity_); }
49
53 const ValueType& viscosity(unsigned phaseIdx) const
54 { return viscosity_[phaseIdx]; }
55
59 void setViscosity(unsigned phaseIdx, ValueType value)
60 { viscosity_[phaseIdx] = value; }
61
66 template <class FluidState>
67 void assign(const FluidState& fs)
68 {
69 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
70 viscosity_[phaseIdx] = decay<ValueType>(fs.viscosity(phaseIdx));
71 }
72 }
73
82 void checkDefined() const
83 {
84 Valgrind::CheckDefined(viscosity_);
85 }
86
87protected:
88 std::array<ValueType, numPhases> viscosity_{};
89};
90
95template <class ValueT,
96 unsigned numPhases,
97 class Implementation>
98class FluidStateNullViscosityModule
99{
100public:
101 FluidStateNullViscosityModule()
102 { }
103
107 const ValueT& viscosity(unsigned /* phaseIdx */) const
108 { throw std::logic_error("Viscosity is not provided by this fluid state"); }
109
114 template <class FluidState>
115 void assign(const FluidState& /* fs */)
116 { }
117
126 void checkDefined() const
127 { }
128};
129
130} // namespace Opm
131
132#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 FluidStateViscosityModules.hpp:67
const ValueType & viscosity(unsigned phaseIdx) const
The viscosity of a fluid phase [-].
Definition FluidStateViscosityModules.hpp:53
void setViscosity(unsigned phaseIdx, ValueType value)
Set the dynamic viscosity of a phase [Pa s].
Definition FluidStateViscosityModules.hpp:59
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateViscosityModules.hpp:82
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateViscosityModules.hpp:126
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateViscosityModules.hpp:115
const ValueT & viscosity(unsigned) const
The viscosity of a fluid phase [-].
Definition FluidStateViscosityModules.hpp:107
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30