flashratevector.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_FLASH_RATE_VECTOR_HH
29 #define EWOMS_FLASH_RATE_VECTOR_HH
30 
31 #include <dune/common/fvector.hh>
32 
34 #include <opm/material/constraintsolvers/NcpFlash.hpp>
35 #include <opm/common/Valgrind.hpp>
36 
38 
39 namespace Ewoms {
40 
46 template <class TypeTag>
48  : public Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Evaluation),
49  GET_PROP_VALUE(TypeTag, NumEq)>
50 {
51  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
52  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
53  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
54  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
55 
56  enum { conti0EqIdx = Indices::conti0EqIdx };
57  enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) };
58  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
59 
60  typedef Dune::FieldVector<Evaluation, numEq> ParentType;
62 
63 public:
64  FlashRateVector() : ParentType()
65  { Opm::Valgrind::SetUndefined(*this); }
66 
70  FlashRateVector(const Evaluation& value) : ParentType(value)
71  {}
72 
77  FlashRateVector(const FlashRateVector& value) : ParentType(value)
78  {}
79 
83  void setMassRate(const ParentType& value)
84  {
85  // convert to molar rates
86  ParentType molarRate(value);
87  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
88  molarRate[conti0EqIdx + compIdx] /= FluidSystem::molarMass(compIdx);
89 
90  setMolarRate(molarRate);
91  }
92 
96  void setMolarRate(const ParentType& value)
97  { ParentType::operator=(value); }
98 
102  void setEnthalpyRate(const Evaluation& rate)
103  { EnergyModule::setEnthalpyRate(*this, rate); }
104 
108  template <class FluidState, class RhsEval>
109  void setVolumetricRate(const FluidState& fluidState, unsigned phaseIdx, const RhsEval& volume)
110  {
111  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
112  (*this)[conti0EqIdx + compIdx] =
113  fluidState.density(phaseIdx, compIdx)
114  * fluidState.moleFraction(phaseIdx, compIdx)
115  * volume;
116 
117  EnergyModule::setEnthalpyRate(*this, fluidState, phaseIdx, volume);
118  }
119 
123  template <class RhsEval>
124  FlashRateVector& 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
void setEnthalpyRate(const Evaluation &rate)
Set an enthalpy rate [J/As] where .
Definition: flashratevector.hh:102
FlashRateVector(const FlashRateVector &value)
Default constructor.
Definition: flashratevector.hh:77
Contains the intensive quantities of the flash-based compositional multi-phase model.
void setVolumetricRate(const FluidState &fluidState, unsigned phaseIdx, const RhsEval &volume)
Set a volumetric rate of a phase.
Definition: flashratevector.hh:109
Definition: baseauxiliarymodule.hh:37
FlashRateVector & operator=(const FlashRateVector &other)
Assignment operator from another rate vector.
Definition: flashratevector.hh:134
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:59
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...
Implements a vector representing rates of conserved quantities.
Definition: flashratevector.hh:47
void setMassRate(const ParentType &value)
Set a mass rate of the conservation quantities.
Definition: flashratevector.hh:83
void setMolarRate(const ParentType &value)
Set a molar rate of the conservation quantities.
Definition: flashratevector.hh:96
FlashRateVector(const Evaluation &value)
Definition: flashratevector.hh:70
FlashRateVector & operator=(const RhsEval &value)
Assignment operator from a scalar or a function evaluation.
Definition: flashratevector.hh:124