13#ifndef DUMUX_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORENETWORK_COUPLINGMANAGER_HH
14#define DUMUX_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORENETWORK_COUPLINGMANAGER_HH
19#include <dune/common/indices.hh>
31namespace FreeFlowPoreNetworkDetail {
46 auto map = std::array<std::array<std::size_t, 3>, 3>{};
63template<std::
size_t i>
74template<std::
size_t i, std::
size_t j>
77 static_assert(i <= 2 && j <= 2);
78 static_assert(i != j);
81 return std::pair<Dune::index_constant<0>, Dune::index_constant<1>>{};
83 return std::pair<Dune::index_constant<1>, Dune::index_constant<0>>{};
93 template<std::
size_t i, std::
size_t j>
94 static constexpr auto globalToLocal(Dune::index_constant<i> domainI, Dune::index_constant<j> domainJ)
99 template<std::
size_t i>
106template<
class MDTraits>
109 template<std::
size_t id>
138template<
class MDTraits>
142 FreeFlowPoreNetworkDetail::CouplingMaps,
143 typename FreeFlowPoreNetworkDetail::CouplingManagers<MDTraits>::FreeFlowCouplingManager,
144 typename FreeFlowPoreNetworkDetail::CouplingManagers<MDTraits>::FreeFlowMomentumPoreNetworkCouplingManager,
145 typename FreeFlowPoreNetworkDetail::CouplingManagers<MDTraits>::FreeFlowMassPoreNetworkCouplingManager
158 using Scalar =
typename MDTraits::Scalar;
161 template<std::
size_t id>
162 using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
166 template<std::
size_t id>
using FVElementGeometry =
typename GridGeometry<id>::LocalView;
167 template<std::
size_t id>
using SubControlVolumeFace =
typename FVElementGeometry<id>::SubControlVolumeFace;
168 template<std::
size_t id>
using SubControlVolume =
typename FVElementGeometry<id>::SubControlVolume;
170 template<std::
size_t id>
using NumEqVector =
typename Problem<id>::Traits::NumEqVector;
172 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
173 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
174 using SolutionVector =
typename MDTraits::SolutionVector;
181 template<std::
size_t i, std::
size_t j>
189 using ParentType::ParentType;
191 template<
class Gr
idVarsTuple>
192 void init(std::shared_ptr<Problem<freeFlowMomentumIndex>> freeFlowMomentumProblem,
193 std::shared_ptr<Problem<freeFlowMassIndex>> freeFlowMassProblem,
194 std::shared_ptr<Problem<poreNetworkIndex>> poreNetworkProblem,
195 GridVarsTuple&& gridVarsTuple,
196 const SolutionVector&
curSol)
200 auto couplingMapper = std::make_shared<CouplingMapper>();
201 couplingMapper->update(freeFlowMomentumProblem->gridGeometry(),
202 freeFlowMassProblem->gridGeometry(),
203 poreNetworkProblem->gridGeometry()
208 std::get<0>(ffSolVecTuple) = std::get<freeFlowMomentumIndex>(this->
curSol());
209 std::get<1>(ffSolVecTuple) = std::get<freeFlowMassIndex>(this->
curSol());
211 freeFlowMomentumProblem, freeFlowMassProblem,
212 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<freeFlowMassIndex>(gridVarsTuple)),
217 std::get<0>(ffMassPmSolVecTuple) = std::get<freeFlowMassIndex>(this->
curSol());
218 std::get<1>(ffMassPmSolVecTuple) = std::get<poreNetworkIndex>(this->
curSol());
220 freeFlowMassProblem, poreNetworkProblem, couplingMapper, ffMassPmSolVecTuple
224 std::get<0>(ffMomentumPmSolVecTuple) = std::get<freeFlowMomentumIndex>(this->
curSol());
225 std::get<1>(ffMomentumPmSolVecTuple) = std::get<poreNetworkIndex>(this->
curSol());
227 freeFlowMomentumProblem, poreNetworkProblem,
228 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<poreNetworkIndex>(gridVarsTuple)),
229 couplingMapper, ffMomentumPmSolVecTuple
236 auto massCouplingCondition(Dune::index_constant<poreNetworkIndex> domainI, Dune::index_constant<freeFlowMassIndex> domainJ,
237 const FVElementGeometry<poreNetworkIndex>& fvGeometry,
238 const typename FVElementGeometry<poreNetworkIndex>::SubControlVolume& scv,
239 const ElementVolumeVariables<poreNetworkIndex>& elemVolVars)
const
242 const auto& couplingContext = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
243 return cm.couplingContext(ii, fvGeometry, scv);
246 const auto& freeFlowMassGridGeometry = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
247 return cm.problem(jj).gridGeometry();
250 for (
auto& c : couplingContext)
252 const auto& freeFlowElement = freeFlowMassGridGeometry.element(c.scv.elementIndex());
256 return CouplingConditions::massCouplingCondition(domainI, domainJ, fvGeometry, scv, elemVolVars, couplingContext);
262 auto massCouplingCondition(Dune::index_constant<freeFlowMassIndex> domainI, Dune::index_constant<poreNetworkIndex> domainJ,
263 const FVElementGeometry<freeFlowMassIndex>& fvGeometry,
264 const typename FVElementGeometry<freeFlowMassIndex>::SubControlVolumeFace& scvf,
265 const ElementVolumeVariables<freeFlowMassIndex>& elemVolVars)
const
268 const auto& couplingContext = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
269 return cm.couplingContext(ii, fvGeometry, scvf);
273 return CouplingConditions::massCouplingCondition(domainI, domainJ, fvGeometry, scvf, elemVolVars, couplingContext);
280 Dune::index_constant<poreNetworkIndex> domainJ,
281 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
282 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf,
283 const ElementVolumeVariables<freeFlowMomentumIndex>& elemVolVars)
const
285 if (scvf.isLateral())
286 return NumEqVector<freeFlowMomentumIndex>(0.0);
292 return CouplingConditions::momentumCouplingCondition(fvGeometry, scvf, elemVolVars, context);
296 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf)
const
302 const auto& pnmScv = [&]
304 for (
const auto& scv : scvs(context.fvGeometry))
305 if (scv.dofIndex() == context.poreNetworkDofIdx)
308 DUNE_THROW(Dune::InvalidStateException,
"No scv found");
311 return context.elemVolVars[pnmScv].poreInscribedRadius();
315 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf)
const
321 return CouplingConditions::interfaceThroatVelocity(fvGeometry, scvf, context);
330 Scalar
pressure(
const Element<freeFlowMomentumIndex>& element,
331 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
332 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
335 element, fvGeometry, scvf
346 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
356 Scalar
density(
const Element<freeFlowMomentumIndex>& element,
357 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
358 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf,
359 const bool considerPreviousTimeStep =
false)
const
362 element, fvGeometry, scvf, considerPreviousTimeStep
367 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
368 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf,
369 const bool considerPreviousTimeStep =
false)
const
372 element, fvGeometry, scvf, considerPreviousTimeStep
379 Scalar
density(
const Element<freeFlowMomentumIndex>& element,
380 const SubControlVolume<freeFlowMomentumIndex>& scv,
381 const bool considerPreviousTimeStep =
false)
const
384 element, scv, considerPreviousTimeStep
392 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
393 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
396 element, fvGeometry, scvf
404 const SubControlVolumeFace<freeFlowMassIndex>& scvf)
const
411 template<std::
size_t i>
412 const Problem<i>&
problem(Dune::index_constant<i> domainI)
const
414 return this->
subApply(domainI, [&](
const auto& cm,
auto&& ii) ->
const auto& {
415 return cm.problem(ii);
419 template<std::
size_t i, std::
size_t j>
421 Dune::index_constant<j> domainJ,
422 const SubControlVolumeFace<i>& scvf)
const
424 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj){
425 return cm.isCoupled(ii, scvf);
435 template<std::
size_t i, std::
size_t j>
437 Dune::index_constant<j> domainJ,
438 const SubControlVolume<i>& scv)
const
440 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj){
441 return cm.isCoupled(ii, scv);
468 template<std::
size_t j>
470 const Element<freeFlowMomentumIndex>& elementI,
471 const SubControlVolume<freeFlowMomentumIndex>& scvI,
472 Dune::index_constant<j> domainJ)
const
475 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
476 return cm.couplingStencil(ii, elementI, scvI, jj);
Coupling manager for free-flow mass and pore-network models.
Definition: multidomain/boundary/freeflowporenetwork/ffmassporenetwork/couplingmanager.hh:35
Coupling manager for free-flow momentum and pore-network models.
Definition: multidomain/boundary/freeflowporenetwork/ffmomentumporenetwork/couplingmanager.hh:35
Definition: freeflowporenetwork/couplingconditions.hh:31
Coupling manager for coupling freeflow and pore-network models.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:147
auto insideAndOutsideDensity(const Element< freeFlowMomentumIndex > &element, const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const SubControlVolumeFace< freeFlowMomentumIndex > &scvf, const bool considerPreviousTimeStep=false) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:366
bool isCoupled(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ, const SubControlVolumeFace< i > &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:420
void init(std::shared_ptr< Problem< freeFlowMomentumIndex > > freeFlowMomentumProblem, std::shared_ptr< Problem< freeFlowMassIndex > > freeFlowMassProblem, std::shared_ptr< Problem< poreNetworkIndex > > poreNetworkProblem, GridVarsTuple &&gridVarsTuple, const SolutionVector &curSol)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:192
Scalar density(const Element< freeFlowMomentumIndex > &element, const SubControlVolume< freeFlowMomentumIndex > &scv, const bool considerPreviousTimeStep=false) const
Returns the density at a given sub control volume.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:379
static constexpr auto freeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:184
Scalar density(const Element< freeFlowMomentumIndex > &element, const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const SubControlVolumeFace< freeFlowMomentumIndex > &scvf, const bool considerPreviousTimeStep=false) const
Returns the density at a given sub control volume face.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:356
Scalar effectiveViscosity(const Element< freeFlowMomentumIndex > &element, const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const SubControlVolumeFace< freeFlowMomentumIndex > &scvf) const
Returns the pressure at a given sub control volume face.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:391
auto massCouplingCondition(Dune::index_constant< poreNetworkIndex > domainI, Dune::index_constant< freeFlowMassIndex > domainJ, const FVElementGeometry< poreNetworkIndex > &fvGeometry, const typename FVElementGeometry< poreNetworkIndex >::SubControlVolume &scv, const ElementVolumeVariables< poreNetworkIndex > &elemVolVars) const
Returns the mass flux across the coupling boundary.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:236
const auto & couplingStencil(Dune::index_constant< freeFlowMomentumIndex > domainI, const Element< freeFlowMomentumIndex > &elementI, const SubControlVolume< freeFlowMomentumIndex > &scvI, Dune::index_constant< j > domainJ) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:469
static constexpr auto freeFlowMassIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:185
typename ParentType::template SubCouplingManager< i, j > SubCouplingManager
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:182
Scalar pressure(const Element< freeFlowMomentumIndex > &element, const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const SubControlVolumeFace< freeFlowMomentumIndex > &scvf) const
Returns the pressure at a given sub control volume face.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:330
const Problem< i > & problem(Dune::index_constant< i > domainI) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:412
Scalar cellPressure(const Element< freeFlowMomentumIndex > &element, const SubControlVolumeFace< freeFlowMomentumIndex > &scvf) const
Returns the pressure at the center of a sub control volume corresponding to a given sub control volum...
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:345
NumEqVector< freeFlowMomentumIndex > momentumCouplingCondition(Dune::index_constant< freeFlowMomentumIndex > domainI, Dune::index_constant< poreNetworkIndex > domainJ, const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMomentumIndex >::SubControlVolumeFace &scvf, const ElementVolumeVariables< freeFlowMomentumIndex > &elemVolVars) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:279
Scalar coupledPoreInscribedRadius(const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMomentumIndex >::SubControlVolumeFace &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:295
auto faceVelocity(const Element< freeFlowMassIndex > &element, const SubControlVolumeFace< freeFlowMassIndex > &scvf) const
Returns the velocity at a given sub control volume face.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:403
auto interfaceThroatVelocity(const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMomentumIndex >::SubControlVolumeFace &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:314
static constexpr auto poreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:186
bool isCoupled(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ, const SubControlVolume< i > &scv) const
If the boundary entity is on a coupling boundary.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:436
auto massCouplingCondition(Dune::index_constant< freeFlowMassIndex > domainI, Dune::index_constant< poreNetworkIndex > domainJ, const FVElementGeometry< freeFlowMassIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMassIndex >::SubControlVolumeFace &scvf, const ElementVolumeVariables< freeFlowMassIndex > &elemVolVars) const
Returns the mass flux across the coupling boundary.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:262
Coupling manager that combines an arbitrary number of binary coupling manager (coupling two domains e...
Definition: multibinarycouplingmanager.hh:50
const auto & couplingStencil(Dune::index_constant< i > domainI, const Entity &entity, Dune::index_constant< j > domainJ) const
Return the coupling element stencil for a given bulk domain element.
Definition: multibinarycouplingmanager.hh:203
decltype(auto) subApply(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ, Apply &&apply)
apply a function to the domainI-domainJ sub coupling manager using its local indices
Definition: multibinarycouplingmanager.hh:137
auto & subCouplingManager(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ)
return the binary sub-coupling manager
Definition: multibinarycouplingmanager.hh:119
SolutionVectors & curSol()
Definition: multibinarycouplingmanager.hh:370
void updateSolution(const typename MDTraits::SolutionVector &curSol)
Update the solution vector before assembly.
Definition: multibinarycouplingmanager.hh:178
Coupling mapper for staggered free-flow and pore-network models.
Definition: boundary/freeflowporenetwork/couplingmapper.hh:42
Defines all properties used in Dumux.
Coupling conditions specialized for different discretization schemes.
typename Detail::FreeFlowCouplingManagerSelector< Traits >::type FreeFlowCouplingManager
The interface of the coupling manager for free flow systems.
Definition: multidomain/freeflow/couplingmanager.hh:47
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
Freeflow coupling managers (Navier-Stokes mass-momentum coupling)
constexpr auto coupledDomains(Dune::index_constant< i > domainI)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:64
constexpr auto globalToLocalDomainIndices(Dune::index_constant< i >, Dune::index_constant< j >)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:75
static constexpr auto freeFlowMassIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:35
static constexpr auto freeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:34
static constexpr auto freeFlowMomentumToPoreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:40
static constexpr auto noCouplingIdx
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:42
static constexpr auto poreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:36
static constexpr auto freeFlowMassToFreeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:39
constexpr auto makeCouplingManagerMap()
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:44
static constexpr auto freeFlowMassToPoreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:41
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:108
Dumux::FreeFlowCouplingManager< FreeFlowTraits > FreeFlowCouplingManager
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:125
typename MDTraits::template SubDomain< id >::TypeTag SubDomainTypeTag
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:110
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:87
static constexpr auto globalToLocal(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:94
static constexpr auto managerMap()
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:88
static constexpr auto coupledDomains(Dune::index_constant< i > domainI)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:100
Definition: multidomain/traits.hh:134