12#ifndef DUMUX_FACETCOUPLING_MANAGER_HH
13#define DUMUX_FACETCOUPLING_MANAGER_HH
23namespace FacetCoupling{
39template<
class VolumeVariables,
class Problem,
class SolutionVector,
class FVGeometry>
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)
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;
59 volVars.update(elemSol, problem, element, *scvs(fvGeometry).begin());
78template<
class MDTraits,
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 >
97template<
class MDTraits,
99 std::size_t bulkDomainId = 0,
100 std::size_t facetDomainId = 1,
101 std::size_t edgeDomainId = 2 >
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();
118 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
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;
130 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
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;
137 template<std::
size_t id>
138 static constexpr bool usesMpfa(Dune::index_constant<id> domainId)
143 template<std::
size_t i, std::
size_t j>
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,
166 BulkFacetManager::init(bulkProblem, facetProblem, couplingMapper, curSol);
167 FacetEdgeManager::init(facetProblem, edgeProblem, couplingMapper, curSol);
171 using BulkFacetManager::couplingStencil;
172 using FacetEdgeManager::couplingStencil;
174 using BulkFacetManager::isCoupled;
175 using FacetEdgeManager::isCoupled;
177 using BulkFacetManager::isOnInteriorBoundary;
178 using FacetEdgeManager::isOnInteriorBoundary;
180 using BulkFacetManager::getLowDimVolVars;
181 using FacetEdgeManager::getLowDimVolVars;
183 using BulkFacetManager::getLowDimElement;
184 using FacetEdgeManager::getLowDimElement;
186 using BulkFacetManager::getLowDimElementIndex;
187 using FacetEdgeManager::getLowDimElementIndex;
189 using BulkFacetManager::evalSourcesFromBulk;
190 using FacetEdgeManager::evalSourcesFromBulk;
192 using BulkFacetManager::evalCouplingResidual;
193 using FacetEdgeManager::evalCouplingResidual;
195 using BulkFacetManager::bindCouplingContext;
196 using FacetEdgeManager::bindCouplingContext;
198 using BulkFacetManager::updateCouplingContext;
199 using FacetEdgeManager::updateCouplingContext;
201 using BulkFacetManager::updateCoupledVariables;
202 using FacetEdgeManager::updateCoupledVariables;
204 using BulkFacetManager::extendJacobianPattern;
205 using FacetEdgeManager::extendJacobianPattern;
207 using BulkFacetManager::evalAdditionalDomainDerivatives;
208 using FacetEdgeManager::evalAdditionalDomainDerivatives;
212 template<
class JacobianPattern>
214 { BulkFacetManager::extendJacobianPattern(facetId, pattern); }
216 template<
class FacetLocalAssembler,
class JacobianMatrixDiagBlock,
class Gr
idVariables>
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); }
228 const Element<bulkId>& element,
229 EdgeIdType domainJ)
const
230 {
return FacetEdgeManager::getEmptyStencil(edgeId); }
236 const Element<edgeId>& element,
237 BulkIdType domainJ)
const
238 {
return BulkFacetManager::getEmptyStencil(bulkId); }
246 BulkFacetManager::updateSolution(sol);
247 FacetEdgeManager::updateSolution(sol);
256 template<std::size_t i,
258 class LocalAssembler,
259 std::enable_if_t<((i==bulkId && j==edgeId) || ((i==edgeId && j==bulkId))),
int> = 0>
260 typename LocalResidual<i>::ElementResidualVector
262 const LocalAssembler& localAssembler,
263 Dune::index_constant<j> domainJ,
264 GridIndexType<j> dofIdxGlobalJ)
266 typename LocalResidual<i>::ElementResidualVector res(1);
275 template<
class Assembler >
278 BulkFacetManager::bindCouplingContext(facetId, element, assembler);
279 FacetEdgeManager::bindCouplingContext(facetId, element, assembler);
286 template<
class FacetLocalAssembler >
288 const FacetLocalAssembler& facetLocalAssembler,
290 GridIndexType<facetId> dofIdxGlobalJ,
291 const PrimaryVariables<facetId>& priVarsJ,
294 BulkFacetManager::updateCouplingContext(domainI, facetLocalAssembler, domainJ, dofIdxGlobalJ, priVarsJ, pvIdxJ);
295 FacetEdgeManager::updateCouplingContext(domainI, facetLocalAssembler, domainJ, dofIdxGlobalJ, priVarsJ, pvIdxJ);
303 template<std::size_t i,
305 class LocalAssembler,
306 std::enable_if_t<((i==bulkId && j==edgeId) || (i==edgeId && j==bulkId)),
int> = 0>
308 const LocalAssembler& localAssembler,
309 Dune::index_constant<j> domainJ,
310 GridIndexType<j> dofIdxGlobalJ,
311 const PrimaryVariables<j>& priVarsJ,
320 template<
class FacetLocalAssembler,
class UpdatableElementVolVars,
class UpdatableFluxVarCache>
322 const FacetLocalAssembler& facetLocalAssembler,
323 UpdatableElementVolVars& elemVolVars,
324 UpdatableFluxVarCache& elemFluxVarsCache)
326 BulkFacetManager::updateCoupledVariables(domainI, facetLocalAssembler, elemVolVars, elemFluxVarsCache);
327 FacetEdgeManager::updateCoupledVariables(domainI, facetLocalAssembler, elemVolVars, elemFluxVarsCache);
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>(); }
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>(); }
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>(); }
343 template<std::
size_t id, std::enable_if_t<(
id == edgeId),
int> = 0>
344 Problem<id>&
problem() {
return FacetEdgeManager::template problem<id>(); }
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
The available discretization methods in Dumux.
constexpr CCMpfa ccmpfa
Definition: method.hh:146
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:26