richardsboundaryratevector.hh
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 */
26 #ifndef EWOMS_RICHARDS_BOUNDARY_RATE_VECTOR_HH
27 #define EWOMS_RICHARDS_BOUNDARY_RATE_VECTOR_HH
28 
29 #include <opm/material/common/Valgrind.hpp>
30 #include <opm/material/constraintsolvers/NcpFlash.hpp>
31 
33 
34 namespace Ewoms {
35 
41 template <class TypeTag>
42 class RichardsBoundaryRateVector : public GET_PROP_TYPE(TypeTag, RateVector)
43 {
44  typedef typename GET_PROP_TYPE(TypeTag, RateVector) ParentType;
45  typedef typename GET_PROP_TYPE(TypeTag, ExtensiveQuantities) ExtensiveQuantities;
46  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
47  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
48  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
49  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
50 
51  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
52  enum { contiEqIdx = Indices::contiEqIdx };
53  enum { liquidPhaseIdx = GET_PROP_VALUE(TypeTag, LiquidPhaseIndex) };
54 
55  typedef Opm::MathToolbox<Evaluation> Toolbox;
56 
57 public:
58  RichardsBoundaryRateVector() : ParentType()
59  {}
60 
65  RichardsBoundaryRateVector(const Evaluation& value)
66  : ParentType(value)
67  {}
68 
74  : ParentType(value)
75  {}
76 
80  template <class Context, class FluidState>
81  void setFreeFlow(const Context &context, int bfIdx, int timeIdx, const FluidState &fluidState)
82  {
83  typename FluidSystem::ParameterCache paramCache;
84  paramCache.updateAll(fluidState);
85 
86  ExtensiveQuantities extQuants;
87  extQuants.updateBoundary(context, bfIdx, timeIdx, fluidState, paramCache);
88  const auto &insideIntQuants = context.intensiveQuantities(bfIdx, timeIdx);
89 
91  // advective fluxes of all components in all phases
93  (*this) = Toolbox::createConstant(0.0);
94 
95  int phaseIdx = liquidPhaseIdx;
96  Evaluation density;
97  if (fluidState.pressure(phaseIdx) > insideIntQuants.fluidState().pressure(phaseIdx))
98  density = FluidSystem::density(fluidState, paramCache, phaseIdx);
99  else
100  density = insideIntQuants.fluidState().density(phaseIdx);
101 
102  // add advective flux of current component in current
103  // phase
104  (*this)[contiEqIdx] += extQuants.volumeFlux(phaseIdx) * density;
105 
106 #ifndef NDEBUG
107  for (int i = 0; i < numEq; ++i) {
108  Valgrind::CheckDefined((*this)[i]);
109  }
110  Valgrind::CheckDefined(*this);
111 #endif
112  }
113 
117  template <class Context, class FluidState>
118  void setInFlow(const Context &context, int bfIdx, int timeIdx,
119  const FluidState &fluidState)
120  {
121  this->setFreeFlow(context, bfIdx, timeIdx, fluidState);
122 
123  // we only allow fluxes in the direction opposite to the outer unit normal
124  for (int eqIdx = 0; eqIdx < numEq; ++eqIdx) {
125  Evaluation& val = this->operator[](eqIdx);
126  val = Toolbox::min(0.0, val);
127  }
128  }
129 
133  template <class Context, class FluidState>
134  void setOutFlow(const Context &context, int bfIdx, int timeIdx,
135  const FluidState &fluidState)
136  {
137  this->setFreeFlow(context, bfIdx, timeIdx, fluidState);
138 
139  // we only allow fluxes in the same direction as the outer unit normal
140  for (int eqIdx = 0; eqIdx < numEq; ++eqIdx) {
141  Evaluation& val = this->operator[](eqIdx);
142  val = Toolbox::max(0.0, val);
143  }
144  }
145 
149  void setNoFlow()
150  { (*this) = Toolbox::createConstant(0.0); }
151 };
152 
153 } // namespace Ewoms
154 
155 #endif
RichardsBoundaryRateVector(const RichardsBoundaryRateVector &value)
Definition: richardsboundaryratevector.hh:73
void setInFlow(const Context &context, int bfIdx, int timeIdx, const FluidState &fluidState)
Specify an inflow boundary.
Definition: richardsboundaryratevector.hh:118
void setFreeFlow(const Context &context, int bfIdx, int timeIdx, const FluidState &fluidState)
Specify a free-flow boundary.
Definition: richardsboundaryratevector.hh:81
Implements a boundary vector for the fully implicit Richards model.
Definition: richardsboundaryratevector.hh:42
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
Intensive quantities required by the Richards model.
Definition: baseauxiliarymodule.hh:35
RichardsBoundaryRateVector()
Definition: richardsboundaryratevector.hh:58
RichardsBoundaryRateVector(const Evaluation &value)
Definition: richardsboundaryratevector.hh:65
void setOutFlow(const Context &context, int bfIdx, int timeIdx, const FluidState &fluidState)
Specify an outflow boundary.
Definition: richardsboundaryratevector.hh:134
void setNoFlow()
Specify a no-flow boundary for all conserved quantities.
Definition: richardsboundaryratevector.hh:149