1 #ifndef PARALUTION_SOLVER_HPP_
2 #define PARALUTION_SOLVER_HPP_
5 #include "../base/base_paralution.hpp"
6 #include "../base/local_vector.hpp"
11 template <
class OperatorType,
class VectorType,
typename ValueType>
26 virtual void Print(
void)
const = 0;
29 virtual void Solve(
const VectorType &rhs,
38 virtual void Clear(
void);
42 virtual void Build(
void);
57 virtual void Verbose(
const int verb=1);
62 const OperatorType *
op_;
93 template <
class OperatorType,
class VectorType,
typename ValueType>
103 void Init(
const double abs_tol,
104 const double rel_tol,
105 const double div_tol,
110 void Init(
const double abs_tol,
111 const double rel_tol,
112 const double div_tol,
139 virtual void Verbose(
const int verb=1);
141 virtual void Solve(
const VectorType &rhs,
182 ValueType
Norm(
const VectorType &vec);
188 template <
class OperatorType,
class VectorType,
typename ValueType>
196 virtual void Print(
void)
const;
203 virtual void Build(
void);
205 virtual void Clear(
void);
228 template <
class OperatorType,
class VectorType,
typename ValueType>
236 virtual void Verbose(
const int verb=1);
238 virtual void Solve(
const VectorType &rhs,
244 virtual void Solve_(
const VectorType &rhs, VectorType *x) = 0;
251 #endif // PARALUTION_SOLVER_HPP_
virtual void Solve(const VectorType &rhs, VectorType *x)=0
Solve Operator x = rhs.
virtual void Solve(const VectorType &rhs, VectorType *x)
Solve Operator x = rhs.
Definition: solver.cpp:377
Fixed-point iteration , where the solution of is provide by solver via SetPreconditioner() ...
Definition: solver.hpp:189
virtual void Clear(void)
Clear (free all local data) the solver.
Definition: solver.cpp:510
virtual void Solve_(const VectorType &rhs, VectorType *x)=0
Solution procedure.
Solver()
Definition: solver.cpp:16
virtual int GetAmaxResidualIndex(void)
Return absolute maximum index of residual vector when using Linf norm.
Definition: solver.cpp:293
virtual ~IterativeLinearSolver()
Definition: solver.cpp:185
Base class for all linear (direct) solvers.
Definition: solver.hpp:229
virtual void SolveNonPrecond_(const VectorType &rhs, VectorType *x)
Non-preconditioner solution procedure.
Definition: solver.cpp:576
virtual void PrintEnd_(void) const
Print ending msg of the solver.
Definition: solver.cpp:479
virtual ~Solver()
Definition: solver.cpp:29
virtual void SolvePrecond_(const VectorType &rhs, VectorType *x)=0
Preconditioned solution procedure.
virtual void Build(void)
Build the solver (data allocation, structure computation, numerical computation)
Definition: solver.cpp:81
virtual void MoveToAcceleratorLocalData_(void)
Move all local data to the accelerator.
Definition: solver.cpp:661
virtual void Verbose(const int verb=1)
Provide verbose output of the solver: verb == 0 no output verb == 1 print info about the solver (star...
Definition: solver.cpp:160
Iteration control for iterative solvers, monitor the residual (L2 norm) behavior. ...
Definition: iter_ctrl.hpp:11
LocalVector< int > permutation_
Permutation vector (used if the solver performs permutation/re-ordering techniques) ...
Definition: solver.hpp:72
virtual void MoveToHostLocalData_(void)=0
Move all local data to the host.
virtual int GetSolverStatus(void)
Return the current status.
Definition: solver.cpp:283
virtual void Solve(const VectorType &rhs, VectorType *x)
Solve Operator x = rhs.
Definition: solver.cpp:704
Base class for all linear (iterative) solvers.
Definition: solver.hpp:94
virtual void MoveToHost(void)
Move all the data (i.e. move the solver) to the host.
Definition: solver.cpp:126
virtual void SolveZeroSol(const VectorType &rhs, VectorType *x)
Solve Operator x = rhs; but set first the init x = 0.
Definition: solver.cpp:69
virtual void ReBuildNumeric(void)
Rebuild only with numerical computation (no allocation or data structure computation) ...
Definition: solver.cpp:486
int index_
Absolute maximum index of residual vector when using Linf norm.
Definition: solver.hpp:179
virtual void SolvePrecond_(const VectorType &rhs, VectorType *x)
Preconditioned solution procedure.
Definition: solver.cpp:585
virtual void Verbose(const int verb=1)
Provide verbose output of the solver: verb == 0 no output verb == 1 print info about the solver (star...
Definition: solver.cpp:327
virtual ~DirectLinearSolver()
Definition: solver.cpp:686
void SetResidualNorm(const int resnorm)
Set the residual norm to L1, L2 or Inf norm resnorm == 1 L1 Norm resnorm == 2 L2 Norm (default) resno...
Definition: solver.cpp:339
virtual void MoveToAccelerator(void)
Move all the data (i.e. move the solver) to the accelerator.
Definition: solver.cpp:143
void Init(const double abs_tol, const double rel_tol, const double div_tol, const int max_iter)
Initialize the solver with absolute/relative/divergence tolerance and maximum number of iterations...
Definition: solver.cpp:194
int verb_
Verbose flag verb == 0 no output verb == 1 print info about the solver (start,end); verb == 2 print (...
Definition: solver.hpp:78
IterationControl iter_ctrl_
Iteration control (monitor)
Definition: solver.hpp:162
void RecordHistory(const std::string filename) const
Write the history to file.
Definition: solver.cpp:317
int res_norm_
Residual norm res_norm = 1 L1 Norm res_norm = 2 L2 Norm res_norm = 3 Linf Norm.
Definition: solver.hpp:176
DirectLinearSolver()
Definition: solver.cpp:676
virtual void Verbose(const int verb=1)
Provide verbose output of the solver: verb == 0 no output verb == 1 print info about the solver (star...
Definition: solver.cpp:694
virtual void PrintEnd_(void) const =0
Print ending msg of the solver.
ValueType omega_
Definition: solver.hpp:209
virtual void SolveNonPrecond_(const VectorType &rhs, VectorType *x)=0
Non-preconditioner solution procedure.
bool build_
Flag == true after building the solver (e.g. Build())
Definition: solver.hpp:68
virtual void SetPreconditioner(Solver< OperatorType, VectorType, ValueType > &precond)
Set a preconditioner of the linear solver.
Definition: solver.cpp:411
virtual void PrintStart_(void) const =0
Print starting msg of the solver.
void InitMaxIter(const int max_iter)
Set the maximum number of iterations.
Definition: solver.cpp:238
Solver< OperatorType, VectorType, ValueType > * precond_
Pointer to the defined preconditioner.
Definition: solver.hpp:65
void InitTol(const double abs, const double rel, const double div)
Set the absolute/relative/divergence tolerance.
Definition: solver.cpp:248
virtual void ResetOperator(const OperatorType &op)
Reset the operator; see ReBuildNumeric.
Definition: solver.cpp:55
virtual void PrintStart_(void) const
Print starting msg of the solver.
Definition: solver.cpp:470
VectorType x_old_
Definition: solver.hpp:210
virtual void MoveToHostLocalData_(void)
Move all local data to the host.
Definition: solver.cpp:646
Definition: backend_manager.cpp:43
virtual void Print(void) const =0
Print information about the solver.
Definition: base_paralution.hpp:11
const IndexType const IndexType const IndexType const ValueType const ValueType const ValueType * x
Definition: cuda_kernels_coo.hpp:91
virtual void Clear(void)
Clear (free all local data) the solver.
Definition: solver.cpp:110
const OperatorType * op_
Pointer to the operator.
Definition: solver.hpp:62
The base class for all solvers and preconditioners.
Definition: solver.hpp:12
virtual void MoveToAcceleratorLocalData_(void)=0
Move all local data to the accelerator.
virtual void ReBuildNumeric(void)
Rebuild only with numerical computation (no allocation or data structure computation) ...
Definition: solver.cpp:96
virtual double GetCurrentResidual(void)
Return the current residual.
Definition: solver.cpp:273
virtual void Build(void)
Build the solver (data allocation, structure computation, numerical computation)
Definition: solver.cpp:535
virtual int GetIterationCount(void)
Return the iteration count.
Definition: solver.cpp:263
virtual void SetRelaxation(const ValueType omega)
Set a relaxation parameter of the iterative solver.
Definition: solver.cpp:443
IterativeLinearSolver()
Definition: solver.cpp:172
VectorType x_res_
Definition: solver.hpp:211
virtual void Print(void) const
Print information about the solver.
Definition: solver.cpp:454
void InitMinIter(const int min_iter)
Set the minimum number of iterations.
Definition: solver.cpp:228
virtual ~FixedPoint()
Definition: solver.cpp:432
ValueType Norm(const VectorType &vec)
Computes the vector norm.
Definition: solver.cpp:352
void SetOperator(const OperatorType &op)
Set the Operator of the solver.
Definition: solver.cpp:43
FixedPoint()
Definition: solver.cpp:422
void RecordResidualHistory(void)
Record the residual history.
Definition: solver.cpp:307