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;
176 template<std::
size_t id>
177 using SubSolutionVector
178 = std::decay_t<decltype(std::declval<SolutionVector>()[Dune::index_constant<id>()])>;
185 template<std::
size_t i, std::
size_t j>
193 using ParentType::ParentType;
195 template<
class Gr
idVarsTuple>
196 void init(std::shared_ptr<Problem<freeFlowMomentumIndex>> freeFlowMomentumProblem,
197 std::shared_ptr<Problem<freeFlowMassIndex>> freeFlowMassProblem,
198 std::shared_ptr<Problem<poreNetworkIndex>> poreNetworkProblem,
199 GridVarsTuple&& gridVarsTuple,
200 const SolutionVector&
curSol)
203 this->init_(freeFlowMomentumProblem, freeFlowMassProblem, poreNetworkProblem, std::forward<GridVarsTuple>(gridVarsTuple),
curSol);
208 freeFlowMomentumProblem, freeFlowMassProblem,
209 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<freeFlowMassIndex>(gridVarsTuple)),
210 FFSol{ std::get<freeFlowMomentumIndex>(this->
curSol()), std::get<freeFlowMassIndex>(this->
curSol()) }
214 template<
class Gr
idVarsTuple>
215 void init(std::shared_ptr<Problem<freeFlowMomentumIndex>> freeFlowMomentumProblem,
216 std::shared_ptr<Problem<freeFlowMassIndex>> freeFlowMassProblem,
217 std::shared_ptr<Problem<poreNetworkIndex>> poreNetworkProblem,
218 GridVarsTuple&& gridVarsTuple,
219 const SolutionVector&
curSol,
220 const SolutionVector& prevSol)
223 this->init_(freeFlowMomentumProblem, freeFlowMassProblem, poreNetworkProblem, std::forward<GridVarsTuple>(gridVarsTuple),
curSol);
226 using FFPrevSol = std::tuple<const SubSolutionVector<freeFlowMomentumIndex>*,
const SubSolutionVector<freeFlowMassIndex>*>;
228 freeFlowMomentumProblem, freeFlowMassProblem,
229 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<freeFlowMassIndex>(gridVarsTuple)),
230 FFSol{ std::get<freeFlowMomentumIndex>(this->
curSol()), std::get<freeFlowMassIndex>(this->
curSol()) },
238 auto massCouplingCondition(Dune::index_constant<poreNetworkIndex> domainI, Dune::index_constant<freeFlowMassIndex> domainJ,
239 const FVElementGeometry<poreNetworkIndex>& fvGeometry,
240 const typename FVElementGeometry<poreNetworkIndex>::SubControlVolume& scv,
241 const ElementVolumeVariables<poreNetworkIndex>& elemVolVars)
const
244 const auto& couplingContext = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
245 return cm.couplingContext(ii, fvGeometry, scv);
248 const auto& freeFlowMassGridGeometry = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
249 return cm.problem(jj).gridGeometry();
252 for (
auto& c : couplingContext)
254 const auto& freeFlowElement = freeFlowMassGridGeometry.element(c.scv.elementIndex());
258 return CouplingConditions::massCouplingCondition(domainI, domainJ, fvGeometry, scv, elemVolVars, couplingContext);
264 auto massCouplingCondition(Dune::index_constant<freeFlowMassIndex> domainI, Dune::index_constant<poreNetworkIndex> domainJ,
265 const FVElementGeometry<freeFlowMassIndex>& fvGeometry,
266 const typename FVElementGeometry<freeFlowMassIndex>::SubControlVolumeFace& scvf,
267 const ElementVolumeVariables<freeFlowMassIndex>& elemVolVars)
const
270 const auto& couplingContext = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
271 return cm.couplingContext(ii, fvGeometry, scvf);
275 return CouplingConditions::massCouplingCondition(domainI, domainJ, fvGeometry, scvf, elemVolVars, couplingContext);
282 Dune::index_constant<poreNetworkIndex> domainJ,
283 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
284 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf,
285 const ElementVolumeVariables<freeFlowMomentumIndex>& elemVolVars)
const
287 if (scvf.isLateral())
288 return NumEqVector<freeFlowMomentumIndex>(0.0);
294 return CouplingConditions::momentumCouplingCondition(fvGeometry, scvf, elemVolVars, context);
298 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf)
const
304 const auto& pnmScv = [&]
306 for (
const auto& scv : scvs(context.fvGeometry))
307 if (scv.dofIndex() == context.poreNetworkDofIdx)
310 DUNE_THROW(Dune::InvalidStateException,
"No scv found");
313 return context.elemVolVars[pnmScv].poreInscribedRadius();
317 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf)
const
323 return CouplingConditions::interfaceThroatVelocity(fvGeometry, scvf, context);
332 Scalar
pressure(
const Element<freeFlowMomentumIndex>& element,
333 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
334 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
337 element, fvGeometry, scvf
348 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
358 Scalar
density(
const Element<freeFlowMomentumIndex>& element,
359 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
360 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf,
361 const bool considerPreviousTimeStep =
false)
const
364 element, fvGeometry, scvf, considerPreviousTimeStep
369 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
370 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf,
371 const bool considerPreviousTimeStep =
false)
const
374 element, fvGeometry, scvf, considerPreviousTimeStep
381 Scalar
density(
const Element<freeFlowMomentumIndex>& element,
382 const SubControlVolume<freeFlowMomentumIndex>& scv,
383 const bool considerPreviousTimeStep =
false)
const
386 element, scv, considerPreviousTimeStep
394 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
395 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
398 element, fvGeometry, scvf
406 const SubControlVolumeFace<freeFlowMassIndex>& scvf)
const
413 template<std::
size_t i>
414 const Problem<i>&
problem(Dune::index_constant<i> domainI)
const
416 return this->
subApply(domainI, [&](
const auto& cm,
auto&& ii) ->
const auto& {
417 return cm.problem(ii);
421 template<std::
size_t i, std::
size_t j>
423 Dune::index_constant<j> domainJ,
424 const SubControlVolumeFace<i>& scvf)
const
426 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj){
427 return cm.isCoupled(ii, scvf);
437 template<std::
size_t i, std::
size_t j>
439 Dune::index_constant<j> domainJ,
440 const SubControlVolume<i>& scv)
const
442 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj){
443 return cm.isCoupled(ii, scv);
470 template<std::
size_t j>
472 const Element<freeFlowMomentumIndex>& elementI,
473 const SubControlVolume<freeFlowMomentumIndex>& scvI,
474 Dune::index_constant<j> domainJ)
const
477 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
478 return cm.couplingStencil(ii, elementI, scvI, jj);
486 template<
class Gr
idVarsTuple>
487 void init_(std::shared_ptr<Problem<freeFlowMomentumIndex>> freeFlowMomentumProblem,
488 std::shared_ptr<Problem<freeFlowMassIndex>> freeFlowMassProblem,
489 std::shared_ptr<Problem<poreNetworkIndex>> poreNetworkProblem,
490 GridVarsTuple&& gridVarsTuple,
491 const SolutionVector&
curSol)
495 auto couplingMapper = std::make_shared<CouplingMapper>();
496 couplingMapper->update(freeFlowMomentumProblem->gridGeometry(),
497 freeFlowMassProblem->gridGeometry(),
498 poreNetworkProblem->gridGeometry()
502 using FFMassPNMSol =
typename SubCouplingManager<freeFlowMassIndex, poreNetworkIndex>::SolutionVectorStorage;
504 freeFlowMassProblem, poreNetworkProblem, couplingMapper,
505 FFMassPNMSol{ std::get<freeFlowMassIndex>(this->
curSol()), std::get<poreNetworkIndex>(this->
curSol()) }
508 using FFMomPNMSol =
typename SubCouplingManager<freeFlowMomentumIndex, poreNetworkIndex>::SolutionVectorStorage;
510 freeFlowMomentumProblem, poreNetworkProblem,
511 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<poreNetworkIndex>(gridVarsTuple)),
512 couplingMapper, FFMomPNMSol{ std::get<freeFlowMomentumIndex>(this->
curSol()), std::get<poreNetworkIndex>(this->
curSol()) }
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:368
bool isCoupled(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ, const SubControlVolumeFace< i > &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:422
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:196
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:381
static constexpr auto freeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:188
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:358
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, const SolutionVector &prevSol)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:215
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:393
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:238
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:471
static constexpr auto freeFlowMassIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:189
typename ParentType::template SubCouplingManager< i, j > SubCouplingManager
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:186
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:332
const Problem< i > & problem(Dune::index_constant< i > domainI) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:414
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:347
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:281
Scalar coupledPoreInscribedRadius(const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMomentumIndex >::SubControlVolumeFace &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:297
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:405
auto interfaceThroatVelocity(const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMomentumIndex >::SubControlVolumeFace &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:316
static constexpr auto poreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:190
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:438
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:264
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