11 #ifndef CUBBYFLOW_MULTI_GRID_IMPL_HPP 12 #define CUBBYFLOW_MULTI_GRID_IMPL_HPP 18 template <
typename BlasType>
24 params.
relaxFunc(A[currentLevel], (*b)[currentLevel],
26 &((*x)[currentLevel]), &((*buffer)[currentLevel]));
29 if (currentLevel < A.
levels.size() - 1)
32 BlasType::Residual(A[currentLevel], (*x)[currentLevel],
33 (*b)[currentLevel], &(*r)[currentLevel]);
34 params.
restrictFunc((*r)[currentLevel], &(*b)[currentLevel + 1]);
36 BlasType::Set(0.0, &(*x)[currentLevel + 1]);
40 MGVCycle(A, params, currentLevel + 1, x, b, buffer);
44 params.
correctFunc((*x)[currentLevel + 1], &(*x)[currentLevel]);
49 params.
relaxFunc(A[currentLevel], (*b)[currentLevel],
51 &((*x)[currentLevel]), &((*buffer)[currentLevel]));
55 params.
relaxFunc(A[currentLevel], (*b)[currentLevel],
57 &((*x)[currentLevel]), &((*buffer)[currentLevel]));
63 params.
relaxFunc(A[currentLevel], (*b)[currentLevel],
65 &((*x)[currentLevel]), &((*buffer)[currentLevel]));
67 BlasType::Residual(A[currentLevel], (*x)[currentLevel],
68 (*b)[currentLevel], &(*buffer)[currentLevel]);
71 BlasType::Residual(A[currentLevel], (*x)[currentLevel], (*b)[currentLevel],
72 &(*buffer)[currentLevel]);
80 template <
typename BlasType>
87 template <
typename BlasType>
93 template <
typename BlasType>
96 return levels.Front();
99 template <
typename BlasType>
102 return levels.Front();
105 template <
typename BlasType>
112 template <
typename BlasType>
118 template <
typename BlasType>
121 return levels.Front();
124 template <
typename BlasType>
127 return levels.Front();
130 template <
typename BlasType>
135 return Internal::MGVCycle<BlasType>(A, params, 0u, x, b, buffer);
unsigned int numberOfRestrictionIter
Number of iteration at restriction step.
Definition: MG.hpp:68
std::vector< typename BlasType::MatrixType > levels
Definition: MG.hpp:22
MGRelaxFunc< BlasType > relaxFunc
Relaxation function such as Jacobi or Gauss-Seidel.
Definition: MG.hpp:80
const BlasType::VectorType & Finest() const
Definition: MG-Impl.hpp:119
const BlasType::VectorType & operator[](size_t i) const
Definition: MG-Impl.hpp:106
const BlasType::MatrixType & Finest() const
Definition: MG-Impl.hpp:94
Multi-grid matrix wrapper.
Definition: MG.hpp:20
unsigned int numberOfCoarsestIter
Number of iteration at coarsest step.
Definition: MG.hpp:74
double maxTolerance
Max error tolerance.
Definition: MG.hpp:89
Multi-grid result type.
Definition: MG.hpp:93
unsigned int numberOfFinalIter
Number of iteration at final step.
Definition: MG.hpp:77
Definition: pybind11Utils.hpp:20
unsigned int numberOfCorrectionIter
Number of iteration at correction step.
Definition: MG.hpp:71
double lastResidualNorm
Lastly measured norm of residual.
Definition: MG.hpp:96
Multi-grid vector wrapper.
Definition: MG.hpp:31
MGResult MGVCycle(const MGMatrix< BlasType > &A, MGParameters< BlasType > ¶ms, unsigned int currentLevel, MGVector< BlasType > *x, MGVector< BlasType > *b, MGVector< BlasType > *buffer)
Definition: MG-Impl.hpp:19
Multi-grid input parameter set.
Definition: MG.hpp:62
MGCorrectFunc< BlasType > correctFunc
Correction function that maps coarser to finer grid.
Definition: MG.hpp:86
const BlasType::MatrixType & operator[](size_t i) const
Definition: MG-Impl.hpp:81
MGRestrictFunc< BlasType > restrictFunc
Restrict function that maps finer to coarser grid.
Definition: MG.hpp:83