35#include "arccore/alina/BuiltinBackend.h"
36#include "arccore/alina/Adapters.h"
37#include "arccore/alina/PreconditionedSolver.h"
38#include "arccore/alina/AMG.h"
39#include "arccore/alina/Coarsening.h"
40#include "arccore/alina/Relaxation.h"
41#include "arccore/alina/ConjugateGradientSolver.h"
43#include "arccore/alina/IO.h"
44#include "arccore/alina/Profiler.h"
47using namespace Arcane::Alina;
49int main(
int argc,
char* argv[])
53 std::cerr <<
"Usage: " << argv[0] <<
" <A.mtx> <b.mtx> <coo.mtx>" << std::endl;
58 auto& prof = Alina::Profiler::globalProfiler();
61 ptrdiff_t rows, cols, ndim, ncoo;
62 std::vector<ptrdiff_t> ptr, col;
63 std::vector<double> val, rhs, coo;
71 Alina::precondition(ncoo * ndim == rows && (ndim == 2 || ndim == 3),
72 "The coordinate file has wrong dimensions");
74 std::cout <<
"Matrix " << argv[1] <<
": " << rows <<
"x" << rows << std::endl;
75 std::cout <<
"RHS " << argv[2] <<
": " << rows <<
"x" << cols << std::endl;
76 std::cout <<
"Coords " << argv[3] <<
": " << ncoo <<
"x" << ndim << std::endl;
89 prm.precond.coarsening.aggr.eps_strong = 0;
95 prm.precond.coarsening.nullspace.cols = Alina::rigid_body_modes(ndim, coo, prm.precond.coarsening.nullspace.B);
98 auto A = std::tie(rows, ptr, col, val);
102 Solver solve(A, prm);
106 std::cout << solve << std::endl;
109 std::vector<double> x(rows, 0.0);
117 std::cout <<
"Iters: " << r.nbIteration() << std::endl
118 <<
"Error: " << r.residual() << std::endl
119 << prof << std::endl;
Conjugate Gradients solver.
Convenience class that bundles together a preconditioner and an iterative solver.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-