24#ifndef DUMUX_FACETCOUPLING_MANAGER_HH
25#define DUMUX_FACETCOUPLING_MANAGER_HH
35namespace FacetCoupling{
51template<
class VolumeVariables,
class Problem,
class SolutionVector,
class FVGeometry>
53 const Problem& problem,
54 const SolutionVector& sol,
55 const FVGeometry& fvGeometry,
56 const typename FVGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
57 const typename FVGeometry::GridGeometry::GridView::template Codim<0>::Entity::Geometry& elemGeom,
58 const typename FVGeometry::GridGeometry::GridView::template Codim<0>::Entity::Geometry::GlobalCoordinate& pos)
61 auto elemSol =
elementSolution(element, sol, fvGeometry.gridGeometry());
62 const auto centerSol =
evalSolution(element, elemGeom, fvGeometry.gridGeometry(), elemSol, pos);
63 for (
unsigned int i = 0; i < fvGeometry.numScv(); ++i)
64 elemSol[i] = centerSol;
71 volVars.update(elemSol, problem, element, *scvs(fvGeometry).begin());
90template<
class MDTraits,
92 std::size_t bulkDomainId = 0,
93 std::size_t lowDimDomainId = 1,
94 DiscretizationMethod bulkDM = GetPropType<typename MDTraits::template SubDomain<bulkDomainId>::TypeTag, Properties::GridGeometry>::discMethod >
109template<
class MDTraits,
110 class CouplingMapper,
111 std::size_t bulkDomainId = 0,
112 std::size_t facetDomainId = 1,
113 std::size_t edgeDomainId = 2 >
122 using BulkIdType =
typename MDTraits::template SubDomain<bulkDomainId>::Index;
123 using FacetIdType =
typename MDTraits::template SubDomain<facetDomainId>::Index;
124 using EdgeIdType =
typename MDTraits::template SubDomain<edgeDomainId>::Index;
125 static constexpr auto bulkId = BulkIdType();
126 static constexpr auto facetId = FacetIdType();
127 static constexpr auto edgeId = EdgeIdType();
130 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
138 template<std::
size_t id>
using FVElementGeometry =
typename GridGeometry<id>::LocalView;
139 template<std::
size_t id>
using SubControlVolumeFace =
typename GridGeometry<id>::SubControlVolumeFace;
140 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
142 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
145 template<std::
size_t id>
using ElementVolumeVariables =
typename GridVariables<id>::GridVolumeVariables::LocalView;
146 template<std::
size_t id>
using ElementFluxVariablesCache =
typename GridVariables<id>::GridFluxVariablesCache::LocalView;
149 template<std::
size_t id>
150 static constexpr bool usesMpfa(Dune::index_constant<id> domainId)
155 template<std::
size_t i, std::
size_t j>
172 void init(std::shared_ptr< Problem<bulkId> > bulkProblem,
173 std::shared_ptr< Problem<facetId> > facetProblem,
174 std::shared_ptr< Problem<edgeId> > edgeProblem,
175 std::shared_ptr< CouplingMapper > couplingMapper,
178 BulkFacetManager::init(bulkProblem, facetProblem, couplingMapper, curSol);
179 FacetEdgeManager::init(facetProblem, edgeProblem, couplingMapper, curSol);
183 using BulkFacetManager::couplingStencil;
184 using FacetEdgeManager::couplingStencil;
186 using BulkFacetManager::isCoupled;
187 using FacetEdgeManager::isCoupled;
189 using BulkFacetManager::isOnInteriorBoundary;
190 using FacetEdgeManager::isOnInteriorBoundary;
192 using BulkFacetManager::getLowDimVolVars;
193 using FacetEdgeManager::getLowDimVolVars;
195 using BulkFacetManager::getLowDimElement;
196 using FacetEdgeManager::getLowDimElement;
198 using BulkFacetManager::getLowDimElementIndex;
199 using FacetEdgeManager::getLowDimElementIndex;
201 using BulkFacetManager::evalSourcesFromBulk;
202 using FacetEdgeManager::evalSourcesFromBulk;
204 using BulkFacetManager::evalCouplingResidual;
205 using FacetEdgeManager::evalCouplingResidual;
207 using BulkFacetManager::bindCouplingContext;
208 using FacetEdgeManager::bindCouplingContext;
210 using BulkFacetManager::updateCouplingContext;
211 using FacetEdgeManager::updateCouplingContext;
213 using BulkFacetManager::updateCoupledVariables;
214 using FacetEdgeManager::updateCoupledVariables;
216 using BulkFacetManager::extendJacobianPattern;
217 using FacetEdgeManager::extendJacobianPattern;
219 using BulkFacetManager::evalAdditionalDomainDerivatives;
220 using FacetEdgeManager::evalAdditionalDomainDerivatives;
224 template<
class JacobianPattern>
226 { BulkFacetManager::extendJacobianPattern(facetId, pattern); }
228 template<
class FacetLocalAssembler,
class JacobianMatrixDiagBlock,
class Gr
idVariables>
230 const FacetLocalAssembler& facetLocalAssembler,
231 const typename FacetLocalAssembler::LocalResidual::ElementResidualVector& origResiduals,
232 JacobianMatrixDiagBlock& A,
233 GridVariables& gridVariables)
234 { BulkFacetManager::evalAdditionalDomainDerivatives(facetId, facetLocalAssembler, origResiduals, A, gridVariables); }
237 template<
class GetTensor,
bool mpfa = usesMpfa(bulkId), std::enable_if_t<mpfa,
int> = 0>
239 const SubControlVolumeFace<bulkId>& scvf,
240 const GetTensor& getT)
const
241 {
return BulkFacetManager::getLowDimTensor(element, scvf, getT); }
244 template<
class GetTensor,
bool mpfa = usesMpfa(facetId), std::enable_if_t<mpfa,
int> = 0>
246 const SubControlVolumeFace<facetId>& scvf,
247 const GetTensor& getT)
const
248 {
return FacetEdgeManager::getLowDimTensor(element, scvf, getT); }
254 const Element<bulkId>& element,
255 EdgeIdType domainJ)
const
256 {
return FacetEdgeManager::getEmptyStencil(edgeId); }
262 const Element<edgeId>& element,
263 BulkIdType domainJ)
const
264 {
return BulkFacetManager::getEmptyStencil(bulkId); }
272 BulkFacetManager::updateSolution(sol);
273 FacetEdgeManager::updateSolution(sol);
282 template<std::size_t i,
284 class LocalAssembler,
285 std::enable_if_t<((i==bulkId && j==edgeId) || ((i==edgeId && j==bulkId))),
int> = 0>
286 typename LocalResidual<i>::ElementResidualVector
288 const LocalAssembler& localAssembler,
289 Dune::index_constant<j> domainJ,
290 GridIndexType<j> dofIdxGlobalJ)
292 typename LocalResidual<i>::ElementResidualVector res(1);
301 template<
class Assembler >
304 BulkFacetManager::bindCouplingContext(facetId, element, assembler);
305 FacetEdgeManager::bindCouplingContext(facetId, element, assembler);
312 template<
class FacetLocalAssembler >
314 const FacetLocalAssembler& facetLocalAssembler,
316 GridIndexType<facetId> dofIdxGlobalJ,
317 const PrimaryVariables<facetId>& priVarsJ,
320 BulkFacetManager::updateCouplingContext(domainI, facetLocalAssembler, domainJ, dofIdxGlobalJ, priVarsJ, pvIdxJ);
321 FacetEdgeManager::updateCouplingContext(domainI, facetLocalAssembler, domainJ, dofIdxGlobalJ, priVarsJ, pvIdxJ);
329 template<std::size_t i,
331 class LocalAssembler,
332 std::enable_if_t<((i==bulkId && j==edgeId) || (i==edgeId && j==bulkId)),
int> = 0>
334 const LocalAssembler& localAssembler,
335 Dune::index_constant<j> domainJ,
336 GridIndexType<j> dofIdxGlobalJ,
337 const PrimaryVariables<j>& priVarsJ,
346 template<
class FacetLocalAssembler,
class UpdatableElementVolVars,
class UpdatableFluxVarCache>
348 const FacetLocalAssembler& facetLocalAssembler,
349 UpdatableElementVolVars& elemVolVars,
350 UpdatableFluxVarCache& elemFluxVarsCache)
352 BulkFacetManager::updateCoupledVariables(domainI, facetLocalAssembler, elemVolVars, elemFluxVarsCache);
353 FacetEdgeManager::updateCoupledVariables(domainI, facetLocalAssembler, elemVolVars, elemFluxVarsCache);
357 template<std::
size_t id, std::enable_if_t<(
id == bulkId ||
id == facetId),
int> = 0>
358 const Problem<id>&
problem()
const {
return BulkFacetManager::template problem<id>(); }
361 template<std::
size_t id, std::enable_if_t<(
id == bulkId ||
id == facetId),
int> = 0>
362 Problem<id>&
problem() {
return BulkFacetManager::template problem<id>(); }
365 template<std::
size_t id, std::enable_if_t<(
id == edgeId),
int> = 0>
366 const Problem<id>&
problem()
const {
return FacetEdgeManager::template problem<id>(); }
369 template<std::
size_t id, std::enable_if_t<(
id == edgeId),
int> = 0>
370 Problem<id>&
problem() {
return FacetEdgeManager::template problem<id>(); }
Defines the index types used for grid and local indices.
Element solution classes and factory functions.
free functions for the evaluation of primary variables inside elements.
The available discretization methods in Dumux.
PrimaryVariables evalSolution(const Element &element, const typename Element::Geometry &geometry, const typename FVElementGeometry::GridGeometry &gridGeometry, const BoxElementSolution< 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:95
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:115
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:52
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
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:149
Struture to define the index types used for grid and local indices.
Definition: indextraits.hh:38
A vector of primary variables.
Definition: common/properties.hh:59
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Definition: common/properties.hh:91
Definition: common/properties.hh:150
The grid variables object managing variable data on the grid (volvars/fluxvars cache)
Definition: common/properties.hh:190
Implementation for the coupling manager between two domains of dimension d and (d-1) for models consi...
Definition: multidomain/facet/couplingmanager.hh:95
Class that handles the coupling between three sub-domains in models where the coupling between the tw...
Definition: multidomain/facet/couplingmanager.hh:117
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:333
auto getLowDimTensor(const Element< facetId > &element, const SubControlVolumeFace< facetId > &scvf, const GetTensor &getT) const
Definition: multidomain/facet/couplingmanager.hh:245
const Problem< id > & problem() const
Return a const reference to bulk or facet problem.
Definition: multidomain/facet/couplingmanager.hh:358
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:347
typename MDTraits::SolutionVector SolutionVector
the type of the solution vector
Definition: multidomain/facet/couplingmanager.hh:161
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:270
void evalAdditionalDomainDerivatives(FacetIdType, const FacetLocalAssembler &facetLocalAssembler, const typename FacetLocalAssembler::LocalResidual::ElementResidualVector &origResiduals, JacobianMatrixDiagBlock &A, GridVariables &gridVariables)
Definition: multidomain/facet/couplingmanager.hh:229
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:313
Problem< id > & problem()
Return a reference to bulk or facet problem.
Definition: multidomain/facet/couplingmanager.hh:362
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:158
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:253
auto getLowDimTensor(const Element< bulkId > &element, const SubControlVolumeFace< bulkId > &scvf, const GetTensor &getT) const
Definition: multidomain/facet/couplingmanager.hh:238
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:287
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:261
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:302
void extendJacobianPattern(FacetIdType, JacobianPattern &pattern) const
Definition: multidomain/facet/couplingmanager.hh:225
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:172
Declares all properties used in Dumux.