26#ifndef DUMUX_STAGGERED_COUPLING_MANAGER_HH
27#define DUMUX_STAGGERED_COUPLING_MANAGER_HH
41template<
class MDTraits>
46 template<std::
size_t id>
using GridGeometry =
typename MDTraits::template SubDomain<id>::GridGeometry;
47 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
49 using FVElementGeometry =
typename GridGeometry<0>::LocalView;
50 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
51 using Element =
typename GridView<0>::template Codim<0>::Entity;
54 using CouplingStencil = std::vector<GridIndexType>;
63 static constexpr auto faceIdx = GridGeometry<0>::faceIdx();
68 template<std::
size_t i, std::
size_t j,
class LocalAssemblerI,
class PriVarsJ>
70 const LocalAssemblerI& localAssemblerI,
71 Dune::index_constant<j> domainJ,
72 const std::size_t dofIdxGlobalJ,
73 const PriVarsJ& priVarsJ,
81 curSol[dofIdxGlobalJ][pvIdxJ] = priVarsJ[pvIdxJ];
94 const CouplingStencil&
couplingStencil(Dune::index_constant<cellCenterIdx> domainI,
95 const Element& elementI,
96 Dune::index_constant<faceIdx> domainJ)
const
98 const auto& connectivityMap = this->
problem(domainI).gridGeometry().connectivityMap();
99 const auto eIdx = this->
problem(domainI).gridGeometry().elementMapper().index(elementI);
100 return connectivityMap(domainI, domainJ, eIdx);
113 template<std::
size_t i, std::
size_t j>
115 const SubControlVolumeFace& scvfI,
116 Dune::index_constant<j> domainJ)
const
118 static_assert(i != j,
"Domain i cannot be coupled to itself!");
120 "The coupling manager does not implement the couplingStencil() function" );
122 return CouplingStencil();
136 const SubControlVolumeFace& scvfI,
137 Dune::index_constant<cellCenterIdx> domainJ)
const
139 const auto& connectivityMap = this->
problem(domainI).gridGeometry().connectivityMap();
140 return connectivityMap(domainI, domainJ, scvfI.index());
149 template<
class LocalAssemblerI, std::
size_t j>
151 const LocalAssemblerI& localAssemblerI,
152 Dune::index_constant<j> domainJ,
153 std::size_t dofIdxGlobalJ)
const
155 static_assert(domainI != domainJ,
"Domain i cannot be coupled to itself!");
156 return localAssemblerI.evalLocalResidualForCellCenter();
176 template<
class LocalAssemblerI, std::
size_t j>
178 const SubControlVolumeFace& scvfI,
179 const LocalAssemblerI& localAssemblerI,
180 Dune::index_constant<j> domainJ,
181 std::size_t dofIdxGlobalJ)
const
183 static_assert(domainI != domainJ,
"Domain i cannot be coupled to itself!");
184 return localAssemblerI.evalLocalResidualForFace(scvfI);
191 template<std::
size_t i,
typename std::enable_if_t<(Gr
idGeometry<i>::discMethod != DiscretizationMethods::staggered),
int> = 0>
193 const std::string& paramGroup)
const
202 template<std::
size_t i,
typename std::enable_if_t<(Gr
idGeometry<i>::discMethod == DiscretizationMethods::staggered),
int> = 0>
204 const std::string& paramGroup)
const
206 constexpr std::size_t numEqCellCenter = Traits::template SubDomain<cellCenterIdx>::PrimaryVariables::dimension;
207 constexpr std::size_t numEqFace = Traits::template SubDomain<faceIdx>::PrimaryVariables::dimension;
208 constexpr bool isCellCenter = GridGeometry<i>::isCellCenter();
209 constexpr std::size_t numEq = isCellCenter ? numEqCellCenter : numEqFace;
210 constexpr auto prefix = isCellCenter ?
"CellCenter" :
"Face";
213 if(paramGroup.empty())
218 catch (Dune::RangeError& e)
221 " CellCenter.Assembly.NumericDifference.PriVarMagnitude = mCC\n"
222 " Face.Assembly.NumericDifference.PriVarMagnitude = mFace\n"
223 " CellCenter.Assembly.NumericDifference.BaseEpsilon = eCC_0 ... eCC_numEqCellCenter-1\n"
224 " Face.Assembly.NumericDifference.BaseEpsilon = eFace_0 ... eFace_numEqFace-1\n\n"
225 "Wrong numer of values set for " << prefix <<
" (has " << numEq <<
" primary variable(s))\n\n" << e);
An adapter class for local assemblers using numeric differentiation.
Defines the index types used for grid and local indices.
The available discretization methods in Dumux.
decltype(auto) evalCouplingResidual(Dune::index_constant< faceIdx > domainI, const SubControlVolumeFace &scvfI, const LocalAssemblerI &localAssemblerI, Dune::index_constant< j > domainJ, std::size_t dofIdxGlobalJ) const
evaluates the face residual of a coupled face of domain i which depends on the variables at the degre...
Definition: staggeredcouplingmanager.hh:177
decltype(auto) evalCouplingResidual(Dune::index_constant< i > domainI, const LocalAssemblerI &localAssemblerI, Dune::index_constant< j > domainJ, std::size_t dofIdxGlobalJ) const
evaluates the element residual of a coupled element of domain i which depends on the variables at the...
Definition: multidomain/couplingmanager.hh:261
A helper class for local assemblers using numeric differentiation to determine the epsilon.
Definition: numericepsilon.hh:41
Exception thrown if a run-time parameter is not specified correctly.
Definition: exceptions.hh:60
Struture to define the index types used for grid and local indices.
Definition: indextraits.hh:38
Template which always yields a false value.
Definition: typetraits.hh:35
The interface of the coupling manager for multi domain problems.
Definition: multidomain/couplingmanager.hh:60
decltype(auto) curSol()
the solution vector of the coupled problem
Definition: multidomain/couplingmanager.hh:370
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Return a reference to the sub problem.
Definition: multidomain/couplingmanager.hh:321
decltype(auto) numericEpsilon(Dune::index_constant< i >, const std::string ¶mGroup) const
return the numeric epsilon used for deflecting primary variables of coupled domain i
Definition: multidomain/couplingmanager.hh:287
Base coupling manager for the staggered discretization.
Definition: staggeredcouplingmanager.hh:43
const CouplingStencil & couplingStencil(Dune::index_constant< faceIdx > domainI, const SubControlVolumeFace &scvfI, Dune::index_constant< cellCenterIdx > domainJ) const
returns an iteratable container of all indices of degrees of freedom of domain j that couple with / i...
Definition: staggeredcouplingmanager.hh:135
const CouplingStencil couplingStencil(Dune::index_constant< i > domainI, const SubControlVolumeFace &scvfI, Dune::index_constant< j > domainJ) const
returns an iteratable container of all indices of degrees of freedom of domain j that couple with / i...
Definition: staggeredcouplingmanager.hh:114
decltype(auto) evalCouplingResidual(Dune::index_constant< cellCenterIdx > domainI, const LocalAssemblerI &localAssemblerI, Dune::index_constant< j > domainJ, std::size_t dofIdxGlobalJ) const
evaluates the element residual of a coupled element of domain i which depends on the variables at the...
Definition: staggeredcouplingmanager.hh:150
const CouplingStencil & couplingStencil(Dune::index_constant< cellCenterIdx > domainI, const Element &elementI, Dune::index_constant< faceIdx > domainJ) const
returns an iteratable container of all indices of degrees of freedom of domain j that couple with / i...
Definition: staggeredcouplingmanager.hh:94
decltype(auto) numericEpsilon(Dune::index_constant< i > id, const std::string ¶mGroup) const
return the numeric epsilon used for deflecting primary variables of coupled domain i.
Definition: staggeredcouplingmanager.hh:192
void updateCouplingContext(Dune::index_constant< i > domainI, const LocalAssemblerI &localAssemblerI, Dune::index_constant< j > domainJ, const std::size_t dofIdxGlobalJ, const PriVarsJ &priVarsJ, int pvIdxJ)
updates all data and variables that are necessary to evaluate the residual of the element of domain i...
Definition: staggeredcouplingmanager.hh:69
decltype(auto) numericEpsilon(Dune::index_constant< i >, const std::string ¶mGroup) const
return the numeric epsilon used for deflecting primary variables of coupled domain i.
Definition: staggeredcouplingmanager.hh:203
static constexpr auto cellCenterIdx
Definition: staggeredcouplingmanager.hh:62
MDTraits Traits
Definition: staggeredcouplingmanager.hh:60
static constexpr auto faceIdx
Definition: staggeredcouplingmanager.hh:63
The interface of the coupling manager for multi domain problems.