Arcane  4.1.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
DistributedEigenSparseLUDirectSolver.h
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/* DistributedEigenSparseLUDirectSolver.h (C) 2000-2026 */
9/* */
10/* Distributed wrapper for Eigen::SparseLU solver. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_ALINA_DISTRIBUTEDEIGENSPARSELUDIRECTSOLVER_H
13#define ARCCORE_ALINA_DISTRIBUTEDEIGENSPARSELUDIRECTSOLVER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16/*
17 * This file is based on the work on AMGCL library (version march 2026)
18 * which can be found at https://github.com/ddemidov/amgcl.
19 *
20 * Copyright (c) 2012-2022 Denis Demidov <dennis.demidov@gmail.com>
21 * SPDX-License-Identifier: MIT
22 */
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26#include "arccore/alina/BuiltinBackend.h"
27#include "arccore/alina/EigenSolver.h"
28#include "arccore/alina/MessagePassingUtils.h"
29#include "arccore/alina/DistributedDirectSolverBase.h"
30
31#include <Eigen/SparseLU>
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36namespace Arcane::Alina
37{
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
47template <typename Backend>
49: public DistributedDirectSolverBase<Backend, DistributedEigenSparseLUDirectSolver<Backend>>
50{
51 using Base = DistributedDirectSolverBase<Backend, DistributedEigenSparseLUDirectSolver<Backend>>;
52
53 public:
54
55 using value_type = Backend::value_type;
56 using EigenMatrix = Eigen::SparseMatrix<value_type, Eigen::ColMajor, int>;
58 typedef typename Solver::params params;
59 typedef CSRMatrix<value_type> build_matrix;
60
62 template <class Matrix>
64 const params& prm = params())
65 : prm(prm)
66 {
67 static_cast<Base*>(this)->init(comm, A);
68 }
69
70 static size_t coarse_enough()
71 {
72 return Base::coarse_enough();
73 }
74
75 int comm_size(int /*n*/) const
76 {
77 return 1;
78 }
79
80 void init(mpi_communicator, const build_matrix& A)
81 {
82 S = std::make_shared<Solver>(A, prm);
83 }
84
91 template <class Vec1, class Vec2>
92 void solve(const Vec1& rhs, Vec2& x) const
93 {
94 (*S)(rhs, x);
95 }
96
97 private:
98
99 params prm;
100 std::shared_ptr<Solver> S;
101};
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106} // namespace Arcane::Alina
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111#endif
DistributedEigenSparseLUDirectSolver(mpi_communicator comm, const Matrix &A, const params &prm=params())
Constructor.
void solve(const Vec1 &rhs, Vec2 &x) const
Solves the problem for the given right-hand side.
Wrapper around eigen direct solvers.
Definition EigenSolver.h:51
Matrix class, to be used by user.
Sparse matrix stored in CSR (Compressed Sparse Row) format.
Definition CSRMatrix.h:98
Convenience wrapper around MPI_Comm.