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 Helper function to generate Jacobian pattern for multi domain models | ||
11 | */ | ||
12 | #ifndef DUMUX_MUTLIDOMAIN_COUPLING_JACOBIAN_PATTERN_HH | ||
13 | #define DUMUX_MUTLIDOMAIN_COUPLING_JACOBIAN_PATTERN_HH | ||
14 | |||
15 | #include <type_traits> | ||
16 | #include <dune/common/indices.hh> | ||
17 | #include <dune/istl/matrixindexset.hh> | ||
18 | #include <dumux/discretization/method.hh> | ||
19 | |||
20 | namespace Dumux { | ||
21 | |||
22 | /*! | ||
23 | * \ingroup MultiDomain | ||
24 | * \brief Helper function to generate coupling Jacobian pattern (off-diagonal blocks) | ||
25 | * for cell-centered schemes | ||
26 | */ | ||
27 | template<bool isImplicit, class CouplingManager, class GridGeometryI, class GridGeometryJ, std::size_t i, std::size_t j, | ||
28 | typename std::enable_if_t<( (GridGeometryI::discMethod == DiscretizationMethods::cctpfa) | ||
29 | || (GridGeometryI::discMethod == DiscretizationMethods::ccmpfa) ), int> = 0> | ||
30 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
538 | Dune::MatrixIndexSet getCouplingJacobianPattern(const CouplingManager& couplingManager, |
31 | Dune::index_constant<i> domainI, | ||
32 | const GridGeometryI& gridGeometryI, | ||
33 | Dune::index_constant<j> domainJ, | ||
34 | const GridGeometryJ& gridGeometryJ) | ||
35 | { | ||
36 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
538 | const auto numDofsI = gridGeometryI.numDofs(); |
37 |
1/2✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
|
538 | const auto numDofsJ = gridGeometryJ.numDofs(); |
38 | 538 | Dune::MatrixIndexSet pattern; | |
39 |
1/2✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
|
538 | pattern.resize(numDofsI, numDofsJ); |
40 | |||
41 | // matrix pattern for implicit Jacobians | ||
42 | if (isImplicit) | ||
43 | { | ||
44 |
14/16✓ Branch 2 taken 11744 times.
✓ Branch 3 taken 168 times.
✓ Branch 4 taken 1944671 times.
✓ Branch 1 taken 228 times.
✓ Branch 5 taken 1 times.
✓ Branch 7 taken 1514014 times.
✓ Branch 8 taken 3 times.
✓ Branch 10 taken 100382 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1968 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1927 times.
✓ Branch 16 taken 1 times.
✓ Branch 12 taken 98455 times.
✓ Branch 6 taken 88883 times.
✓ Branch 9 taken 4954 times.
|
11148834 | for (const auto& elementI : elements(gridGeometryI.gridView())) |
45 | { | ||
46 |
1/2✓ Branch 1 taken 1686876 times.
✗ Branch 2 not taken.
|
3812636 | const auto& stencil = couplingManager.couplingStencil(domainI, elementI, domainJ); |
47 |
1/2✓ Branch 1 taken 176917 times.
✗ Branch 2 not taken.
|
3812636 | const auto globalI = gridGeometryI.elementMapper().index(elementI); |
48 |
4/5✓ Branch 1 taken 1095602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89288 times.
✓ Branch 4 taken 1062608 times.
✓ Branch 0 taken 1777942 times.
|
6302008 | for (const auto globalJ : stencil) |
49 |
1/2✓ Branch 1 taken 1777942 times.
✗ Branch 2 not taken.
|
2489372 | pattern.add(globalI, globalJ); |
50 | } | ||
51 | } | ||
52 | |||
53 | // matrix pattern for explicit Jacobians | ||
54 | // -> diagonal matrix, so coupling block is empty | ||
55 | // just return the empty pattern | ||
56 | |||
57 | 538 | return pattern; | |
58 | ✗ | } | |
59 | |||
60 | /*! | ||
61 | * \ingroup MultiDomain | ||
62 | * \brief Helper function to generate coupling Jacobian pattern (off-diagonal blocks) | ||
63 | * for the staggered scheme (degrees of freedom on cell centers) | ||
64 | */ | ||
65 | template<bool isImplicit, class CouplingManager, class GridGeometryI, class GridGeometryJ, std::size_t i, std::size_t j, | ||
66 | typename std::enable_if_t<(GridGeometryI::discMethod == DiscretizationMethods::staggered && | ||
67 | GridGeometryI::isCellCenter()), int> = 0> | ||
68 | 102 | Dune::MatrixIndexSet getCouplingJacobianPattern(const CouplingManager& couplingManager, | |
69 | Dune::index_constant<i> domainI, | ||
70 | const GridGeometryI& gridGeometryI, | ||
71 | Dune::index_constant<j> domainJ, | ||
72 | const GridGeometryJ& gridGeometryJ) | ||
73 | { | ||
74 | 102 | Dune::MatrixIndexSet pattern(gridGeometryI.numDofs(), gridGeometryJ.numDofs()); | |
75 | |||
76 |
4/8✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 160713 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7003 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7000 times.
✗ Branch 10 not taken.
|
908382 | for (const auto& elementI : elements(gridGeometryI.gridView())) |
77 | { | ||
78 |
1/2✓ Branch 1 taken 7000 times.
✗ Branch 2 not taken.
|
302760 | const auto ccGlobalI = gridGeometryI.elementMapper().index(elementI); |
79 |
4/5✓ Branch 1 taken 160648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99056 times.
✓ Branch 4 taken 7000 times.
✓ Branch 0 taken 331124 times.
|
946864 | for (auto&& faceGlobalJ : couplingManager.couplingStencil(domainI, elementI, domainJ)) |
80 |
1/2✓ Branch 1 taken 359124 times.
✗ Branch 2 not taken.
|
644104 | pattern.add(ccGlobalI, faceGlobalJ); |
81 | } | ||
82 | |||
83 | 102 | return pattern; | |
84 | ✗ | } | |
85 | |||
86 | /*! | ||
87 | * \ingroup MultiDomain | ||
88 | * \brief Helper function to generate coupling Jacobian pattern (off-diagonal blocks) | ||
89 | * for the staggered scheme (degrees of freedom on faces) | ||
90 | */ | ||
91 | template<bool isImplicit, class CouplingManager, class GridGeometryI, class GridGeometryJ, std::size_t i, std::size_t j, | ||
92 | typename std::enable_if_t<(GridGeometryI::discMethod == DiscretizationMethods::staggered && | ||
93 | GridGeometryI::isFace()), int> = 0> | ||
94 | 102 | Dune::MatrixIndexSet getCouplingJacobianPattern(const CouplingManager& couplingManager, | |
95 | Dune::index_constant<i> domainI, | ||
96 | const GridGeometryI& gridGeometryI, | ||
97 | Dune::index_constant<j> domainJ, | ||
98 | const GridGeometryJ& gridGeometryJ) | ||
99 | { | ||
100 | 102 | Dune::MatrixIndexSet pattern(gridGeometryI.numDofs(), gridGeometryJ.numDofs()); | |
101 | |||
102 | 102 | auto fvGeometry = localView(gridGeometryI); | |
103 |
4/8✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 160713 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7003 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7000 times.
✗ Branch 10 not taken.
|
908382 | for (const auto& elementI : elements(gridGeometryI.gridView())) |
104 | { | ||
105 |
1/2✓ Branch 1 taken 7000 times.
✗ Branch 2 not taken.
|
302760 | fvGeometry.bindElement(elementI); |
106 | |||
107 | // loop over sub control faces | ||
108 |
4/4✓ Branch 1 taken 642592 times.
✓ Branch 2 taken 89592 times.
✓ Branch 3 taken 284224 times.
✓ Branch 4 taken 71056 times.
|
1513800 | for (auto&& scvf : scvfs(fvGeometry)) |
109 | { | ||
110 | 1211040 | const auto faceGlobalI = scvf.dofIndex(); | |
111 |
4/4✓ Branch 1 taken 1347676 times.
✓ Branch 2 taken 358368 times.
✓ Branch 3 taken 756 times.
✓ Branch 4 taken 284224 times.
|
3122564 | for (auto&& globalJ : couplingManager.couplingStencil(domainI, scvf, domainJ)) |
112 |
1/2✓ Branch 1 taken 1064208 times.
✗ Branch 2 not taken.
|
1911524 | pattern.add(faceGlobalI, globalJ); |
113 | } | ||
114 | } | ||
115 | |||
116 | 102 | return pattern; | |
117 | ✗ | } | |
118 | |||
119 | /*! | ||
120 | * \ingroup MultiDomain | ||
121 | * \brief Helper function to generate coupling Jacobian pattern (off-diagonal blocks) | ||
122 | * for the staggered scheme (degrees of freedom on cell centers) | ||
123 | */ | ||
124 | template<bool isImplicit, class CouplingManager, class GridGeometryI, class GridGeometryJ, std::size_t i, std::size_t j, | ||
125 | typename std::enable_if_t<(GridGeometryI::discMethod == DiscretizationMethods::fcstaggered), int> = 0> | ||
126 | 136 | Dune::MatrixIndexSet getCouplingJacobianPattern(const CouplingManager& couplingManager, | |
127 | Dune::index_constant<i> domainI, | ||
128 | const GridGeometryI& gridGeometryI, | ||
129 | Dune::index_constant<j> domainJ, | ||
130 | const GridGeometryJ& gridGeometryJ) | ||
131 | { | ||
132 | 136 | Dune::MatrixIndexSet pattern(gridGeometryI.numDofs(), gridGeometryJ.numDofs()); | |
133 | |||
134 | 136 | auto fvGeometry = localView(gridGeometryI); | |
135 |
9/12✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 505870 times.
✓ Branch 5 taken 12338 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3536 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3536 times.
✓ Branch 13 taken 6 times.
✓ Branch 6 taken 1940 times.
✓ Branch 3 taken 101 times.
|
1595223 | for (const auto& elementI : elements(gridGeometryI.gridView())) |
136 | { | ||
137 |
1/2✓ Branch 1 taken 6721 times.
✗ Branch 2 not taken.
|
797532 | fvGeometry.bindElement(elementI); |
138 |
5/5✓ Branch 1 taken 987584 times.
✓ Branch 2 taken 16138 times.
✓ Branch 3 taken 551552 times.
✓ Branch 4 taken 137888 times.
✓ Branch 0 taken 1470856 times.
|
3991346 | for (const auto& scv : scvs(fvGeometry)) |
139 | { | ||
140 |
1/2✓ Branch 1 taken 9152 times.
✗ Branch 2 not taken.
|
3193814 | const auto globalI = scv.dofIndex(); |
141 |
1/2✓ Branch 1 taken 542400 times.
✗ Branch 2 not taken.
|
3193814 | const auto& stencil = couplingManager.couplingStencil(domainI, elementI, scv, domainJ); |
142 |
4/5✓ Branch 1 taken 1604002 times.
✓ Branch 2 taken 61510 times.
✓ Branch 3 taken 1552044 times.
✓ Branch 4 taken 2020328 times.
✗ Branch 0 not taken.
|
5361352 | for (const auto globalJ : stencil) |
143 | { | ||
144 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1604002 times.
|
2167538 | assert(globalJ < gridGeometryJ.numDofs()); |
145 |
1/2✓ Branch 1 taken 1604002 times.
✗ Branch 2 not taken.
|
2167538 | pattern.add(globalI, globalJ); |
146 | |||
147 |
2/2✓ Branch 0 taken 49740 times.
✓ Branch 1 taken 1554262 times.
|
2167538 | if (gridGeometryI.isPeriodic()) |
148 | { | ||
149 |
1/2✓ Branch 1 taken 242 times.
✗ Branch 2 not taken.
|
49740 | if (gridGeometryI.dofOnPeriodicBoundary(globalI)) |
150 | { | ||
151 | 242 | const auto globalIP = gridGeometryI.periodicallyMappedDof(globalI); | |
152 | |||
153 |
2/2✓ Branch 0 taken 121 times.
✓ Branch 1 taken 121 times.
|
242 | if (globalI > globalIP) |
154 |
1/2✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
|
121 | pattern.add(globalIP, globalJ); |
155 | } | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | } | ||
160 | |||
161 | 136 | return pattern; | |
162 | ✗ | } | |
163 | |||
164 | /*! | ||
165 | * \ingroup MultiDomain | ||
166 | * \brief Helper function to generate coupling Jacobian pattern (off-diagonal blocks) | ||
167 | * for control-volume finite element schemes (CVFE) | ||
168 | */ | ||
169 | template<bool isImplicit, class CouplingManager, class GridGeometryI, class GridGeometryJ, std::size_t i, std::size_t j, | ||
170 | typename std::enable_if_t<DiscretizationMethods::isCVFE<typename GridGeometryI::DiscretizationMethod>, int> = 0> | ||
171 |
2/4✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
166 | Dune::MatrixIndexSet getCouplingJacobianPattern(const CouplingManager& couplingManager, |
172 | Dune::index_constant<i> domainI, | ||
173 | const GridGeometryI& gridGeometryI, | ||
174 | Dune::index_constant<j> domainJ, | ||
175 | const GridGeometryJ& gridGeometryJ) | ||
176 | { | ||
177 |
2/4✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
166 | Dune::MatrixIndexSet pattern; |
178 | |||
179 | // matrix pattern for implicit Jacobians | ||
180 | if constexpr (isImplicit) | ||
181 | { | ||
182 |
3/5✓ Branch 1 taken 87 times.
✓ Branch 2 taken 1 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✗ Branch 3 not taken.
|
164 | pattern.resize(gridGeometryI.numDofs(), gridGeometryJ.numDofs()); |
183 | 164 | auto fvGeometry = localView(gridGeometryI); | |
184 |
11/15✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1046 times.
✓ Branch 4 taken 268144 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 271 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 83378 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 83378 times.
✓ Branch 13 taken 27 times.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✓ Branch 6 taken 252438 times.
✓ Branch 9 taken 943 times.
✓ Branch 3 taken 38 times.
|
1261178 | for (const auto& elementI : elements(gridGeometryI.gridView())) |
185 | { | ||
186 |
1/2✓ Branch 1 taken 337049 times.
✗ Branch 2 not taken.
|
618685 | fvGeometry.bindElement(elementI); |
187 |
1/2✓ Branch 1 taken 349404 times.
✗ Branch 2 not taken.
|
618685 | const auto& stencil = couplingManager.couplingStencil(domainI, elementI, domainJ); |
188 |
2/2✓ Branch 0 taken 1372486 times.
✓ Branch 1 taken 352535 times.
|
3027157 | for (const auto& scv : scvs(fvGeometry)) |
189 | { | ||
190 |
4/5✓ Branch 1 taken 1064771 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61437 times.
✓ Branch 4 taken 369152 times.
✓ Branch 0 taken 3226818 times.
|
8723618 | for (const auto globalJ : stencil) |
191 |
1/2✓ Branch 1 taken 3288255 times.
✗ Branch 2 not taken.
|
6315146 | pattern.add(scv.dofIndex(), globalJ); |
192 | |||
193 | } | ||
194 | } | ||
195 | 95 | } | |
196 | |||
197 | // matrix pattern for explicit Jacobians | ||
198 | // -> diagonal matrix, so coupling block is empty | ||
199 | // just return the empty pattern | ||
200 | |||
201 | 164 | return pattern; | |
202 | ✗ | } | |
203 | |||
204 | } // end namespace Dumux | ||
205 | |||
206 | #endif | ||
207 |