25#ifndef DUMUX_STAGGERED_COUPLING_MANAGER_HH
26#define DUMUX_STAGGERED_COUPLING_MANAGER_HH
40template<
class MDTraits>
45 template<std::
size_t id>
using GridGeometry =
typename MDTraits::template SubDomain<id>::GridGeometry;
46 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
48 using FVElementGeometry =
typename GridGeometry<0>::LocalView;
49 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
50 using Element =
typename GridView<0>::template Codim<0>::Entity;
53 using CouplingStencil = std::vector<GridIndexType>;
62 static constexpr auto faceIdx = GridGeometry<0>::faceIdx();
67 template<std::
size_t i, std::
size_t j,
class LocalAssemblerI,
class PriVarsJ>
69 const LocalAssemblerI& localAssemblerI,
70 Dune::index_constant<j> domainJ,
71 const std::size_t dofIdxGlobalJ,
72 const PriVarsJ& priVarsJ,
80 curSol[dofIdxGlobalJ][pvIdxJ] = priVarsJ[pvIdxJ];
93 const CouplingStencil&
couplingStencil(Dune::index_constant<cellCenterIdx> domainI,
94 const Element& elementI,
95 Dune::index_constant<faceIdx> domainJ)
const
97 const auto& connectivityMap = this->
problem(domainI).gridGeometry().connectivityMap();
98 const auto eIdx = this->
problem(domainI).gridGeometry().elementMapper().index(elementI);
99 return connectivityMap(domainI, domainJ, eIdx);
112 template<std::
size_t i, std::
size_t j>
114 const SubControlVolumeFace& scvfI,
115 Dune::index_constant<j> domainJ)
const
117 static_assert(i != j,
"Domain i cannot be coupled to itself!");
119 "The coupling manager does not implement the couplingStencil() function" );
121 return CouplingStencil();
135 const SubControlVolumeFace& scvfI,
136 Dune::index_constant<cellCenterIdx> domainJ)
const
138 const auto& connectivityMap = this->
problem(domainI).gridGeometry().connectivityMap();
139 return connectivityMap(domainI, domainJ, scvfI.index());
148 template<
class LocalAssemblerI, std::
size_t j>
150 const LocalAssemblerI& localAssemblerI,
151 Dune::index_constant<j> domainJ,
152 std::size_t dofIdxGlobalJ)
const
154 static_assert(domainI != domainJ,
"Domain i cannot be coupled to itself!");
155 return localAssemblerI.evalLocalResidualForCellCenter();
174 template<
class LocalAssemblerI, std::
size_t j>
176 const SubControlVolumeFace& scvfI,
177 const LocalAssemblerI& localAssemblerI,
178 Dune::index_constant<j> domainJ,
179 std::size_t dofIdxGlobalJ)
const
181 static_assert(domainI != domainJ,
"Domain i cannot be coupled to itself!");
182 return localAssemblerI.evalLocalResidualForFace(scvfI);
189 template<std::
size_t i,
typename std::enable_if_t<(Gr
idGeometry<i>::discMethod != DiscretizationMethod::staggered),
int> = 0>
191 const std::string& paramGroup)
const
200 template<std::
size_t i,
typename std::enable_if_t<(Gr
idGeometry<i>::discMethod == DiscretizationMethod::staggered),
int> = 0>
202 const std::string& paramGroup)
const
204 constexpr std::size_t numEqCellCenter = Traits::template SubDomain<cellCenterIdx>::PrimaryVariables::dimension;
205 constexpr std::size_t numEqFace = Traits::template SubDomain<faceIdx>::PrimaryVariables::dimension;
206 constexpr bool isCellCenter = GridGeometry<i>::isCellCenter();
207 constexpr std::size_t numEq = isCellCenter ? numEqCellCenter : numEqFace;
208 constexpr auto prefix = isCellCenter ?
"CellCenter" :
"Face";
211 if(paramGroup.empty())
216 catch (Dune::RangeError& e)
219 " CellCenter.Assembly.NumericDifference.PriVarMagnitude = mCC\n"
220 " Face.Assembly.NumericDifference.PriVarMagnitude = mFace\n"
221 " CellCenter.Assembly.NumericDifference.BaseEpsilon = eCC_0 ... eCC_numEqCellCenter-1\n"
222 " Face.Assembly.NumericDifference.BaseEpsilon = eFace_0 ... eFace_numEqFace-1\n\n"
223 "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:175
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:209
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:36
Definition: multidomain/couplingmanager.hh:46
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Return a reference to the sub problem.
Definition: multidomain/couplingmanager.hh:264
SolutionVector & curSol()
the solution vector of the coupled problem
Definition: multidomain/couplingmanager.hh:278
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:235
Base coupling manager for the staggered discretization.
Definition: staggeredcouplingmanager.hh:42
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:134
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:113
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:149
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:93
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:190
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:68
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:201
static constexpr auto cellCenterIdx
Definition: staggeredcouplingmanager.hh:61
MDTraits Traits
Definition: staggeredcouplingmanager.hh:59
static constexpr auto faceIdx
Definition: staggeredcouplingmanager.hh:62
The interface of the coupling manager for multi domain problems.