richardsratevector.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_RICHARDS_RATE_VECTOR_HH
29#define EWOMS_RICHARDS_RATE_VECTOR_HH
30
31#include <dune/common/fvector.hh>
32
33#include <opm/material/common/Valgrind.hpp>
34#include <opm/material/constraintsolvers/NcpFlash.hpp>
35
37
38namespace Opm {
39
48template <class TypeTag>
50 : public Dune::FieldVector<GetPropType<TypeTag, Properties::Evaluation>,
51 getPropValue<TypeTag, Properties::NumEq>()>
52{
58
59 enum { contiEqIdx = Indices::contiEqIdx };
60 enum { liquidCompIdx = getPropValue<TypeTag, Properties::LiquidComponentIndex>() };
61 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
62
63 using ParentType = Dune::FieldVector<Evaluation, numEq>;
64
65public:
66 RichardsRateVector() : ParentType()
67 { Opm::Valgrind::SetUndefined(*this); }
68
72 RichardsRateVector(const Evaluation& value)
73 : ParentType(value)
74 {}
75
81 : ParentType(value)
82 {}
83
87 void setMassRate(const ParentType& value)
88 { ParentType::operator=(value); }
89
93 void setMolarRate(const ParentType& value)
94 {
95 // convert to mass rates
96 ParentType::operator[](contiEqIdx) =
97 value[contiEqIdx]*FluidSystem::molarMass(liquidCompIdx);
98 }
99
103 template <class RhsEval>
104 void setEnthalpyRate(const RhsEval& rate)
105 { EnergyModule::setEnthalpyRate(*this, rate); }
106
110 template <class FluidState, class RhsEval>
111 void setVolumetricRate(const FluidState& fluidState, unsigned phaseIdx, const RhsEval& volume)
112 {
113 (*this)[contiEqIdx] =
114 fluidState.density(phaseIdx)
115 * fluidState.massFraction(phaseIdx, liquidCompIdx)
116 * volume;
117
118 EnergyModule::setEnthalpyRate(*this, fluidState, phaseIdx, volume);
119 }
120
121
125 template <class RhsEval>
126 RichardsRateVector& operator=(const RhsEval& value)
127 {
128 for (unsigned i=0; i < this->size(); ++i)
129 (*this)[i] = value;
130 return *this;
131 }
132
137 {
138 for (unsigned i=0; i < this->size(); ++i)
139 (*this)[i] = other[i];
140 return *this;
141 }
142};
143
144} // namespace Opm
145
146#endif
Implements a vector representing mass, molar or volumetric rates.
Definition: richardsratevector.hh:52
RichardsRateVector(const Evaluation &value)
Definition: richardsratevector.hh:72
void setEnthalpyRate(const RhsEval &rate)
Set an enthalpy rate [J/As] where .
Definition: richardsratevector.hh:104
void setMassRate(const ParentType &value)
Set a mass rate of the conservation quantities.
Definition: richardsratevector.hh:87
void setVolumetricRate(const FluidState &fluidState, unsigned phaseIdx, const RhsEval &volume)
Set a volumetric rate of a phase.
Definition: richardsratevector.hh:111
RichardsRateVector(const RichardsRateVector &value)
Definition: richardsratevector.hh:80
void setMolarRate(const ParentType &value)
Set a molar rate of the conservation quantities.
Definition: richardsratevector.hh:93
RichardsRateVector()
Definition: richardsratevector.hh:66
RichardsRateVector & operator=(const RhsEval &value)
Assignment operator from a scalar or a function evaluation.
Definition: richardsratevector.hh:126
RichardsRateVector & operator=(const RichardsRateVector &other)
Assignment operator from another rate vector.
Definition: richardsratevector.hh:136
Definition: blackoilboundaryratevector.hh:37
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:242