Loading...
Searching...
No Matches
flashintensivequantities.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_FLASH_INTENSIVE_QUANTITIES_HH
#define EWOMS_FLASH_INTENSIVE_QUANTITIES_HH
#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
#include <opm/models/common/diffusionmodule.hh>
#include <opm/models/common/energymodule.hh>
#include <opm/models/flash/flashindices.hh>
#include <opm/models/flash/flashparameters.hh>
#include <opm/models/flash/flashproperties.hh>
#include <array>
namespace Opm {
template <class TypeTag>
class FlashIntensiveQuantities
: public GetPropType<TypeTag, Properties::DiscIntensiveQuantities>
, public DiffusionIntensiveQuantities<TypeTag, getPropValue<TypeTag, Properties::EnableDiffusion>() >
, public EnergyIntensiveQuantities<TypeTag, getPropValue<TypeTag, Properties::EnableEnergy>() >
, public GetPropType<TypeTag, Properties::FluxModule>::FluxIntensiveQuantities
{
using ParentType = GetPropType<TypeTag, Properties::DiscIntensiveQuantities>;
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
using Indices = GetPropType<TypeTag, Properties::Indices>;
using FluxModule = GetPropType<TypeTag, Properties::FluxModule>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
using ThreadManager = GetPropType<TypeTag, Properties::ThreadManager>;
// primary variable indices
enum { cTot0Idx = Indices::cTot0Idx };
enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
enum { numComponents = getPropValue<TypeTag, Properties::NumComponents>() };
enum { enableDiffusion = getPropValue<TypeTag, Properties::EnableDiffusion>() };
enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
enum { dimWorld = GridView::dimensionworld };
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Evaluation = GetPropType<TypeTag, Properties::Evaluation>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using FlashSolver = GetPropType<TypeTag, Properties::FlashSolver>;
using ComponentVector = Dune::FieldVector<Evaluation, numComponents>;
using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using FluxIntensiveQuantities = typename FluxModule::FluxIntensiveQuantities;
using DiffusionIntensiveQuantities = ::Opm::DiffusionIntensiveQuantities<TypeTag, enableDiffusion>;
using EnergyIntensiveQuantities = ::Opm::EnergyIntensiveQuantities<TypeTag, enableEnergy>;
public:
using FluidState = CompositionalFluidState<Evaluation, FluidSystem, enableEnergy>;
FlashIntensiveQuantities() = default;
FlashIntensiveQuantities(const FlashIntensiveQuantities& other) = default;
FlashIntensiveQuantities& operator=(const FlashIntensiveQuantities& other) = default;
void update(const ElementContext& elemCtx, unsigned dofIdx, unsigned timeIdx)
{
ParentType::update(elemCtx, dofIdx, timeIdx);
EnergyIntensiveQuantities::updateTemperatures_(fluidState_, elemCtx, dofIdx, timeIdx);
const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
const auto& problem = elemCtx.problem();
const Scalar flashTolerance = Parameters::Get<Parameters::FlashTolerance<Scalar>>();
// extract the total molar densities of the components
ComponentVector cTotal;
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
cTotal[compIdx] = priVars.makeEvaluation(cTot0Idx + compIdx, timeIdx);
}
const auto* hint = elemCtx.thermodynamicHint(dofIdx, timeIdx);
if (hint) {
// use the same fluid state as the one of the hint, but
// make sure that we don't overwrite the temperature
// specified by the primary variables
const Evaluation T = fluidState_.temperature(/*phaseIdx=*/0);
fluidState_.assign(hint->fluidState());
fluidState_.setTemperature(T);
}
else {
FlashSolver::guessInitial(fluidState_, cTotal);
}
// compute the phase compositions, densities and pressures
typename FluidSystem::template ParameterCache<Evaluation> paramCache;
const MaterialLawParams& materialParams =
problem.materialLawParams(elemCtx, dofIdx, timeIdx);
FlashSolver::template solve<MaterialLaw>(fluidState_,
materialParams,
paramCache,
cTotal,
flashTolerance);
// calculate relative permeabilities
MaterialLaw::relativePermeabilities(relativePermeability_,
materialParams, fluidState_);
Valgrind::CheckDefined(relativePermeability_);
// set the phase viscosities
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
paramCache.updatePhase(fluidState_, phaseIdx);
const Evaluation& mu = FluidSystem::viscosity(fluidState_, paramCache, phaseIdx);
fluidState_.setViscosity(phaseIdx, mu);
mobility_[phaseIdx] = relativePermeability_[phaseIdx] / mu;
Valgrind::CheckDefined(mobility_[phaseIdx]);
}
// calculate the remaining quantities
// porosity
porosity_ = problem.porosity(elemCtx, dofIdx, timeIdx);
Valgrind::CheckDefined(porosity_);
// intrinsic permeability
intrinsicPerm_ = problem.intrinsicPermeability(elemCtx, dofIdx, timeIdx);
// update the quantities specific for the velocity model
FluxIntensiveQuantities::update_(elemCtx, dofIdx, timeIdx);
// energy related quantities
EnergyIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);
// update the diffusion specific quantities of the intensive quantities
DiffusionIntensiveQuantities::update_(fluidState_, paramCache, elemCtx, dofIdx, timeIdx);
}
const FluidState& fluidState() const
{ return fluidState_; }
const DimMatrix& intrinsicPermeability() const
{ return intrinsicPerm_; }
const Evaluation& relativePermeability(unsigned phaseIdx) const
{ return relativePermeability_[phaseIdx]; }
const Evaluation& mobility(unsigned phaseIdx) const
{ return mobility_[phaseIdx]; }
const Evaluation& porosity() const
{ return porosity_; }
private:
DimMatrix intrinsicPerm_;
FluidState fluidState_;
Evaluation porosity_;
std::array<Evaluation,numPhases> relativePermeability_;
std::array<Evaluation,numPhases> mobility_;
};
} // namespace Opm
#endif
Opm::DiffusionIntensiveQuantities
Provides the volumetric quantities required for the calculation of molecular diffusive fluxes.
Definition diffusionmodule.hh:143
Opm::EnergyIntensiveQuantities
Provides the volumetric quantities required for the energy equation.
Definition energymodule.hh:535
Opm::FlashIntensiveQuantities::mobility
const Evaluation & mobility(unsigned phaseIdx) const
Returns the effective mobility of a given phase within the control volume.
Definition flashintensivequantities.hh:200
Opm::FlashIntensiveQuantities::intrinsicPermeability
const DimMatrix & intrinsicPermeability() const
Returns the intrinsic permeability tensor a degree of freedom.
Definition flashintensivequantities.hh:188
Opm::FlashIntensiveQuantities::fluidState
const FluidState & fluidState() const
Returns the phase state for the control-volume.
Definition flashintensivequantities.hh:182
Opm::FlashIntensiveQuantities::porosity
const Evaluation & porosity() const
Returns the average porosity within the control volume.
Definition flashintensivequantities.hh:206
Opm::FlashIntensiveQuantities::relativePermeability
const Evaluation & relativePermeability(unsigned phaseIdx) const
Returns the relative permeability of a given phase within the control volume.
Definition flashintensivequantities.hh:194
Opm::FlashIntensiveQuantities::FluidState
CompositionalFluidState< Evaluation, FluidSystem, enableEnergy > FluidState
The type of the object returned by the fluidState() method.
Definition flashintensivequantities.hh:93
Opm::FlashIntensiveQuantities::update
void update(const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx)
Definition flashintensivequantities.hh:104
diffusionmodule.hh
Classes required for molecular diffusion.
energymodule.hh
Contains the classes required to consider energy as a conservation quantity in a multi-phase module.
flashindices.hh
Defines the primary variable and equation indices for the compositional multi-phase model based on fl...
flashparameters.hh
Declares the parameters for the compositional multi-phase model based on flash calculations.
flashproperties.hh
Declares the properties required by the compositional multi-phase model based on flash calculations.
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
Opm::Parameters::Get
auto Get(bool errorIfNotRegistered=true)
Retrieve a runtime parameter.
Definition parametersystem.hpp:187