25#ifndef DUMUX_POROMECHANICS_COUPLING_MANAGER_HH
26#define DUMUX_POROMECHANICS_COUPLING_MANAGER_HH
50template<
class MDTraits,
51 std::size_t PMFlowId = 0,
52 std::size_t PoroMechId = PMFlowId+1 >
58 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
65 template<std::
size_t id>
using PrimaryVariables =
typename GridVariables<id>::PrimaryVariables;
66 template<std::
size_t id>
using GridVolumeVariables =
typename GridVariables<id>::GridVolumeVariables;
67 template<std::
size_t id>
using ElementVolumeVariables =
typename GridVolumeVariables<id>::LocalView;
68 template<std::
size_t id>
using VolumeVariables =
typename GridVolumeVariables<id>::VolumeVariables;
69 template<std::
size_t id>
using GridGeometry =
typename GridVariables<id>::GridGeometry;
70 template<std::
size_t id>
using FVElementGeometry =
typename GridGeometry<id>::LocalView;
71 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
72 template<std::
size_t id>
using GridIndexType =
typename GridView<id>::IndexSet::IndexType;
73 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
74 template<std::
size_t id>
using GlobalPosition =
typename Element<id>::Geometry::GlobalCoordinate;
77 static_assert(std::is_same< GridView<PMFlowId>, GridView<PoroMechId> >::value,
78 "The grid types of the two sub-problems have to be equal!");
82 "Poro-mechanical problem must be discretized with the box scheme for this coupling manager!");
86 "Porous medium flow problem must be discretized with a cell-centered scheme for this coupling manager!");
90 "Poromechanics framework does not yet work for enabled grid volume variables caching");
93 template<std::
size_t id>
94 using CouplingIndexType =
typename std::conditional<
id == PMFlowId,
95 GridIndexType<PoroMechId>,
96 GridIndexType<PMFlowId> >::type;
103 struct PoroMechanicsCouplingContext
106 Element<PMFlowId> pmFlowElement;
107 std::unique_ptr< FVElementGeometry<PMFlowId> > pmFlowFvGeometry;
108 std::unique_ptr< ElementVolumeVariables<PMFlowId> > pmFlowElemVolVars;
114 static constexpr auto pmFlowId = Dune::index_constant<PMFlowId>();
115 static constexpr auto poroMechId = Dune::index_constant<PoroMechId>();
122 template<std::
size_t i, std::
size_t j = (i == PMFlowId) ? PoroMechId : PMFlowId>
124 std::vector< CouplingIndexType<i> >,
125 std::array< CouplingIndexType<i>, 1> >::type;
137 void init(std::shared_ptr< Problem<PMFlowId> > pmFlowProblem,
138 std::shared_ptr< Problem<PoroMechId> > poroMechanicalProblem,
148 initializeCouplingMap_();
155 const Element<PMFlowId>& element,
156 Dune::index_constant<PoroMechId> poroMechDomainId)
const
158 return pmFlowCouplingMap_[ this->
problem(
pmFlowId).gridGeometry().elementMapper().index(element) ];
165 const Element<PoroMechId>& element,
166 Dune::index_constant<PMFlowId> pmFlowDomainId)
const
168 const auto eIdx = this->
problem(
pmFlowId).gridGeometry().elementMapper().index(element);
179 template<
class Assembler >
181 const Element<PoroMechId>& element,
182 const Assembler& assembler)
185 poroMechCouplingContext_.pmFlowFvGeometry.reset(
nullptr);
186 poroMechCouplingContext_.pmFlowElemVolVars.reset(
nullptr);
191 const auto elemVolVars =
localView(assembler.gridVariables(Dune::index_constant<PMFlowId>()).curGridVolVars()).bindElement(element,
193 this->
curSol(Dune::index_constant<PMFlowId>()));
195 poroMechCouplingContext_.pmFlowElement = element;
196 poroMechCouplingContext_.pmFlowFvGeometry = std::make_unique< FVElementGeometry<PMFlowId> >(fvGeometry);
197 poroMechCouplingContext_.pmFlowElemVolVars = std::make_unique< ElementVolumeVariables<PMFlowId> >(elemVolVars);
205 template<
class PoroMechLocalAssembler >
207 const PoroMechLocalAssembler& poroMechLocalAssembler,
208 Dune::index_constant<PMFlowId> pmFlowDomainId,
209 GridIndexType<PMFlowId> dofIdxGlobalJ,
210 const PrimaryVariables<PMFlowId>& priVarsJ,
217 const auto& element = poroMechCouplingContext_.pmFlowElement;
218 const auto& fvGeometry = *poroMechCouplingContext_.pmFlowFvGeometry;
219 poroMechCouplingContext_.pmFlowElemVolVars->bindElement(element, fvGeometry, this->
curSol(pmFlowDomainId));
228 template<
class PoroMechLocalAssembler >
230 const PoroMechLocalAssembler& poroMechLocalAssembler,
231 Dune::index_constant<PoroMechId> poroMechDomainIdJ,
232 GridIndexType<PoroMechId> dofIdxGlobalJ,
233 const PrimaryVariables<PoroMechId>& priVarsJ,
240 (*poroMechCouplingContext_.pmFlowElemVolVars).bindElement(poroMechCouplingContext_.pmFlowElement,
241 *poroMechCouplingContext_.pmFlowFvGeometry,
242 this->curSol(Dune::index_constant<PMFlowId>()));
249 template< std::
size_t j,
class PMFlowLocalAssembler >
251 const PMFlowLocalAssembler& pmFlowLocalAssembler,
252 Dune::index_constant<j> domainIdJ,
253 GridIndexType<j> dofIdxGlobalJ,
254 const PrimaryVariables<j>& priVarsJ,
269 template<
class PMFlowLocalAssembler,
class UpdatableFluxVarCache >
271 const PMFlowLocalAssembler& pmFlowLocalAssembler,
272 ElementVolumeVariables<PMFlowId>& elemVolVars,
273 UpdatableFluxVarCache& elemFluxVarsCache)
276 elemVolVars.bind(pmFlowLocalAssembler.element(),
277 pmFlowLocalAssembler.fvGeometry(),
278 this->curSol(pmFlowDomainId));
281 elemFluxVarsCache.update(pmFlowLocalAssembler.element(),
282 pmFlowLocalAssembler.fvGeometry(),
291 template<
class PoroMechLocalAssembler,
class UpdatableFluxVarCache >
293 const PoroMechLocalAssembler& poroMechLocalAssembler,
294 ElementVolumeVariables<PoroMechId>& elemVolVars,
295 UpdatableFluxVarCache& elemFluxVarsCache)
297 elemVolVars.bind(poroMechLocalAssembler.element(),
298 poroMechLocalAssembler.fvGeometry(),
299 this->curSol(poroMechDomainId));
308 template<
class PMFlowLocalAssembler >
309 typename LocalResidual<PMFlowId>::ElementResidualVector
311 const PMFlowLocalAssembler& pmFlowLocalAssembler,
312 Dune::index_constant<PoroMechId> poroMechDomainId,
313 GridIndexType<PoroMechId> dofIdxGlobalJ)
315 auto res = pmFlowLocalAssembler.localResidual().evalFluxAndSource(pmFlowLocalAssembler.element(),
316 pmFlowLocalAssembler.fvGeometry(),
317 pmFlowLocalAssembler.curElemVolVars(),
318 pmFlowLocalAssembler.elemFluxVarsCache(),
319 pmFlowLocalAssembler.elemBcTypes());
322 if (!pmFlowLocalAssembler.localResidual().isStationary())
323 res += pmFlowLocalAssembler.localResidual().evalStorage(pmFlowLocalAssembler.element(),
324 pmFlowLocalAssembler.fvGeometry(),
325 pmFlowLocalAssembler.prevElemVolVars(),
326 pmFlowLocalAssembler.curElemVolVars());
337 template<
class PoroMechLocalAssembler >
338 typename LocalResidual<PoroMechId>::ElementResidualVector
340 const PoroMechLocalAssembler& poroMechLocalAssembler,
341 Dune::index_constant<PMFlowId> pmFlowDomainId,
342 GridIndexType<PMFlowId> dofIdxGlobalJ)
344 return poroMechLocalAssembler.localResidual().evalFluxAndSource(poroMechLocalAssembler.element(),
345 poroMechLocalAssembler.fvGeometry(),
346 poroMechLocalAssembler.curElemVolVars(),
347 poroMechLocalAssembler.elemFluxVarsCache(),
348 poroMechLocalAssembler.elemBcTypes());
352 const VolumeVariables<PMFlowId>&
getPMFlowVolVars(
const Element<PoroMechId>& element)
const
355 const auto eIdx = this->
problem(
poroMechId).gridGeometry().elementMapper().index(element);
356 return (*poroMechCouplingContext_.pmFlowElemVolVars)[eIdx];
364 template<std::
size_t i>
365 const auto&
curSol(Dune::index_constant<i> domainIdx)
const
375 void initializeCouplingMap_()
383 if (pmFlowGridGeom.gridView().size(0) != poroMechGridGeom.gridView().size(0))
384 DUNE_THROW(Dune::InvalidStateException,
"The two sub-problems are assumed to operate on the same mesh!");
386 pmFlowCouplingMap_.resize(pmFlowGridGeom.gridView().size(0));
387 static constexpr int dim = GridView<PMFlowId>::dimension;
388 for (
const auto& element : elements(pmFlowGridGeom.gridView()))
390 const auto eIdx = pmFlowGridGeom.elementMapper().index(element);
393 for (
int i = 0; i < element.geometry().corners(); ++i)
394 pmFlowCouplingMap_[eIdx].push_back( poroMechGridGeom.vertexMapper().subIndex(element, i , dim) );
399 const auto& inverseConnectivity = pmFlowGridGeom.connectivityMap()[eIdx];
400 for (
const auto& dataJ : inverseConnectivity)
401 for (
int i = 0; i < element.geometry().corners(); ++i)
402 pmFlowCouplingMap_[dataJ.globalJ].push_back( poroMechGridGeom.vertexMapper().subIndex(element, i , dim) );
406 for (
auto& stencil : pmFlowCouplingMap_)
408 std::sort(stencil.begin(), stencil.end());
409 stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end());
414 std::vector< CouplingStencilType<PMFlowId> > pmFlowCouplingMap_;
417 PoroMechanicsCouplingContext poroMechCouplingContext_;
Element solution classes and factory functions.
free functions for the evaluation of primary variable gradients inside elements.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
void updateCouplingContext(Dune::index_constant< i > domainI, const LocalAssemblerI &localAssemblerI, Dune::index_constant< j > domainJ, std::size_t dofIdxGlobalJ, const PrimaryVariables< j > &priVarsJ, int pvIdxJ)
updates all data and variables that are necessary to evaluate the residual of the element of domain i...
Definition: multidomain/couplingmanager.hh:195
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
constexpr CCMpfa ccmpfa
Definition: method.hh:135
constexpr CCTpfa cctpfa
Definition: method.hh:134
constexpr Box box
Definition: method.hh:136
Property to specify the type of scalar values.
Definition: common/properties.hh:43
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:55
Definition: common/properties.hh:72
The grid variables object managing variable data on the grid (volvars/fluxvars cache)
Definition: common/properties.hh:121
Coupling manager for porous medium flow problems coupled to a poro-mechanical problem.
Definition: geomechanics/poroelastic/couplingmanager.hh:54
void bindCouplingContext(Dune::index_constant< PoroMechId > poroMechDomainId, const Element< PoroMechId > &element, const Assembler &assembler)
For the assembly of the element residual of an element of the poro-mechanics domain,...
Definition: geomechanics/poroelastic/couplingmanager.hh:180
typename std::conditional< i==PMFlowId, std::vector< CouplingIndexType< i > >, std::array< CouplingIndexType< i >, 1 > >::type CouplingStencilType
The types used for coupling stencils. An element of the poro-mechanical domain always only couples to...
Definition: geomechanics/poroelastic/couplingmanager.hh:125
void updateCoupledVariables(Dune::index_constant< PoroMechId > poroMechDomainId, const PoroMechLocalAssembler &poroMechLocalAssembler, ElementVolumeVariables< PoroMechId > &elemVolVars, UpdatableFluxVarCache &elemFluxVarsCache)
Update the poro-mechanics volume variables after the coupling context has been updated....
Definition: geomechanics/poroelastic/couplingmanager.hh:292
void updateCoupledVariables(Dune::index_constant< PMFlowId > pmFlowDomainId, const PMFlowLocalAssembler &pmFlowLocalAssembler, ElementVolumeVariables< PMFlowId > &elemVolVars, UpdatableFluxVarCache &elemFluxVarsCache)
Update the porous medium flow domain volume variables and flux variables cache after the coupling con...
Definition: geomechanics/poroelastic/couplingmanager.hh:270
const VolumeVariables< PMFlowId > & getPMFlowVolVars(const Element< PoroMechId > &element) const
Return the porous medium flow variables an element/scv of the poromech domain couples to.
Definition: geomechanics/poroelastic/couplingmanager.hh:352
void updateCouplingContext(Dune::index_constant< PMFlowId > pmFlowDomainId, const PMFlowLocalAssembler &pmFlowLocalAssembler, Dune::index_constant< j > domainIdJ, GridIndexType< j > dofIdxGlobalJ, const PrimaryVariables< j > &priVarsJ, unsigned int pvIdxJ)
We need this overload to avoid ambiguity. However, for the porous medium flow domain weonly have to u...
Definition: geomechanics/poroelastic/couplingmanager.hh:250
static constexpr auto pmFlowId
Definition: geomechanics/poroelastic/couplingmanager.hh:114
void updateCouplingContext(Dune::index_constant< PoroMechId > poroMechDomainIdI, const PoroMechLocalAssembler &poroMechLocalAssembler, Dune::index_constant< PoroMechId > poroMechDomainIdJ, GridIndexType< PoroMechId > dofIdxGlobalJ, const PrimaryVariables< PoroMechId > &priVarsJ, unsigned int pvIdxJ)
After deflection of the solution in the poromechanics domain during element residual assembly in that...
Definition: geomechanics/poroelastic/couplingmanager.hh:229
void updateCouplingContext(Dune::index_constant< PoroMechId > poroMechDomainId, const PoroMechLocalAssembler &poroMechLocalAssembler, Dune::index_constant< PMFlowId > pmFlowDomainId, GridIndexType< PMFlowId > dofIdxGlobalJ, const PrimaryVariables< PMFlowId > &priVarsJ, unsigned int pvIdxJ)
After deflection of the solution in the porous medium flow domain during element residual assembly in...
Definition: geomechanics/poroelastic/couplingmanager.hh:206
LocalResidual< PMFlowId >::ElementResidualVector evalCouplingResidual(Dune::index_constant< PMFlowId > pmFlowDomainId, const PMFlowLocalAssembler &pmFlowLocalAssembler, Dune::index_constant< PoroMechId > poroMechDomainId, GridIndexType< PoroMechId > dofIdxGlobalJ)
Evaluates the coupling element residual of the porous medium flow domain with respect to the poro-mec...
Definition: geomechanics/poroelastic/couplingmanager.hh:310
void init(std::shared_ptr< Problem< PMFlowId > > pmFlowProblem, std::shared_ptr< Problem< PoroMechId > > poroMechanicalProblem, const SolutionVector &curSol)
Initialize the coupling manager.
Definition: geomechanics/poroelastic/couplingmanager.hh:137
const CouplingStencilType< PoroMechId > couplingStencil(Dune::index_constant< PoroMechId > poroMechDomainId, const Element< PoroMechId > &element, Dune::index_constant< PMFlowId > pmFlowDomainId) const
Return the coupling element stencil for a given poro-mechanical domain element.
Definition: geomechanics/poroelastic/couplingmanager.hh:164
const auto & curSol(Dune::index_constant< i > domainIdx) const
the solution vector of the subproblem
Definition: geomechanics/poroelastic/couplingmanager.hh:365
typename MDTraits::SolutionVector SolutionVector
the type of the solution vector
Definition: geomechanics/poroelastic/couplingmanager.hh:128
LocalResidual< PoroMechId >::ElementResidualVector evalCouplingResidual(Dune::index_constant< PoroMechId > poroMechDomainId, const PoroMechLocalAssembler &poroMechLocalAssembler, Dune::index_constant< PMFlowId > pmFlowDomainId, GridIndexType< PMFlowId > dofIdxGlobalJ)
Evaluates the coupling element residual of the poromechanical domain with respect to the porous mediu...
Definition: geomechanics/poroelastic/couplingmanager.hh:339
static constexpr auto poroMechId
Definition: geomechanics/poroelastic/couplingmanager.hh:115
const CouplingStencilType< PMFlowId > & couplingStencil(Dune::index_constant< PMFlowId > pmFlowDomainId, const Element< PMFlowId > &element, Dune::index_constant< PoroMechId > poroMechDomainId) const
Return the coupling stencil for a given porous medium flow domain element.
Definition: geomechanics/poroelastic/couplingmanager.hh:154
The interface of the coupling manager for multi domain problems.
Definition: multidomain/couplingmanager.hh:60
void updateCoupledVariables(Dune::index_constant< i > domainI, const LocalAssemblerI &localAssemblerI, UpdatableElementVolVars &elemVolVars, UpdatableFluxVarCache &elemFluxVarsCache)
update variables of domain i that depend on variables in domain j after the coupling context has been...
Definition: multidomain/couplingmanager.hh:220
void setSubProblem(std::shared_ptr< SubProblem > problem, Dune::index_constant< i > domainIdx)
set a pointer to one of the sub problems
Definition: multidomain/couplingmanager.hh:312
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Return a reference to the sub problem.
Definition: multidomain/couplingmanager.hh:321
void bindCouplingContext(Dune::index_constant< i > domainI, const Element< i > &elementI, const Assembler &assembler)
prepares all data and variables that are necessary to evaluate the residual of the element of domain ...
Definition: multidomain/couplingmanager.hh:169
SubSolutionVector< i > & curSol(Dune::index_constant< i > domainIdx)
the solution vector of the subproblem
Definition: multidomain/couplingmanager.hh:350
void updateSolution(const SolutionVector &curSol)
Updates the entire solution vector, e.g. before assembly or after grid adaption Overload might want t...
Definition: multidomain/couplingmanager.hh:231
Declares all properties used in Dumux.
The interface of the coupling manager for multi domain problems.