Loading...
Searching...
No Matches
richardsprimaryvariables.hh
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef EWOMS_RICHARDS_PRIMARY_VARIABLES_HH
#define EWOMS_RICHARDS_PRIMARY_VARIABLES_HH
#include <dune/common/fvector.hh>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/constraintsolvers/ImmiscibleFlash.hpp>
#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
#include <opm/models/richards/richardsproperties.hh>
#include <opm/models/discretization/common/fvbaseprimaryvariables.hh>
namespace Opm {
template <class TypeTag>
class RichardsPrimaryVariables : public FvBasePrimaryVariables<TypeTag>
{
using ParentType = FvBasePrimaryVariables<TypeTag>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Evaluation = GetPropType<TypeTag, Properties::Evaluation>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
using EnergyModule = GetPropType<TypeTag, Properties::IntensiveQuantities>;
using Indices = GetPropType<TypeTag, Properties::Indices>;
// primary variable indices
enum { pressureWIdx = Indices::pressureWIdx };
enum { liquidPhaseIdx = getPropValue<TypeTag, Properties::LiquidPhaseIndex>() };
enum { gasPhaseIdx = getPropValue<TypeTag, Properties::GasPhaseIndex>() };
enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
using ComponentVector = Dune::FieldVector<Scalar, numComponents>;
using PhaseVector = Dune::FieldVector<Scalar, numPhases>;
using Toolbox = MathToolbox<Evaluation>;
using ImmiscibleFlash = ::Opm::ImmiscibleFlash<Scalar, FluidSystem>;
public:
RichardsPrimaryVariables()
: ParentType()
{ Opm::Valgrind::SetUndefined(*this); }
RichardsPrimaryVariables(const RichardsPrimaryVariables& value) = default;
RichardsPrimaryVariables& operator=(const RichardsPrimaryVariables& value) = default;
using ParentType::operator=;
void assignImmiscibleFromWetting(Scalar T, Scalar pw, Scalar Sw,
const MaterialLawParams& matParams)
{
ImmiscibleFluidState<Scalar, FluidSystem> fs;
fs.setTemperature(T);
fs.setSaturation(liquidPhaseIdx, Sw);
fs.setSaturation(gasPhaseIdx, 1 - Sw);
// set phase pressures
PhaseVector pC;
MaterialLaw::capillaryPressures(pC, matParams, fs);
fs.setPressure(liquidPhaseIdx, pw);
fs.setPressure(gasPhaseIdx, pw + (pC[gasPhaseIdx] - pC[liquidPhaseIdx]));
assignNaive(fs);
}
void assignImmiscibleFromNonWetting(Scalar T, Scalar pn, Scalar Sn,
const MaterialLawParams& matParams)
{
Opm::ImmiscibleFluidState<Scalar, FluidSystem> fs;
fs.setTemperature(T);
fs.setSaturation(liquidPhaseIdx, 1 - Sn);
fs.setSaturation(gasPhaseIdx, Sn);
// set phase pressures
PhaseVector pC;
MaterialLaw::capillaryPressures(pC, matParams, fs);
fs.setPressure(gasPhaseIdx, pn);
fs.setPressure(gasPhaseIdx, pn + (pC[liquidPhaseIdx] - pC[gasPhaseIdx]));
assignNaive(fs);
}
template <class FluidState>
void assignMassConservative(const FluidState& fluidState,
const MaterialLawParams& matParams,
bool = false)
{
ComponentVector globalMolarities(0.0);
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
globalMolarities[compIdx] +=
fluidState.molarity(phaseIdx, compIdx) * fluidState.saturation(phaseIdx);
}
}
ImmiscibleFluidState<Scalar, FluidSystem> fsFlash;
fsFlash.assign(fluidState);
typename FluidSystem::ParameterCache paramCache;
ImmiscibleFlash::template solve<MaterialLaw>(fsFlash, paramCache,
matParams,
globalMolarities);
assignNaive(fsFlash);
}
template <class FluidState>
void assignNaive(const FluidState& fluidState)
{
// assign the phase temperatures. this is out-sourced to
// the energy module
EnergyModule::setPriVarTemperatures(*this, fluidState);
(*this)[pressureWIdx] = fluidState.pressure(liquidPhaseIdx);
}
};
} // namespace Opm
#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.