version 3.8.0
Loading...
Searching...
No Matches
couplingmanager_base.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_MULTIDOMAIN_BOUNDARY_FREEFLOW_POROUSMEDIUM_COUPLINGMANAGER_BASE_HH
14#define DUMUX_MULTIDOMAIN_BOUNDARY_FREEFLOW_POROUSMEDIUM_COUPLINGMANAGER_BASE_HH
15
16#include <utility>
17#include <memory>
18
19#include <dune/common/indices.hh>
25
26namespace Dumux {
27
28#ifndef DOXYGEN
29namespace FreeFlowPorousMediumDetail {
30
31// global subdomain indices
32static constexpr auto freeFlowMomentumIndex = Dune::index_constant<0>();
33static constexpr auto freeFlowMassIndex = Dune::index_constant<1>();
34static constexpr auto porousMediumIndex = Dune::index_constant<2>();
35
36// coupling indices
37static constexpr auto freeFlowMassToFreeFlowMomentumIndex = Dune::index_constant<0>();
38static constexpr auto freeFlowMomentumToPorousMediumIndex = Dune::index_constant<1>();
39static constexpr auto freeFlowMassToPorousMediumIndex = Dune::index_constant<2>();
40static constexpr auto noCouplingIdx = Dune::index_constant<99>();
41
42constexpr auto makeCouplingManagerMap()
43{
44 auto map = std::array<std::array<std::size_t, 3>, 3>{};
45
46 // free flow (momentum-mass)
47 map[freeFlowMomentumIndex][freeFlowMassIndex] = freeFlowMassToFreeFlowMomentumIndex;
48 map[freeFlowMassIndex][freeFlowMomentumIndex] = freeFlowMassToFreeFlowMomentumIndex;
49
50 // free flow momentum - porous medium
51 map[freeFlowMomentumIndex][porousMediumIndex] = freeFlowMomentumToPorousMediumIndex;
52 map[porousMediumIndex][freeFlowMomentumIndex] = freeFlowMomentumToPorousMediumIndex;
53
54 // free flow mass - porous medium
55 map[freeFlowMassIndex][porousMediumIndex] = freeFlowMassToPorousMediumIndex;
56 map[porousMediumIndex][freeFlowMassIndex] = freeFlowMassToPorousMediumIndex;
57
58 return map;
59}
60
61template<std::size_t i>
62constexpr auto coupledDomains(Dune::index_constant<i> domainI)
63{
64 if constexpr (i == freeFlowMomentumIndex)
65 return std::make_tuple(freeFlowMassIndex, porousMediumIndex);
66 else if constexpr (i == freeFlowMassIndex)
67 return std::make_tuple(freeFlowMomentumIndex, porousMediumIndex);
68 else // i == porousMediumIndex
69 return std::make_tuple(freeFlowMomentumIndex, freeFlowMassIndex);
70}
71
72template<std::size_t i, std::size_t j>
73constexpr auto globalToLocalDomainIndices(Dune::index_constant<i>, Dune::index_constant<j>)
74{
75 static_assert(i <= 2 && j <= 2);
76 static_assert(i != j);
77
78 if constexpr (i < j)
79 return std::pair<Dune::index_constant<0>, Dune::index_constant<1>>{};
80 else
81 return std::pair<Dune::index_constant<1>, Dune::index_constant<0>>{};
82}
83
84struct CouplingMaps
85{
86 static constexpr auto managerMap()
87 {
88 return FreeFlowPorousMediumDetail::makeCouplingManagerMap();
89 }
90
91 template<std::size_t i, std::size_t j>
92 static constexpr auto globalToLocal(Dune::index_constant<i> domainI, Dune::index_constant<j> domainJ)
93 {
94 return FreeFlowPorousMediumDetail::globalToLocalDomainIndices(domainI, domainJ);
95 }
96
97 template<std::size_t i>
98 static constexpr auto coupledDomains(Dune::index_constant<i> domainI)
99 {
100 return FreeFlowPorousMediumDetail::coupledDomains(domainI);
101 }
102};
103
104template<class MDTraits>
105struct CouplingManagers
106{
107 template<std::size_t id>
108 using SubDomainTypeTag = typename MDTraits::template SubDomain<id>::TypeTag;
109
110 using FreeFlowTraits = MultiDomainTraits<
111 SubDomainTypeTag<freeFlowMomentumIndex>, SubDomainTypeTag<freeFlowMassIndex>
112 >;
113
114 using FreeFlowMomentumPorousMediumTraits = MultiDomainTraits<
115 SubDomainTypeTag<freeFlowMomentumIndex>, SubDomainTypeTag<porousMediumIndex>
116 >;
117
118 using FreeFlowMassPorousMediumTraits = MultiDomainTraits<
119 SubDomainTypeTag<freeFlowMassIndex>, SubDomainTypeTag<porousMediumIndex>
120 >;
121
128};
129
130} // end namespace FreeFlowPorousMediumDetail
131#endif // DOXYGEN
132
137template<class MDTraits>
140 MDTraits,
141 FreeFlowPorousMediumDetail::CouplingMaps,
142 typename FreeFlowPorousMediumDetail::CouplingManagers<MDTraits>::FreeFlowCouplingManager,
143 typename FreeFlowPorousMediumDetail::CouplingManagers<MDTraits>::FreeFlowMomentumPorousMediumCouplingManager,
144 typename FreeFlowPorousMediumDetail::CouplingManagers<MDTraits>::FreeFlowMassPorousMediumCouplingManager
145>
146{
148 MDTraits,
149 FreeFlowPorousMediumDetail::CouplingMaps,
150 typename FreeFlowPorousMediumDetail::CouplingManagers<MDTraits>::FreeFlowCouplingManager,
151 typename FreeFlowPorousMediumDetail::CouplingManagers<MDTraits>::FreeFlowMomentumPorousMediumCouplingManager,
152 typename FreeFlowPorousMediumDetail::CouplingManagers<MDTraits>::FreeFlowMassPorousMediumCouplingManager
153 >;
154
155 using Scalar = typename MDTraits::Scalar;
156
157 // the sub domain type tags
158 template<std::size_t id>
159 using SubDomainTypeTag = typename MDTraits::template SubDomain<id>::TypeTag;
160
161 template<std::size_t id> using Problem = GetPropType<SubDomainTypeTag<id>, Properties::Problem>;
162 template<std::size_t id> using GridGeometry = GetPropType<SubDomainTypeTag<id>, Properties::GridGeometry>;
163 template<std::size_t id> using FVElementGeometry = typename GridGeometry<id>::LocalView;
164 template<std::size_t id> using SubControlVolumeFace = typename FVElementGeometry<id>::SubControlVolumeFace;
165 template<std::size_t id> using SubControlVolume = typename FVElementGeometry<id>::SubControlVolume;
166 template<std::size_t id> using ElementVolumeVariables = typename GetPropType<SubDomainTypeTag<id>, Properties::GridVolumeVariables>::LocalView;
167 template<std::size_t id> using NumEqVector = typename Problem<id>::Traits::NumEqVector;
168
169 template<std::size_t id> using GridView = typename GridGeometry<id>::GridView;
170 template<std::size_t id> using Element = typename GridView<id>::template Codim<0>::Entity;
171 using SolutionVector = typename MDTraits::SolutionVector;
172
173public:
174
175 template<std::size_t i, std::size_t j>
176 using SubCouplingManager = typename ParentType::template SubCouplingManager<i, j>;
177
178 static constexpr auto freeFlowMomentumIndex = FreeFlowPorousMediumDetail::freeFlowMomentumIndex;
179 static constexpr auto freeFlowMassIndex = FreeFlowPorousMediumDetail::freeFlowMassIndex;
180 static constexpr auto porousMediumIndex = FreeFlowPorousMediumDetail::porousMediumIndex;
181
182public:
183 using ParentType::ParentType;
184
185 template<class GridVarsTuple>
186 void init(std::shared_ptr<Problem<freeFlowMomentumIndex>> freeFlowMomentumProblem,
187 std::shared_ptr<Problem<freeFlowMassIndex>> freeFlowMassProblem,
188 std::shared_ptr<Problem<porousMediumIndex>> porousMediumProblem,
189 GridVarsTuple&& gridVarsTuple,
190 const SolutionVector& curSol)
191 {
192 this->updateSolution(curSol); // generic coupling manager stores tuple of shared_ptr
193
194 // initialize the binary sub coupling managers
196 std::get<0>(ffSolVecTuple) = std::get<freeFlowMomentumIndex>(this->curSol());
197 std::get<1>(ffSolVecTuple) = std::get<freeFlowMassIndex>(this->curSol());
199 freeFlowMomentumProblem, freeFlowMassProblem,
200 std::make_tuple(std::get<freeFlowMomentumIndex>(gridVarsTuple), std::get<freeFlowMassIndex>(gridVarsTuple)),
201 ffSolVecTuple
202 );
203
205 std::get<0>(ffMassPmSolVecTuple) = std::get<freeFlowMassIndex>(this->curSol());
206 std::get<1>(ffMassPmSolVecTuple) = std::get<porousMediumIndex>(this->curSol());
208 freeFlowMassProblem, porousMediumProblem, ffMassPmSolVecTuple
209 );
210
212 std::get<0>(ffMomentumPmSolVecTuple) = std::get<freeFlowMomentumIndex>(this->curSol());
213 std::get<1>(ffMomentumPmSolVecTuple) = std::get<porousMediumIndex>(this->curSol());
215 freeFlowMomentumProblem, porousMediumProblem, ffMomentumPmSolVecTuple
216 );
217 }
218
219 template<std::size_t i>
220 const Problem<i>& problem(Dune::index_constant<i> domainI) const
221 {
222 return this->subApply(domainI, [&](const auto& cm, auto&& ii) -> const auto& {
223 return cm.problem(ii);
224 });
225 }
226
227 template<std::size_t i, std::size_t j>
228 bool isCoupled(Dune::index_constant<i> domainI,
229 Dune::index_constant<j> domainJ,
230 const SubControlVolumeFace<i>& scvf) const
231 {
232 return this->subApply(domainI, domainJ, [&](const auto& cm, auto&& ii, auto&& jj){
233 return cm.isCoupled(ii, scvf);
234 });
235 }
236
243 template<std::size_t i, std::size_t j>
244 bool isCoupled(Dune::index_constant<i> domainI,
245 Dune::index_constant<j> domainJ,
246 const SubControlVolume<i>& scv) const
247 {
248 return this->subApply(domainI, domainJ, [&](const auto& cm, auto&& ii, auto&& jj){
249 return cm.isCoupled(ii, scv);
250 });
251 }
252
263 template<std::size_t j>
264 const auto& couplingStencil(Dune::index_constant<freeFlowMomentumIndex> domainI,
265 const Element<freeFlowMomentumIndex>& elementI,
266 const SubControlVolume<freeFlowMomentumIndex>& scvI,
267 Dune::index_constant<j> domainJ) const
268 {
269 static_assert(freeFlowMomentumIndex != j);
270 return this->subApply(domainI, domainJ, [&](const auto& cm, auto&& ii, auto&& jj) -> const auto& {
271 return cm.couplingStencil(ii, elementI, scvI, jj);
272 });
273 }
274};
275
276} // end namespace Dumux
277
278#endif
Base coupling manager for coupling freeflow and porous medium flow models.
Definition couplingmanager_base.hh:146
void init(std::shared_ptr< Problem< freeFlowMomentumIndex > > freeFlowMomentumProblem, std::shared_ptr< Problem< freeFlowMassIndex > > freeFlowMassProblem, std::shared_ptr< Problem< porousMediumIndex > > porousMediumProblem, GridVarsTuple &&gridVarsTuple, const SolutionVector &curSol)
Definition couplingmanager_base.hh:186
static constexpr auto porousMediumIndex
Definition couplingmanager_base.hh:180
static constexpr auto freeFlowMassIndex
Definition couplingmanager_base.hh:179
typename ParentType::template SubCouplingManager< i, j > SubCouplingManager
Definition couplingmanager_base.hh:176
bool isCoupled(Dune::index_constant< i > domainI, Dune::index_constant< j > domainJ, const SubControlVolumeFace< i > &scvf) const
Definition couplingmanager_base.hh:228
const auto & couplingStencil(Dune::index_constant< freeFlowMomentumIndex > domainI, const Element< freeFlowMomentumIndex > &elementI, const SubControlVolume< freeFlowMomentumIndex > &scvI, Dune::index_constant< j > domainJ) const
returns an iterable container of all indices of degrees of freedom of domain j that couple with / inf...
Definition couplingmanager_base.hh:264
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 couplingmanager_base.hh:244
const Problem< i > & problem(Dune::index_constant< i > domainI) const
Definition couplingmanager_base.hh:220
static constexpr auto freeFlowMomentumIndex
Definition couplingmanager_base.hh:178
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
Defines all properties used in Dumux.
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
Coupling manager that combines an arbitrary number of binary coupling manager (coupling two domains e...
Coupling managers specialized for different discretization schemes for mass coupling.
Coupling managers specialized for different discretization schemes for momentum coupling.
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
constexpr auto makeCouplingManagerMap()
Definition multidomain/boundary/freeflowporenetwork/couplingmanager.hh:44
Definition adapt.hh:17
typename FreeFlowMassPorousMediumDetail::FreeFlowMassPorousMediumCouplingManagerSelector< MDTraits >::type FreeFlowMassPorousMediumCouplingManager
Definition multidomain/boundary/freeflowporousmedium/ffmasspm/couplingmanager.hh:40
typename FreeFlowMomentumPorousMediumDetail::FreeFlowMomentumPorousMediumCouplingManagerSelector< MDTraits >::type FreeFlowMomentumPorousMediumCouplingManager
Definition multidomain/boundary/freeflowporousmedium/ffmomentumpm/couplingmanager.hh:40