EffToAbsLawParams.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) 2009-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 */
25 #ifndef OPM_EFF_TO_ABS_LAW_PARAMS_HPP
26 #define OPM_EFF_TO_ABS_LAW_PARAMS_HPP
27 
28 #include <cassert>
29 
30 namespace Opm {
38 template <class EffLawParamsT, int numPhases>
39 class EffToAbsLawParams : public EffLawParamsT
40 {
41  typedef EffLawParamsT EffLawParams;
42  typedef typename EffLawParams::Traits::Scalar Scalar;
43 
44 public:
45  typedef typename EffLawParams::Traits Traits;
46 
47 
49  : EffLawParams()
50  {
51  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
52  residualSaturation_[phaseIdx] = 0.0;
53 
54 #ifndef NDEBUG
55  finalized_ = false;
56 #endif
57  }
58 
63  void finalize()
64  {
65  sumResidualSaturations_ = 0.0;
66  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
67  sumResidualSaturations_ += residualSaturation_[phaseIdx];
68 
69  EffLawParams::finalize();
70 
71 #ifndef NDEBUG
72  finalized_ = true;
73 #endif
74  }
75 
79  Scalar residualSaturation(unsigned phaseIdx) const
80  { assertFinalized_(); return residualSaturation_[phaseIdx]; }
81 
85  Scalar sumResidualSaturations() const
86  { assertFinalized_(); return sumResidualSaturations_; }
87 
91  void setResidualSaturation(unsigned phaseIdx, Scalar value)
92  { residualSaturation_[phaseIdx] = value; }
93 
94 private:
95 #ifndef NDEBUG
96  void assertFinalized_() const
97  { assert(finalized_); }
98 
99  bool finalized_;
100 #else
101  void assertFinalized_() const
102  { }
103 #endif
104 
105  Scalar residualSaturation_[numPhases];
106  Scalar sumResidualSaturations_;
107 };
108 
109 } // namespace Opm
110 
111 #endif
EffLawParams::Traits Traits
Definition: EffToAbsLawParams.hpp:45
A default implementation of the parameters for the adapter class to convert material laws from effect...
Definition: EffToAbsLawParams.hpp:39
Definition: Air_Mesitylene.hpp:31
Scalar residualSaturation(unsigned phaseIdx) const
Return the residual saturation of a phase.
Definition: EffToAbsLawParams.hpp:79
EffToAbsLawParams()
Definition: EffToAbsLawParams.hpp:48
void setResidualSaturation(unsigned phaseIdx, Scalar value)
Set the residual saturation of a phase.
Definition: EffToAbsLawParams.hpp:91
void finalize()
Calculate all dependent quantities once the independent quantities of the parameter object have been ...
Definition: EffToAbsLawParams.hpp:63
Scalar sumResidualSaturations() const
Return the sum of the residual saturations.
Definition: EffToAbsLawParams.hpp:85