Arcane  v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestEigenSolver.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 <gtest/gtest.h>
20
21// To remove warnings about deprecated Eigen usage.
22#pragma GCC diagnostic ignored "-Wdeprecated-copy"
23#pragma GCC diagnostic ignored "-Wint-in-bool-context"
24
25#include <Eigen/SparseLU>
26#include "arccore/alina/EigenSolver.h"
27#include "arccore/alina/BuiltinBackend.h"
28#include "arccore/alina/Adapters.h"
29#include "arccore/alina/Profiler.h"
30#include "SampleProblemCommon.h"
31
32namespace
33{
35}
36
37using namespace Arcane;
38
39TEST(alina_test_solvers, eigen_solver)
40{
41 std::vector<int> ptr;
42 std::vector<int> col;
43 std::vector<double> val;
44 std::vector<double> rhs;
45
46 size_t n = sample_problem(16, val, col, ptr, rhs);
47 Alina::CSRMatrix<double> A(std::tie(n, ptr, col, val));
48
50
51 Solver solve(A);
52
53 std::vector<double> x(n);
54 std::vector<double> r(n);
55
56 solve(rhs, x);
57
58 Alina::backend::residual(rhs, A, x, r);
59
60 ASSERT_NEAR(sqrt(Alina::backend::inner_product(r, r)), 0.0, 1e-8);
61}
Wrapper around eigen direct solvers.
Definition EigenSolver.h:51
Profiler class.
Definition Profiler.h:50
__host__ __device__ double sqrt(double v)
Racine carrée de v.
Definition Math.h:135
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Sparse matrix stored in CSR (Compressed Sparse Row) format.
Definition CSRMatrix.h:98