-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapplySymmetryShift.inl
More file actions
155 lines (123 loc) · 5.69 KB
/
applySymmetryShift.inl
File metadata and controls
155 lines (123 loc) · 5.69 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#pragma once
#ifdef GMGPOLAR_USE_MUMPS
/* ----------------------- */
/* Boundary Symmetry Shift */
/* ----------------------- */
template <concepts::DomainGeometry DomainGeometry>
void DirectSolver_COO_MUMPS_Give<DomainGeometry>::applySymmetryShiftInnerBoundary(Vector<double> x) const
{
const PolarGrid& grid = DirectSolver<DomainGeometry>::grid_;
const LevelCache<DomainGeometry>& level_cache = DirectSolver<DomainGeometry>::level_cache_;
assert(DirectSolver<DomainGeometry>::DirBC_Interior_);
int i_r;
double r;
int global_index;
double h1, h2, k1, k2;
double coeff1, coeff2;
double coeff_beta, arr, att, art, detDF;
for (int i_theta = 0; i_theta < grid.ntheta(); i_theta++) {
const double theta = grid.theta(i_theta);
/* -------------------------- */
/* Node on the inner boundary */
/* -------------------------- */
i_r = 0;
r = grid.radius(i_r);
global_index = grid.index(i_r, i_theta);
level_cache.obtainValues(i_r, i_theta, global_index, r, theta, coeff_beta, arr, att, art, detDF);
h2 = grid.radialSpacing(i_r);
k1 = grid.angularSpacing(i_theta - 1);
k2 = grid.angularSpacing(i_theta);
coeff2 = 0.5 * (k1 + k2) / h2;
/* Fill x(i+1,j) */
x(grid.index(i_r + 1, i_theta)) -= -coeff2 * arr * x(grid.index(i_r, i_theta)) /* Left */
+ 0.25 * art * x(grid.index(i_r, i_theta + 1)) /* Top Left */
- 0.25 * art * x(grid.index(i_r, i_theta - 1)); /* Bottom Left */
/* --------------------------- */
/* Node next to inner boundary */
/* --------------------------- */
i_r = 1;
r = grid.radius(i_r);
global_index = grid.index(i_r, i_theta);
level_cache.obtainValues(i_r, i_theta, global_index, r, theta, coeff_beta, arr, att, art, detDF);
h1 = grid.radialSpacing(i_r - 1);
k1 = grid.angularSpacing(i_theta - 1);
k2 = grid.angularSpacing(i_theta);
coeff1 = 0.5 * (k1 + k2) / h1;
/* Fill x(i,j) */
x(grid.index(i_r, i_theta)) -= -coeff1 * arr * x(grid.index(i_r - 1, i_theta)); /* Left */
/* Fill x(i,j-1) */
x(grid.index(i_r, i_theta - 1)) -= +0.25 * art * x(grid.index(i_r - 1, i_theta)); /* Top Left */
/* Fill x(i,j+1) */
x(grid.index(i_r, i_theta + 1)) -= -0.25 * art * x(grid.index(i_r - 1, i_theta)); /* Bottom Left */
}
}
template <concepts::DomainGeometry DomainGeometry>
void DirectSolver_COO_MUMPS_Give<DomainGeometry>::applySymmetryShiftOuterBoundary(Vector<double> x) const
{
const PolarGrid& grid = DirectSolver<DomainGeometry>::grid_;
const LevelCache<DomainGeometry>& level_cache = DirectSolver<DomainGeometry>::level_cache_;
int i_r;
double r;
int global_index;
double h1, h2, k1, k2;
double coeff1, coeff2;
double coeff_beta, arr, att, art, detDF;
for (int i_theta = 0; i_theta < grid.ntheta(); i_theta++) {
const double theta = grid.theta(i_theta);
/* --------------------------- */
/* Node next to outer boundary */
/* --------------------------- */
i_r = grid.nr() - 2;
r = grid.radius(i_r);
global_index = grid.index(i_r, i_theta);
level_cache.obtainValues(i_r, i_theta, global_index, r, theta, coeff_beta, arr, att, art, detDF);
h2 = grid.radialSpacing(i_r);
k1 = grid.angularSpacing(i_theta - 1);
k2 = grid.angularSpacing(i_theta);
coeff2 = 0.5 * (k1 + k2) / h2;
/* Fill result(i,j) */
x(grid.index(i_r, i_theta)) -= -coeff2 * arr * x(grid.index(i_r + 1, i_theta)); /* Right */
/* Fill result(i,j-1) */
x(grid.index(i_r, i_theta - 1)) -= -0.25 * art * x(grid.index(i_r + 1, i_theta)); /* Top Right */
/* Fill result(i,j+1) */
x(grid.index(i_r, i_theta + 1)) -= +0.25 * art * x(grid.index(i_r + 1, i_theta)); /* Bottom Right */
/* -------------------------- */
/* Node on the outer boundary */
/* -------------------------- */
i_r = grid.nr() - 1;
r = grid.radius(i_r);
global_index = grid.index(i_r, i_theta);
level_cache.obtainValues(i_r, i_theta, global_index, r, theta, coeff_beta, arr, att, art, detDF);
h1 = grid.radialSpacing(i_r - 1);
k1 = grid.angularSpacing(i_theta - 1);
k2 = grid.angularSpacing(i_theta);
coeff1 = 0.5 * (k1 + k2) / h1;
/* Fill result(i-1,j) */
x(grid.index(i_r - 1, i_theta)) -= -coeff1 * arr * x(grid.index(i_r, i_theta)) /* Right */
- 0.25 * art * x(grid.index(i_r, i_theta + 1)) /* Top Right */
+ 0.25 * art * x(grid.index(i_r, i_theta - 1)); /* Bottom Right */
}
}
template <concepts::DomainGeometry DomainGeometry>
void DirectSolver_COO_MUMPS_Give<DomainGeometry>::applySymmetryShift(Vector<double> x) const
{
const PolarGrid& grid = DirectSolver<DomainGeometry>::grid_;
const bool DirBC_Interior = DirectSolver<DomainGeometry>::DirBC_Interior_;
const int num_omp_threads = DirectSolver<DomainGeometry>::num_omp_threads_;
assert(std::ssize(x) == grid.numberOfNodes());
assert(grid.nr() >= 4);
#pragma omp parallel sections num_threads(num_omp_threads)
{
#pragma omp section
{
if (DirBC_Interior) {
applySymmetryShiftInnerBoundary(x);
}
}
#pragma omp section
{
applySymmetryShiftOuterBoundary(x);
}
}
}
#endif