25#ifndef DUMUX_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORENETWORK_COUPLINGMANAGER_HH
26#define DUMUX_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORENETWORK_COUPLINGMANAGER_HH
31#include <dune/common/indices.hh>
43namespace FreeFlowPoreNetworkDetail {
58 auto map = std::array<std::array<std::size_t, 3>, 3>{};
75template<std::
size_t i>
86template<std::
size_t i, std::
size_t j>
89 static_assert(i <= 2 && j <= 2);
90 static_assert(i != j);
93 return std::pair<Dune::index_constant<0>, Dune::index_constant<1>>{};
95 return std::pair<Dune::index_constant<1>, Dune::index_constant<0>>{};
105 template<std::
size_t i, std::
size_t j>
106 static constexpr auto globalToLocal(Dune::index_constant<i> domainI, Dune::index_constant<j> domainJ)
111 template<std::
size_t i>
118template<
class MDTraits>
121 template<std::
size_t id>
150template<
class MDTraits>
154 FreeFlowPoreNetworkDetail::CouplingMaps,
155 typename FreeFlowPoreNetworkDetail::CouplingManagers<MDTraits>::FreeFlowCouplingManager,
156 typename FreeFlowPoreNetworkDetail::CouplingManagers<MDTraits>::FreeFlowMomentumPoreNetworkCouplingManager,
157 typename FreeFlowPoreNetworkDetail::CouplingManagers<MDTraits>::FreeFlowMassPoreNetworkCouplingManager
170 using Scalar =
typename MDTraits::Scalar;
173 template<std::
size_t id>
174 using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
178 template<std::
size_t id>
using FVElementGeometry =
typename GridGeometry<id>::LocalView;
179 template<std::
size_t id>
using SubControlVolumeFace =
typename FVElementGeometry<id>::SubControlVolumeFace;
180 template<std::
size_t id>
using SubControlVolume =
typename FVElementGeometry<id>::SubControlVolume;
182 template<std::
size_t id>
using NumEqVector =
typename Problem<id>::Traits::NumEqVector;
184 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
185 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
186 using SolutionVector =
typename MDTraits::SolutionVector;
193 template<std::
size_t i, std::
size_t j>
201 using ParentType::ParentType;
203 template<
class Gr
idVarsTuple>
204 void init(std::shared_ptr<Problem<freeFlowMomentumIndex>> freeFlowMomentumProblem,
205 std::shared_ptr<Problem<freeFlowMassIndex>> freeFlowMassProblem,
206 std::shared_ptr<Problem<poreNetworkIndex>> poreNetworkProblem,
207 GridVarsTuple&& gridVarsTuple,
208 const SolutionVector&
curSol)
212 auto couplingMapper = std::make_shared<CouplingMapper>();
213 couplingMapper->update(freeFlowMomentumProblem->gridGeometry(),
214 freeFlowMassProblem->gridGeometry(),
215 poreNetworkProblem->gridGeometry()
220 std::get<0>(ffSolVecTuple) = std::get<freeFlowMomentumIndex>(this->
curSol());
221 std::get<1>(ffSolVecTuple) = std::get<freeFlowMassIndex>(this->
curSol());
223 freeFlowMomentumProblem, freeFlowMassProblem,
224 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<freeFlowMassIndex>(gridVarsTuple)),
229 std::get<0>(ffMassPmSolVecTuple) = std::get<freeFlowMassIndex>(this->
curSol());
230 std::get<1>(ffMassPmSolVecTuple) = std::get<poreNetworkIndex>(this->
curSol());
232 freeFlowMassProblem, poreNetworkProblem, couplingMapper, ffMassPmSolVecTuple
236 std::get<0>(ffMomentumPmSolVecTuple) = std::get<freeFlowMomentumIndex>(this->
curSol());
237 std::get<1>(ffMomentumPmSolVecTuple) = std::get<poreNetworkIndex>(this->
curSol());
239 freeFlowMomentumProblem, poreNetworkProblem,
240 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<poreNetworkIndex>(gridVarsTuple)),
241 couplingMapper, ffMomentumPmSolVecTuple
248 auto massCouplingCondition(Dune::index_constant<poreNetworkIndex> domainI, Dune::index_constant<freeFlowMassIndex> domainJ,
249 const FVElementGeometry<poreNetworkIndex>& fvGeometry,
250 const typename FVElementGeometry<poreNetworkIndex>::SubControlVolume& scv,
251 const ElementVolumeVariables<poreNetworkIndex>& elemVolVars)
const
254 const auto& couplingContext = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
255 return cm.couplingContext(ii, fvGeometry, scv);
258 const auto& freeFlowMassGridGeometry = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
259 return cm.problem(jj).gridGeometry();
262 for (
auto& c : couplingContext)
264 const auto& freeFlowElement = freeFlowMassGridGeometry.element(c.scv.elementIndex());
268 return CouplingConditions::massCouplingCondition(domainI, domainJ, fvGeometry, scv, elemVolVars, couplingContext);
274 auto massCouplingCondition(Dune::index_constant<freeFlowMassIndex> domainI, Dune::index_constant<poreNetworkIndex> domainJ,
275 const FVElementGeometry<freeFlowMassIndex>& fvGeometry,
276 const typename FVElementGeometry<freeFlowMassIndex>::SubControlVolumeFace& scvf,
277 const ElementVolumeVariables<freeFlowMassIndex>& elemVolVars)
const
280 const auto& couplingContext = this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
281 return cm.couplingContext(ii, fvGeometry, scvf);
285 return CouplingConditions::massCouplingCondition(domainI, domainJ, fvGeometry, scvf, elemVolVars, couplingContext);
292 Dune::index_constant<poreNetworkIndex> domainJ,
293 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
294 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf,
295 const ElementVolumeVariables<freeFlowMomentumIndex>& elemVolVars)
const
297 if (scvf.isLateral())
298 return NumEqVector<freeFlowMomentumIndex>(0.0);
304 return CouplingConditions::momentumCouplingCondition(fvGeometry, scvf, elemVolVars, context);
308 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf)
const
314 const auto& pnmScv = [&]
316 for (
const auto& scv : scvs(context.fvGeometry))
317 if (scv.dofIndex() == context.poreNetworkDofIdx)
320 DUNE_THROW(Dune::InvalidStateException,
"No scv found");
323 return context.elemVolVars[pnmScv].poreInscribedRadius();
327 const typename FVElementGeometry<freeFlowMomentumIndex>::SubControlVolumeFace& scvf)
const
333 return CouplingConditions::interfaceThroatVelocity(fvGeometry, scvf, context);
342 Scalar
pressure(
const Element<freeFlowMomentumIndex>& element,
343 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
344 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
347 element, fvGeometry, scvf
358 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
368 Scalar
density(
const Element<freeFlowMomentumIndex>& element,
369 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
370 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf,
371 const bool considerPreviousTimeStep =
false)
const
374 element, fvGeometry, scvf, considerPreviousTimeStep
379 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
380 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf,
381 const bool considerPreviousTimeStep =
false)
const
384 element, fvGeometry, scvf, considerPreviousTimeStep
391 Scalar
density(
const Element<freeFlowMomentumIndex>& element,
392 const SubControlVolume<freeFlowMomentumIndex>& scv,
393 const bool considerPreviousTimeStep =
false)
const
396 element, scv, considerPreviousTimeStep
404 const FVElementGeometry<freeFlowMomentumIndex>& fvGeometry,
405 const SubControlVolumeFace<freeFlowMomentumIndex>& scvf)
const
408 element, fvGeometry, scvf
416 const SubControlVolumeFace<freeFlowMassIndex>& scvf)
const
423 template<std::
size_t i>
424 const Problem<i>&
problem(Dune::index_constant<i> domainI)
const
426 return this->
subApply(domainI, [&](
const auto& cm,
auto&& ii) ->
const auto& {
427 return cm.problem(ii);
431 template<std::
size_t i, std::
size_t j>
433 Dune::index_constant<j> domainJ,
434 const SubControlVolumeFace<i>& scvf)
const
436 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj){
437 return cm.isCoupled(ii, scvf);
447 template<std::
size_t i, std::
size_t j>
449 Dune::index_constant<j> domainJ,
450 const SubControlVolume<i>& scv)
const
452 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj){
453 return cm.isCoupled(ii, scv);
480 template<std::
size_t j>
482 const Element<freeFlowMomentumIndex>& elementI,
483 const SubControlVolume<freeFlowMomentumIndex>& scvI,
484 Dune::index_constant<j> domainJ)
const
487 return this->
subApply(domainI, domainJ, [&](
const auto& cm,
auto&& ii,
auto&& jj) ->
const auto& {
488 return cm.couplingStencil(ii, elementI, scvI, jj);
typename Detail::FreeFlowCouplingManagerSelector< Traits >::type FreeFlowCouplingManager
The interface of the coupling manager for free flow systems.
Definition: multidomain/freeflow/couplingmanager.hh:67
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
constexpr auto coupledDomains(Dune::index_constant< i > domainI)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:76
constexpr auto globalToLocalDomainIndices(Dune::index_constant< i >, Dune::index_constant< j >)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:87
static constexpr auto freeFlowMassIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:47
static constexpr auto freeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:46
static constexpr auto freeFlowMomentumToPoreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:52
static constexpr auto noCouplingIdx
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:54
static constexpr auto poreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:48
static constexpr auto freeFlowMassToFreeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:51
constexpr auto makeCouplingManagerMap()
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:56
static constexpr auto freeFlowMassToPoreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:53
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:55
Definition: common/properties.hh:100
The type for a global container for the volume variables.
Definition: common/properties.hh:107
Definition: freeflowporenetwork/couplingconditions.hh:43
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:99
static constexpr auto globalToLocal(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:106
static constexpr auto managerMap()
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:100
static constexpr auto coupledDomains(Dune::index_constant< i > domainI)
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:112
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:120
Dumux::FreeFlowCouplingManager< FreeFlowTraits > FreeFlowCouplingManager
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:137
typename MDTraits::template SubDomain< id >::TypeTag SubDomainTypeTag
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:122
Coupling manager for coupling freeflow and pore-network models.
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:159
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:378
bool isCoupled(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ, const SubControlVolumeFace< i > &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:432
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:204
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:391
static constexpr auto freeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:196
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:368
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:403
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:248
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:481
static constexpr auto freeFlowMassIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:197
typename ParentType::template SubCouplingManager< i, j > SubCouplingManager
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:194
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:342
const Problem< i > & problem(Dune::index_constant< i > domainI) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:424
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:357
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:291
Scalar coupledPoreInscribedRadius(const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMomentumIndex >::SubControlVolumeFace &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:307
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:415
auto interfaceThroatVelocity(const FVElementGeometry< freeFlowMomentumIndex > &fvGeometry, const typename FVElementGeometry< freeFlowMomentumIndex >::SubControlVolumeFace &scvf) const
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:326
static constexpr auto poreNetworkIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:198
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:448
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:274
Coupling mapper for staggered free-flow and pore-network models.
Definition: boundary/freeflowporenetwork/couplingmapper.hh:54
Coupling manager for free-flow mass and pore-network models.
Definition: multidomain/boundary/freeflowporenetwork/ffmassporenetwork/couplingmanager.hh:47
Coupling manager for free-flow momentum and pore-network models.
Definition: multidomain/boundary/freeflowporenetwork/ffmomentumporenetwork/couplingmanager.hh:47
Coupling manager that combines an arbitrary number of binary coupling manager (coupling two domains e...
Definition: multibinarycouplingmanager.hh:62
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:215
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:149
auto & subCouplingManager(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ)
return the binary sub-coupling manager
Definition: multibinarycouplingmanager.hh:131
SolutionVectors & curSol()
Definition: multibinarycouplingmanager.hh:382
void updateSolution(const typename MDTraits::SolutionVector &curSol)
Update the solution vector before assembly.
Definition: multibinarycouplingmanager.hh:190
Definition: multidomain/traits.hh:141
Declares all properties used in Dumux.
Freeflow coupling managers (Navier-Stokes mass-momentum coupling)