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  Copyright (C) 2011-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_BLACK_OIL_RATE_VECTOR_HH
27 #define EWOMS_BLACK_OIL_RATE_VECTOR_HH
28 
29 #include <dune/common/fvector.hh>
30 
31 #include <opm/material/common/Valgrind.hpp>
32 #include <opm/material/constraintsolvers/NcpFlash.hpp>
33 
35 
36 namespace Ewoms {
37 
47 template <class TypeTag>
49  : public Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Evaluation),
50  GET_PROP_VALUE(TypeTag, NumEq)>
51 {
52  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
53  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
54  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
55  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
56 
57  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
58  enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) };
59  enum { conti0EqIdx = Indices::conti0EqIdx };
60 
61  typedef Opm::MathToolbox<Evaluation> Toolbox;
62  typedef Dune::FieldVector<Evaluation, numEq> ParentType;
63 
64 public:
65  BlackOilRateVector() : ParentType()
66  { Valgrind::SetUndefined(*this); }
67 
71  BlackOilRateVector(Scalar value) : ParentType(Toolbox::createConstant(value))
72  {}
73 
74  template <class Eval = Evaluation>
75  BlackOilRateVector(const typename std::enable_if<std::is_same<Eval, Evaluation>::value, Evaluation>::type& value) : ParentType(value)
76  {}
77 
82  BlackOilRateVector(const BlackOilRateVector &value) : ParentType(value)
83  {}
84 
88  void setMassRate(const ParentType &value)
89  {
90  // convert to molar rates
91  ParentType molarRate(value);
92  for (int compIdx = 0; compIdx < numComponents; ++compIdx)
93  molarRate[conti0EqIdx + compIdx] /= FluidSystem::molarMass(compIdx);
94 
95  // set the molar rate
96  setMolarRate(molarRate);
97  }
98 
102  void setMolarRate(const ParentType &value)
103  { ParentType::operator=(value); }
104 
108  template <class FluidState, class RhsEval>
109  void setVolumetricRate(const FluidState &fluidState,
110  int phaseIdx,
111  const RhsEval& volume)
112  {
113  for (int compIdx = 0; compIdx < numComponents; ++compIdx)
114  (*this)[conti0EqIdx + compIdx] =
115  fluidState.molarDensity(phaseIdx)
116  * fluidState.moleFraction(phaseIdx, compIdx)
117  * volume;
118  }
119 
123  template <class RhsEval>
124  BlackOilRateVector& operator=(const RhsEval& value)
125  {
126  for (unsigned i=0; i < this->size(); ++i)
127  (*this)[i] = value;
128  return *this;
129  }
130 
135  {
136  for (unsigned i=0; i < this->size(); ++i)
137  (*this)[i] = other[i];
138  return *this;
139  }
140 };
141 
142 } // namespace Ewoms
143 
144 #endif
BlackOilRateVector()
Definition: blackoilratevector.hh:65
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
void setMolarRate(const ParentType &value)
Set a molar rate of the conservation quantities.
Definition: blackoilratevector.hh:102
Implements a vector representing mass, molar or volumetric rates for the black oil model...
Definition: blackoilratevector.hh:48
BlackOilRateVector(const typename std::enable_if< std::is_same< Eval, Evaluation >::value, Evaluation >::type &value)
Definition: blackoilratevector.hh:75
void setVolumetricRate(const FluidState &fluidState, int phaseIdx, const RhsEval &volume)
Set a volumetric rate of a phase.
Definition: blackoilratevector.hh:109
BlackOilRateVector(const BlackOilRateVector &value)
Default constructor.
Definition: blackoilratevector.hh:82
BlackOilRateVector & operator=(const RhsEval &value)
Assignment operator from a scalar or a function evaluation.
Definition: blackoilratevector.hh:124
Definition: baseauxiliarymodule.hh:35
BlackOilRateVector(Scalar value)
Definition: blackoilratevector.hh:71
Contains the quantities which are are constant within a finite volume in the black-oil model...
BlackOilRateVector & operator=(const BlackOilRateVector &other)
Assignment operator from another rate vector.
Definition: blackoilratevector.hh:134
void setMassRate(const ParentType &value)
Set a mass rate of the conservation quantities.
Definition: blackoilratevector.hh:88