Arcane  v4.1.10.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 value_type>
49: public DistributedDirectSolverBase<value_type, DistributedEigenSparseLUDirectSolver<value_type>>
50{
51 public:
52
53 using EigenMatrix = Eigen::SparseMatrix<value_type, Eigen::ColMajor, int>;
55 typedef typename Solver::params params;
56 typedef CSRMatrix<value_type> build_matrix;
57
59 template <class Matrix>
61 const params& prm = params())
62 : prm(prm)
63 {
64 static_cast<Base*>(this)->init(comm, A);
65 }
66
67 static size_t coarse_enough()
68 {
69 return Base::coarse_enough();
70 }
71
72 int comm_size(int /*n*/) const
73 {
74 return 1;
75 }
76
77 void init(mpi_communicator, const build_matrix& A)
78 {
79 S = std::make_shared<Solver>(A, prm);
80 }
81
88 template <class Vec1, class Vec2>
89 void solve(const Vec1& rhs, Vec2& x) const
90 {
91 (*S)(rhs, x);
92 }
93
94 private:
95
97 params prm;
98 std::shared_ptr<Solver> S;
99};
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103
104} // namespace Arcane::Alina
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109#endif
Base class for distributed direct solver.
void solve(const Vec1 &rhs, Vec2 &x) const
Solves the problem for the given right-hand side.
DistributedEigenSparseLUDirectSolver(mpi_communicator comm, const Matrix &A, const params &prm=params())
Constructor.
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.