multiphasebasemodel.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_MULTI_PHASE_BASE_MODEL_HH
29#define EWOMS_MULTI_PHASE_BASE_MODEL_HH
30
31#include <opm/material/densead/Math.hpp>
32
36
41
42#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
43#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
44#include <opm/material/thermal/NullThermalConductionLaw.hpp>
45#include <opm/material/thermal/NullSolidEnergyLaw.hpp>
46
47namespace Opm {
48template <class TypeTag>
49class MultiPhaseBaseModel;
50}
51
52namespace Opm::Properties {
53
55// Create new type tags
56namespace TTag {
57struct MultiPhaseBaseModel { using InheritsFrom = std::tuple<VtkTemperature, VtkMultiPhase>; };
58} // end namespace TTag
59
61template<class TypeTag>
62struct Splices<TypeTag, TTag::MultiPhaseBaseModel>
63{
64 using type = std::tuple<GetSplicePropType<TypeTag, TTag::MultiPhaseBaseModel, Properties::SpatialDiscretizationSplice>>;
65};
66
70template<class TypeTag>
72
74template<class TypeTag>
75struct NumEq<TypeTag, TTag::MultiPhaseBaseModel> { static constexpr int value = GetPropType<TypeTag, Properties::Indices>::numEq; };
77template<class TypeTag>
78struct NumPhases<TypeTag, TTag::MultiPhaseBaseModel> { static constexpr int value = GetPropType<TypeTag, Properties::FluidSystem>::numPhases; };
80template<class TypeTag>
82
84template<class TypeTag>
86
88template<class TypeTag>
89struct FluxModule<TypeTag, TTag::MultiPhaseBaseModel> { using type = DarcyFluxModule<TypeTag>; };
90
94template<class TypeTag>
95struct MaterialLaw<TypeTag, TTag::MultiPhaseBaseModel>
96{
97private:
100 using Traits = NullMaterialTraits<Scalar, FluidSystem::numPhases>;
101
102public:
103 using type = NullMaterial<Traits>;
104};
105
110template<class TypeTag>
113
116template<class TypeTag>
118{ using type = NullSolidEnergyLaw<GetPropType<TypeTag, Properties::Scalar>>; };
119
122template<class TypeTag>
125
127template<class TypeTag>
129{ using type = NullThermalConductionLaw<GetPropType<TypeTag, Properties::Scalar>>; };
130
133template<class TypeTag>
136
138template<class TypeTag>
139struct EnableGravity<TypeTag, TTag::MultiPhaseBaseModel> { static constexpr bool value = false; };
140
141
142} // namespace Opm::Properties
143
144namespace Opm {
145
151template <class TypeTag>
152class MultiPhaseBaseModel : public GetPropType<TypeTag, Properties::Discretization>
153{
155 using Implementation = GetPropType<TypeTag, Properties::Model>;
164
165 using ElementIterator = typename GridView::template Codim<0>::Iterator;
166 using Element = typename GridView::template Codim<0>::Entity;
167
168 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
169 enum { numComponents = FluidSystem::numComponents };
170
171public:
172 MultiPhaseBaseModel(Simulator& simulator)
173 : ParentType(simulator)
174 { }
175
179 static void registerParameters()
180 {
181 ParentType::registerParameters();
182
183 // register runtime parameters of the VTK output modules
186 }
187
193 bool phaseIsConsidered(unsigned) const
194 { return true; }
195
203 void globalPhaseStorage(EqVector& storage, unsigned phaseIdx)
204 {
205 assert(phaseIdx < numPhases);
206
207 storage = 0;
208
209 ThreadedEntityIterator<GridView, /*codim=*/0> threadedElemIt(this->gridView());
210 std::mutex mutex;
211#ifdef _OPENMP
212#pragma omp parallel
213#endif
214 {
215 // Attention: the variables below are thread specific and thus cannot be
216 // moved in front of the #pragma!
217 unsigned threadId = ThreadManager::threadId();
218 ElementContext elemCtx(this->simulator_);
219 ElementIterator elemIt = threadedElemIt.beginParallel();
220 EqVector tmp;
221
222 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
223 const Element& elem = *elemIt;
224 if (elem.partitionType() != Dune::InteriorEntity)
225 continue; // ignore ghost and overlap elements
226
227 elemCtx.updateStencil(elem);
228 elemCtx.updateIntensiveQuantities(/*timeIdx=*/0);
229
230 const auto& stencil = elemCtx.stencil(/*timeIdx=*/0);
231
232 for (unsigned dofIdx = 0; dofIdx < elemCtx.numDof(/*timeIdx=*/0); ++dofIdx) {
233 const auto& scv = stencil.subControlVolume(dofIdx);
234 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0);
235
236 tmp = 0;
237 this->localResidual(threadId).addPhaseStorage(tmp,
238 elemCtx,
239 dofIdx,
240 /*timeIdx=*/0,
241 phaseIdx);
242 tmp *= scv.volume()*intQuants.extrusionFactor();
243
244 mutex.lock();
245 storage += tmp;
246 mutex.unlock();
247 }
248 }
249 }
250
251 storage = this->gridView_.comm().sum(storage);
252 }
253
255 {
256 ParentType::registerOutputModules_();
257
258 // add the VTK output modules which make sense for all multi-phase models
259 this->addOutputModule(new VtkMultiPhaseModule<TypeTag>(this->simulator_));
260 this->addOutputModule(new VtkTemperatureModule<TypeTag>(this->simulator_));
261 }
262
263private:
264 const Implementation& asImp_() const
265 { return *static_cast<const Implementation *>(this); }
266};
267} // namespace Opm
268
269#endif
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:153
void globalPhaseStorage(EqVector &storage, unsigned phaseIdx)
Compute the total storage inside one phase of all conservation quantities.
Definition: multiphasebasemodel.hh:203
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:179
void registerOutputModules_()
Definition: multiphasebasemodel.hh:254
MultiPhaseBaseModel(Simulator &simulator)
Definition: multiphasebasemodel.hh:172
bool phaseIsConsidered(unsigned) const
Returns true iff a fluid phase is used by the model.
Definition: multiphasebasemodel.hh:193
The base class for the problems of ECFV discretizations which deal with a multi-phase flow through a ...
Definition: multiphasebaseproblem.hh:57
static unsigned threadId()
Return the index of the current OpenMP thread.
Definition: threadmanager.hh:124
Provides an STL-iterator like interface to iterate over the enties of a GridView in OpenMP threaded a...
Definition: threadedentityiterator.hh:43
bool isFinished(const EntityIterator &it) const
Definition: threadedentityiterator.hh:67
EntityIterator increment()
Definition: threadedentityiterator.hh:80
EntityIterator beginParallel()
Definition: threadedentityiterator.hh:55
VTK output module for quantities which make sense for all models which deal with multiple fluid phase...
Definition: vtkmultiphasemodule.hh:129
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkmultiphasemodule.hh:163
VTK output module for the temperature in which assume thermal equilibrium.
Definition: vtktemperaturemodule.hh:67
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtktemperaturemodule.hh:89
This file contains the necessary classes to calculate the velocity out of a pressure potential gradie...
Defines the common properties required by the porous medium multi-phase models.
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
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:242
Specifies a flux module which uses the Darcy relation.
Definition: darcyfluxmodule.hh:63
The type of the base class for all problems which use this model.
Definition: fvbaseproperties.hh:101
Returns whether gravity is considered in the problem.
Definition: multiphasebaseproperties.hh:79
Specifies the relation used for velocity.
Definition: multiphasebaseproperties.hh:72
NullMaterial< Traits > type
Definition: multiphasebasemodel.hh:103
typename GetPropType< TypeTag, Properties::MaterialLaw >::Params type
Definition: multiphasebasemodel.hh:112
The context material law (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:54
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:51
Number of chemical species in the system.
Definition: multiphasebaseproperties.hh:45
Number of equations in the system of PDEs.
Definition: basicproperties.hh:73
Number of fluid phases in the system.
Definition: multiphasebaseproperties.hh:42
NullSolidEnergyLaw< GetPropType< TypeTag, Properties::Scalar > > type
Definition: multiphasebasemodel.hh:118
typename GetPropType< TypeTag, Properties::SolidEnergyLaw >::Params type
Definition: multiphasebasemodel.hh:124
The parameters of the material law for energy storage of the solid.
Definition: multiphasebaseproperties.hh:60
The material law for the energy stored in the solid matrix.
Definition: multiphasebaseproperties.hh:57
The splice to be used for the spatial discretization.
Definition: multiphasebaseproperties.hh:39
std::tuple< GetSplicePropType< TypeTag, TTag::MultiPhaseBaseModel, Properties::SpatialDiscretizationSplice > > type
Definition: multiphasebasemodel.hh:64
Definition: propertysystem.hh:44
Definition: multiphasebasemodel.hh:57
std::tuple< VtkTemperature, VtkMultiPhase > InheritsFrom
Definition: multiphasebasemodel.hh:57
Definition: vcfvproperties.hh:41
NullThermalConductionLaw< GetPropType< TypeTag, Properties::Scalar > > type
Definition: multiphasebasemodel.hh:129
typename GetPropType< TypeTag, Properties::ThermalConductionLaw >::Params type
Definition: multiphasebasemodel.hh:135
The parameters of the material law for thermal conduction.
Definition: multiphasebaseproperties.hh:66
The material law for thermal conduction.
Definition: multiphasebaseproperties.hh:63