Arcane  v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MixedPrecision.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/*---------------------------------------------------------------------------*/
9/*
10 * This file is based on the work on AMGCL library (version march 2026)
11 * which can be found at https://github.com/ddemidov/amgcl.
12 *
13 * Copyright (c) 2012-2022 Denis Demidov <dennis.demidov@gmail.com>
14 * SPDX-License-Identifier: MIT
15 */
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19#include <vector>
20#include <tuple>
21
22#include "arccore/alina/Adapters.h"
23#include "arccore/alina/PreconditionedSolver.h"
24#include "arccore/alina/AMG.h"
25#include "arccore/alina/Coarsening.h"
26#include "arccore/alina/Relaxation.h"
27#include "arccore/alina/ConjugateGradientSolver.h"
28#include "arccore/alina/Profiler.h"
29
30#ifndef SOLVER_BACKEND_BUILTIN
31#define SOLVER_BACKEND_BUILTIN
32#endif
33#include "arccore/alina/BuiltinBackend.h"
36
37#include "SampleProblemCommon.h"
38
39using namespace Arcane;
40using namespace Arcane::Alina;
41
42int main()
43{
44 // Combine single-precision preconditioner with a
45 // double-precision Krylov solver.
50 Solver;
51
52 std::vector<ptrdiff_t> ptr, col;
53 std::vector<double> val, rhs;
54
56
57 ARCCORE_ALINA_TIC("assemble");
58 int n = sample_problem(128, val, col, ptr, rhs);
59 ARCCORE_ALINA_TOC("assemble");
60
61 auto A_d = std::tie(n, ptr, col, val);
62 std::vector<double>& f = rhs;
63 std::vector<double> x(n, 0.0);
64
65 ARCCORE_ALINA_TIC("setup");
66 Solver S(std::tie(n, ptr, col, val), Solver::params(), bprm);
67 ARCCORE_ALINA_TIC("setup");
68
69 std::cout << S << std::endl;
70
71 ARCCORE_ALINA_TIC("solve");
72 SolverResult r = S(A_d, f, x);
73 ARCCORE_ALINA_TIC("solve");
74
75 std::cout << "Iterations: " << r.nbIteration() << std::endl
76 << "Error: " << r.residual() << std::endl
77 << Alina::Profiler::globalProfiler() << std::endl;
78}
Algebraic multigrid method.
Definition AMG.h:71
Convenience class that bundles together a preconditioner and an iterative solver.
Result of a solving.
Definition AlinaUtils.h:52
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Alina::detail::empty_params params
Sparse approximate interface smoother.
Smoothed aggregation coarsening.