Arcane  4.2.3.0
Developer documentation
Loading...
Searching...
No Matches
TestDistributedAlinaLib.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 "arccore/alina/MessagePassingUtils.h"
20#include "arccore/alina/AlinaLib.h"
21
22#include "./SampleProblemCommon.h"
23
24#include <gtest/gtest.h>
25
26using namespace Arcane;
27
28TEST(alina_test_mpi, DistributedAlinaLib)
29{
30 Alina::AlinaCommunicator world(MPI_COMM_WORLD);
31
32 int comm_rank = world.rank;
33 int comm_size = world.size;
34
35 const Int32 n = 64;
36
37 // For 32 bit indexing
38 using ColumnType = Int32;
39 // For 64 bit indexing
40 // using ColumnType = Int64;
41
42 std::vector<ColumnType> ptr;
43 std::vector<ColumnType> col;
44 std::vector<double> val;
45 std::vector<double> rhs;
46
47 Int32 chunk = sample_problem_distributed(comm_rank, comm_size, n, 1, ptr, col, val, rhs);
48
49 // Setup
51
52 prm.setString("local.coarsening.type", "smoothed_aggregation");
53 prm.setString("local.relax.type", "spai0");
54 prm.setString("isolver.type", "bicgstabl");
55 prm.setString("dsolver.type", "skyline_lu");
56
57 UniqueArray<double> x(rhs.size(), 0.0);
58
59 // Solve
60 {
62 AlinaCSRMatrixView matrix_view(chunk, ptr.data(), col.data(), val.data());
63 AlinaDistributedSolver solver(mpm.get(), matrix_view, prm);
64 SmallSpan<const double> rhs_view(rhs.data(), rhs.size());
65 AlinaConvergenceInfo cnv = solver.solve(rhs_view, x.smallSpan());
66
67 std::cout << "Iterations: " << cnv.iterations << std::endl
68 << "Error: " << cnv.residual << std::endl;
69 }
70}
CSR Matrix view used in AlinaLib.
Definition AlinaLib.h:100
Distributed solver.
Definition AlinaLib.h:222
Handle parameters for Alina.
Definition AlinaLib.h:62
void setString(const char *name, const char *value)
Set floating point parameter in the parameter list.
Definition AlinaLib.cc:101
static Ref< IMessagePassingMng > createRef(MPI_Comm comm, bool clean_comm=false)
Creates a manager associated with the communicator comm.
InstanceType * get() const
Associated instance or nullptr if none.
Reference to an instance.
View of an array of elements of type T.
Definition Span.h:803
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Convergence info.
Definition AlinaLib.h:38
Convenience wrapper around MPI_Comm.