24#ifndef DUMUX_JACOBIAN_PATTERN_HH
25#define DUMUX_JACOBIAN_PATTERN_HH
28#include <dune/istl/matrixindexset.hh>
37template<
bool isImplicit,
class GridGeometry,
41 const auto numDofs = gridGeometry.numDofs();
42 Dune::MatrixIndexSet pattern;
43 pattern.resize(numDofs, numDofs);
46 if constexpr (isImplicit)
48 static constexpr int dim = std::decay_t<
decltype(gridGeometry.gridView())>::dimension;
49 for (
const auto& element : elements(gridGeometry.gridView()))
51 for (
unsigned int vIdx = 0; vIdx < element.subEntities(dim); ++vIdx)
53 const auto globalI = gridGeometry.vertexMapper().subIndex(element, vIdx, dim);
54 for (
unsigned int vIdx2 = 0; vIdx2 < element.subEntities(dim); ++vIdx2)
56 const auto globalJ = gridGeometry.vertexMapper().subIndex(element, vIdx2, dim);
57 pattern.add(globalI, globalJ);
59 if (gridGeometry.dofOnPeriodicBoundary(globalI) && globalI != globalJ)
61 const auto globalIP = gridGeometry.periodicallyMappedDof(globalI);
62 pattern.add(globalIP, globalI);
63 pattern.add(globalI, globalIP);
64 if (globalI > globalIP)
65 pattern.add(globalIP, globalJ);
75 for (
unsigned int globalI = 0; globalI < numDofs; ++globalI)
76 pattern.add(globalI, globalI);
86template<
bool isImplicit,
class GridGeometry,
90 const auto numDofs = gridGeometry.numDofs();
91 Dune::MatrixIndexSet pattern;
92 pattern.resize(numDofs, numDofs);
95 if constexpr (isImplicit)
97 static constexpr int dim = std::decay_t<
decltype(gridGeometry.gridView())>::dimension;
98 for (
const auto& element : elements(gridGeometry.gridView()))
100 const auto eIdx = gridGeometry.dofMapper().index(element);
101 pattern.add(eIdx, eIdx);
102 for (
unsigned int vIdx = 0; vIdx < element.subEntities(dim); ++vIdx)
104 const auto globalI = gridGeometry.dofMapper().subIndex(element, vIdx, dim);
105 pattern.add(eIdx, globalI);
106 pattern.add(globalI, eIdx);
107 for (
unsigned int vIdx2 = 0; vIdx2 < element.subEntities(dim); ++vIdx2)
109 const auto globalJ = gridGeometry.dofMapper().subIndex(element, vIdx2, dim);
110 pattern.add(globalI, globalJ);
112 if (gridGeometry.dofOnPeriodicBoundary(globalI) && globalI != globalJ)
114 const auto globalIP = gridGeometry.periodicallyMappedDof(globalI);
115 pattern.add(globalIP, globalI);
116 pattern.add(globalI, globalIP);
117 if (globalI > globalIP)
118 pattern.add(globalIP, globalJ);
128 for (
unsigned int globalI = 0; globalI < numDofs; ++globalI)
129 pattern.add(globalI, globalI);
139template<
bool isImplicit,
class GridGeometry,
144 const auto numDofs = gridGeometry.numDofs();
145 Dune::MatrixIndexSet pattern;
146 pattern.resize(numDofs, numDofs);
151 for (
unsigned int globalI = 0; globalI < numDofs; ++globalI)
153 pattern.add(globalI, globalI);
154 for (
const auto& dataJ : gridGeometry.connectivityMap()[globalI])
155 pattern.add(dataJ.globalJ, globalI);
162 for (
unsigned int globalI = 0; globalI < numDofs; ++globalI)
163 pattern.add(globalI, globalI);
173template<
bool isImplicit,
class GridGeometry,
178 const auto numDofs = gridGeometry.numDofs();
179 Dune::MatrixIndexSet pattern(numDofs, numDofs);
181 const auto& connectivityMap = gridGeometry.connectivityMap();
183 auto fvGeometry =
localView(gridGeometry);
185 for (
const auto& element : elements(gridGeometry.gridView()))
187 if(gridGeometry.isCellCenter())
190 static constexpr auto cellCenterIdx = GridGeometry::cellCenterIdx();
191 const auto ccGlobalI = gridGeometry.elementMapper().index(element);
192 pattern.add(ccGlobalI, ccGlobalI);
193 for (
auto&& ccGlobalJ : connectivityMap(cellCenterIdx, cellCenterIdx, ccGlobalI))
194 pattern.add(ccGlobalI, ccGlobalJ);
198 static constexpr auto faceIdx = GridGeometry::faceIdx();
199 fvGeometry.bindElement(element);
202 for (
auto&& scvf : scvfs(fvGeometry))
204 const auto faceGlobalI = scvf.dofIndex();
205 pattern.add(faceGlobalI, faceGlobalI);
206 for (
auto&& faceGlobalJ : connectivityMap(faceIdx, faceIdx, scvf.index()))
207 pattern.add(faceGlobalI, faceGlobalJ);
219template<
class FEBasis>
222 const auto numDofs = feBasis.size();
224 Dune::MatrixIndexSet pattern;
225 pattern.resize(numDofs, numDofs);
229 for (
const auto& element : elements(feBasis.gridView()))
233 const auto& finiteElement =
localView.tree().finiteElement();
234 const auto numLocalDofs = finiteElement.localBasis().size();
235 for (std::size_t i = 0; i < numLocalDofs; i++)
238 for (std::size_t j = 0; j < numLocalDofs; j++)
241 pattern.add(dofIdxI, dofIdxJ);
255template<
bool isImplicit,
class GridGeometry,
264template<
bool isImplicit,
class GridGeometry,
269 const auto numDofs = gridGeometry.numDofs();
270 Dune::MatrixIndexSet pattern(numDofs, numDofs);
272 const auto& connectivityMap = gridGeometry.connectivityMap();
273 auto fvGeometry =
localView(gridGeometry);
276 for (
const auto& element : elements(gridGeometry.gridView()))
278 fvGeometry.bind(element);
279 for (
const auto& scv : scvs(fvGeometry))
281 const auto globalI = scv.dofIndex();
282 pattern.add(globalI, globalI);
284 for (
const auto& scvIdxJ : connectivityMap[scv.index()])
286 const auto globalJ = fvGeometry.scv(scvIdxJ).dofIndex();
287 pattern.add(globalI, globalJ);
289 if (gridGeometry.isPeriodic())
291 if (gridGeometry.dofOnPeriodicBoundary(globalI) && globalI != globalJ)
293 const auto globalIP = gridGeometry.periodicallyMappedDof(globalI);
294 pattern.add(globalIP, globalI);
295 pattern.add(globalI, globalIP);
297 if (globalI > globalIP)
298 pattern.add(globalIP, globalJ);
312template<
bool isImplicit,
class GridGeometry,
317 const auto numDofs = gridGeometry.numDofs();
318 Dune::MatrixIndexSet pattern(numDofs, numDofs);
320 auto fvGeometry =
localView(gridGeometry);
321 for (
const auto& element : elements(gridGeometry.gridView()))
323 fvGeometry.bind(element);
324 for (
const auto& scv : scvs(fvGeometry))
326 const auto globalI = scv.dofIndex();
327 for (
const auto& scvJ : scvs(fvGeometry))
329 const auto globalJ = scvJ.dofIndex();
330 pattern.add(globalI, globalJ);
332 if (gridGeometry.isPeriodic())
334 if (gridGeometry.dofOnPeriodicBoundary(globalI) && globalI != globalJ)
336 const auto globalIP = gridGeometry.periodicallyMappedDof(globalI);
337 pattern.add(globalIP, globalI);
338 pattern.add(globalI, globalIP);
340 if (globalI > globalIP)
341 pattern.add(globalIP, globalJ);
The available discretization methods in Dumux.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
Dune::MatrixIndexSet getJacobianPattern(const GridGeometry &gridGeometry)
Helper function to generate Jacobian pattern for the box method.
Definition: jacobianpattern.hh:39
Dune::MatrixIndexSet getFEJacobianPattern(const FEBasis &feBasis)
Helper function to generate Jacobian pattern for finite element scheme.
Definition: jacobianpattern.hh:220
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
constexpr CCMpfa ccmpfa
Definition: method.hh:135
constexpr FCDiamond fcdiamond
Definition: method.hh:141
constexpr CCTpfa cctpfa
Definition: method.hh:134
constexpr Box box
Definition: method.hh:136
constexpr Staggered staggered
Definition: method.hh:138
constexpr FEM fem
Definition: method.hh:139
constexpr PQ1Bubble pq1bubble
Definition: method.hh:137
constexpr FCStaggered fcstaggered
Definition: method.hh:140