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