-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BiCGStab solver + generate polygonal mesh from cartesian
- Loading branch information
Showing
9 changed files
with
189 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,48 @@ | ||
#pragma once | ||
#include "../IterativeSolver.h" | ||
#include <Eigen/IterativeLinearSolvers> | ||
using namespace std; | ||
|
||
class EigenBiCGSTAB : public IterativeSolver | ||
{ | ||
private: | ||
Eigen::BiCGSTAB<SparseMatrix, Eigen::DiagonalPreconditioner<double>> _solver; | ||
|
||
public: | ||
|
||
EigenBiCGSTAB() : IterativeSolver() {} | ||
|
||
void Serialize(ostream& os) const override | ||
{ | ||
os << "BiCGSTAB (Eigen library)"; | ||
} | ||
|
||
void Setup(const SparseMatrix& A) override | ||
{ | ||
Solver::Setup(A); | ||
_solver.compute(A); | ||
Eigen::ComputationInfo info = _solver.info(); | ||
if (info != Eigen::ComputationInfo::Success) | ||
{ | ||
cout << "----------------- A -------------------" << A << endl; | ||
cout << "Error: ConjugateGradient failed to execute with the code " << info << "." << endl; | ||
exit(EXIT_FAILURE); | ||
} | ||
_solver.setTolerance(this->Tolerance); | ||
_solver.setMaxIterations(this->MaxIterations); | ||
} | ||
|
||
void Solve(const Vector& b, Vector& x, bool xEquals0, bool computeResidual, bool computeAx) override | ||
{ | ||
if (xEquals0) | ||
x = _solver.solve(b); | ||
else | ||
x = _solver.solveWithGuess(b, x); | ||
this->IterationCount = _solver.iterations(); | ||
} | ||
|
||
Vector Solve(const Vector& b) override | ||
{ | ||
return IterativeSolver::Solve(b); | ||
} | ||
}; |
This file contains 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.