My Project
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 
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 unsigned 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 (unsigned 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  { 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;
116 
117  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
118  const Evaluation& S =
119  decay<Evaluation>(fluidState.saturation(phaseIdx));
120  values[phaseIdx] = max(min(S, 1.0), 0.0);
121  }
122  }
123 
127  template <class FluidState, class Evaluation = typename FluidState::Scalar>
128  static typename std::enable_if<(numPhases > 1), Evaluation>::type
129  pcnw(const Params& /*params*/, const FluidState& /*fluidState*/)
130  { return 0; }
131 
132  template <class Evaluation>
133  static typename std::enable_if<numPhases == 2, Evaluation>::type
134  twoPhaseSatPcnw(const Params& /*params*/, const Evaluation& /*Sw*/)
135  { return 0; }
136 
141  template <class FluidState, class Evaluation = typename FluidState::Scalar>
142  static Scalar Sw(const Params& /*params*/, const FluidState& /*fluidState*/)
143  { throw std::logic_error("Not defined: Sw()"); }
144 
145  template <class Evaluation>
146  static typename std::enable_if<numPhases == 2, Evaluation>::type
147  twoPhaseSatSw(const Params& /*params*/, const Evaluation& /*pcnw*/)
148  { throw std::logic_error("Not defined: twoPhaseSatSw()"); }
149 
154  template <class FluidState, class Evaluation = typename FluidState::Scalar>
155  static Scalar Sn(const Params& /*params*/, const FluidState& /*fluidState*/)
156  { throw std::logic_error("Not defined: Sn()"); }
157 
158  template <class Evaluation>
159  static typename std::enable_if<numPhases == 2, Evaluation>::type
160  twoPhaseSatSn(const Params& /*params*/, const Evaluation& /*pcnw*/)
161  { throw std::logic_error("Not defined: twoPhaseSatSn()"); }
162 
169  template <class FluidState, class Evaluation = typename FluidState::Scalar>
170  static typename std::enable_if< (numPhases > 2), Evaluation>::type
171  Sg(const Params& /*params*/, const FluidState& /*fluidState*/)
172  { throw std::logic_error("Not defined: Sg()"); }
173 
177  template <class FluidState, class Evaluation = typename FluidState::Scalar>
178  static typename std::enable_if<(numPhases > 1), Evaluation>::type
179  krw(const Params& /*params*/, const FluidState& fluidState)
180  {
181  const Evaluation& Sw =
182  decay<Evaluation>(fluidState.saturation(Traits::wettingPhaseIdx));
183 
184  return max(0.0, min(1.0, Sw));
185  }
186 
187  template <class Evaluation>
188  static typename std::enable_if<numPhases == 2, Evaluation>::type
189  twoPhaseSatKrw(const Params& /*params*/, const Evaluation& Sw)
190  { return max(0.0, min(1.0, Sw)); }
191 
195  template <class FluidState, class Evaluation = typename FluidState::Scalar>
196  static typename std::enable_if<(numPhases > 1), Evaluation>::type
197  krn(const Params& /*params*/, const FluidState& fluidState)
198  {
199  const Evaluation& Sn =
200  decay<Evaluation>(fluidState.saturation(Traits::nonWettingPhaseIdx));
201 
202  return max(0.0, min(1.0, Sn));
203  }
204 
205  template <class Evaluation>
206  static typename std::enable_if<numPhases == 2, Evaluation>::type
207  twoPhaseSatKrn(const Params& /*params*/, const Evaluation& Sw)
208  {
209  return max(0.0, min(1.0, 1.0 - decay<Evaluation>(Sw)));
210  }
211 
217  template <class FluidState, class Evaluation = typename FluidState::Scalar>
218  static typename std::enable_if< (numPhases > 2), Evaluation>::type
219  krg(const Params& /*params*/, const FluidState& fluidState)
220  {
221  const Evaluation& Sg =
222  decay<Evaluation>(fluidState.saturation(Traits::gasPhaseIdx));
223 
224  return max(0.0, min(1.0, Sg));
225  }
226 
232  template <class FluidState, class Evaluation = typename FluidState::Scalar>
233  static typename std::enable_if< (Traits::numPhases > 2), Evaluation>::type
234  pcgn(const Params& /*params*/, const FluidState& /*fluidState*/)
235  { return 0.0; }
236 };
237 } // namespace Opm
238 
239 #endif
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Reference implementation of params for the linear M-phase material material.
Reference implementation of params for the linear M-phase material material.
Definition: NullMaterialParams.hpp:37
Implements a dummy linear saturation-capillary pressure relation which just disables capillary pressu...
Definition: NullMaterial.hpp:46
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:234
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:171
static const bool isTemperatureDependent
Specify whether the quantities defined by this material law are temperature dependent.
Definition: NullMaterial.hpp:76
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:155
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:142
static const unsigned numPhases
The number of fluid phases.
Definition: NullMaterial.hpp:53
static const bool implementsTwoPhaseSatApi
Specify whether this material law implements the two-phase convenience API which only depends on the ...
Definition: NullMaterial.hpp:61
static const bool isSaturationDependent
Specify whether the quantities defined by this material law are saturation dependent.
Definition: NullMaterial.hpp:68
static void saturations(ContainerT &, const Params &, const FluidState &)
The inverse of the capillary pressure.
Definition: NullMaterial.hpp:102
static void capillaryPressures(ContainerT &values, const Params &, const FluidState &)
Returns constant 0 for all phases.
Definition: NullMaterial.hpp:90
static std::enable_if<(numPhases > 2), Evaluation >::type krg(const Params &, const FluidState &fluidState)
The relative permability of the gas phase.
Definition: NullMaterial.hpp:219
static const bool implementsTwoPhaseApi
Specify whether this material law implements the two-phase convenience API.
Definition: NullMaterial.hpp:57
static void relativePermeabilities(ContainerT &values, const Params &, const FluidState &fluidState)
The relative permeability of all phases.
Definition: NullMaterial.hpp:111
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:197
static std::enable_if<(numPhases > 1), Evaluation >::type krw(const Params &, const FluidState &fluidState)
The relative permability of the wetting phase.
Definition: NullMaterial.hpp:179
static const bool isCompositionDependent
Specify whether the quantities defined by this material law are dependent on the phase composition.
Definition: NullMaterial.hpp:80
static const bool isPressureDependent
Specify whether the quantities defined by this material law are dependent on the absolute pressure.
Definition: NullMaterial.hpp:72
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:129