All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ncpratevector.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_NCP_RATE_VECTOR_HH
29 #define EWOMS_NCP_RATE_VECTOR_HH
30 
31 #include "ncpindices.hh"
32 
33 #include <opm/common/Valgrind.hpp>
34 #include <opm/material/constraintsolvers/NcpFlash.hpp>
35 
36 #include <dune/common/fvector.hh>
37 
38 namespace Ewoms {
47 template <class TypeTag>
49  : public Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Evaluation),
50  GET_PROP_VALUE(TypeTag, NumEq)>
51 {
52  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
53  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
54  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
55  typedef Dune::FieldVector<Evaluation, numEq> ParentType;
56  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
57  typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
58 
59  enum { conti0EqIdx = Indices::conti0EqIdx };
60  enum { numComponents = GET_PROP_VALUE(TypeTag, NumComponents) };
61  enum { enableEnergy = GET_PROP_VALUE(TypeTag, EnableEnergy) };
62 
64 
65  typedef Opm::MathToolbox<Evaluation> Toolbox;
66 
67 public:
68  NcpRateVector() : ParentType()
69  { Opm::Valgrind::SetUndefined(*this); }
70 
74  NcpRateVector(const Evaluation& value)
75  : ParentType(value)
76  {}
77 
83  : ParentType(value)
84  {}
85 
89  void setMassRate(const ParentType& value)
90  {
91  // convert to molar rates
92  ParentType molarRate(value);
93  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
94  molarRate[conti0EqIdx + compIdx] /= FluidSystem::molarMass(compIdx);
95 
96  // set the molar rate
97  setMolarRate(molarRate);
98  }
99 
103  void setMolarRate(const ParentType& value)
104  { ParentType::operator=(value); }
105 
109  template <class RhsEval>
110  void setEnthalpyRate(const RhsEval& rate)
111  { EnergyModule::setEnthalpyRate(*this, rate); }
112 
116  template <class FluidState, class RhsEval>
117  void setVolumetricRate(const FluidState& fluidState, unsigned phaseIdx, const RhsEval& volume)
118  {
119  *this = 0.0;
120  for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
121  (*this)[conti0EqIdx + compIdx] = fluidState.molarity(phaseIdx, compIdx) * volume;
122 
123  EnergyModule::setEnthalpyRate(*this, fluidState, phaseIdx, volume);
124  Opm::Valgrind::CheckDefined(*this);
125  }
126 
130  template <class RhsEval>
131  NcpRateVector& operator=(const RhsEval& value)
132  {
133  for (unsigned i=0; i < this->size(); ++i)
134  (*this)[i] = value;
135  return *this;
136  }
137 
142  {
143  for (unsigned i=0; i < this->size(); ++i)
144  (*this)[i] = other[i];
145  return *this;
146  }
147 };
148 
149 } // namespace Ewoms
150 
151 #endif
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
NcpRateVector & operator=(const RhsEval &value)
Assignment operator from a scalar or a function evaluation.
Definition: ncpratevector.hh:131
void setMassRate(const ParentType &value)
Set a mass rate of the conservation quantities.
Definition: ncpratevector.hh:89
void setEnthalpyRate(const RhsEval &rate)
Set an enthalpy rate [J/As] where .
Definition: ncpratevector.hh:110
NcpRateVector(const NcpRateVector &value)
Default constructor.
Definition: ncpratevector.hh:82
Implements a vector representing mass, molar or volumetric rates.
Definition: ncpratevector.hh:48
void setVolumetricRate(const FluidState &fluidState, unsigned phaseIdx, const RhsEval &volume)
Set a volumetric rate of a phase.
Definition: ncpratevector.hh:117
NcpRateVector(const Evaluation &value)
Definition: ncpratevector.hh:74
void setMolarRate(const ParentType &value)
Set a molar rate of the conservation quantities.
Definition: ncpratevector.hh:103
NcpRateVector & operator=(const NcpRateVector &other)
Assignment operator from another rate vector.
Definition: ncpratevector.hh:141
The primary variable and equation indices for the compositional multi-phase NCP model.