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  Copyright (C) 2008-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_NULL_MATERIAL_HPP
26 #define OPM_NULL_MATERIAL_HPP
27 
28 #include "NullMaterialParams.hpp"
29 
30 #include <opm/common/ErrorMacros.hpp>
31 #include <opm/common/Exceptions.hpp>
33 
34 #include <algorithm>
35 
36 namespace Opm
37 {
44 template <class TraitsT>
45 class NullMaterial : public TraitsT
46 {
47 public:
48  typedef TraitsT Traits;
50  typedef typename Traits::Scalar Scalar;
51 
53  static const int numPhases = Traits::numPhases;
54 
57  static const bool implementsTwoPhaseApi = (numPhases == 2);
58 
61  static const bool implementsTwoPhaseSatApi = (numPhases == 2);
62 
68  static const bool isSaturationDependent = true;
69 
72  static const bool isPressureDependent = false;
73 
76  static const bool isTemperatureDependent = false;
77 
80  static const bool isCompositionDependent = false;
81 
89  template <class ContainerT, class FluidState>
90  static void capillaryPressures(ContainerT &values,
91  const Params &/*params*/,
92  const FluidState &/*fluidState*/)
93  {
94  for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
95  values[phaseIdx] = 0.0;
96  }
97 
101  template <class ContainerT, class FluidState>
102  static void saturations(ContainerT &/*values*/,
103  const Params &/*params*/,
104  const FluidState &/*fluidState*/)
105  { OPM_THROW(std::logic_error, "Not defined: NullMaterial::saturations()"); }
106 
110  template <class ContainerT, class FluidState>
111  static void relativePermeabilities(ContainerT &values,
112  const Params &/*params*/,
113  const FluidState &fluidState)
114  {
115  typedef typename std::remove_reference<decltype(values[0])>::type Evaluation;
117  typedef MathToolbox<Evaluation> Toolbox;
118 
119  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
120  const Evaluation& S =
121  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(phaseIdx));
122  values[phaseIdx] = Toolbox::max(Toolbox::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  {
184  typedef MathToolbox<Evaluation> Toolbox;
185 
186  const Evaluation& Sw =
187  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(Traits::wettingPhaseIdx));
188 
189  return Toolbox::max(0.0, Toolbox::min(1.0, Sw));
190  }
191 
192  template <class Evaluation>
193  static typename std::enable_if<numPhases == 2, Evaluation>::type
194  twoPhaseSatKrw(const Params &/*params*/, const Evaluation& Sw)
195  {
196  typedef MathToolbox<Evaluation> Toolbox;
197 
198  return Toolbox::max(0.0, Toolbox::min(1.0, Sw));
199  }
200 
204  template <class FluidState, class Evaluation = typename FluidState::Scalar>
205  static typename std::enable_if<(numPhases > 1), Evaluation>::type
206  krn(const Params &/*params*/, const FluidState &fluidState)
207  {
209  typedef MathToolbox<Evaluation> Toolbox;
210 
211  const Evaluation& Sn =
212  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(Traits::nonWettingPhaseIdx));
213 
214  return Toolbox::max(0.0, Toolbox::min(1.0, Sn));
215  }
216 
217  template <class Evaluation>
218  static typename std::enable_if<numPhases == 2, Evaluation>::type
219  twoPhaseSatKrn(const Params &/*params*/, const Evaluation& Sw)
220  {
221  typedef MathToolbox<Evaluation> Toolbox;
222 
223  return Toolbox::max(0.0, Toolbox::min(1.0, 1.0 - Sw));
224  }
225 
231  template <class FluidState, class Evaluation = typename FluidState::Scalar>
232  static typename std::enable_if< (numPhases > 2), Evaluation>::type
233  krg(const Params &/*params*/, const FluidState &fluidState)
234  {
236  typedef MathToolbox<Evaluation> Toolbox;
237 
238  const Evaluation& Sg =
239  FsToolbox::template toLhs<Evaluation>(fluidState.saturation(Traits::gasPhaseIdx));
240 
241  return Toolbox::max(0.0, Toolbox::min(1.0, Sg));
242  }
243 
249  template <class FluidState, class Evaluation = typename FluidState::Scalar>
250  static typename std::enable_if< (Traits::numPhases > 2), Evaluation>::type
251  pcgn(const Params &/*params*/, const FluidState &/*fluidState*/)
252  { return 0; }
253 };
254 } // namespace Opm
255 
256 #endif
static std::enable_if< numPhases==2, Evaluation >::type twoPhaseSatSn(const Params &, const Evaluation &)
Definition: NullMaterial.hpp:162
static std::enable_if< numPhases==2, Evaluation >::type twoPhaseSatKrn(const Params &, const Evaluation &Sw)
Definition: NullMaterial.hpp:219
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:251
static const bool isTemperatureDependent
Definition: NullMaterial.hpp:76
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
static const bool isSaturationDependent
Definition: NullMaterial.hpp:68
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
static std::enable_if< (numPhases > 2), Evaluation >::type krg(const Params &, const FluidState &fluidState)
The relative permability of the gas phase.
Definition: NullMaterial.hpp:233
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
Evaluation< Scalar, VarSetTag, numVars > max(const Evaluation< Scalar, VarSetTag, numVars > &x1, const Evaluation< Scalar, VarSetTag, numVars > &x2)
Definition: Math.hpp:114
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:206
static std::enable_if< numPhases==2, Evaluation >::type twoPhaseSatSw(const Params &, const Evaluation &)
Definition: NullMaterial.hpp:149
static std::enable_if< numPhases==2, Evaluation >::type twoPhaseSatKrw(const Params &, const Evaluation &Sw)
Definition: NullMaterial.hpp:194
static void relativePermeabilities(ContainerT &values, const Params &, const FluidState &fluidState)
The relative permeability of all phases.
Definition: NullMaterial.hpp:111
static const bool isPressureDependent
Definition: NullMaterial.hpp:72
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: NullMaterial.hpp:102
TraitsT Traits
Definition: NullMaterial.hpp:48
Reference implementation of params for the linear M-phase material material.
Definition: NullMaterialParams.hpp:34
Implements a dummy linear saturation-capillary pressure relation which just disables capillary pressu...
Definition: NullMaterial.hpp:45
static std::enable_if< numPhases==2, Evaluation >::type twoPhaseSatPcnw(const Params &, const Evaluation &)
Definition: NullMaterial.hpp:136
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 isCompositionDependent
Definition: NullMaterial.hpp:80
Evaluation< Scalar, VarSetTag, numVars > min(const Evaluation< Scalar, VarSetTag, numVars > &x1, const Evaluation< Scalar, VarSetTag, numVars > &x2)
Definition: Math.hpp:61
Traits::Scalar Scalar
Definition: NullMaterial.hpp:50
static const bool implementsTwoPhaseSatApi
Definition: NullMaterial.hpp:61
static const bool implementsTwoPhaseApi
Definition: NullMaterial.hpp:57
Reference implementation of params for the linear M-phase material material.
static const int numPhases
The number of fluid phases.
Definition: NullMaterial.hpp:53
NullMaterialParams< TraitsT > Params
Definition: NullMaterial.hpp:49
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 void capillaryPressures(ContainerT &values, const Params &, const FluidState &)
Returns constant 0 for all phases.
Definition: NullMaterial.hpp:90
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...