GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/multidomain/couplingmanager.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 34 34 100.0%
Functions: 440 440 100.0%
Branches: 266 361 73.7%

Line Branch Exec Source
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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup MultiDomain
10 * \brief The interface of the coupling manager for multi domain problems
11 */
12
13 #ifndef DUMUX_MULTIDOMAIN_COUPLING_MANAGER_HH
14 #define DUMUX_MULTIDOMAIN_COUPLING_MANAGER_HH
15
16 #include <memory>
17 #include <tuple>
18 #include <vector>
19 #include <dune/common/exceptions.hh>
20 #include <dune/common/indices.hh>
21 #include <dune/common/shared_ptr.hh>
22 #include <dune/common/hybridutilities.hh>
23 #include <dune/istl/multitypeblockvector.hh>
24
25 #include <dumux/assembly/numericepsilon.hh>
26 #include <dumux/common/properties.hh>
27 #include <dumux/common/typetraits/typetraits.hh>
28
29 namespace Dumux {
30
31 /*!
32 * \ingroup MultiDomain
33 * \brief The interface of the coupling manager for multi domain problems
34 */
35 template<class Traits>
36 37 class CouplingManager
37 {
38 template<std::size_t id> using SubDomainTypeTag = typename Traits::template SubDomain<id>::TypeTag;
39 template<std::size_t id> using PrimaryVariables = GetPropType<SubDomainTypeTag<id>, Properties::PrimaryVariables>;
40 template<std::size_t id> using GridView = typename GetPropType<SubDomainTypeTag<id>, Properties::GridGeometry>::GridView;
41 template<std::size_t id> using Element = typename GridView<id>::template Codim<0>::Entity;
42 template<std::size_t id> using Problem = GetPropType<SubDomainTypeTag<id>, Properties::Problem>;
43 template<std::size_t id> using ProblemPtr = const Problem<id> *;
44 using ProblemPtrs = typename Traits::template Tuple<ProblemPtr>;
45
46 template<std::size_t id>
47 using SubSolutionVector
48 = std::decay_t<decltype(std::declval<typename Traits::SolutionVector>()[Dune::index_constant<id>()])>;
49
50 public:
51 //! default type used for coupling element stencils
52 template<std::size_t i, std::size_t j>
53 using CouplingStencilType = std::vector<std::size_t>;
54
55 //! the type of the solution vector
56 using SolutionVector = typename Traits::SolutionVector;
57
58 protected:
59 //! the type in which the solution vector is stored in the manager
60 using SolutionVectorStorage = typename Traits::template TupleOfSharedPtr<SubSolutionVector>;
61
62 public:
63 /*!
64 * \brief Default constructor
65 *
66 * The coupling manager stores pointers to the sub-solution vectors. Note that they can be either
67 * owning pointers (default `updateSolution`) or non-owning. In the non-owning case attach the solution
68 * vector managed elsewhere using `attachSolution` and make sure that object stays alive of the lifetime
69 * of the coupling manager.
70 */
71 334 CouplingManager()
72 334 {
73 using namespace Dune::Hybrid;
74
1/2
✓ Branch 1 taken 265 times.
✗ Branch 2 not taken.
334 forEach(problems_, [](auto& problem){
75 problem = nullptr;
76 });
77
78
2/3
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
✓ Branch 1 taken 134 times.
1022 forEach(curSols_, [](auto& solutionVector){
79 549 solutionVector = std::make_shared<typename std::decay_t<decltype(solutionVector)>::element_type>();
80 });
81 334 }
82
83 /*!
84 * \name member functions concerning the coupling stencils
85 */
86 // \{
87
88 /*!
89 * \brief returns an iterable container of all indices of degrees of freedom of domain j
90 * that couple with / influence the element residual of the given element of domain i
91 *
92 * \param domainI the domain index of domain i
93 * \param elementI the coupled element of domain í
94 * \param domainJ the domain index of domain j
95 *
96 * \note The element residual definition depends on the discretization scheme of domain i
97 * box: a container of the residuals of all sub control volumes
98 * cc : the residual of the (sub) control volume
99 * fem: the residual of the element
100 * \note This function has to be implemented by all coupling managers for all combinations of i and j
101 */
102 template<std::size_t i, std::size_t j>
103 const CouplingStencilType<i, j>& couplingStencil(Dune::index_constant<i> domainI,
104 const Element<i>& elementI,
105 Dune::index_constant<j> domainJ) const
106 {
107 static_assert(i != j, "Domain i cannot be coupled to itself!");
108 static_assert(AlwaysFalse<Dune::index_constant<i>>::value,
109 "The coupling manager does not implement the couplingStencil() function");
110 }
111
112 /*!
113 * \brief extend the jacobian pattern of the diagonal block of domain i
114 * by those entries that are not already in the uncoupled pattern
115 * \note per default we do not add such additional dependencies
116 * \note Such additional dependencies can arise from the coupling, e.g. if a coupling source
117 * term depends on a non-local average of a quantity of the same domain
118 * \warning if you overload this also implement evalAdditionalDomainDerivatives
119 */
120 template<std::size_t id, class JacobianPattern>
121 void extendJacobianPattern(Dune::index_constant<id> domainI, JacobianPattern& pattern) const
122 {}
123
124 // \}
125
126 /*!
127 * \name member functions concerning variable caching for element residual evaluations
128 */
129 // \{
130
131 /*!
132 * \brief prepares all data and variables that are necessary to evaluate the residual of the element of domain i
133 *
134 * \param domainI the domain index of domain i
135 * \param elementI the element whose residual we are assemling next
136 * \param assembler the multidomain assembler for access to all data necessary for the assembly of all domains
137 *
138 * \note this concerns all data that is used in the evaluation of the element residual and depends on one of the
139 * degrees of freedom returned by CouplingManager::couplingStencil
140 * \note every coupled element residual depends at least on the solution of another domain, that why we always store a
141 * copy of the solution vector in the coupling manager, hence, in case the element residual
142 * only depends on primary variables of the other domain this function does nothing
143 * \note overload this function in case the element residual depends on more than the primary variables of domain j
144 */
145 template<std::size_t i, class Assembler>
146 void bindCouplingContext(Dune::index_constant<i> domainI,
147 const Element<i>& elementI,
148 const Assembler& assembler)
149 {}
150
151
152 /*!
153 * \ingroup MultiDomain
154 * \brief updates all data and variables that are necessary to evaluate the residual of the element of domain i
155 * this is called whenever one of the primary variables that the element residual depends on changes in domain j
156 *
157 * \param domainI the domain index of domain i
158 * \param localAssemblerI the local assembler assembling the element residual of an element of domain i
159 * \param domainJ the domain index of domain j
160 * \param dofIdxGlobalJ the index of the degree of freedom of domain j whose solution changed
161 * \param priVarsJ the new solution at the degree of freedom of domain j with index dofIdxGlobalJ
162 * \param pvIdxJ the index of the primary variable of domain j which has been updated
163 *
164 * \note this concerns all data that is used in the evaluation of the element residual and depends on
165 * the primary variables at the degree of freedom location with index dofIdxGlobalJ
166 * \note the element whose residual is to be evaluated can be retrieved from the local assembler
167 * as localAssemblerI.element()
168 * \note per default, we update the solution vector, if the element residual of domain i depends on more than
169 * the primary variables of domain j update the other dependent data here by overloading this function
170 */
171 template<std::size_t i, std::size_t j, class LocalAssemblerI>
172 52511072 void updateCouplingContext(Dune::index_constant<i> domainI,
173 const LocalAssemblerI& localAssemblerI,
174 Dune::index_constant<j> domainJ,
175 std::size_t dofIdxGlobalJ,
176 const PrimaryVariables<j>& priVarsJ,
177 int pvIdxJ)
178 {
179
3/6
✓ Branch 0 taken 269464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208768 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67928 times.
✗ Branch 5 not taken.
48541552 curSol(domainJ)[dofIdxGlobalJ][pvIdxJ] = priVarsJ[pvIdxJ];
180 }
181
182 /*!
183 * \brief update variables of domain i that depend on variables in domain j after the coupling context has been updated
184 *
185 * \param domainI the index of domain i
186 * \param localAssemblerI the local assembler assembling the element residual of an element of domain i
187 * \param elemVolVars the element volume variables (all volume variables in the element local stencil) to be updated
188 * \param elemFluxVarsCache the element flux variable cache (all flux variables in the element local stencil) to be updated
189 *
190 * \note Such variables do not necessarily exist and then this function does nothing (default)
191 * \note some examples
192 * from poromechanics: the porosity of (physical) domain i (porous medium flow) depends on the displacement vector of physical domain j (mechanics)
193 * from domaindecomposition: the transmissibilities for fluxes of domain i to domain j depend on the permeability in domain j
194 * (which might depend in turn on the primary variables of domain i)
195 */
196 template<std::size_t i, class LocalAssemblerI, class UpdatableElementVolVars, class UpdatableFluxVarCache>
197 void updateCoupledVariables(Dune::index_constant<i> domainI,
198 const LocalAssemblerI& localAssemblerI,
199 UpdatableElementVolVars& elemVolVars,
200 UpdatableFluxVarCache& elemFluxVarsCache)
201 {}
202
203 /*!
204 * \brief Updates the entire solution vector, e.g. before assembly or after grid adaption
205 * Overload might want to overload function if the solution vector is stored outside this class
206 * to make sure updates don't happen more than once.
207 */
208 11122 void updateSolution(const SolutionVector& curSol)
209 {
210 using namespace Dune::Hybrid;
211
11/12
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 118 times.
✓ Branch 8 taken 100 times.
✓ Branch 9 taken 19 times.
✓ Branch 11 taken 106 times.
✓ Branch 12 taken 19 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
11126 forEach(integralRange(Dune::Hybrid::size(curSols_)), [&](const auto id)
212 {
213 // copy external solution into object stored in this class
214 11147 *std::get<id>(curSols_) = curSol[id];
215 });
216 }
217
218 // \}
219
220 /*!
221 * \ingroup MultiDomain
222 * \brief evaluates the element residual of a coupled element of domain i which depends on the variables
223 * at the degree of freedom with index dofIdxGlobalJ of domain j
224 *
225 * \param domainI the domain index of domain i
226 * \param localAssemblerI the local assembler assembling the element residual of an element of domain i
227 * \param domainJ the domain index of domain j
228 * \param dofIdxGlobalJ the index of the degree of freedom of domain j which has an influence on the element residual of domain i
229 *
230 * \note the element whose residual is to be evaluated can be retrieved from the local assembler
231 * as localAssemblerI.element() as well as all up-to-date variables and caches.
232 * \note the default implementation evaluates the complete element residual
233 * if only parts (i.e. only certain scvs, or only certain terms of the residual) of the residual are coupled
234 * to dof with index dofIdxGlobalJ the function can be overloaded in the coupling manager
235 * \return the element residual
236 */
237 template<std::size_t i, std::size_t j, class LocalAssemblerI>
238 24383620 decltype(auto) evalCouplingResidual(Dune::index_constant<i> domainI,
239 const LocalAssemblerI& localAssemblerI,
240 Dune::index_constant<j> domainJ,
241 std::size_t dofIdxGlobalJ) const
242 {
243
2/4
✓ Branch 1 taken 6192504 times.
✗ Branch 2 not taken.
✓ Branch 7 taken 1839816 times.
✗ Branch 8 not taken.
24383620 return localAssemblerI.evalLocalResidual();
244 }
245
246 /*!
247 * \brief evaluate additional derivatives of the element residual of a domain with respect
248 * to dofs in the same domain that are not in the regular stencil (see CouplingManager::extendJacobianPattern)
249 * \note Such additional dependencies can arise from the coupling, e.g. if a coupling source
250 * term depends on a non-local average of a quantity of the same domain
251 */
252 template<std::size_t i, class LocalAssemblerI, class JacobianMatrixDiagBlock, class GridVariables>
253 void evalAdditionalDomainDerivatives(Dune::index_constant<i> domainI,
254 const LocalAssemblerI& localAssemblerI,
255 const typename LocalAssemblerI::LocalResidual::ElementResidualVector& origResiduals,
256 JacobianMatrixDiagBlock& A,
257 GridVariables& gridVariables)
258 {}
259
260 /*!
261 * \brief return the numeric epsilon used for deflecting primary variables of coupled domain i
262 */
263 template<std::size_t i>
264 460 decltype(auto) numericEpsilon(Dune::index_constant<i>,
265 const std::string& paramGroup) const
266 {
267 460 constexpr auto numEq = PrimaryVariables<i>::dimension;
268
10/17
✓ Branch 1 taken 186 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 46 times.
✓ Branch 5 taken 138 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 19 times.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 21 times.
✗ Branch 18 not taken.
✗ Branch 6 not taken.
✗ Branch 10 not taken.
✓ Branch 13 taken 19 times.
✓ Branch 21 taken 19 times.
✗ Branch 22 not taken.
460 return NumericEpsilon<typename Traits::Scalar, numEq>(paramGroup);
269 }
270
271 /*!
272 * \brief set the pointers to the sub problems
273 * \param problems A tuple of shared pointers to the sub problems
274 */
275 template<typename... SubProblems>
276 266 void setSubProblems(const std::tuple<std::shared_ptr<SubProblems>...>& problems)
277 {
278 using namespace Dune::Hybrid;
279 1706 forEach(integralRange(size(problems_)), [&](const auto i)
280 423 { setSubProblem(std::get<i>(problems), i); });
281 249 }
282
283 /*!
284 * \brief set a pointer to one of the sub problems
285 * \param problem a pointer to the sub problem
286 * \param domainIdx the domain index of the sub problem
287 */
288 template<class SubProblem, std::size_t i>
289 551 void setSubProblem(std::shared_ptr<SubProblem> problem, Dune::index_constant<i> domainIdx)
290
6/12
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
551 { std::get<i>(problems_) = problem.get(); }
291
292 /*!
293 * \brief Return a reference to the sub problem
294 * \param domainIdx The domain index
295 * We avoid exception handling here because the performance of this function is critical
296 */
297 template<std::size_t i>
298 958909265 const Problem<i>& problem(Dune::index_constant<i> domainIdx) const
299 {
300
91/100
✗ Branch 0 not taken.
✓ Branch 1 taken 34713681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10912544 times.
✓ Branch 4 taken 74268 times.
✓ Branch 5 taken 54821568 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 37162960 times.
✓ Branch 8 taken 6615048 times.
✓ Branch 9 taken 9673547 times.
✓ Branch 10 taken 386404 times.
✓ Branch 11 taken 14512028 times.
✓ Branch 12 taken 468194 times.
✓ Branch 13 taken 21396213 times.
✓ Branch 14 taken 510244 times.
✓ Branch 15 taken 2680230 times.
✓ Branch 16 taken 472432 times.
✓ Branch 17 taken 48214442 times.
✓ Branch 18 taken 955929 times.
✓ Branch 19 taken 524882 times.
✓ Branch 20 taken 756733 times.
✓ Branch 21 taken 519055 times.
✓ Branch 22 taken 239874 times.
✓ Branch 23 taken 720313 times.
✓ Branch 24 taken 33190 times.
✓ Branch 25 taken 1146025 times.
✓ Branch 26 taken 3098903 times.
✓ Branch 27 taken 468505 times.
✓ Branch 28 taken 102229 times.
✓ Branch 29 taken 109896 times.
✓ Branch 30 taken 58850 times.
✓ Branch 31 taken 32589272 times.
✓ Branch 32 taken 24074 times.
✓ Branch 33 taken 325676312 times.
✓ Branch 34 taken 78596 times.
✓ Branch 35 taken 299043849 times.
✓ Branch 36 taken 331537 times.
✓ Branch 37 taken 133271 times.
✓ Branch 38 taken 4120194 times.
✓ Branch 39 taken 227091 times.
✓ Branch 40 taken 30805 times.
✓ Branch 41 taken 1836444 times.
✓ Branch 42 taken 27901 times.
✓ Branch 43 taken 65493 times.
✓ Branch 44 taken 9463 times.
✓ Branch 45 taken 371429 times.
✓ Branch 46 taken 6766 times.
✓ Branch 47 taken 184140 times.
✓ Branch 48 taken 51264 times.
✓ Branch 49 taken 533483 times.
✓ Branch 50 taken 50274 times.
✓ Branch 51 taken 2480896 times.
✓ Branch 52 taken 50523 times.
✓ Branch 53 taken 15416513 times.
✓ Branch 54 taken 444433 times.
✓ Branch 55 taken 412809 times.
✓ Branch 56 taken 1066798 times.
✓ Branch 57 taken 366766 times.
✓ Branch 58 taken 757834 times.
✓ Branch 59 taken 56507 times.
✓ Branch 60 taken 4476 times.
✓ Branch 61 taken 74959 times.
✓ Branch 62 taken 562750 times.
✓ Branch 63 taken 100329 times.
✓ Branch 64 taken 598372 times.
✓ Branch 65 taken 163980 times.
✓ Branch 66 taken 556145 times.
✓ Branch 67 taken 964119 times.
✓ Branch 68 taken 522570 times.
✓ Branch 69 taken 152796 times.
✓ Branch 70 taken 419 times.
✓ Branch 71 taken 206600 times.
✓ Branch 72 taken 138519 times.
✓ Branch 73 taken 1059955 times.
✓ Branch 74 taken 44 times.
✓ Branch 75 taken 219764 times.
✓ Branch 76 taken 32 times.
✓ Branch 77 taken 13094 times.
✓ Branch 78 taken 32 times.
✓ Branch 79 taken 2543 times.
✓ Branch 80 taken 5876 times.
✓ Branch 81 taken 2833 times.
✓ Branch 82 taken 480 times.
✓ Branch 83 taken 22983 times.
✓ Branch 84 taken 528 times.
✓ Branch 85 taken 23923 times.
✗ Branch 86 not taken.
✓ Branch 87 taken 2066 times.
✗ Branch 88 not taken.
✓ Branch 89 taken 313 times.
✗ Branch 90 not taken.
✓ Branch 91 taken 313 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 64 times.
✗ Branch 94 not taken.
✓ Branch 95 taken 7708 times.
✗ Branch 96 not taken.
✓ Branch 97 taken 640 times.
✗ Branch 98 not taken.
✓ Branch 99 taken 640 times.
943533297 const Problem<i>* p = std::get<i>(problems_);
301
90/142
✗ Branch 0 not taken.
✓ Branch 1 taken 37567164 times.
✓ Branch 4 taken 10099093 times.
✓ Branch 5 taken 948946 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 54745356 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 43186596 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 10738129 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 13705694 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 14466361 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 12119743 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 40303443 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 752347 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 818200 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1646076 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 3713858 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 592211 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 141912 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 32484158 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 32457044 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 4463002 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 3917074 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 454045 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 303568 times.
✓ Branch 64 taken 595709 times.
✓ Branch 65 taken 1827439 times.
✓ Branch 67 taken 467440 times.
✓ Branch 68 taken 2703 times.
✓ Branch 70 taken 994171 times.
✓ Branch 71 taken 16994 times.
✓ Branch 73 taken 187437 times.
✓ Branch 74 taken 277 times.
✓ Branch 76 taken 752702 times.
✓ Branch 77 taken 118 times.
✓ Branch 79 taken 361190 times.
✓ Branch 80 taken 4049487 times.
✓ Branch 82 taken 3525416 times.
✓ Branch 83 taken 13112745 times.
✓ Branch 85 taken 702296 times.
✓ Branch 86 taken 18 times.
✓ Branch 88 taken 2351499 times.
✓ Branch 89 taken 2005858 times.
✓ Branch 91 taken 1832720 times.
✓ Branch 92 taken 54929 times.
✓ Branch 94 taken 176552 times.
✓ Branch 95 taken 32964 times.
✓ Branch 97 taken 233797 times.
✓ Branch 98 taken 38241 times.
✓ Branch 100 taken 100231 times.
✓ Branch 101 taken 13843 times.
✓ Branch 103 taken 260397 times.
✓ Branch 104 taken 2882875 times.
✓ Branch 106 taken 966325 times.
✓ Branch 107 taken 55257 times.
✓ Branch 109 taken 151022 times.
✓ Branch 110 taken 165254 times.
✗ Branch 3 not taken.
✗ Branch 63 not taken.
✗ Branch 66 not taken.
✗ Branch 69 not taken.
✗ Branch 72 not taken.
✗ Branch 75 not taken.
✗ Branch 78 not taken.
✗ Branch 81 not taken.
✗ Branch 84 not taken.
✗ Branch 87 not taken.
✗ Branch 90 not taken.
✗ Branch 93 not taken.
✗ Branch 96 not taken.
✗ Branch 99 not taken.
✗ Branch 102 not taken.
✗ Branch 105 not taken.
✗ Branch 108 not taken.
✓ Branch 112 taken 149180 times.
✓ Branch 113 taken 34360 times.
✓ Branch 115 taken 1038156 times.
✓ Branch 116 taken 9 times.
✓ Branch 118 taken 219716 times.
✓ Branch 119 taken 65 times.
✓ Branch 121 taken 535773 times.
✓ Branch 122 taken 97 times.
✓ Branch 124 taken 932 times.
✓ Branch 125 taken 2091 times.
✓ Branch 127 taken 1432 times.
✓ Branch 128 taken 1 times.
✓ Branch 130 taken 24496 times.
✓ Branch 131 taken 1 times.
✓ Branch 133 taken 23082 times.
✓ Branch 134 taken 38 times.
✓ Branch 59 taken 56598 times.
✓ Branch 62 taken 18 times.
✓ Branch 11 taken 1728 times.
✓ Branch 29 taken 9197952 times.
✓ Branch 32 taken 2 times.
✓ Branch 35 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 820498 times.
✓ Branch 44 taken 2 times.
✓ Branch 47 taken 2 times.
✓ Branch 50 taken 2 times.
✓ Branch 53 taken 289574608 times.
✓ Branch 56 taken 298723402 times.
✗ Branch 111 not taken.
✗ Branch 114 not taken.
✗ Branch 117 not taken.
✗ Branch 120 not taken.
✗ Branch 123 not taken.
✗ Branch 126 not taken.
✗ Branch 129 not taken.
✗ Branch 132 not taken.
✗ Branch 135 not taken.
✓ Branch 136 taken 3382 times.
✗ Branch 138 not taken.
✓ Branch 139 taken 313 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 313 times.
✗ Branch 144 not taken.
✓ Branch 145 taken 64 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 7708 times.
✗ Branch 150 not taken.
✓ Branch 151 taken 640 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 640 times.
957956809 assert(p && "The problem pointer is invalid. Use setSubProblems() before calling this function");
302 return *p;
303 }
304
305 protected:
306 /*!
307 * \brief Attach a solution vector stored outside of this class.
308 * \note The caller has to make sure that curSol stays alive for the lifetime of
309 * the coupling manager. Otherwise we have a dangling reference here. Use with care.
310 */
311 126 void attachSolution(const SolutionVectorStorage& curSol)
312 {
313 using namespace Dune::Hybrid;
314 378 forEach(integralRange(Dune::Hybrid::size(curSols_)), [&](const auto id)
315 {
316 // do not take ownership of the external pointer's object
317
6/12
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 21 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 21 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 21 times.
✗ Branch 17 not taken.
126 std::get<id>(curSols_) = Dune::stackobject_to_shared_ptr(*std::get<id>(curSol));
318 });
319 126 }
320
321 /*!
322 * \brief the solution vector of the subproblem
323 * \param domainIdx The domain index
324 * \note in case of numeric differentiation the solution vector always carries the deflected solution
325 */
326 template<std::size_t i>
327 617234408 SubSolutionVector<i>& curSol(Dune::index_constant<i> domainIdx)
328
37/42
✓ Branch 0 taken 7524832 times.
✓ Branch 1 taken 39661388 times.
✓ Branch 3 taken 69809466 times.
✓ Branch 4 taken 2570972 times.
✓ Branch 6 taken 6165628 times.
✓ Branch 7 taken 7342384 times.
✓ Branch 8 taken 270788 times.
✓ Branch 9 taken 31273964 times.
✓ Branch 11 taken 17262816 times.
✓ Branch 12 taken 13415 times.
✓ Branch 13 taken 70258622 times.
✓ Branch 14 taken 22198 times.
✓ Branch 16 taken 34477 times.
✓ Branch 17 taken 312 times.
✓ Branch 18 taken 6385 times.
✓ Branch 19 taken 20286 times.
✓ Branch 21 taken 28926 times.
✓ Branch 22 taken 9688 times.
✓ Branch 24 taken 516 times.
✓ Branch 25 taken 352 times.
✓ Branch 26 taken 264 times.
✓ Branch 27 taken 1618 times.
✓ Branch 30 taken 16 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 64 times.
✓ Branch 34 taken 12 times.
✓ Branch 36 taken 704 times.
✓ Branch 37 taken 528 times.
✓ Branch 39 taken 64 times.
✗ Branch 40 not taken.
✓ Branch 42 taken 704 times.
✗ Branch 43 not taken.
✓ Branch 5 taken 4907376 times.
✓ Branch 10 taken 82217 times.
✓ Branch 20 taken 528 times.
✓ Branch 23 taken 528 times.
✓ Branch 2 taken 8497412 times.
✓ Branch 15 taken 42825048 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 328 times.
✓ Branch 32 taken 24 times.
✗ Branch 35 not taken.
617231864 { return *std::get<i>(curSols_); }
329
330 /*!
331 * \brief the solution vector of the subproblem
332 * \param domainIdx The domain index
333 * \note in case of numeric differentiation the solution vector always carries the deflected solution
334 */
335 template<std::size_t i>
336 754030372 const SubSolutionVector<i>& curSol(Dune::index_constant<i> domainIdx) const
337
7/9
✓ Branch 1 taken 6541648 times.
✓ Branch 2 taken 768853 times.
✓ Branch 5 taken 484985 times.
✗ Branch 6 not taken.
✓ Branch 4 taken 3472 times.
✓ Branch 3 taken 7466899 times.
✓ Branch 0 taken 670560 times.
✓ Branch 9 taken 300 times.
✗ Branch 10 not taken.
633386366 { return *std::get<i>(curSols_); }
338
339 private:
340 /*!
341 * \brief A tuple of shared_ptr's to solution vectors of the subproblems
342 * \note in case of numeric differentiation the solution vector always carries the deflected solution
343 */
344 SolutionVectorStorage curSols_;
345
346 /*!
347 * \brief A tuple of (raw) pointers to the sub problems
348 * \note these are raw pointers and not shared pointers to break the cyclic dependency between coupling manager and problems
349 */
350 ProblemPtrs problems_;
351 };
352
353 } // end namespace Dumux
354
355 #endif
356