version 3.7
multidomain/facet/couplingmanager.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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_FACETCOUPLING_MANAGER_HH
13#define DUMUX_FACETCOUPLING_MANAGER_HH
14
17
21
22namespace Dumux {
23namespace FacetCoupling{
24
39template<class VolumeVariables, class Problem, class SolutionVector, class FVGeometry>
40void makeInterpolatedVolVars(VolumeVariables& volVars,
41 const Problem& problem,
42 const SolutionVector& sol,
43 const FVGeometry& fvGeometry,
44 const typename FVGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
45 const typename FVGeometry::GridGeometry::GridView::template Codim<0>::Entity::Geometry& elemGeom,
46 const typename FVGeometry::GridGeometry::GridView::template Codim<0>::Entity::Geometry::GlobalCoordinate& pos)
47{
48 // interpolate solution and set it for each entry in element solution
49 auto elemSol = elementSolution(element, sol, fvGeometry.gridGeometry());
50 const auto centerSol = evalSolution(element, elemGeom, fvGeometry.gridGeometry(), elemSol, pos);
51 for (unsigned int i = 0; i < fvGeometry.numScv(); ++i)
52 elemSol[i] = centerSol;
53
54 // Update volume variables with the interpolated solution. Note that this standard
55 // implementation only works for element-wise constant parameters as we simply use
56 // the first element scv for the vol var update. For heterogeneities within the element
57 // or more complex models (e.g. 2p with interface solver) a corresponding overload
58 // of this function has to be provided!
59 volVars.update(elemSol, problem, element, *scvs(fvGeometry).begin());
60}
61} // end namespace FacetCoupling
62
78template< class MDTraits,
79 class CouplingMapper,
80 std::size_t bulkDomainId = 0,
81 std::size_t lowDimDomainId = 1,
82 class DiscretizationMethod = typename GetPropType<typename MDTraits::template SubDomain<bulkDomainId>::TypeTag, Properties::GridGeometry>::DiscretizationMethod >
84
97template< class MDTraits,
98 class CouplingMapper,
99 std::size_t bulkDomainId = 0,
100 std::size_t facetDomainId = 1,
101 std::size_t edgeDomainId = 2 >
103: public FacetCouplingManager<MDTraits, CouplingMapper, bulkDomainId, facetDomainId>
104, public FacetCouplingManager<MDTraits, CouplingMapper, facetDomainId, edgeDomainId>
105{
108
109 // convenience aliases and instances of the domain ids
110 using BulkIdType = typename MDTraits::template SubDomain<bulkDomainId>::Index;
111 using FacetIdType = typename MDTraits::template SubDomain<facetDomainId>::Index;
112 using EdgeIdType = typename MDTraits::template SubDomain<edgeDomainId>::Index;
113 static constexpr auto bulkId = BulkIdType();
114 static constexpr auto facetId = FacetIdType();
115 static constexpr auto edgeId = EdgeIdType();
116
117 // the sub-domain type tags
118 template<std::size_t id> using SubDomainTypeTag = typename MDTraits::template SubDomain<id>::TypeTag;
119
120 // further types specific to the sub-problems
121 template<std::size_t id> using LocalResidual = GetPropType<SubDomainTypeTag<id>, Properties::LocalResidual>;
122 template<std::size_t id> using PrimaryVariables = GetPropType<SubDomainTypeTag<id>, Properties::PrimaryVariables>;
123 template<std::size_t id> using Problem = GetPropType<SubDomainTypeTag<id>, Properties::Problem>;
124
125 template<std::size_t id> using GridGeometry = GetPropType<SubDomainTypeTag<id>, Properties::GridGeometry>;
126 template<std::size_t id> using FVElementGeometry = typename GridGeometry<id>::LocalView;
127 template<std::size_t id> using SubControlVolumeFace = typename GridGeometry<id>::SubControlVolumeFace;
128 template<std::size_t id> using GridView = typename GridGeometry<id>::GridView;
129 template<std::size_t id> using GridIndexType = typename IndexTraits<GridView<id>>::GridIndex;
130 template<std::size_t id> using Element = typename GridView<id>::template Codim<0>::Entity;
131
132 template<std::size_t id> using GridVariables = GetPropType<SubDomainTypeTag<id>, Properties::GridVariables>;
133 template<std::size_t id> using ElementVolumeVariables = typename GridVariables<id>::GridVolumeVariables::LocalView;
134 template<std::size_t id> using ElementFluxVariablesCache = typename GridVariables<id>::GridFluxVariablesCache::LocalView;
135
136 // helper function to check if a domain uses mpfa
137 template<std::size_t id>
138 static constexpr bool usesMpfa(Dune::index_constant<id> domainId)
139 { return GridGeometry<domainId>::discMethod == DiscretizationMethods::ccmpfa; }
140
141public:
143 template<std::size_t i, std::size_t j>
144 using CouplingStencilType = typename std::conditional< (j == edgeDomainId),
145 typename FacetEdgeManager::template CouplingStencilType<i, j>,
146 typename BulkFacetManager::template CouplingStencilType<i, j> >::type;
147
149 using SolutionVector = typename MDTraits::SolutionVector;
150
160 void init(std::shared_ptr< Problem<bulkId> > bulkProblem,
161 std::shared_ptr< Problem<facetId> > facetProblem,
162 std::shared_ptr< Problem<edgeId> > edgeProblem,
163 std::shared_ptr< CouplingMapper > couplingMapper,
164 const SolutionVector& curSol)
165 {
166 BulkFacetManager::init(bulkProblem, facetProblem, couplingMapper, curSol);
167 FacetEdgeManager::init(facetProblem, edgeProblem, couplingMapper, curSol);
168 }
169
171 using BulkFacetManager::couplingStencil;
172 using FacetEdgeManager::couplingStencil;
173
174 using BulkFacetManager::isCoupled;
175 using FacetEdgeManager::isCoupled;
176
177 using BulkFacetManager::isOnInteriorBoundary;
178 using FacetEdgeManager::isOnInteriorBoundary;
179
180 using BulkFacetManager::getLowDimVolVars;
181 using FacetEdgeManager::getLowDimVolVars;
182
183 using BulkFacetManager::getLowDimElement;
184 using FacetEdgeManager::getLowDimElement;
185
186 using BulkFacetManager::getLowDimElementIndex;
187 using FacetEdgeManager::getLowDimElementIndex;
188
189 using BulkFacetManager::evalSourcesFromBulk;
190 using FacetEdgeManager::evalSourcesFromBulk;
191
192 using BulkFacetManager::evalCouplingResidual;
193 using FacetEdgeManager::evalCouplingResidual;
194
195 using BulkFacetManager::bindCouplingContext;
196 using FacetEdgeManager::bindCouplingContext;
197
198 using BulkFacetManager::updateCouplingContext;
199 using FacetEdgeManager::updateCouplingContext;
200
201 using BulkFacetManager::updateCoupledVariables;
202 using FacetEdgeManager::updateCoupledVariables;
203
204 using BulkFacetManager::extendJacobianPattern;
205 using FacetEdgeManager::extendJacobianPattern;
206
207 using BulkFacetManager::evalAdditionalDomainDerivatives;
208 using FacetEdgeManager::evalAdditionalDomainDerivatives;
209
210 // extension of the jacobian pattern for the facet domain only occurs
211 // within the bulk-facet coupling & for mpfa being used in the bulk domain.
212 template<class JacobianPattern>
213 void extendJacobianPattern(FacetIdType, JacobianPattern& pattern) const
214 { BulkFacetManager::extendJacobianPattern(facetId, pattern); }
215
216 template<class FacetLocalAssembler, class JacobianMatrixDiagBlock, class GridVariables>
218 const FacetLocalAssembler& facetLocalAssembler,
219 const typename FacetLocalAssembler::LocalResidual::ElementResidualVector& origResiduals,
220 JacobianMatrixDiagBlock& A,
221 GridVariables& gridVariables)
222 { BulkFacetManager::evalAdditionalDomainDerivatives(facetId, facetLocalAssembler, origResiduals, A, gridVariables); }
223
228 const Element<bulkId>& element,
229 EdgeIdType domainJ) const
230 { return FacetEdgeManager::getEmptyStencil(edgeId); }
231
236 const Element<edgeId>& element,
237 BulkIdType domainJ) const
238 { return BulkFacetManager::getEmptyStencil(bulkId); }
239
245 {
246 BulkFacetManager::updateSolution(sol);
247 FacetEdgeManager::updateSolution(sol);
248 }
249
256 template<std::size_t i,
257 std::size_t j,
258 class LocalAssembler,
259 std::enable_if_t<((i==bulkId && j==edgeId) || ((i==edgeId && j==bulkId))), int> = 0>
260 typename LocalResidual<i>::ElementResidualVector
261 evalCouplingResidual(Dune::index_constant<i> domainI,
262 const LocalAssembler& localAssembler,
263 Dune::index_constant<j> domainJ,
264 GridIndexType<j> dofIdxGlobalJ)
265 {
266 typename LocalResidual<i>::ElementResidualVector res(1);
267 res = 0.0;
268 return res;
269 }
270
275 template< class Assembler >
276 void bindCouplingContext(FacetIdType, const Element<facetId>& element, const Assembler& assembler)
277 {
278 BulkFacetManager::bindCouplingContext(facetId, element, assembler);
279 FacetEdgeManager::bindCouplingContext(facetId, element, assembler);
280 }
281
286 template< class FacetLocalAssembler >
287 void updateCouplingContext(FacetIdType domainI,
288 const FacetLocalAssembler& facetLocalAssembler,
289 FacetIdType domainJ,
290 GridIndexType<facetId> dofIdxGlobalJ,
291 const PrimaryVariables<facetId>& priVarsJ,
292 unsigned int pvIdxJ)
293 {
294 BulkFacetManager::updateCouplingContext(domainI, facetLocalAssembler, domainJ, dofIdxGlobalJ, priVarsJ, pvIdxJ);
295 FacetEdgeManager::updateCouplingContext(domainI, facetLocalAssembler, domainJ, dofIdxGlobalJ, priVarsJ, pvIdxJ);
296 }
297
303 template<std::size_t i,
304 std::size_t j,
305 class LocalAssembler,
306 std::enable_if_t<((i==bulkId && j==edgeId) || (i==edgeId && j==bulkId)), int> = 0>
307 void updateCouplingContext(Dune::index_constant<i> domainI,
308 const LocalAssembler& localAssembler,
309 Dune::index_constant<j> domainJ,
310 GridIndexType<j> dofIdxGlobalJ,
311 const PrimaryVariables<j>& priVarsJ,
312 unsigned int pvIdxJ)
313 { /*do nothing here*/ }
314
320 template< class FacetLocalAssembler, class UpdatableElementVolVars, class UpdatableFluxVarCache>
321 void updateCoupledVariables(FacetIdType domainI,
322 const FacetLocalAssembler& facetLocalAssembler,
323 UpdatableElementVolVars& elemVolVars,
324 UpdatableFluxVarCache& elemFluxVarsCache)
325 {
326 BulkFacetManager::updateCoupledVariables(domainI, facetLocalAssembler, elemVolVars, elemFluxVarsCache);
327 FacetEdgeManager::updateCoupledVariables(domainI, facetLocalAssembler, elemVolVars, elemFluxVarsCache);
328 }
329
331 template<std::size_t id, std::enable_if_t<(id == bulkId || id == facetId), int> = 0>
332 const Problem<id>& problem() const { return BulkFacetManager::template problem<id>(); }
333
335 template<std::size_t id, std::enable_if_t<(id == bulkId || id == facetId), int> = 0>
336 Problem<id>& problem() { return BulkFacetManager::template problem<id>(); }
337
339 template<std::size_t id, std::enable_if_t<(id == edgeId), int> = 0>
340 const Problem<id>& problem() const { return FacetEdgeManager::template problem<id>(); }
341
343 template<std::size_t id, std::enable_if_t<(id == edgeId), int> = 0>
344 Problem<id>& problem() { return FacetEdgeManager::template problem<id>(); }
345};
346
347} // end namespace Dumux
348
349// Here, we have to include all available implementations
353
354#endif
Implementation for the coupling manager between two domains of dimension d and (d-1) for models consi...
Definition: multidomain/facet/couplingmanager.hh:83
Class that handles the coupling between three sub-domains in models where the coupling between the tw...
Definition: multidomain/facet/couplingmanager.hh:105
void updateCouplingContext(Dune::index_constant< i > domainI, const LocalAssembler &localAssembler, Dune::index_constant< j > domainJ, GridIndexType< j > dofIdxGlobalJ, const PrimaryVariables< j > &priVarsJ, unsigned int pvIdxJ)
Interface for updating the coupling context between the bulk and the edge domain. We do nothing here ...
Definition: multidomain/facet/couplingmanager.hh:307
const Problem< id > & problem() const
Return a const reference to bulk or facet problem.
Definition: multidomain/facet/couplingmanager.hh:332
void updateCoupledVariables(FacetIdType domainI, const FacetLocalAssembler &facetLocalAssembler, UpdatableElementVolVars &elemVolVars, UpdatableFluxVarCache &elemFluxVarsCache)
Interface for updating the local views of the facet domain after updateCouplingContext the coupling c...
Definition: multidomain/facet/couplingmanager.hh:321
typename MDTraits::SolutionVector SolutionVector
the type of the solution vector
Definition: multidomain/facet/couplingmanager.hh:149
void updateSolution(const SolutionVector &sol)
updates the current solution. We have to overload this here to avoid ambiguity and update the solutio...
Definition: multidomain/facet/couplingmanager.hh:244
void evalAdditionalDomainDerivatives(FacetIdType, const FacetLocalAssembler &facetLocalAssembler, const typename FacetLocalAssembler::LocalResidual::ElementResidualVector &origResiduals, JacobianMatrixDiagBlock &A, GridVariables &gridVariables)
Definition: multidomain/facet/couplingmanager.hh:217
void updateCouplingContext(FacetIdType domainI, const FacetLocalAssembler &facetLocalAssembler, FacetIdType domainJ, GridIndexType< facetId > dofIdxGlobalJ, const PrimaryVariables< facetId > &priVarsJ, unsigned int pvIdxJ)
Interface for updating the coupling context of the facet domain. In this case we have to update both ...
Definition: multidomain/facet/couplingmanager.hh:287
Problem< id > & problem()
Return a reference to bulk or facet problem.
Definition: multidomain/facet/couplingmanager.hh:336
typename std::conditional<(j==edgeDomainId), typename FacetEdgeManager::template CouplingStencilType< i, j >, typename BulkFacetManager::template CouplingStencilType< i, j > >::type CouplingStencilType
types used for coupling stencils
Definition: multidomain/facet/couplingmanager.hh:146
const CouplingStencilType< bulkId, edgeId > & couplingStencil(BulkIdType domainI, const Element< bulkId > &element, EdgeIdType domainJ) const
The coupling stencil of the bulk with the edge domain (empty stencil).
Definition: multidomain/facet/couplingmanager.hh:227
LocalResidual< i >::ElementResidualVector evalCouplingResidual(Dune::index_constant< i > domainI, const LocalAssembler &localAssembler, Dune::index_constant< j > domainJ, GridIndexType< j > dofIdxGlobalJ)
Interface for evaluating the coupling residual between the bulk and the edge domain....
Definition: multidomain/facet/couplingmanager.hh:261
const CouplingStencilType< edgeId, bulkId > & couplingStencil(EdgeIdType domainI, const Element< edgeId > &element, BulkIdType domainJ) const
The coupling stencil of the edge with the bulk domain (empty stencil).
Definition: multidomain/facet/couplingmanager.hh:235
void bindCouplingContext(FacetIdType, const Element< facetId > &element, const Assembler &assembler)
Interface for binding the coupling context for the facet domain. In this case we have to bind both th...
Definition: multidomain/facet/couplingmanager.hh:276
void extendJacobianPattern(FacetIdType, JacobianPattern &pattern) const
Definition: multidomain/facet/couplingmanager.hh:213
void init(std::shared_ptr< Problem< bulkId > > bulkProblem, std::shared_ptr< Problem< facetId > > facetProblem, std::shared_ptr< Problem< edgeId > > edgeProblem, std::shared_ptr< CouplingMapper > couplingMapper, const SolutionVector &curSol)
Initialize the coupling manager.
Definition: multidomain/facet/couplingmanager.hh:160
Defines all properties used in Dumux.
Element solution classes and factory functions.
free functions for the evaluation of primary variables inside elements.
PrimaryVariables evalSolution(const Element &element, const typename Element::Geometry &geometry, const typename FVElementGeometry::GridGeometry &gridGeometry, const CVFEElementSolution< FVElementGeometry, PrimaryVariables > &elemSol, const typename Element::Geometry::GlobalCoordinate &globalPos, bool ignoreState=false)
Interpolates a given box element solution at a given global position. Uses the finite element cache o...
Definition: evalsolution.hh:152
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::cctpfa||GridGeometry::discMethod==DiscretizationMethods::ccmpfa, CCElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for cell-centered schemes.
Definition: cellcentered/elementsolution.hh:101
void makeInterpolatedVolVars(VolumeVariables &volVars, const Problem &problem, const SolutionVector &sol, const FVGeometry &fvGeometry, const typename FVGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const typename FVGeometry::GridGeometry::GridView::template Codim< 0 >::Entity::Geometry &elemGeom, const typename FVGeometry::GridGeometry::GridView::template Codim< 0 >::Entity::Geometry::GlobalCoordinate &pos)
Free function that allows the creation of a volume variables object interpolated to a given position ...
Definition: multidomain/facet/couplingmanager.hh:40
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:267
Defines the index types used for grid and local indices.
The available discretization methods in Dumux.
constexpr CCMpfa ccmpfa
Definition: method.hh:146
Definition: adapt.hh:17
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:26