MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
solver.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_BATCHED_SOLVER
13#define MFEM_BATCHED_SOLVER
14
15#include "batched.hpp"
16#include "../operator.hpp"
17
18namespace mfem
19{
20
21/// @brief Solve block-diagonal systems using batched LU or inverses.
22///
23/// LU factorization is more numerically stable, but exposes less fine-grained
24/// parallelism. Inverse matrices have worse conditioning (and increased setup
25/// time), but solving the system is more efficient in parallel (e.g. on GPUs).
27{
28public:
29 /// %Solver mode: whether to use LU factorization or inverses.
30 enum Mode
31 {
32 LU, ///< LU factorization.
33 INVERSE ///< Inverse matrices.
34 };
35protected:
36 DenseTensor A; ///< The LU factors/inverses of the input matrices.
37 Array<int> P; ///< Pivots (needed only for LU factors).
38 Mode mode; ///< Solver mode.
39 BatchedLinAlg::Backend backend; ///< Requested batched linear algebra backend.
40public:
41 /// @brief Constructor.
42 ///
43 /// The DenseTensor @a A_ has dimensions $(m, m, n)$, and represents a block
44 /// diagonal matrix $A$ with $n$ blocks of size $m \times m$.
45 ///
46 /// A deep copy is made of the input @a A_, and so it does not need to be
47 /// retained by the caller.
48 BatchedDirectSolver(const DenseTensor &A_, Mode mode_,
49 BatchedLinAlg::Backend backend_ =
51 /// Sets $y = A^{-1} x$.
52 void Mult(const Vector &x, Vector &y) const;
53 /// Not supported (aborts).
54 void SetOperator(const Operator &op);
55};
56
57} // namespace mfem
58
59#endif
Solve block-diagonal systems using batched LU or inverses.
Definition solver.hpp:27
Mode mode
Solver mode.
Definition solver.hpp:38
DenseTensor A
The LU factors/inverses of the input matrices.
Definition solver.hpp:36
Mode
Solver mode: whether to use LU factorization or inverses.
Definition solver.hpp:31
@ INVERSE
Inverse matrices.
Definition solver.hpp:33
@ LU
LU factorization.
Definition solver.hpp:32
void Mult(const Vector &x, Vector &y) const
Sets .
Definition solver.cpp:32
BatchedDirectSolver(const DenseTensor &A_, Mode mode_, BatchedLinAlg::Backend backend_=BatchedLinAlg::GetActiveBackend())
Constructor.
Definition solver.cpp:17
void SetOperator(const Operator &op)
Not supported (aborts).
Definition solver.cpp:45
Array< int > P
Pivots (needed only for LU factors).
Definition solver.hpp:37
BatchedLinAlg::Backend backend
Requested batched linear algebra backend.
Definition solver.hpp:39
Backend
Available backends for implementations of batched algorithms.
Definition batched.hpp:39
static Backend GetActiveBackend()
Get the default backend for batched linear algebra operations.
Definition batched.cpp:98
Rank 3 tensor (array of matrices)
Abstract operator.
Definition operator.hpp:25
Base class for solvers.
Definition operator.hpp:780
Vector data type.
Definition vector.hpp:82