My Project
Loading...
Searching...
No Matches
richardsprimaryvariables.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_PRIMARY_VARIABLES_HH
29#define EWOMS_RICHARDS_PRIMARY_VARIABLES_HH
30
31#include <dune/common/fvector.hh>
32
34
36
37#include <opm/material/common/Valgrind.hpp>
38#include <opm/material/constraintsolvers/ImmiscibleFlash.hpp>
39#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
40
41namespace Opm {
42
51template <class TypeTag>
53{
62
63 // primary variable indices
64 enum { pressureWIdx = Indices::pressureWIdx };
65
68
70 enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
71
72 using ComponentVector = Dune::FieldVector<Scalar, numComponents>;
73 using PhaseVector = Dune::FieldVector<Scalar, numPhases>;
74 using Toolbox = typename Opm::MathToolbox<Evaluation>;
75 using ImmiscibleFlash = Opm::ImmiscibleFlash<Scalar, FluidSystem>;
76
77public:
79 { Opm::Valgrind::SetUndefined(*this); }
80
86 RichardsPrimaryVariables& operator=(const RichardsPrimaryVariables& value) = default;
87
88 using ParentType::operator=;
89
99 void assignImmiscibleFromWetting(Scalar T, Scalar pw, Scalar Sw,
100 const MaterialLawParams& matParams)
101 {
103
104 fs.setTemperature(T);
105 fs.setSaturation(liquidPhaseIdx, Sw);
106 fs.setSaturation(gasPhaseIdx, 1 - Sw);
107
108 // set phase pressures
109 PhaseVector pC;
110 MaterialLaw::capillaryPressures(pC, matParams, fs);
111
112 fs.setPressure(liquidPhaseIdx, pw);
113 fs.setPressure(gasPhaseIdx, pw + (pC[gasPhaseIdx] - pC[liquidPhaseIdx]));
114
115 assignNaive(fs);
116 }
117
127 void assignImmiscibleFromNonWetting(Scalar T, Scalar pn, Scalar Sn,
128 const MaterialLawParams& matParams)
129 {
131
132 fs.setTemperature(T);
133 fs.setSaturation(liquidPhaseIdx, 1 - Sn);
134 fs.setSaturation(gasPhaseIdx, Sn);
135
136 // set phase pressures
137 PhaseVector pC;
138 MaterialLaw::capillaryPressures(pC, matParams, fs);
139
140 fs.setPressure(gasPhaseIdx, pn);
141 fs.setPressure(gasPhaseIdx, pn + (pC[liquidPhaseIdx] - pC[gasPhaseIdx]));
142
143 assignNaive(fs);
144 }
145
149 template <class FluidState>
150 void assignMassConservative(const FluidState& fluidState,
151 const MaterialLawParams& matParams,
152 bool = false)
153 {
154 ComponentVector globalMolarities(0.0);
155 for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
156 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
158 fluidState.molarity(phaseIdx, compIdx) * fluidState.saturation(phaseIdx);
159 }
160 }
161
163 fsFlash.assign(fluidState);
164 typename FluidSystem::ParameterCache paramCache;
165 ImmiscibleFlash::template solve<MaterialLaw>(fsFlash, paramCache,
166 matParams,
168
170 }
171
175 template <class FluidState>
176 void assignNaive(const FluidState& fluidState)
177 {
178 // assign the phase temperatures. this is out-sourced to
179 // the energy module
180 EnergyModule::setPriVarTemperatures(*this, fluidState);
181
182 (*this)[pressureWIdx] = fluidState.pressure(liquidPhaseIdx);
183 }
184};
185
186} // namespace Opm
187
188#endif
Represents the primary variables used by the a model.
Definition fvbaseprimaryvariables.hh:52
Represents the primary variables used in the Richards model.
Definition richardsprimaryvariables.hh:53
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &matParams, bool=false)
< Import base class assignment operators.
Definition richardsprimaryvariables.hh:150
RichardsPrimaryVariables(const RichardsPrimaryVariables &value)=default
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition richardsprimaryvariables.hh:176
void assignImmiscibleFromWetting(Scalar T, Scalar pw, Scalar Sw, const MaterialLawParams &matParams)
< Import base class assignment operators.
Definition richardsprimaryvariables.hh:99
void assignImmiscibleFromNonWetting(Scalar T, Scalar pn, Scalar Sn, const MaterialLawParams &matParams)
Set the primary variables with the non-wetting phase pressure, saturation and temperature.
Definition richardsprimaryvariables.hh:127
Represents the primary variables used by the a model.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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:235
Contains the property declarations for the Richards model.