opm-simulators
Toggle main menu visibility
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
33
#include <opm/material/common/Valgrind.hpp>
34
#include <opm/material/constraintsolvers/ImmiscibleFlash.hpp>
35
#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
36
37
#include <
opm/models/richards/richardsproperties.hh
>
38
39
#include <
opm/models/discretization/common/fvbaseprimaryvariables.hh
>
40
41
namespace
Opm
{
42
51
template
<
class
TypeTag>
52
class
RichardsPrimaryVariables :
public
FvBasePrimaryVariables<TypeTag>
53
{
54
using
ParentType = FvBasePrimaryVariables<TypeTag>;
55
using
Scalar =
GetPropType<TypeTag, Properties::Scalar>
;
56
using
Evaluation =
GetPropType<TypeTag, Properties::Evaluation>
;
57
using
FluidSystem =
GetPropType<TypeTag, Properties::FluidSystem>
;
58
using
MaterialLaw =
GetPropType<TypeTag, Properties::MaterialLaw>
;
59
using
MaterialLawParams =
GetPropType<TypeTag, Properties::MaterialLawParams>
;
60
using
EnergyModule =
GetPropType<TypeTag, Properties::IntensiveQuantities>
;
61
using
Indices =
GetPropType<TypeTag, Properties::Indices>
;
62
63
// primary variable indices
64
enum
{ pressureWIdx = Indices::pressureWIdx };
65
66
enum
{ liquidPhaseIdx =
getPropValue<TypeTag, Properties::LiquidPhaseIndex>
() };
67
enum
{ gasPhaseIdx =
getPropValue<TypeTag, Properties::GasPhaseIndex>
() };
68
69
enum
{ numPhases =
getPropValue<TypeTag, Properties::NumPhases>
() };
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 = MathToolbox<Evaluation>;
75
using
ImmiscibleFlash = ::Opm::ImmiscibleFlash<Scalar, FluidSystem>;
76
77
public
:
78
RichardsPrimaryVariables()
79
: ParentType()
80
{ Opm::Valgrind::SetUndefined(*
this
); }
81
86
RichardsPrimaryVariables
(
const
RichardsPrimaryVariables& value) =
default
;
87
RichardsPrimaryVariables& operator=(
const
RichardsPrimaryVariables& value) =
default
;
88
89
using
ParentType::operator=;
90
100
void
assignImmiscibleFromWetting
(Scalar T, Scalar pw, Scalar Sw,
101
const
MaterialLawParams& matParams)
102
{
103
ImmiscibleFluidState<Scalar, FluidSystem> fs;
104
105
fs.setTemperature(T);
106
fs.setSaturation(liquidPhaseIdx, Sw);
107
fs.setSaturation(gasPhaseIdx, 1 - Sw);
108
109
// set phase pressures
110
PhaseVector pC;
111
MaterialLaw::capillaryPressures(pC, matParams, fs);
112
113
fs.setPressure(liquidPhaseIdx, pw);
114
fs.setPressure(gasPhaseIdx, pw + (pC[gasPhaseIdx] - pC[liquidPhaseIdx]));
115
116
assignNaive
(fs);
117
}
118
128
void
assignImmiscibleFromNonWetting
(Scalar T, Scalar pn, Scalar Sn,
129
const
MaterialLawParams& matParams)
130
{
131
Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
132
133
fs.setTemperature(T);
134
fs.setSaturation(liquidPhaseIdx, 1 - Sn);
135
fs.setSaturation(gasPhaseIdx, Sn);
136
137
// set phase pressures
138
PhaseVector pC;
139
MaterialLaw::capillaryPressures(pC, matParams, fs);
140
141
fs.setPressure(gasPhaseIdx, pn);
142
fs.setPressure(gasPhaseIdx, pn + (pC[liquidPhaseIdx] - pC[gasPhaseIdx]));
143
144
assignNaive
(fs);
145
}
146
150
template
<
class
Flu
id
State>
151
void
assignMassConservative
(
const
FluidState& fluidState,
152
const
MaterialLawParams& matParams,
153
bool
=
false
)
154
{
155
ComponentVector globalMolarities(0.0);
156
for
(
unsigned
compIdx = 0; compIdx < numComponents; ++compIdx) {
157
for
(
unsigned
phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
158
globalMolarities[compIdx] +=
159
fluidState.molarity(phaseIdx, compIdx) * fluidState.saturation(phaseIdx);
160
}
161
}
162
163
ImmiscibleFluidState<Scalar, FluidSystem> fsFlash;
164
fsFlash.assign(fluidState);
165
typename
FluidSystem::ParameterCache paramCache;
166
ImmiscibleFlash::template solve<MaterialLaw>(fsFlash, paramCache,
167
matParams,
168
globalMolarities);
169
170
assignNaive
(fsFlash);
171
}
172
176
template
<
class
Flu
id
State>
177
void
assignNaive
(
const
FluidState& fluidState)
178
{
179
// assign the phase temperatures. this is out-sourced to
180
// the energy module
181
EnergyModule::setPriVarTemperatures(*
this
, fluidState);
182
183
(*this)[pressureWIdx] = fluidState.pressure(liquidPhaseIdx);
184
}
185
};
186
187
}
// namespace Opm
188
189
#endif
Opm::RichardsPrimaryVariables::assignMassConservative
void assignMassConservative(const FluidState &fluidState, const MaterialLawParams &matParams, bool=false)
< Import base class assignment operators.
Definition
richardsprimaryvariables.hh:151
Opm::RichardsPrimaryVariables::RichardsPrimaryVariables
RichardsPrimaryVariables(const RichardsPrimaryVariables &value)=default
Opm::RichardsPrimaryVariables::assignNaive
void assignNaive(const FluidState &fluidState)
Directly retrieve the primary variables from an arbitrary fluid state.
Definition
richardsprimaryvariables.hh:177
Opm::RichardsPrimaryVariables::assignImmiscibleFromWetting
void assignImmiscibleFromWetting(Scalar T, Scalar pw, Scalar Sw, const MaterialLawParams &matParams)
< Import base class assignment operators.
Definition
richardsprimaryvariables.hh:100
Opm::RichardsPrimaryVariables::assignImmiscibleFromNonWetting
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:128
fvbaseprimaryvariables.hh
Represents the primary variables used by the a model.
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition
blackoilbioeffectsmodules.hh:43
Opm::GetPropType
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:233
Opm::getPropValue
constexpr auto getPropValue()
get the value data member of a property
Definition
propertysystem.hh:240
richardsproperties.hh
Contains the property declarations for the Richards model.
opm
models
richards
richardsprimaryvariables.hh
Generated by
1.17.0