GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/multidomain/couplingmanager.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 21 40 52.5%
Functions: 441 2499 17.6%
Branches: 320 612 52.3%

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-FileCopyrightInfo: 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 namespace Detail {
32
33 // helper to create a multitype vector of references to solution vectors
34 template<class... Args, std::size_t ...Is>
35 auto toRef(const std::tuple<Args...>& v, std::index_sequence<Is...> indices)
36 {
37 return Dune::MultiTypeBlockVector<std::add_lvalue_reference_t<typename Args::element_type>...>(*std::get<Is>(v)...);
38 }
39
40 } // end namespace Detail
41
42 /*!
43 * \ingroup MultiDomain
44 * \brief The interface of the coupling manager for multi domain problems
45 */
46 template<class Traits>
47 37 class CouplingManager
48 {
49 template<std::size_t id> using SubDomainTypeTag = typename Traits::template SubDomain<id>::TypeTag;
50 template<std::size_t id> using PrimaryVariables = GetPropType<SubDomainTypeTag<id>, Properties::PrimaryVariables>;
51 template<std::size_t id> using GridView = typename GetPropType<SubDomainTypeTag<id>, Properties::GridGeometry>::GridView;
52 template<std::size_t id> using Element = typename GridView<id>::template Codim<0>::Entity;
53 template<std::size_t id> using Problem = GetPropType<SubDomainTypeTag<id>, Properties::Problem>;
54 template<std::size_t id> using ProblemPtr = const Problem<id> *;
55 using ProblemPtrs = typename Traits::template Tuple<ProblemPtr>;
56
57 template<std::size_t id>
58 using SubSolutionVector
59 = std::decay_t<decltype(std::declval<typename Traits::SolutionVector>()[Dune::index_constant<id>()])>;
60
61 public:
62 //! default type used for coupling element stencils
63 template<std::size_t i, std::size_t j>
64 using CouplingStencilType = std::vector<std::size_t>;
65
66 //! the type of the solution vector
67 using SolutionVector = typename Traits::SolutionVector;
68
69 protected:
70 //! the type in which the solution vector is stored in the manager
71 using SolutionVectorStorage = typename Traits::template TupleOfSharedPtr<SubSolutionVector>;
72
73 public:
74 /*!
75 * \brief Default constructor
76 *
77 * The coupling manager stores pointers to the sub-solution vectors. Note that they can be either
78 * owning pointers (default `updateSolution`) or non-owning. In the non-owning case attach the solution
79 * vector managed elsewhere using `attachSolution` and make sure that object stays alive of the lifetime
80 * of the coupling manager.
81 */
82 297 CouplingManager()
83 594 {
84 using namespace Dune::Hybrid;
85
1/2
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
297 forEach(problems_, [](auto& problem){
86 problem = nullptr;
87 });
88
89
1/2
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
1199 forEach(curSols_, [](auto& solutionVector){
90
6/24
✗ Branch 1 not taken.
✓ Branch 2 taken 368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 368 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 103 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 34 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
505 solutionVector = std::make_shared<typename std::decay_t<decltype(solutionVector)>::element_type>();
91 });
92 297 }
93
94 /*!
95 * \name member functions concerning the coupling stencils
96 */
97 // \{
98
99 /*!
100 * \brief returns an iterable container of all indices of degrees of freedom of domain j
101 * that couple with / influence the element residual of the given element of domain i
102 *
103 * \param domainI the domain index of domain i
104 * \param elementI the coupled element of domain í
105 * \param domainJ the domain index of domain j
106 *
107 * \note The element residual definition depends on the discretization scheme of domain i
108 * box: a container of the residuals of all sub control volumes
109 * cc : the residual of the (sub) control volume
110 * fem: the residual of the element
111 * \note This function has to be implemented by all coupling managers for all combinations of i and j
112 */
113 template<std::size_t i, std::size_t j>
114 const CouplingStencilType<i, j>& couplingStencil(Dune::index_constant<i> domainI,
115 const Element<i>& elementI,
116 Dune::index_constant<j> domainJ) const
117 {
118 static_assert(i != j, "Domain i cannot be coupled to itself!");
119 static_assert(AlwaysFalse<Dune::index_constant<i>>::value,
120 "The coupling manager does not implement the couplingStencil() function");
121 }
122
123 /*!
124 * \brief extend the jacobian pattern of the diagonal block of domain i
125 * by those entries that are not already in the uncoupled pattern
126 * \note per default we do not add such additional dependencies
127 * \note Such additional dependencies can arise from the coupling, e.g. if a coupling source
128 * term depends on a non-local average of a quantity of the same domain
129 * \warning if you overload this also implement evalAdditionalDomainDerivatives
130 */
131 template<std::size_t id, class JacobianPattern>
132 void extendJacobianPattern(Dune::index_constant<id> domainI, JacobianPattern& pattern) const
133 {}
134
135 // \}
136
137 /*!
138 * \name member functions concerning variable caching for element residual evaluations
139 */
140 // \{
141
142 /*!
143 * \brief prepares all data and variables that are necessary to evaluate the residual of the element of domain i
144 *
145 * \param domainI the domain index of domain i
146 * \param elementI the element whose residual we are assemling next
147 * \param assembler the multidomain assembler for access to all data necessary for the assembly of all domains
148 *
149 * \note this concerns all data that is used in the evaluation of the element residual and depends on one of the
150 * degrees of freedom returned by CouplingManager::couplingStencil
151 * \note every coupled element residual depends at least on the solution of another domain, that why we always store a
152 * copy of the solution vector in the coupling manager, hence, in case the element residual
153 * only depends on primary variables of the other domain this function does nothing
154 * \note overload this function in case the element residual depends on more than the primary variables of domain j
155 */
156 template<std::size_t i, class Assembler>
157 void bindCouplingContext(Dune::index_constant<i> domainI,
158 const Element<i>& elementI,
159 const Assembler& assembler)
160 {}
161
162
163 /*!
164 * \ingroup MultiDomain
165 * \brief updates all data and variables that are necessary to evaluate the residual of the element of domain i
166 * this is called whenever one of the primary variables that the element residual depends on changes in domain j
167 *
168 * \param domainI the domain index of domain i
169 * \param localAssemblerI the local assembler assembling the element residual of an element of domain i
170 * \param domainJ the domain index of domain j
171 * \param dofIdxGlobalJ the index of the degree of freedom of domain j whose solution changed
172 * \param priVarsJ the new solution at the degree of freedom of domain j with index dofIdxGlobalJ
173 * \param pvIdxJ the index of the primary variable of domain j which has been updated
174 *
175 * \note this concerns all data that is used in the evaluation of the element residual and depends on
176 * the primary variables at the degree of freedom location with index dofIdxGlobalJ
177 * \note the element whose residual is to be evaluated can be retrieved from the local assembler
178 * as localAssemblerI.element()
179 * \note per default, we update the solution vector, if the element residual of domain i depends on more than
180 * the primary variables of domain j update the other dependent data here by overloading this function
181 */
182 template<std::size_t i, std::size_t j, class LocalAssemblerI>
183 void updateCouplingContext(Dune::index_constant<i> domainI,
184 const LocalAssemblerI& localAssemblerI,
185 Dune::index_constant<j> domainJ,
186 std::size_t dofIdxGlobalJ,
187 const PrimaryVariables<j>& priVarsJ,
188 int pvIdxJ)
189 {
190
11/18
✓ Branch 0 taken 169528 times.
✓ Branch 1 taken 7872 times.
✓ Branch 2 taken 184704 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 160012 times.
✓ Branch 5 taken 40 times.
✓ Branch 6 taken 232616 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 237784 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 236080 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 89824 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 89824 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 89824 times.
✗ Branch 17 not taken.
66526464 curSol(domainJ)[dofIdxGlobalJ][pvIdxJ] = priVarsJ[pvIdxJ];
191 }
192
193 /*!
194 * \brief update variables of domain i that depend on variables in domain j after the coupling context has been updated
195 *
196 * \param domainI the index of domain i
197 * \param localAssemblerI the local assembler assembling the element residual of an element of domain i
198 * \param elemVolVars the element volume variables (all volume variables in the element local stencil) to be updated
199 * \param elemFluxVarsCache the element flux variable cache (all flux variables in the element local stencil) to be updated
200 *
201 * \note Such variables do not necessarily exist and then this function does nothing (default)
202 * \note some examples
203 * from geomechanics: the porosity of (physical) domain i (porous medium flow) depends on the displacement vector of physical domain j (mechanics)
204 * from domaindecomposition: the transmissibilities for fluxes of domain i to domain j depend on the permeability in domain j
205 * (which might depend in turn on the primary variables of domain i)
206 */
207 template<std::size_t i, class LocalAssemblerI, class UpdatableElementVolVars, class UpdatableFluxVarCache>
208 void updateCoupledVariables(Dune::index_constant<i> domainI,
209 const LocalAssemblerI& localAssemblerI,
210 UpdatableElementVolVars& elemVolVars,
211 UpdatableFluxVarCache& elemFluxVarsCache)
212 {}
213
214 /*!
215 * \brief Updates the entire solution vector, e.g. before assembly or after grid adaption
216 * Overload might want to overload function if the solution vector is stored outside this class
217 * to make sure updates don't happen more than once.
218 */
219 void updateSolution(const SolutionVector& curSol)
220 {
221 using namespace Dune::Hybrid;
222
11/12
✓ Branch 3 taken 119 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 118 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 100 times.
✓ Branch 9 taken 19 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 106 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
10690 forEach(integralRange(Dune::Hybrid::size(curSols_)), [&](const auto id)
223 {
224 // copy external solution into object stored in this class
225 *std::get<id>(curSols_) = curSol[id];
226 });
227 }
228
229 // \}
230
231 /*!
232 * \ingroup MultiDomain
233 * \brief evaluates the element residual of a coupled element of domain i which depends on the variables
234 * at the degree of freedom with index dofIdxGlobalJ of domain j
235 *
236 * \param domainI the domain index of domain i
237 * \param localAssemblerI the local assembler assembling the element residual of an element of domain i
238 * \param domainJ the domain index of domain j
239 * \param dofIdxGlobalJ the index of the degree of freedom of domain j which has an influence on the element residual of domain i
240 *
241 * \note the element whose residual is to be evaluated can be retrieved from the local assembler
242 * as localAssemblerI.element() as well as all up-to-date variables and caches.
243 * \note the default implementation evaluates the complete element residual
244 * if only parts (i.e. only certain scvs, or only certain terms of the residual) of the residual are coupled
245 * to dof with index dofIdxGlobalJ the function can be overloaded in the coupling manager
246 * \return the element residual
247 */
248 template<std::size_t i, std::size_t j, class LocalAssemblerI>
249 decltype(auto) evalCouplingResidual(Dune::index_constant<i> domainI,
250 const LocalAssemblerI& localAssemblerI,
251 Dune::index_constant<j> domainJ,
252 std::size_t dofIdxGlobalJ) const
253 {
254
11/43
✗ Branch 0 not taken.
✓ Branch 1 taken 7511178 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1219565 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1527404 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 7020 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 33 times.
✓ Branch 12 taken 3160 times.
✓ Branch 13 taken 33 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 33 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 3160 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 3864 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 1484800 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
24166010 return localAssemblerI.evalLocalResidual();
255 }
256
257 /*!
258 * \brief evaluate additional derivatives of the element residual of a domain with respect
259 * to dofs in the same domain that are not in the regular stencil (see CouplingManager::extendJacobianPattern)
260 * \note Such additional dependencies can arise from the coupling, e.g. if a coupling source
261 * term depends on a non-local average of a quantity of the same domain
262 */
263 template<std::size_t i, class LocalAssemblerI, class JacobianMatrixDiagBlock, class GridVariables>
264 void evalAdditionalDomainDerivatives(Dune::index_constant<i> domainI,
265 const LocalAssemblerI& localAssemblerI,
266 const typename LocalAssemblerI::LocalResidual::ElementResidualVector& origResiduals,
267 JacobianMatrixDiagBlock& A,
268 GridVariables& gridVariables)
269 {}
270
271 /*!
272 * \brief return the numeric epsilon used for deflecting primary variables of coupled domain i
273 */
274 template<std::size_t i>
275 decltype(auto) numericEpsilon(Dune::index_constant<i>,
276 const std::string& paramGroup) const
277 {
278 416 constexpr auto numEq = PrimaryVariables<i>::dimension;
279
9/27
✓ Branch 1 taken 174 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 42 times.
✓ Branch 5 taken 130 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 18 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 4 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 20 taken 14 times.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 16 times.
✗ Branch 25 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 35 taken 16 times.
✗ Branch 36 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
416 return NumericEpsilon<typename Traits::Scalar, numEq>(paramGroup);
280 }
281
282 /*!
283 * \brief set the pointers to the sub problems
284 * \param problems A tuple of shared pointers to the sub problems
285 */
286 template<typename... SubProblems>
287 void setSubProblems(const std::tuple<std::shared_ptr<SubProblems>...>& problems)
288 {
289 using namespace Dune::Hybrid;
290 939 forEach(integralRange(size(problems_)), [&](const auto i)
291 758 { setSubProblem(std::get<i>(problems), i); });
292 }
293
294 /*!
295 * \brief set a pointer to one of the sub problems
296 * \param problem a pointer to the sub problem
297 * \param domainIdx the domain index of the sub problem
298 */
299 template<class SubProblem, std::size_t i>
300 void setSubProblem(std::shared_ptr<SubProblem> problem, Dune::index_constant<i> domainIdx)
301
12/48
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 208 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 208 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 38 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 21 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 21 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 16 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 16 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 16 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 16 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
1014 { std::get<i>(problems_) = problem.get(); }
302
303 /*!
304 * \brief Return a reference to the sub problem
305 * \param domainIdx The domain index
306 * We avoid exception handling here because the performance of this function is critical
307 */
308 template<std::size_t i>
309 const Problem<i>& problem(Dune::index_constant<i> domainIdx) const
310 {
311
61/104
✗ Branch 0 not taken.
✓ Branch 1 taken 9260782 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14498515 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 43845583 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 38216275 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8570525 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 26686245 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 892951 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1015010 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 38578778 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1284087 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 467058 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 9325972 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 469996 times.
✗ Branch 26 not taken.
✓ Branch 27 taken 736735 times.
✓ Branch 28 taken 1580 times.
✓ Branch 29 taken 919815 times.
✓ Branch 30 taken 7712 times.
✓ Branch 31 taken 34255736 times.
✓ Branch 32 taken 2040 times.
✓ Branch 33 taken 33889152 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 2284148 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 919729 times.
✗ Branch 38 not taken.
✓ Branch 39 taken 289876999 times.
✗ Branch 40 not taken.
✓ Branch 41 taken 300088939 times.
✓ Branch 42 taken 1580 times.
✓ Branch 43 taken 1862121 times.
✓ Branch 44 taken 5280 times.
✓ Branch 45 taken 364555 times.
✓ Branch 46 taken 2040 times.
✓ Branch 47 taken 3339380 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 547248 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 581012 times.
✗ Branch 52 not taken.
✓ Branch 53 taken 541083 times.
✓ Branch 54 taken 2658 times.
✓ Branch 55 taken 606338 times.
✗ Branch 56 not taken.
✓ Branch 57 taken 544178 times.
✗ Branch 58 not taken.
✓ Branch 59 taken 446099 times.
✓ Branch 60 taken 2432 times.
✓ Branch 61 taken 5282691 times.
✗ Branch 62 not taken.
✓ Branch 63 taken 14262112 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 2781135 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 3048902 times.
✗ Branch 68 not taken.
✓ Branch 69 taken 211210 times.
✗ Branch 70 not taken.
✓ Branch 71 taken 1124512 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 132535 times.
✗ Branch 74 not taken.
✓ Branch 75 taken 201062 times.
✗ Branch 76 not taken.
✓ Branch 77 taken 3008825 times.
✗ Branch 78 not taken.
✓ Branch 79 taken 180144 times.
✗ Branch 80 not taken.
✓ Branch 81 taken 120907 times.
✗ Branch 82 not taken.
✓ Branch 83 taken 77259 times.
✗ Branch 84 not taken.
✓ Branch 85 taken 999197 times.
✓ Branch 86 taken 95 times.
✓ Branch 87 taken 229509 times.
✗ Branch 88 not taken.
✓ Branch 89 taken 539990 times.
✗ Branch 90 not taken.
✓ Branch 91 taken 140595 times.
✗ Branch 92 not taken.
✓ Branch 93 taken 2521 times.
✗ Branch 94 not taken.
✓ Branch 95 taken 6200 times.
✗ Branch 96 not taken.
✓ Branch 97 taken 2578 times.
✗ Branch 98 not taken.
✓ Branch 99 taken 8846 times.
✗ Branch 100 not taken.
✓ Branch 101 taken 2032 times.
✗ Branch 102 not taken.
✓ Branch 103 taken 640 times.
897816368 const Problem<i>* p = std::get<i>(problems_);
312
52/104
✗ Branch 0 not taken.
✓ Branch 1 taken 9296648 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14650907 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43884994 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38216395 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 8544864 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 26632745 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 764672 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 1244344 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 38552537 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1239909 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 681799 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 9892299 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 691430 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 615186 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 1285764 times.
✗ Branch 45 not taken.
✓ Branch 46 taken 34291136 times.
✗ Branch 48 not taken.
✓ Branch 49 taken 33627053 times.
✗ Branch 51 not taken.
✓ Branch 52 taken 2421931 times.
✗ Branch 54 not taken.
✓ Branch 55 taken 540354 times.
✗ Branch 57 not taken.
✓ Branch 58 taken 289944406 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 302834706 times.
✗ Branch 63 not taken.
✓ Branch 64 taken 2678884 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 872312 times.
✗ Branch 69 not taken.
✓ Branch 70 taken 654512 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 208740 times.
✗ Branch 75 not taken.
✓ Branch 76 taken 101398 times.
✗ Branch 78 not taken.
✓ Branch 79 taken 137619 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 422831 times.
✗ Branch 84 not taken.
✓ Branch 85 taken 239068 times.
✗ Branch 87 not taken.
✓ Branch 88 taken 396378 times.
✗ Branch 90 not taken.
✓ Branch 91 taken 6190033 times.
✗ Branch 93 not taken.
✓ Branch 94 taken 14115940 times.
✗ Branch 96 not taken.
✓ Branch 97 taken 2816494 times.
✗ Branch 99 not taken.
✓ Branch 100 taken 2115636 times.
✗ Branch 102 not taken.
✓ Branch 103 taken 157078 times.
✗ Branch 105 not taken.
✓ Branch 106 taken 1185492 times.
✗ Branch 108 not taken.
✓ Branch 109 taken 179644 times.
✗ Branch 111 not taken.
✓ Branch 112 taken 201256 times.
✗ Branch 114 not taken.
✓ Branch 115 taken 3920787 times.
✗ Branch 117 not taken.
✓ Branch 118 taken 226595 times.
✗ Branch 120 not taken.
✓ Branch 121 taken 587351 times.
✗ Branch 123 not taken.
✓ Branch 124 taken 33288 times.
✗ Branch 126 not taken.
✓ Branch 127 taken 174219 times.
✗ Branch 129 not taken.
✓ Branch 130 taken 23104 times.
✗ Branch 132 not taken.
✓ Branch 133 taken 24605 times.
✗ Branch 135 not taken.
✓ Branch 136 taken 2607 times.
✗ Branch 138 not taken.
✓ Branch 139 taken 3853 times.
✗ Branch 141 not taken.
✓ Branch 142 taken 314 times.
✗ Branch 144 not taken.
✓ Branch 145 taken 65 times.
✗ Branch 147 not taken.
✓ Branch 148 taken 7709 times.
✗ Branch 150 not taken.
✓ Branch 151 taken 678 times.
✗ Branch 153 not taken.
✓ Branch 154 taken 640 times.
897530790 assert(p && "The problem pointer is invalid. Use setSubProblems() before calling this function");
313 return *p;
314 }
315
316 protected:
317 /*!
318 * \brief Attach a solution vector stored outside of this class.
319 * \note The caller has to make sure that curSol stays alive for the lifetime of
320 * the coupling manager. Otherwise we have a dangling reference here. Use with care.
321 */
322 void attachSolution(SolutionVectorStorage& curSol)
323 {
324 using namespace Dune::Hybrid;
325 240 forEach(integralRange(Dune::Hybrid::size(curSols_)), [&](const auto id)
326 {
327 // do not take ownership of the external pointer's object
328
18/72
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16 times.
✓ Branch 21 taken 16 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 16 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 16 times.
✓ Branch 30 taken 16 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 16 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 16 times.
✓ Branch 39 taken 16 times.
✗ Branch 40 not taken.
✓ Branch 41 taken 16 times.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✓ Branch 44 taken 16 times.
✓ Branch 48 taken 16 times.
✗ Branch 49 not taken.
✓ Branch 50 taken 16 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✓ Branch 53 taken 16 times.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✗ Branch 80 not taken.
✗ Branch 84 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✗ Branch 88 not taken.
✗ Branch 89 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✗ Branch 97 not taken.
✗ Branch 98 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
384 std::get<id>(curSols_) = Dune::stackobject_to_shared_ptr(*std::get<id>(curSol));
329 });
330 }
331
332 /*!
333 * \brief the solution vector of the subproblem
334 * \param domainIdx The domain index
335 * \note in case of numeric differentiation the solution vector always carries the deflected solution
336 */
337 template<std::size_t i>
338 SubSolutionVector<i>& curSol(Dune::index_constant<i> domainIdx)
339
98/122
✓ Branch 0 taken 1627088 times.
✓ Branch 1 taken 8194 times.
✓ Branch 2 taken 1627088 times.
✓ Branch 3 taken 8184 times.
✓ Branch 4 taken 1683674 times.
✓ Branch 5 taken 8184 times.
✓ Branch 6 taken 275588 times.
✓ Branch 7 taken 6328554 times.
✓ Branch 8 taken 275588 times.
✓ Branch 9 taken 6807636 times.
✓ Branch 10 taken 748100 times.
✓ Branch 11 taken 6807636 times.
✓ Branch 12 taken 246620 times.
✓ Branch 13 taken 1060016 times.
✓ Branch 14 taken 246620 times.
✓ Branch 15 taken 697592 times.
✓ Branch 16 taken 903536 times.
✓ Branch 17 taken 697592 times.
✓ Branch 18 taken 7883740 times.
✓ Branch 19 taken 35276952 times.
✓ Branch 20 taken 7883740 times.
✓ Branch 21 taken 34852392 times.
✓ Branch 22 taken 7230964 times.
✓ Branch 23 taken 34852392 times.
✓ Branch 24 taken 7074260 times.
✓ Branch 25 taken 69038972 times.
✓ Branch 26 taken 7074260 times.
✓ Branch 27 taken 68788320 times.
✓ Branch 28 taken 7230559 times.
✓ Branch 29 taken 68788320 times.
✓ Branch 30 taken 175911 times.
✓ Branch 31 taken 1056 times.
✓ Branch 32 taken 175911 times.
✓ Branch 33 taken 17498 times.
✓ Branch 34 taken 87287 times.
✓ Branch 35 taken 17498 times.
✓ Branch 36 taken 10159 times.
✓ Branch 37 taken 3884778 times.
✓ Branch 38 taken 10159 times.
✓ Branch 39 taken 5457154 times.
✓ Branch 40 taken 94650 times.
✓ Branch 41 taken 5457154 times.
✓ Branch 42 taken 17770 times.
✓ Branch 43 taken 9077700 times.
✓ Branch 44 taken 17770 times.
✓ Branch 45 taken 8985904 times.
✓ Branch 46 taken 25657 times.
✓ Branch 47 taken 8985904 times.
✓ Branch 48 taken 20274 times.
✓ Branch 49 taken 30042227 times.
✓ Branch 50 taken 20274 times.
✓ Branch 51 taken 31273308 times.
✓ Branch 52 taken 17828 times.
✓ Branch 53 taken 31273308 times.
✓ Branch 54 taken 1056 times.
✓ Branch 55 taken 17251971 times.
✓ Branch 56 taken 1056 times.
✓ Branch 57 taken 17242836 times.
✓ Branch 58 taken 19779 times.
✓ Branch 59 taken 17242836 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 60110438 times.
✗ Branch 62 not taken.
✓ Branch 63 taken 70219634 times.
✓ Branch 64 taken 9688 times.
✓ Branch 65 taken 70219634 times.
✗ Branch 66 not taken.
✓ Branch 67 taken 42834012 times.
✗ Branch 68 not taken.
✓ Branch 69 taken 42820100 times.
✓ Branch 70 taken 14012 times.
✓ Branch 71 taken 42820100 times.
✗ Branch 72 not taken.
✓ Branch 73 taken 13026680 times.
✗ Branch 74 not taken.
✓ Branch 75 taken 352 times.
✓ Branch 76 taken 4524 times.
✓ Branch 77 taken 352 times.
✗ Branch 78 not taken.
✓ Branch 79 taken 2234 times.
✗ Branch 80 not taken.
✓ Branch 81 taken 1354 times.
✓ Branch 82 taken 880 times.
✓ Branch 83 taken 1354 times.
✓ Branch 85 taken 984 times.
✗ Branch 86 not taken.
✓ Branch 87 taken 24 times.
✓ Branch 88 taken 320 times.
✓ Branch 89 taken 24 times.
✗ Branch 90 not taken.
✓ Branch 91 taken 344 times.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✓ Branch 94 taken 40 times.
✗ Branch 95 not taken.
✓ Branch 96 taken 24 times.
✓ Branch 97 taken 64 times.
✓ Branch 98 taken 24 times.
✓ Branch 100 taken 76 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 76 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 716 times.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✓ Branch 109 taken 1232 times.
✗ Branch 110 not taken.
✓ Branch 111 taken 528 times.
✓ Branch 112 taken 704 times.
✓ Branch 113 taken 528 times.
✓ Branch 118 taken 64 times.
✗ Branch 119 not taken.
✓ Branch 121 taken 64 times.
✗ Branch 122 not taken.
✓ Branch 124 taken 64 times.
✗ Branch 125 not taken.
✓ Branch 127 taken 704 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 704 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 704 times.
✗ Branch 134 not taken.
1838157438 { return *std::get<i>(curSols_); }
340
341 /*!
342 * \brief the solution vector of the subproblem
343 * \param domainIdx The domain index
344 * \note in case of numeric differentiation the solution vector always carries the deflected solution
345 */
346 template<std::size_t i>
347 const SubSolutionVector<i>& curSol(Dune::index_constant<i> domainIdx) const
348
29/34
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1032947 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1018734 times.
✓ Branch 4 taken 14217 times.
✓ Branch 5 taken 1018734 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 7389990 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 7375777 times.
✓ Branch 10 taken 1995812 times.
✓ Branch 11 taken 7375777 times.
✓ Branch 12 taken 1229211 times.
✓ Branch 13 taken 1245332 times.
✓ Branch 14 taken 1229211 times.
✓ Branch 15 taken 473501 times.
✓ Branch 16 taken 773258 times.
✓ Branch 17 taken 473501 times.
✓ Branch 18 taken 2057 times.
✓ Branch 19 taken 935078 times.
✓ Branch 20 taken 2057 times.
✓ Branch 21 taken 465951 times.
✓ Branch 22 taken 467377 times.
✓ Branch 23 taken 465951 times.
✓ Branch 25 taken 465320 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 4736 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 5036 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 5036 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 300 times.
✗ Branch 38 not taken.
2828269521 { return *std::get<i>(curSols_); }
349
350 private:
351 /*!
352 * \brief A tuple of shared_ptr's to solution vectors of the subproblems
353 * \note in case of numeric differentiation the solution vector always carries the deflected solution
354 */
355 SolutionVectorStorage curSols_;
356
357 /*!
358 * \brief A tuple of (raw) pointers to the sub problems
359 * \note these are raw pointers and not shared pointers to break the cyclic dependency between coupling manager and problems
360 */
361 ProblemPtrs problems_;
362 };
363
364 } // end namespace Dumux
365
366 #endif
367