PARALUTION  1.0.0
PARALUTION
base_multigrid.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_BASE_MULTIGRID_HPP_
2 #define PARALUTION_BASE_MULTIGRID_HPP_
3 
4 #include "../solver.hpp"
5 #include "../../base/operator.hpp"
6 
7 namespace paralution {
8 
9 enum _cycle {
10  Vcycle = 0,
11  Wcycle = 1,
12  Kcycle = 2,
13  Fcycle = 3
14 };
15 
16 template <class OperatorType, class VectorType, typename ValueType>
17 class BaseMultiGrid : public IterativeLinearSolver<OperatorType, VectorType, ValueType> {
18 
19 public:
20 
21  BaseMultiGrid();
22  virtual ~BaseMultiGrid();
23 
24  virtual void Print(void) const;
25 
28 
31 
34 
36  virtual void SetSmootherPreIter(const int iter);
37 
39  virtual void SetSmootherPostIter(const int iter);
40 
42  virtual void SetRestrictOperator(OperatorType **op) = 0;
43 
45  virtual void SetProlongOperator(OperatorType **op) = 0;
46 
48  virtual void SetOperatorHierarchy(OperatorType **op) = 0;
49 
51  virtual void SetScaling(const bool scaling);
52 
54  virtual void SetCycle(const _cycle cycle);
55 
57  virtual void SetKcycleFull(const bool kcycle_full);
58 
60  virtual void InitLevels(const int levels);
61 
63  virtual void Solve(const VectorType &rhs,
64  VectorType *x);
65 
66  virtual void Build(void);
67  virtual void Clear(void);
68 
69 protected:
70 
71  // Restricts from level 'level' to 'level-1'
72  virtual void Restrict_(const VectorType &fine, VectorType *coarse, const int level);
73 
74  // Prolongs from level 'level' to 'level+1'
75  virtual void Prolong_(const VectorType &coarse, VectorType *fine, const int level);
76 
77  void Vcycle_(const VectorType &rhs, VectorType *x);
78  void Wcycle_(const VectorType &rhs, VectorType *x);
79  void Fcycle_(const VectorType &rhs, VectorType *x);
80  void Kcycle_(const VectorType &rhs, VectorType *x);
81 
83  virtual void SolveNonPrecond_(const VectorType &rhs,
84  VectorType *x);
85 
87  virtual void SolvePrecond_(const VectorType &rhs,
88  VectorType *x);
89 
90  virtual void PrintStart_(void) const;
91  virtual void PrintEnd_(void) const;
92 
93  virtual void MoveToHostLocalData_(void);
94  virtual void MoveToAcceleratorLocalData_(void);
95 
96 
97  int levels_ ;
99  bool scaling_;
102  int cycle_;
104 
105  double res_norm_;
106 
107  OperatorType **op_level_;
108 
111 
112  VectorType **d_level_;
113  VectorType **r_level_;
114  VectorType **t_level_;
115  VectorType **s_level_;
116  VectorType **p_level_;
117  VectorType **q_level_;
118  VectorType **k_level_;
119  VectorType **l_level_;
120 
123 
124 };
125 
126 
127 }
128 
129 #endif // PARALUTION_BASE_MULTIGRID_HPP_
virtual void PrintStart_(void) const
Print starting msg of the solver.
Definition: base_multigrid.cpp:169
int levels_
Definition: base_multigrid.hpp:97
VectorType ** s_level_
Definition: base_multigrid.hpp:115
virtual void SetProlongOperator(OperatorType **op)=0
Set the prolongation operator for each level.
virtual void SetSmootherPreIter(const int iter)
Set the number of pre-smoothing steps.
Definition: base_multigrid.cpp:98
double res_norm_
Definition: base_multigrid.hpp:105
Definition: base_multigrid.hpp:13
virtual void SetSmoother(IterativeLinearSolver< OperatorType, VectorType, ValueType > **smoother)
Set the smoother for each level.
Definition: base_multigrid.cpp:85
virtual void SetRestrictOperator(OperatorType **op)=0
Set thre restriction method by operator for each level.
virtual void Build(void)
Build the solver (data allocation, structure computation, numerical computation)
Definition: base_multigrid.cpp:188
virtual void SetKcycleFull(const bool kcycle_full)
Set the MultiGrid Kcycle on all levels or only on finest level.
Definition: base_multigrid.cpp:151
IterativeLinearSolver< OperatorType, VectorType, ValueType > ** smoother_level_
Definition: base_multigrid.hpp:122
OperatorType ** op_level_
Definition: base_multigrid.hpp:107
virtual void Print(void) const
Print information about the solver.
Definition: base_multigrid.cpp:161
VectorType ** r_level_
Definition: base_multigrid.hpp:113
Definition: base_multigrid.hpp:10
virtual void SetPreconditioner(Solver< OperatorType, VectorType, ValueType > &precond)
disabled function
Definition: base_multigrid.cpp:77
BaseMultiGrid()
Definition: base_multigrid.cpp:17
Base class for all linear (iterative) solvers.
Definition: solver.hpp:94
VectorType ** d_level_
Definition: base_multigrid.hpp:112
virtual void Solve(const VectorType &rhs, VectorType *x)
Called by default the V-cycle.
Definition: base_multigrid.cpp:455
VectorType ** k_level_
Definition: base_multigrid.hpp:118
void Vcycle_(const VectorType &rhs, VectorType *x)
Definition: base_multigrid.cpp:551
virtual void SetSmootherPostIter(const int iter)
Set the number of post-smoothing steps.
Definition: base_multigrid.cpp:108
_cycle
Definition: base_multigrid.hpp:9
virtual void SetSolver(Solver< OperatorType, VectorType, ValueType > &solver)
Set the smoother for each level.
Definition: base_multigrid.cpp:118
VectorType ** q_level_
Definition: base_multigrid.hpp:117
VectorType ** t_level_
Definition: base_multigrid.hpp:114
bool kcycle_full_
Definition: base_multigrid.hpp:103
bool scaling_
Definition: base_multigrid.hpp:99
Definition: base_multigrid.hpp:12
virtual void MoveToAcceleratorLocalData_(void)
Move all local data to the accelerator.
Definition: base_multigrid.cpp:407
int cycle_
Definition: base_multigrid.hpp:102
virtual void SolveNonPrecond_(const VectorType &rhs, VectorType *x)
disabled function
Definition: base_multigrid.cpp:701
virtual void Prolong_(const VectorType &coarse, VectorType *fine, const int level)
Definition: base_multigrid.cpp:540
virtual void Restrict_(const VectorType &fine, VectorType *coarse, const int level)
Definition: base_multigrid.cpp:528
VectorType ** p_level_
Definition: base_multigrid.hpp:116
void Kcycle_(const VectorType &rhs, VectorType *x)
Definition: base_multigrid.cpp:692
Operator< ValueType > ** restrict_op_level_
Definition: base_multigrid.hpp:109
Operator< ValueType > ** prolong_op_level_
Definition: base_multigrid.hpp:110
Operator class defines the generic interface for applying an operator (e.g. matrix, stencil) from/to global and local vectors.
Definition: operator.hpp:19
Definition: backend_manager.cpp:43
VectorType ** l_level_
Definition: base_multigrid.hpp:119
void Fcycle_(const VectorType &rhs, VectorType *x)
Definition: base_multigrid.cpp:684
virtual void InitLevels(const int levels)
Set the depth of the multigrid solver.
Definition: base_multigrid.cpp:64
virtual void SolvePrecond_(const VectorType &rhs, VectorType *x)
disabled function
Definition: base_multigrid.cpp:711
const IndexType const IndexType const IndexType const ValueType const ValueType const ValueType * x
Definition: cuda_kernels_coo.hpp:91
virtual void MoveToHostLocalData_(void)
Move all local data to the host.
Definition: base_multigrid.cpp:363
int current_level_
Definition: base_multigrid.hpp:98
The base class for all solvers and preconditioners.
Definition: solver.hpp:12
virtual void SetCycle(const _cycle cycle)
Set the MultiGrid Cycle (default: Vcycle)
Definition: base_multigrid.cpp:141
Definition: base_multigrid.hpp:17
virtual ~BaseMultiGrid()
Definition: base_multigrid.cpp:54
Solver< OperatorType, VectorType, ValueType > * solver_coarse_
Definition: base_multigrid.hpp:121
virtual void Clear(void)
Clear (free all local data) the solver.
Definition: base_multigrid.cpp:307
Definition: base_multigrid.hpp:11
virtual void SetScaling(const bool scaling)
Enable/disable scaling of intergrid transfers.
Definition: base_multigrid.cpp:131
int iter_pre_smooth_
Definition: base_multigrid.hpp:100
virtual void SetOperatorHierarchy(OperatorType **op)=0
Set the operator for each level.
void Wcycle_(const VectorType &rhs, VectorType *x)
Definition: base_multigrid.cpp:676
virtual void PrintEnd_(void) const
Print ending msg of the solver.
Definition: base_multigrid.cpp:181
int iter_post_smooth_
Definition: base_multigrid.hpp:101