-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdirectSolverGive.h
More file actions
81 lines (68 loc) · 3.02 KB
/
directSolverGive.h
File metadata and controls
81 lines (68 loc) · 3.02 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
#pragma once
#include "../directSolver.h"
#ifdef GMGPOLAR_USE_MUMPS
class DirectSolver_COO_MUMPS_Give : public DirectSolver
{
public:
explicit DirectSolver_COO_MUMPS_Give(const PolarGrid& grid, const LevelCache& level_cache,
const DomainGeometry& domain_geometry,
const DensityProfileCoefficients& density_profile_coefficients,
bool DirBC_Interior, int num_omp_threads);
// Note: The rhs (right-hand side) vector gets overwritten during the solution process.
void solveInPlace(Vector<double> solution) override;
private:
// clang-format off
const Stencil stencil_interior_ = {
7, 4, 8,
1, 0, 2,
5, 3, 6
};
const Stencil stencil_across_origin_ = {
-1, 4, 6,
1, 0, 2,
-1, 3, 5
};
const Stencil stencil_DB_ = {
-1, -1, -1,
-1, 0, -1,
-1, -1, -1
};
const Stencil stencil_next_inner_DB_ = {
-1, 3, 5,
-1, 0, 1,
-1, 2, 4
};
const Stencil stencil_next_outer_DB_ = {
5, 3, -1,
1, 0, -1,
4, 2, -1
};
// clang-format on
// MUMPS solver structure with the solver matrix initialized in the constructor.
// Defined below stencils to ensure that the solver matrix is built after the stencils are defined.
CooMumpsSolver mumps_solver_;
// Constructs a symmetric solver matrix.
SparseMatrixCOO<double> buildSolverMatrix();
void buildSolverMatrixCircleSection(const int i_r, SparseMatrixCOO<double>& solver_matrix);
void buildSolverMatrixRadialSection(const int i_theta, SparseMatrixCOO<double>& solver_matrix);
// Adjusts the right-hand side vector for symmetry corrections.
// This modifies the system from
// A * solution = rhs
// to the equivalent system
// symmetric_DBc(A) * solution = rhs - applySymmetryShift(rhs).
// The correction modifies the rhs to account for the influence of the Dirichlet boundary conditions,
// ensuring that the solution at the boundary is correctly adjusted and maintains the required symmetry.
void applySymmetryShift(Vector<double> rhs) const;
void applySymmetryShiftInnerBoundary(Vector<double> x) const;
void applySymmetryShiftOuterBoundary(Vector<double> x) const;
// Returns the total number of non-zero elements in the solver matrix.
int getNonZeroCountSolverMatrix() const;
// Returns the index of the first non-zero element in the solver matrix for the given position.
int getSolverMatrixIndex(int i_r, int i_theta) const;
// Retrieves the stencil for the solver matrix at the given radial index.
const Stencil& getStencil(int i_r) const;
void nodeBuildSolverMatrixGive(int i_r, int i_theta, const PolarGrid& grid, bool DirBC_Interior,
SparseMatrixCOO<double>& solver_matrix, double arr, double att, double art,
double detDF, double coeff_beta);
};
#endif