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
33#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
34#include <opm/material/fluidmatrixinteractions/NullMaterial.hpp>
35
36#include <opm/material/thermal/NullSolidEnergyLaw.hpp>
37#include <opm/material/thermal/NullThermalConductionLaw.hpp>
38
44
46
49
50namespace Opm {
51template <class TypeTag>
52class MultiPhaseBaseModel;
53}
54
55namespace Opm::Properties {
56
58// Create new type tags
59namespace TTag {
60
62
63} // end namespace TTag
64
66template<class TypeTag>
67struct Splices<TypeTag, TTag::MultiPhaseBaseModel>
68{
69 using type = std::tuple<GetSplicePropType<TypeTag, TTag::MultiPhaseBaseModel, Properties::SpatialDiscretizationSplice>>;
70};
71
75template<class TypeTag>
77
79template<class TypeTag>
80struct NumEq<TypeTag, TTag::MultiPhaseBaseModel> { static constexpr int value = GetPropType<TypeTag, Properties::Indices>::numEq; };
82template<class TypeTag>
83struct NumPhases<TypeTag, TTag::MultiPhaseBaseModel> { static constexpr int value = GetPropType<TypeTag, Properties::FluidSystem>::numPhases; };
85template<class TypeTag>
87
89template<class TypeTag>
91
93template<class TypeTag>
94struct FluxModule<TypeTag, TTag::MultiPhaseBaseModel> { using type = DarcyFluxModule<TypeTag>; };
95
99template<class TypeTag>
100struct MaterialLaw<TypeTag, TTag::MultiPhaseBaseModel>
101{
102private:
105 using Traits = NullMaterialTraits<Scalar, FluidSystem::numPhases>;
106
107public:
108 using type = NullMaterial<Traits>;
109};
110
115template<class TypeTag>
118
121template<class TypeTag>
123{ using type = NullSolidEnergyLaw<GetPropType<TypeTag, Properties::Scalar>>; };
124
127template<class TypeTag>
130
132template<class TypeTag>
134{ using type = NullThermalConductionLaw<GetPropType<TypeTag, Properties::Scalar>>; };
135
138template<class TypeTag>
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:60
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:85
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkmultiphasemodule.hh:119
VTK output module for the temperature in which assume thermal equilibrium.
Definition: vtktemperaturemodule.hh:57
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtktemperaturemodule.hh:79
This file contains the necessary classes to calculate the velocity out of a pressure potential gradie...
Defines the common parameters for the porous medium multi-phase models.
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:235
Specifies a flux module which uses the Darcy relation.
Definition: darcyfluxmodule.hh:61
The type of the base class for all problems which use this model.
Definition: fvbaseproperties.hh:84
Specifies the relation used for velocity.
Definition: multiphasebaseproperties.hh:72
NullMaterial< Traits > type
Definition: multiphasebasemodel.hh:108
typename GetPropType< TypeTag, Properties::MaterialLaw >::Params type
Definition: multiphasebasemodel.hh:117
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:80
Number of fluid phases in the system.
Definition: multiphasebaseproperties.hh:42
NullSolidEnergyLaw< GetPropType< TypeTag, Properties::Scalar > > type
Definition: multiphasebasemodel.hh:123
typename GetPropType< TypeTag, Properties::SolidEnergyLaw >::Params type
Definition: multiphasebasemodel.hh:129
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:69
Definition: propertysystem.hh:44
Definition: multiphasebasemodel.hh:61
Definition: vcfvproperties.hh:41
NullThermalConductionLaw< GetPropType< TypeTag, Properties::Scalar > > type
Definition: multiphasebasemodel.hh:134
typename GetPropType< TypeTag, Properties::ThermalConductionLaw >::Params type
Definition: multiphasebasemodel.hh:140
The parameters of the material law for thermal conduction.
Definition: multiphasebaseproperties.hh:66
The material law for thermal conduction.
Definition: multiphasebaseproperties.hh:63