NullMaterial.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 */
27 #ifndef OPM_NULL_MATERIAL_HPP
28 #define OPM_NULL_MATERIAL_HPP
29 
30 #include "NullMaterialParams.hpp"
31 
32 #include <opm/common/ErrorMacros.hpp>
33 #include <opm/common/Exceptions.hpp>
35 
36 #include <algorithm>
37 
38 namespace Opm
39 {
46 template <class TraitsT>
47 class NullMaterial : public TraitsT
48 {
49 public:
50  typedef TraitsT Traits;
52  typedef typename Traits::Scalar Scalar;
53 
55  static const unsigned numPhases = Traits::numPhases;
56 
59  static const bool implementsTwoPhaseApi = (numPhases == 2);
60 
63  static const bool implementsTwoPhaseSatApi = (numPhases == 2);
64 
70  static const bool isSaturationDependent = true;
71 
74  static const bool isPressureDependent = false;
75 
78  static const bool isTemperatureDependent = false;
79 
82  static const bool isCompositionDependent = false;
83 
91  template <class ContainerT, class FluidState>
92  static void capillaryPressures(ContainerT& values,
93  const Params& /*params*/,
94  const FluidState& /*fluidState*/)
95  {
96  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
97  values[phaseIdx] = 0.0;
98  }
99 
103  template <class ContainerT, class FluidState>
104  static void saturations(ContainerT& /*values*/,
105  const Params& /*params*/,
106  const FluidState& /*fluidState*/)
107  { OPM_THROW(std::logic_error, "Not defined: NullMaterial::saturations()"); }
108 
112  template <class ContainerT, class FluidState>
113  static void relativePermeabilities(ContainerT& values,
114  const Params& /*params*/,
115  const FluidState& fluidState)
116  {
117  typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
118 
119  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
120  const Evaluation& S =
121  Opm::decay<Evaluation>(fluidState.saturation(phaseIdx));
122  values[phaseIdx] = Opm::max(Opm::min(S, 1.0), 0.0);
123  }
124  }
125 
129  template <class FluidState, class Evaluation = typename FluidState::Scalar>
130  static typename std::enable_if<(numPhases > 1), Evaluation>::type
131  pcnw(const Params& /*params*/, const FluidState& /*fluidState*/)
132  { return 0; }
133 
134  template <class Evaluation>
135  static typename std::enable_if<numPhases == 2, Evaluation>::type
136  twoPhaseSatPcnw(const Params& /*params*/, const Evaluation& /*Sw*/)
137  { return 0; }
138 
143  template <class FluidState, class Evaluation = typename FluidState::Scalar>
144  static Scalar Sw(const Params& /*params*/, const FluidState& /*fluidState*/)
145  { OPM_THROW(std::logic_error, "Not defined: Sw()"); }
146 
147  template <class Evaluation>
148  static typename std::enable_if<numPhases == 2, Evaluation>::type
149  twoPhaseSatSw(const Params& /*params*/, const Evaluation& /*pcnw*/)
150  { OPM_THROW(std::logic_error, "Not defined: twoPhaseSatSw()"); }
151 
156  template <class FluidState, class Evaluation = typename FluidState::Scalar>
157  static Scalar Sn(const Params& /*params*/, const FluidState& /*fluidState*/)
158  { OPM_THROW(std::logic_error, "Not defined: Sn()"); }
159 
160  template <class Evaluation>
161  static typename std::enable_if<numPhases == 2, Evaluation>::type
162  twoPhaseSatSn(const Params& /*params*/, const Evaluation& /*pcnw*/)
163  { OPM_THROW(std::logic_error, "Not defined: twoPhaseSatSn()"); }
164 
171  template <class FluidState, class Evaluation = typename FluidState::Scalar>
172  static typename std::enable_if< (numPhases > 2), Evaluation>::type
173  Sg(const Params& /*params*/, const FluidState& /*fluidState*/)
174  { OPM_THROW(std::logic_error, "Not defined: Sg()"); }
175 
179  template <class FluidState, class Evaluation = typename FluidState::Scalar>
180  static typename std::enable_if<(numPhases > 1), Evaluation>::type
181  krw(const Params& /*params*/, const FluidState& fluidState)
182  {
183  const Evaluation& Sw =
184  Opm::decay<Evaluation>(fluidState.saturation(Traits::wettingPhaseIdx));
185 
186  return Opm::max(0.0, Opm::min(1.0, Sw));
187  }
188 
189  template <class Evaluation>
190  static typename std::enable_if<numPhases == 2, Evaluation>::type
191  twoPhaseSatKrw(const Params& /*params*/, const Evaluation& Sw)
192  { return Opm::max(0.0, Opm::min(1.0, Sw)); }
193 
197  template <class FluidState, class Evaluation = typename FluidState::Scalar>
198  static typename std::enable_if<(numPhases > 1), Evaluation>::type
199  krn(const Params& /*params*/, const FluidState& fluidState)
200  {
201  const Evaluation& Sn =
202  Opm::decay<Evaluation>(fluidState.saturation(Traits::nonWettingPhaseIdx));
203 
204  return Opm::max(0.0, Opm::min(1.0, Sn));
205  }
206 
207  template <class Evaluation>
208  static typename std::enable_if<numPhases == 2, Evaluation>::type
209  twoPhaseSatKrn(const Params& /*params*/, const Evaluation& Sw)
210  {
211  return Opm::max(0.0, Opm::min(1.0, 1.0 - Opm::decay<Evaluation>(Sw)));
212  }
213 
219  template <class FluidState, class Evaluation = typename FluidState::Scalar>
220  static typename std::enable_if< (numPhases > 2), Evaluation>::type
221  krg(const Params& /*params*/, const FluidState& fluidState)
222  {
223  const Evaluation& Sg =
224  Opm::decay<Evaluation>(fluidState.saturation(Traits::gasPhaseIdx));
225 
226  return Opm::max(0.0, Opm::min(1.0, Sg));
227  }
228 
234  template <class FluidState, class Evaluation = typename FluidState::Scalar>
235  static typename std::enable_if< (Traits::numPhases > 2), Evaluation>::type
236  pcgn(const Params& /*params*/, const FluidState& /*fluidState*/)
237  { return 0.0; }
238 };
239 } // namespace Opm
240 
241 #endif
static void relativePermeabilities(ContainerT &values, const Params &, const FluidState &fluidState)
The relative permeability of all phases.
Definition: NullMaterial.hpp:113
Reference implementation of params for the linear M-phase material material.
static std::enable_if<(numPhases > 1), Evaluation >::type pcnw(const Params &, const FluidState &)
The difference between the pressures of the non-wetting and wetting phase.
Definition: NullMaterial.hpp:131
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
static std::enable_if<(Traits::numPhases > 2), Evaluation >::type pcgn(const Params &, const FluidState &)
The difference between the pressures of the gas and the non-wetting phase.
Definition: NullMaterial.hpp:236
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition...
Definition: NullMaterial.hpp:82
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure...
Definition: NullMaterial.hpp:74
static const unsigned numPhases
The number of fluid phases.
Definition: NullMaterial.hpp:55
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: NullMaterial.hpp:104
Definition: Air_Mesitylene.hpp:33
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition: NullMaterial.hpp:63
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition: NullMaterial.hpp:70
Implements a dummy linear saturation-capillary pressure relation which just disables capillary pressu...
Definition: NullMaterial.hpp:47
static std::enable_if<(numPhases > 2), Evaluation >::type Sg(const Params &, const FluidState &)
Calculate gas phase saturation given that the rest of the fluid state has been initialized.
Definition: NullMaterial.hpp:173
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition: NullMaterial.hpp:78
static std::enable_if<(numPhases > 1), Evaluation >::type krn(const Params &, const FluidState &fluidState)
The relative permability of the liquid non-wetting phase.
Definition: NullMaterial.hpp:199
static Scalar Sn(const Params &, const FluidState &)
Calculate non-wetting phase saturation given that the rest of the fluid state has been initialized...
Definition: NullMaterial.hpp:157
static std::enable_if<(numPhases > 2), Evaluation >::type krg(const Params &, const FluidState &fluidState)
The relative permability of the gas phase.
Definition: NullMaterial.hpp:221
static void capillaryPressures(ContainerT &values, const Params &, const FluidState &)
Returns constant 0 for all phases.
Definition: NullMaterial.hpp:92
static Scalar Sw(const Params &, const FluidState &)
Calculate wetting phase saturation given that the rest of the fluid state has been initialized...
Definition: NullMaterial.hpp:144
static std::enable_if<(numPhases > 1), Evaluation >::type krw(const Params &, const FluidState &fluidState)
The relative permability of the wetting phase.
Definition: NullMaterial.hpp:181
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition: NullMaterial.hpp:59
Reference implementation of params for the linear M-phase material material.
Definition: NullMaterialParams.hpp:36