19#include "arccore/alina/AMG.h"
20#include "arccore/alina/Adapters.h"
21#include "arccore/alina/Coarsening.h"
22#include "arccore/alina/PreconditionedSolver.h"
23#include "arccore/alina/Relaxation.h"
24#include "arccore/alina/BiCGStabSolver.h"
34 typedef double val_type;
35 typedef long col_type;
42 , h2i((n - 1) * (n - 1))
45 size_t rows()
const {
return n * n; }
46 size_t nonzeros()
const {
return 5 * rows(); }
48 void operator()(
size_t row,
49 std::vector<col_type>& col,
50 std::vector<val_type>& val)
const
56 col.push_back(row - n);
61 col.push_back(row - 1);
66 val.push_back(4 * h2i);
69 col.push_back(row + 1);
74 col.push_back(row + n);
80int main(
int argc,
char* argv[])
82 auto& prof = Alina::Profiler::globalProfiler();
84 int m = argc > 1 ? atoi(argv[1]) : 1024;
88 std::vector<double> f(n);
89 std::vector<double> x(n);
96 Solver solve(Alina::adapter::make_matrix(
poisson_2d(m)));
101 std::fill_n(f.data(), n, 1.0);
102 std::fill_n(x.data(), n, 0.0);
108 std::cout <<
"Iterations: " << r.nbIteration() << std::endl
109 <<
"Error: " << r.residual() << std::endl
112 std::cout << prof << std::endl;
Algebraic multigrid method.
Convenience class that bundles together a preconditioner and an iterative solver.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-