All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
blackoilratevector.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  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 */
28 #ifndef EWOMS_BLACK_OIL_RATE_VECTOR_HH
29 #define EWOMS_BLACK_OIL_RATE_VECTOR_HH
30 
31 #include <dune/common/fvector.hh>
32 
33 #include <opm/common/Valgrind.hpp>
34 #include <opm/material/constraintsolvers/NcpFlash.hpp>
35 
37 
38 namespace Ewoms {
39 
49 template <class TypeTag>
51  : public Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Evaluation),
52  GET_PROP_VALUE(TypeTag, NumEq)>
53 {
54  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
55  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
56  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
57  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
58 
59  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
60  enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) };
61  enum { conti0EqIdx = Indices::conti0EqIdx };
62 
63  typedef Opm::MathToolbox<Evaluation> Toolbox;
64  typedef Dune::FieldVector<Evaluation, numEq> ParentType;
65 
66 public:
67  BlackOilRateVector() : ParentType()
68  { Opm::Valgrind::SetUndefined(*this); }
69 
73  BlackOilRateVector(Scalar value) : ParentType(Toolbox::createConstant(value))
74  {}
75 
76  template <class Eval = Evaluation>
77  BlackOilRateVector(const typename std::enable_if<std::is_same<Eval, Evaluation>::value, Evaluation>::type& value) : ParentType(value)
78  {}
79 
84  BlackOilRateVector(const BlackOilRateVector& value) : ParentType(value)
85  {}
86 
90  void setMassRate(const ParentType& value)
91  { ParentType::operator=(value); }
92 
96  void setMolarRate(const ParentType& value)
97  {
98  // first, assign molar rates
99  ParentType::operator=(value);
100 
101  // then, convert them to mass rates
102  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
103  (*this)[conti0EqIdx + compIdx] *= FluidSystem::molarMass(compIdx);
104  }
105 
109  template <class FluidState, class RhsEval>
110  void setVolumetricRate(const FluidState& fluidState,
111  unsigned phaseIdx,
112  const RhsEval& volume)
113  {
114  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
115  (*this)[conti0EqIdx + compIdx] =
116  fluidState.density(phaseIdx)
117  * fluidState.massFraction(phaseIdx, compIdx)
118  * volume;
119  }
120 
124  template <class RhsEval>
125  BlackOilRateVector& operator=(const RhsEval& value)
126  {
127  for (unsigned i=0; i < this->size(); ++i)
128  (*this)[i] = value;
129  return *this;
130  }
131 
136  {
137  for (unsigned i=0; i < this->size(); ++i)
138  (*this)[i] = other[i];
139  return *this;
140  }
141 };
142 
143 } // namespace Ewoms
144 
145 #endif
BlackOilRateVector(const BlackOilRateVector &value)
Default constructor.
Definition: blackoilratevector.hh:84
Contains the quantities which are are constant within a finite volume in the black-oil model...
Implements a vector representing mass, molar or volumetric rates for the black oil model...
Definition: blackoilratevector.hh:50
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
void setMassRate(const ParentType &value)
Set a mass rate of the conservation quantities.
Definition: blackoilratevector.hh:90
void setVolumetricRate(const FluidState &fluidState, unsigned phaseIdx, const RhsEval &volume)
Set a volumetric rate of a phase.
Definition: blackoilratevector.hh:110
BlackOilRateVector & operator=(const RhsEval &value)
Assignment operator from a scalar or a function evaluation.
Definition: blackoilratevector.hh:125
void setMolarRate(const ParentType &value)
Set a molar rate of the conservation quantities.
Definition: blackoilratevector.hh:96
BlackOilRateVector & operator=(const BlackOilRateVector &other)
Assignment operator from another rate vector.
Definition: blackoilratevector.hh:135
BlackOilRateVector(Scalar value)
Definition: blackoilratevector.hh:73