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
47
48#include <cassert>
49#include <memory>
50#include <mutex>
51#include <tuple>
52
53namespace Opm {
54template <class TypeTag>
55class MultiPhaseBaseModel;
56}
57
58namespace Opm::Properties {
59
61// Create new type tags
62namespace TTag {
63
65
66} // end namespace TTag
67
69template<class TypeTag>
70struct Splices<TypeTag, TTag::MultiPhaseBaseModel>
71{
72 using type = std::tuple<GetSplicePropType<TypeTag,
75};
76
78template<class TypeTag>
79struct NumEq<TypeTag, TTag::MultiPhaseBaseModel>
80{ static constexpr int value = GetPropType<TypeTag, Properties::Indices>::numEq; };
81
83// Default is a fully implicit approach where numDerivaties = numEq;
84template<class TypeTag>
85struct NumDerivatives<TypeTag, TTag::MultiPhaseBaseModel>
86{ static constexpr int value = GetPropType<TypeTag, Properties::Indices>::numEq; };
87
88
90template<class TypeTag>
91struct NumPhases<TypeTag, TTag::MultiPhaseBaseModel>
93
95template<class TypeTag>
96struct NumComponents<TypeTag, TTag::MultiPhaseBaseModel>
98
100template<class TypeTag>
101struct BaseProblem<TypeTag, TTag::MultiPhaseBaseModel>
103
107template<class TypeTag>
108struct MaterialLaw<TypeTag, TTag::MultiPhaseBaseModel>
109{
110private:
113 using Traits = NullMaterialTraits<Scalar, FluidSystem::numPhases>;
114
115public:
116 using type = NullMaterial<Traits>;
117};
118
123template<class TypeTag>
126
129template<class TypeTag>
131{ using type = NullSolidEnergyLaw<GetPropType<TypeTag, Properties::Scalar>>; };
132
135template<class TypeTag>
138
140template<class TypeTag>
142{ using type = NullThermalConductionLaw<GetPropType<TypeTag, Properties::Scalar>>; };
143
146template<class TypeTag>
149
150} // namespace Opm::Properties
151
152namespace Opm {
153
159template <class TypeTag>
160class MultiPhaseBaseModel : public GetPropType<TypeTag, Properties::Discretization>
161{
163 using Implementation = GetPropType<TypeTag, Properties::Problem>;
169
170 using ElementIterator = typename GridView::template Codim<0>::Iterator;
171 using Element = typename GridView::template Codim<0>::Entity;
172
173 enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
174
175public:
176 explicit MultiPhaseBaseModel(Simulator& simulator)
177 : ParentType(simulator)
178 {}
179
183 static void registerParameters()
184 {
185 ParentType::registerParameters();
186
187 // register runtime parameters of the VTK output modules
190 }
191
197 bool phaseIsConsidered(unsigned) const
198 { return true; }
199
207 void globalPhaseStorage(EqVector& storage, unsigned phaseIdx)
208 {
209 assert(phaseIdx < numPhases);
210
211 storage = 0;
212
213 ThreadedEntityIterator<GridView, /*codim=*/0> threadedElemIt(this->gridView());
214 std::mutex mutex;
215#ifdef _OPENMP
216#pragma omp parallel
217#endif
218 {
219 // Attention: the variables below are thread specific and thus cannot be
220 // moved in front of the #pragma!
221 const unsigned threadId = ThreadManager::threadId();
222 ElementContext elemCtx(this->simulator_);
223 ElementIterator elemIt = threadedElemIt.beginParallel();
224 EqVector tmp;
225
226 for (; !threadedElemIt.isFinished(elemIt); elemIt = threadedElemIt.increment()) {
227 const Element& elem = *elemIt;
228 if (elem.partitionType() != Dune::InteriorEntity) {
229 continue; // ignore ghost and overlap elements
230 }
231
232 elemCtx.updateStencil(elem);
233 elemCtx.updateIntensiveQuantities(/*timeIdx=*/0);
234
235 const auto& stencil = elemCtx.stencil(/*timeIdx=*/0);
236
237 for (unsigned dofIdx = 0; dofIdx < elemCtx.numDof(/*timeIdx=*/0); ++dofIdx) {
238 const auto& scv = stencil.subControlVolume(dofIdx);
239 const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, /*timeIdx=*/0);
240
241 tmp = 0;
242 this->localResidual(threadId).addPhaseStorage(tmp,
243 elemCtx,
244 dofIdx,
245 /*timeIdx=*/0,
246 phaseIdx);
247 tmp *= scv.volume() * intQuants.extrusionFactor();
248
249 mutex.lock();
250 storage += tmp;
251 mutex.unlock();
252 }
253 }
254 }
255
256 storage = this->gridView_.comm().sum(storage);
257 }
258
260 {
261 ParentType::registerOutputModules_();
262
263 // add the VTK output modules which make sense for all multi-phase models
264 this->addOutputModule(std::make_unique<VtkMultiPhaseModule<TypeTag>>(this->simulator_));
265 this->addOutputModule(std::make_unique<VtkTemperatureModule<TypeTag>>(this->simulator_));
266 }
267
268private:
269 const Implementation& asImp_() const
270 { return *static_cast<const Implementation*>(this); }
271};
272
273} // namespace Opm
274
275#endif
A base class for fully-implicit multi-phase porous-media flow models which assume multiple fluid phas...
Definition: multiphasebasemodel.hh:161
void globalPhaseStorage(EqVector &storage, unsigned phaseIdx)
Compute the total storage inside one phase of all conservation quantities.
Definition: multiphasebasemodel.hh:207
static void registerParameters()
Register all run-time parameters for the immiscible model.
Definition: multiphasebasemodel.hh:183
void registerOutputModules_()
Definition: multiphasebasemodel.hh:259
MultiPhaseBaseModel(Simulator &simulator)
Definition: multiphasebasemodel.hh:176
bool phaseIsConsidered(unsigned) const
Returns true iff a fluid phase is used by the model.
Definition: multiphasebasemodel.hh:197
The base class for the problems of ECFV discretizations which deal with a multi-phase flow through a ...
Definition: multiphasebaseproblem.hh:65
static unsigned threadId()
Return the index of the current OpenMP thread.
Provides an STL-iterator like interface to iterate over the enties of a GridView in OpenMP threaded a...
Definition: threadedentityiterator.hh:42
bool isFinished(const EntityIterator &it) const
Definition: threadedentityiterator.hh:67
EntityIterator increment()
Definition: threadedentityiterator.hh:80
EntityIterator beginParallel()
Definition: threadedentityiterator.hh:54
VTK output module for quantities which make sense for all models which deal with multiple fluid phase...
Definition: vtkmultiphasemodule.hpp:73
static void registerParameters()
Register all run-time parameters for the multi-phase VTK output module.
Definition: vtkmultiphasemodule.hpp:110
VTK output module for the temperature in which assume thermal equilibrium.
Definition: vtktemperaturemodule.hpp:51
static void registerParameters()
Register all run-time parameters for the Vtk output module.
Definition: vtktemperaturemodule.hpp:75
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:74
Definition: blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetSplicePropImpl< TypeTag, SpliceTypeTag, Property >::type::type GetSplicePropType
Definition: propertysystem.hh:236
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
The type of the base class for all problems which use this model.
Definition: fvbaseproperties.hh:89
NullMaterial< Traits > type
Definition: multiphasebasemodel.hh:116
typename GetPropType< TypeTag, Properties::MaterialLaw >::Params type
Definition: multiphasebasemodel.hh:125
The context material law (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:59
The material law which ought to be used (extracted from the spatial parameters)
Definition: multiphasebaseproperties.hh:55
Number of chemical species in the system.
Definition: multiphasebaseproperties.hh:47
Number of derivatives in the system of PDEs.
Definition: basicproperties.hh:84
Number of equations in the system of PDEs.
Definition: basicproperties.hh:80
Number of fluid phases in the system.
Definition: multiphasebaseproperties.hh:43
NullSolidEnergyLaw< GetPropType< TypeTag, Properties::Scalar > > type
Definition: multiphasebasemodel.hh:131
typename GetPropType< TypeTag, Properties::SolidEnergyLaw >::Params type
Definition: multiphasebasemodel.hh:137
The parameters of the material law for energy storage of the solid.
Definition: multiphasebaseproperties.hh:67
The material law for the energy stored in the solid matrix.
Definition: multiphasebaseproperties.hh:63
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:74
Definition: propertysystem.hh:42
Definition: multiphasebasemodel.hh:64
NullThermalConductionLaw< GetPropType< TypeTag, Properties::Scalar > > type
Definition: multiphasebasemodel.hh:142
typename GetPropType< TypeTag, Properties::ThermalConductionLaw >::Params type
Definition: multiphasebasemodel.hh:148
The parameters of the material law for thermal conduction.
Definition: multiphasebaseproperties.hh:75
The material law for thermal conduction.
Definition: multiphasebaseproperties.hh:71