Loading...
Searching...
No Matches
multiphasebasemodel.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_MULTI_PHASE_BASE_MODEL_HH
#define EWOMS_MULTI_PHASE_BASE_MODEL_HH
#include <opm/material/densead/Math.hpp>
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
#include <opm/material/thermal/NullSolidEnergyLaw.hpp>
#include <opm/material/thermal/NullThermalConductionLaw.hpp>
#include <opm/models/common/flux.hh>
#include <opm/models/common/multiphasebaseparameters.hh>
#include <opm/models/common/multiphasebaseproperties.hh>
#include <opm/models/common/multiphasebaseproblem.hh>
#include <opm/models/common/multiphasebaseextensivequantities.hh>
#include <opm/models/discretization/vcfv/vcfvdiscretization.hh>
#include <opm/models/io/vtkmultiphasemodule.hpp>
#include <opm/models/io/vtktemperaturemodule.hpp>
#include <cassert>
#include <memory>
#include <mutex>
#include <tuple>
namespace Opm {
template <class TypeTag>
class MultiPhaseBaseModel;
}
namespace Opm::Properties {
// Create new type tags
namespace TTag {
struct MultiPhaseBaseModel {};
} // end namespace TTag
template<class TypeTag>
struct Splices<TypeTag, TTag::MultiPhaseBaseModel>
{
using type = std::tuple<GetSplicePropType<TypeTag,
TTag::MultiPhaseBaseModel,
Properties::SpatialDiscretizationSplice>>;
};
template<class TypeTag>
struct SpatialDiscretizationSplice<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = TTag::VcfvDiscretization; };
template<class TypeTag>
struct NumEq<TypeTag, TTag::MultiPhaseBaseModel>
{ static constexpr int value = GetPropType<TypeTag, Properties::Indices>::numEq; };
template<class TypeTag>
struct NumPhases<TypeTag, TTag::MultiPhaseBaseModel>
{ static constexpr int value = GetPropType<TypeTag, Properties::FluidSystem>::numPhases; };
template<class TypeTag>
struct NumComponents<TypeTag, TTag::MultiPhaseBaseModel>
{ static constexpr int value = GetPropType<TypeTag, Properties::FluidSystem>::numComponents; };
template<class TypeTag>
struct BaseProblem<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = MultiPhaseBaseProblem<TypeTag>; };
template<class TypeTag>
struct FluxModule<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = DarcyFluxModule<TypeTag>; };
template<class TypeTag>
struct MaterialLaw<TypeTag, TTag::MultiPhaseBaseModel>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using Traits = NullMaterialTraits<Scalar, FluidSystem::numPhases>;
public:
using type = NullMaterial<Traits>;
};
template<class TypeTag>
struct MaterialLawParams<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = typename GetPropType<TypeTag, Properties::MaterialLaw>::Params; };
template<class TypeTag>
struct SolidEnergyLaw<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = NullSolidEnergyLaw<GetPropType<TypeTag, Properties::Scalar>>; };
template<class TypeTag>
struct SolidEnergyLawParams<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = typename GetPropType<TypeTag, Properties::SolidEnergyLaw>::Params; };
template<class TypeTag>
struct ThermalConductionLaw<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = NullThermalConductionLaw<GetPropType<TypeTag, Properties::Scalar>>; };
template<class TypeTag>
struct ThermalConductionLawParams<TypeTag, TTag::MultiPhaseBaseModel>
{ using type = typename GetPropType<TypeTag, Properties::ThermalConductionLaw>::Params; };
} // namespace Opm::Properties
namespace Opm {
template <class TypeTag>
class MultiPhaseBaseModel : public GetPropType<TypeTag, Properties::Discretization>
{
using ParentType = GetPropType<TypeTag, Properties::Discretization>;
using Implementation = GetPropType<TypeTag, Properties::Problem>;
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
using ThreadManager = GetPropType<TypeTag, Properties::ThreadManager>;
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
using EqVector = GetPropType<TypeTag, Properties::EqVector>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
using ElementIterator = typename GridView::template Codim<0>::Iterator;
using Element = typename GridView::template Codim<0>::Entity;
enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
public:
explicit MultiPhaseBaseModel(Simulator& simulator)
: ParentType(simulator)
{}
static void registerParameters()
{
ParentType::registerParameters();
// register runtime parameters of the VTK output modules
VtkMultiPhaseModule<TypeTag>::registerParameters();
VtkTemperatureModule<TypeTag>::registerParameters();
}
bool phaseIsConsidered(unsigned) const
{ return true; }
void globalPhaseStorage(EqVector& storage, unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
storage = 0;
ThreadedEntityIterator<GridView, /*codim=*/0> threadedElemIt(this->gridView());
std::mutex mutex;
#ifdef _OPENMP
#pragma omp parallel
#endif
{
// Attention: the variables below are thread specific and thus cannot be
// moved in front of the #pragma!
const unsigned threadId = ThreadManager::threadId();
ElementContext elemCtx(this->simulator_);
ElementIterator elemIt = threadedElemIt.beginParallel();
EqVector tmp;
for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
const Element& elem = *elemIt;
if (elem.partitionType() != Dune::InteriorEntity) {
continue; // ignore ghost and overlap elements
}
elemCtx.updateStencil(elem);
elemCtx.updateIntensiveQuantities(/*timeIdx=*/0);
const auto& stencil = elemCtx.stencil(/*timeIdx=*/0);
for (unsigned dofIdx = 0; dofIdx < elemCtx.numDof(/*timeIdx=*/0); ++dofIdx) {
const auto& scv = stencil.subControlVolume(dofIdx);
const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0);
tmp = 0;
this->localResidual(threadId).addPhaseStorage(tmp,
elemCtx,
dofIdx,
/*timeIdx=*/0,
phaseIdx);
tmp *= scv.volume() * intQuants.extrusionFactor();
mutex.lock();
storage += tmp;
mutex.unlock();
}
}
}
storage = this->gridView_.comm().sum(storage);
}
void registerOutputModules_()
{
ParentType::registerOutputModules_();
// add the VTK output modules which make sense for all multi-phase models
this->addOutputModule(std::make_unique<VtkMultiPhaseModule<TypeTag>>(this->simulator_));
this->addOutputModule(std::make_unique<VtkTemperatureModule<TypeTag>>(this->simulator_));
}
private:
const Implementation& asImp_() const
{ return *static_cast<const Implementation*>(this); }
};
} // namespace Opm
#endif
Opm::MultiPhaseBaseModel
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition multiphasebasemodel.hh:168
Opm::MultiPhaseBaseModel::globalPhaseStorage
void globalPhaseStorage(EqVector &storage, unsigned phaseIdx)
Compute the total storage inside one phase of all conservation quantities.
Definition multiphasebasemodel.hh:214
Opm::MultiPhaseBaseModel::registerParameters
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition multiphasebasemodel.hh:190
Opm::MultiPhaseBaseModel::phaseIsConsidered
bool phaseIsConsidered(unsigned) const
Returns true iff a fluid phase is used by the model.
Definition multiphasebasemodel.hh:204
Opm::MultiPhaseBaseProblem
The base class for the problems of ECFV discretizations which deal with a multi-phase flow through a ...
Definition multiphasebaseproblem.hh:65
Opm::ThreadManager::threadId
static unsigned threadId()
Return the index of the current OpenMP thread.
Definition threadmanager.cpp:84
Opm::ThreadedEntityIterator
Provides an STL-iterator like interface to iterate over the enties of a GridView in OpenMP threaded a...
Definition threadedentityiterator.hh:42
Opm::VtkMultiPhaseModule
VTK output module for quantities which make sense for all models which deal with multiple fluid phase...
Definition vtkmultiphasemodule.hpp:73
Opm::VtkMultiPhaseModule::registerParameters
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition vtkmultiphasemodule.hpp:110
Opm::VtkTemperatureModule
VTK output module for the temperature in which assume thermal equilibrium.
Definition vtktemperaturemodule.hpp:51
Opm::VtkTemperatureModule::registerParameters
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition vtktemperaturemodule.hpp:75
flux.hh
This file contains the necessary classes to calculate the velocity out of a pressure potential gradie...
multiphasebaseextensivequantities.hh
This class calculates the pressure potential gradients and the filter velocities for multi-phase flow...
multiphasebaseparameters.hh
Defines the common parameters for the porous medium multi-phase models.
multiphasebaseproblem.hh
The base class for the problems of ECFV discretizations which deal with a multi-phase flow through a ...
multiphasebaseproperties.hh
Defines the common properties required by the porous medium multi-phase models.
Opm::Properties::TTag
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
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::DarcyFluxModule
Specifies a flux module which uses the Darcy relation.
Definition darcyfluxmodule.hh:67
Opm::Properties::BaseProblem
The type of the base class for all problems which use this model.
Definition fvbaseproperties.hh:84
Opm::Properties::FluxModule
Specifies the relation used for velocity.
Definition multiphasebaseproperties.hh:83
Opm::Properties::MaterialLawParams
The context material law (extracted from the spatial parameters).
Definition multiphasebaseproperties.hh:59
Opm::Properties::MaterialLaw
The material law which ought to be used (extracted from the spatial parameters).
Definition multiphasebaseproperties.hh:55
Opm::Properties::NumComponents
Number of chemical species in the system.
Definition multiphasebaseproperties.hh:47
Opm::Properties::NumEq
Number of equations in the system of PDEs.
Definition basicproperties.hh:80
Opm::Properties::NumPhases
Number of fluid phases in the system.
Definition multiphasebaseproperties.hh:43
Opm::Properties::SolidEnergyLawParams
The parameters of the material law for energy storage of the solid.
Definition multiphasebaseproperties.hh:67
Opm::Properties::SolidEnergyLaw
The material law for the energy stored in the solid matrix.
Definition multiphasebaseproperties.hh:63
Opm::Properties::SpatialDiscretizationSplice
The splice to be used for the spatial discretization.
Definition multiphasebaseproperties.hh:39
Opm::Properties::Splices
Definition propertysystem.hh:42
Opm::Properties::TTag::MultiPhaseBaseModel
Definition multiphasebasemodel.hh:66
Opm::Properties::TTag::VcfvDiscretization
Definition vcfvproperties.hh:41
Opm::Properties::ThermalConductionLawParams
The parameters of the material law for thermal conduction.
Definition multiphasebaseproperties.hh:75
Opm::Properties::ThermalConductionLaw
The material law for thermal conduction.
Definition multiphasebaseproperties.hh:71
vcfvdiscretization.hh
The base class for the vertex centered finite volume discretization scheme.
vtkmultiphasemodule.hpp
VTK output module for quantities which make sense for all models which deal with multiple fluid phase...
vtktemperaturemodule.hpp
VTK output module for the temperature in which assume thermal equilibrium.