FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ReSolve/resolve/PreconditionerUserMatrix.cpp at develop · ORNL/ReSolve · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ORNL
/
ReSolve
Public
Notifications
You must be signed in to change notification settings
Fork
13
Star
84
Code
Issues
30
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ReSolve
/
resolve
/
PreconditionerUserMatrix.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
97 lines (85 loc) · 2.06 KB
Breadcrumbs
ReSolve
/
resolve
/
PreconditionerUserMatrix.cpp
Copy path
File metadata and controls
97 lines (85 loc) · 2.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
*
* @file PreconditionerUserMatrix.cpp
* @author Jeffery Zhang (jefferyz@vt.edu)
* @author Kakeru Ueda (k.ueda.2290@m.isct.ac.jp)
* @brief Implementation of preconditioner class with user matrix
*
*/
#
include
"
PreconditionerUserMatrix.hpp
"
namespace
ReSolve
{
/*
*
* @brief Constructor for PreconditionerUserMatrix.
*
* @param[in] matrix_handler - Pointer to the matrix handler
*/
PreconditionerUserMatrix::PreconditionerUserMatrix
(MatrixHandler* matrix_handler)
{
matrix_handler_ = matrix_handler;
setMemorySpace
();
}
/*
*
* @brief Destructor for PreconditionerUserMatrix
*/
PreconditionerUserMatrix::~PreconditionerUserMatrix
()
{
}
/*
*
* @brief This preconditioner does not depend on A.
*/
int
PreconditionerUserMatrix::setup
(matrix_type*
/*
A
*/
)
{
return
0
;
}
/*
*
* @brief Set the explicit preconditioner matrix B.
*
* @param[in] B - Pointer to the preconditioning matrix
*/
int
PreconditionerUserMatrix::setPrecMatrix
(matrix_type* B)
{
B_
= B;
return
0
;
}
/*
*
* @brief Get the preconditioner matrix
*
* Necessary for some calculations
*
*/
matrix::Sparse*
PreconditionerUserMatrix::getPrecMatrix
()
{
return
B_
;
}
/*
*
* @brief Applies the preconditioner depending on the side
*
* @param[in] rhs - Right-hand-side vector
* @param[in] x - Solution vector
*
* @return int 0 if successful, 1 if fails
*/
int
PreconditionerUserMatrix::apply
(vector_type* rhs, vector_type* x)
{
using
namespace
constants
;
if
(matrix_handler_ ==
nullptr
||
B_
==
nullptr
)
{
return
1
;
}
matrix_handler_->
matvec
(
B_
, rhs, x, &
ONE
, &
ZERO
, memspace_);
return
0
;
}
void
PreconditionerUserMatrix::setMemorySpace
()
{
bool
is_matrix_handler_cuda = matrix_handler_->
getIsCudaEnabled
();
bool
is_matrix_handler_hip = matrix_handler_->
getIsHipEnabled
();
if
(is_matrix_handler_cuda || is_matrix_handler_hip)
{
memspace_ = memory::
DEVICE
;
}
else
{
memspace_ = memory::
HOST
;
}
}
}
//
namespace ReSolve
Back
|
FazBrowse Home
|
New Git URL