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  Copyright (C) 2012 by Bernd Flemisch
5  Copyright (C) 2011-2013 by Andreas Lauser
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 2 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
27 #ifndef OPM_FLUID_STATE_VISCOSITY_MODULES_HPP
28 #define OPM_FLUID_STATE_VISCOSITY_MODULES_HPP
29 
30 #include <opm/common/ErrorMacros.hpp>
31 #include <opm/common/Exceptions.hpp>
32 
35 
36 #include <algorithm>
37 
38 namespace Opm {
43 template <class Scalar,
44  int numPhases,
45  class Implementation>
47 {
48 public:
51 
55  Scalar viscosity(unsigned phaseIdx) const
56  { return viscosity_[phaseIdx]; }
57 
61  void setViscosity(unsigned phaseIdx, Scalar value)
62  { viscosity_[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  viscosity_[phaseIdx] = FsToolbox::template toLhs<Scalar>(fs.viscosity(phaseIdx));
75  }
76  }
77 
86  void checkDefined() const
87  {
89  }
90 
91 protected:
92  Scalar viscosity_[numPhases];
93 };
94 
99 template <class Scalar,
100  int numPhases,
101  class Implementation>
103 {
104 public:
106  { }
107 
111  Scalar viscosity(int /* phaseIdx */) const
112  { OPM_THROW(std::logic_error, "Viscosity is not provided by this fluid state"); }
113 
118  template <class FluidState>
119  void assign(const FluidState& /* fs */)
120  { }
121 
130  void checkDefined() const
131  { }
132 };
133 
134 } // namespace Opm
135 
136 #endif
void SetUndefined(const T &value OPM_UNUSED)
Make the memory on which an object resides undefined in valgrind runs.
Definition: Valgrind.hpp:138
Scalar viscosity(unsigned phaseIdx) const
The viscosity of a fluid phase [-].
Definition: FluidStateViscosityModules.hpp:55
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
Module for the modular fluid state which stores the viscosities explicitly.
Definition: FluidStateViscosityModules.hpp:46
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateViscosityModules.hpp:119
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
FluidStateExplicitViscosityModule()
Definition: FluidStateViscosityModules.hpp:49
Some templates to wrap the valgrind client request macros.
FluidStateNullViscosityModule()
Definition: FluidStateViscosityModules.hpp:105
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateViscosityModules.hpp:130
Module for the modular fluid state which does not the viscosities but throws std::logic_error instead...
Definition: FluidStateViscosityModules.hpp:102
Scalar viscosity(int) const
The viscosity of a fluid phase [-].
Definition: FluidStateViscosityModules.hpp:111
void setViscosity(unsigned phaseIdx, Scalar value)
Set the dynamic viscosity of a phase [Pa s].
Definition: FluidStateViscosityModules.hpp:61
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateViscosityModules.hpp:86
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateViscosityModules.hpp:69
Scalar viscosity_[numPhases]
Definition: FluidStateViscosityModules.hpp:92
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...