-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmatrixStencil.inl
More file actions
63 lines (51 loc) · 2.08 KB
/
matrixStencil.inl
File metadata and controls
63 lines (51 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
template <class LevelCacheType>
int DirectSolver_CSR_LU_Give<LevelCacheType>::getStencilSize(int global_index) const
{
const PolarGrid& grid = DirectSolver<LevelCacheType>::grid_;
const bool DirBC_Interior = DirectSolver<LevelCacheType>::DirBC_Interior_;
int i_r, i_theta;
grid.multiIndex(global_index, i_r, i_theta);
const int size_stencil_inner_boundary = DirBC_Interior ? 1 : 7;
const int size_stencil_interior = 9;
const int size_stencil_outer_boundary = 1;
if ((i_r > 0 && i_r < grid.nr() - 1)) {
return size_stencil_interior;
}
else if (i_r == 0 && !DirBC_Interior) {
return size_stencil_inner_boundary;
}
else if ((i_r == 0 && DirBC_Interior) || i_r == grid.nr() - 1) {
return size_stencil_outer_boundary;
}
throw std::out_of_range("Invalid index for stencil");
}
template <class LevelCacheType>
const Stencil& DirectSolver_CSR_LU_Give<LevelCacheType>::getStencil(int i_r) const
{
const PolarGrid& grid = DirectSolver<LevelCacheType>::grid_;
const bool DirBC_Interior = DirectSolver<LevelCacheType>::DirBC_Interior_;
assert(0 <= i_r && i_r < grid.nr());
assert(grid.nr() >= 4);
if ((i_r > 0 && i_r < grid.nr() - 1)) {
return stencil_interior_;
}
else if (i_r == 0 && !DirBC_Interior) {
return stencil_across_origin_;
}
else if ((i_r == 0 && DirBC_Interior) || i_r == grid.nr() - 1) {
return stencil_DB_;
}
throw std::out_of_range("Invalid index for stencil");
}
template <class LevelCacheType>
int DirectSolver_CSR_LU_Give<LevelCacheType>::getNonZeroCountSolverMatrix() const
{
const PolarGrid& grid = DirectSolver<LevelCacheType>::grid_;
const bool DirBC_Interior = DirectSolver<LevelCacheType>::DirBC_Interior_;
const int size_stencil_inner_boundary = DirBC_Interior ? 1 : 7;
const int size_stencil_interior = 9;
const int size_stencil_outer_boundary = 1;
return grid.ntheta() *
(size_stencil_inner_boundary + (grid.nr() - 2) * size_stencil_interior + size_stencil_outer_boundary);
}