FluidStatePressureModules.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_PRESSURE_MODULES_HPP
27 #define OPM_FLUID_STATE_PRESSURE_MODULES_HPP
28 
31 #include <opm/common/Exceptions.hpp>
32 #include <opm/common/ErrorMacros.hpp>
33 
34 #include <algorithm>
35 
36 namespace Opm {
37 
42 template <class Scalar,
43  int numPhases,
44  class Implementation>
46 {
47 public:
50 
54  const Scalar& pressure(unsigned phaseIdx) const
55  { return pressure_[phaseIdx]; }
56 
57 
61  void setPressure(unsigned phaseIdx, const Scalar& value)
62  { pressure_[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  pressure_[phaseIdx] = FsToolbox::template toLhs<Scalar>(fs.pressure(phaseIdx));
75  }
76  }
77 
86  void checkDefined() const
87  {
89  }
90 
91 protected:
92  Scalar pressure_[numPhases];
93 };
94 
99 template <class Scalar>
101 {
102 public:
104  { }
105 
109  const Scalar& pressure(int /* phaseIdx */) const
110  { OPM_THROW(std::logic_error, "Pressure is not provided by this fluid state"); }
111 
112 
117  template <class FluidState>
118  void assign(const FluidState& /* fs */)
119  { }
120 
129  void checkDefined() const
130  { }
131 };
132 
133 } // namespace Opm
134 
135 #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
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
Module for the modular fluid state which does not the pressures but throws std::logic_error instead...
Definition: FluidStatePressureModules.hpp:100
Some templates to wrap the valgrind client request macros.
const Scalar & pressure(unsigned phaseIdx) const
The pressure of a fluid phase [Pa].
Definition: FluidStatePressureModules.hpp:54
void setPressure(unsigned phaseIdx, const Scalar &value)
Set the pressure of a phase [Pa].
Definition: FluidStatePressureModules.hpp:61
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStatePressureModules.hpp:69
FluidStateExplicitPressureModule()
Definition: FluidStatePressureModules.hpp:48
Scalar pressure_[numPhases]
Definition: FluidStatePressureModules.hpp:92
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStatePressureModules.hpp:129
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStatePressureModules.hpp:118
Module for the modular fluid state which stores the pressures explicitly.
Definition: FluidStatePressureModules.hpp:45
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStatePressureModules.hpp:86
const Scalar & pressure(int) const
The pressure of a fluid phase [Pa].
Definition: FluidStatePressureModules.hpp:109
FluidStateNullPressureModule()
Definition: FluidStatePressureModules.hpp:103
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...