-
Notifications
You must be signed in to change notification settings - Fork 9
ABBA GMRES Solver #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JeffZ594
wants to merge
12
commits into
develop
Choose a base branch
from
jeffery/ABBAGMRES_solver
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ABBA GMRES Solver #408
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a3cdcbf
ABBA GMRES Commit
JeffZ594 fda9694
Added check for preconditioner being set
JeffZ594 0b3c99a
Apply pre-commmit fixes
JeffZ594 797ce6c
Use Preconditioner Class for ABBAGMRES
JeffZ594 750138f
Use Preconditioner class for ABBAGMRES
JeffZ594 b5f9e50
Apply pre-commmit fixes
JeffZ594 5786f8a
Update resolve/PreconditionerMatvec.cpp
JeffZ594 abbf592
Update resolve/LinSolverIterativeFGMRES.cpp
JeffZ594 0e91e24
Update resolve/Preconditioner.hpp
JeffZ594 2d290e0
Apply pre-commmit fixes
JeffZ594 26749fa
Renamed PreconditionerMatvec to PreconditionerABBA
JeffZ594 f1547d4
Apply pre-commmit fixes
JeffZ594 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /** | ||
| * @file PreconditionerABBA.cpp | ||
| * @author Jeffery Zhang (jefferyz@vt.edu) | ||
| * @brief Declaration of PreconditionerMatrix class. | ||
| */ | ||
|
|
||
| #include "PreconditionerABBA.hpp" | ||
|
|
||
| namespace ReSolve | ||
| { | ||
| using out = io::Logger; | ||
|
|
||
| /** | ||
| * @brief Constructor for PreconditionerMatrix. | ||
| * | ||
| * @param[in] A - Pointer to the forward operator | ||
| * @param[in] matrix_handler - Pointer to the matrix handler | ||
| */ | ||
| PreconditionerABBA::PreconditionerABBA(matrix::Sparse* A, MatrixHandler* matrix_handler) | ||
| { | ||
| A_ = A; | ||
| matrix_handler_ = matrix_handler; | ||
| setMemorySpace(); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Destructor for PreconditionerLU | ||
| */ | ||
| PreconditionerABBA::~PreconditionerABBA() | ||
| { | ||
| } | ||
|
|
||
| /** | ||
| * @brief Set the preconditioning matrix | ||
| * | ||
| * @param[in] B - Pointer to the preconditioning matrix | ||
| */ | ||
| int PreconditionerABBA::setup(matrix::Sparse* B) | ||
| { | ||
| B_ = B; | ||
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Get the preconditioner matrix | ||
| * | ||
| * Necessary for some calculations | ||
| * | ||
| */ | ||
| matrix::Sparse* PreconditionerABBA::getPrecMatrix() | ||
| { | ||
| return B_; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Setter for the side | ||
| * | ||
| * @param[in] The new side | ||
| */ | ||
| int PreconditionerABBA::setSide(std::string side) | ||
| { | ||
| if (side == "left" || side == "right") | ||
| { | ||
| side_ = side; | ||
| return 0; | ||
| } | ||
| out::error() << "Choose either left (BA) or right (AB)\n"; | ||
| return 1; | ||
| } | ||
|
|
||
| /** | ||
| * @brief getter for the side | ||
| */ | ||
| std::string PreconditionerABBA::getSide() | ||
| { | ||
| return side_; | ||
| } | ||
|
|
||
| /** | ||
| * @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 PreconditionerABBA::apply(vector_type* rhs, vector_type* x) | ||
| { | ||
| using namespace constants; | ||
| matrix_handler_->matvec(B_, rhs, x, &ONE, &ZERO, memspace_); | ||
| return 0; | ||
| } | ||
|
|
||
| void PreconditionerABBA::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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** | ||
| * @file PreconditionerABBA.hpp | ||
| * @author Jeffery Zhang (jefferyz@vt.edu) | ||
| * @brief Declaration of left and right preconditioner class | ||
| */ | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "Common.hpp" | ||
| #include <resolve/MemoryUtils.hpp> | ||
| #include <resolve/Preconditioner.hpp> | ||
| #include <resolve/matrix/MatrixHandler.hpp> | ||
|
|
||
| namespace ReSolve | ||
| { | ||
|
|
||
| namespace matrix | ||
| { | ||
| class Sparse; | ||
| } // namespace matrix | ||
|
|
||
| namespace vector | ||
| { | ||
| class Vector; | ||
| } // namespace vector | ||
|
|
||
| // Forward declaration of MatrixHandler class | ||
| class MatrixHandler; | ||
|
|
||
| /** | ||
| * @brief Class allows for a user specified matrix to be used for preconditioning | ||
| * Allows user to switch between right preconditioning (AB) and | ||
| * left preconditioning (BA) | ||
| * | ||
| * @author Jeffery Zhang (jefferyz@vt.edu) | ||
| * | ||
| */ | ||
| class PreconditionerABBA : public Preconditioner | ||
| { | ||
| public: | ||
| using vector_type = vector::Vector; | ||
| using matrix_type = matrix::Sparse; | ||
|
|
||
| PreconditionerABBA(matrix_type* A, MatrixHandler* matrix_handler); | ||
| ~PreconditionerABBA(); | ||
|
|
||
| int apply(vector_type* rhs, vector_type* x) override; // Applies preconditioning | ||
| int setup(matrix_type*) override; | ||
| std::string getSide() override; | ||
| matrix_type* getPrecMatrix() override; // Used to get the preconditioning matrix for calculation of initial residual for BAGMRES | ||
| int setSide(std::string side); // Changes the preconditioning side for BAGMRES | ||
|
|
||
| private: | ||
| void setMemorySpace(); | ||
|
|
||
| matrix_type* A_{nullptr}; | ||
| matrix_type* B_{nullptr}; | ||
| std::string side_ = "right"; // Defaults to ABGMRES | ||
| MatrixHandler* matrix_handler_{nullptr}; | ||
| memory::MemorySpace memspace_; | ||
| }; | ||
| } // namespace ReSolve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.