deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
trilinos_tpetra_solver_direct.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2024 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_trilinos_tpetra_solver_direct_h
14#define dealii_trilinos_tpetra_solver_direct_h
15
16#include <deal.II/base/config.h>
17
19
21
22#include <string>
23
24#ifdef DEAL_II_TRILINOS_WITH_TPETRA
25# ifdef DEAL_II_TRILINOS_WITH_AMESOS2
26
27# include <deal.II/base/types.h>
28
32
34# include <Amesos2.hpp>
35# include <Teuchos_ConfigDefs.hpp>
36# include <Teuchos_ParameterList.hpp>
37# include <Teuchos_RCPDecl.hpp>
39
40# endif // DEAL_II_TRILINOS_WITH_AMESOS2
41#endif // DEAL_II_TRILINOS_WITH_TPETRA
42
44
45#ifdef DEAL_II_TRILINOS_WITH_TPETRA
46# ifdef DEAL_II_TRILINOS_WITH_AMESOS2
47namespace LinearAlgebra
48{
49 namespace TpetraWrappers
50 {
51 // forward declarations
52# ifndef DOXYGEN
53 template <typename Number, typename MemorySpace>
54 class SparseMatrix;
55# endif
56
60 std::string,
61 << "You tried to select the solver type <" << arg1 << ">\n"
62 << "but this solver is not supported by Trilinos/Amesos2\n"
63 << "due to one of the following reasons:\n"
64 << "* This solver does not exist\n"
65 << "* This solver is not (yet) supported by Trilinos/Amesos2\n"
66 << "* Trilinos/Amesos2 was not configured for its use.");
67
68
75 template <typename Number, typename MemorySpace = ::MemorySpace::Host>
77 {
78 public:
82 virtual ~SolverDirectBase() = default;
83
90 void
92
98 void
101
108 void
112
113
118 control() const;
119
124 int,
125 << "An error with error number " << arg1
126 << " occurred while calling a Trilinos function");
127
128 protected:
138 void
140
148
152 Teuchos::RCP<
153 Amesos2::Solver<TpetraTypes::MatrixType<Number, MemorySpace>,
156
157 /*
158 * The set solver type to be handed to the solver factory of Amesos2.
159 */
160 std::string solver_type;
161
167 Teuchos::ParameterList parameter_list;
168 }; // Base
169
170
171
185 template <typename Number, typename MemorySpace = ::MemorySpace::Host>
186 class SolverDirect : public SolverDirectBase<Number, MemorySpace>
187 {
188 public:
195 {
196 AdditionalData(const std::string &solver_name = "KLU2");
197
198
222 std::string solver_name;
223 };
224
229 const AdditionalData &additional_data = AdditionalData());
230
237 void
238 set_pararameter_list(Teuchos::ParameterList &parameter_list);
239 }; // SolverDirect
240
241
252 template <typename Number, typename MemorySpace = ::MemorySpace::Host>
253 class SolverDirectKLU2 : public SolverDirectBase<Number, MemorySpace>
254 {
255 public:
262 {
263 AdditionalData(const std::string &transpose_mode = "NOTRANS",
264 const bool symmetric_mode = false,
265 const bool equilibrate_matrix = true,
266 const std::string &column_permutation = "COLAMD",
267 const std::string &iterative_refinement = "NO");
274 std::string transpose_mode;
275
280
285
294
303 };
304
309 SolverControl &cn,
310 const AdditionalData &additional_data = AdditionalData());
311 }; // KLU2
312
313 } // namespace TpetraWrappers
314} // namespace LinearAlgebra
315
316
317# endif // DEAL_II_TRILINOS_WITH_AMESOS2
318
319#endif // DEAL_II_TRILINOS_WITH_TPETRA
320
322
323#endif
void solve(const SparseMatrix< Number, MemorySpace > &A, Vector< Number, MemorySpace > &x, const Vector< Number, MemorySpace > &b)
void initialize(const SparseMatrix< Number, MemorySpace > &A)
SolverDirectBase(SolverControl &cn, const std::string &solver_type)
void solve(Vector< Number, MemorySpace > &x, const Vector< Number, MemorySpace > &b)
Teuchos::RCP< Amesos2::Solver< TpetraTypes::MatrixType< Number, MemorySpace >, TpetraTypes::MultiVectorType< Number, MemorySpace > > > solver
SolverDirectKLU2(SolverControl &cn, const AdditionalData &additional_data=AdditionalData())
void set_pararameter_list(Teuchos::ParameterList &parameter_list)
SolverDirect(SolverControl &cn, const AdditionalData &additional_data=AdditionalData())
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition config.h:636
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition config.h:680
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcTrilinosAmesos2SolverUnsupported(std::string arg1)
The chosen Solver is not supported or configured with Amesos2.
#define DeclException1(Exception1, type1, outsequence)
Tpetra::MultiVector< Number, LO, GO, NodeType< MemorySpace > > MultiVectorType
AdditionalData(const std::string &transpose_mode="NOTRANS", const bool symmetric_mode=false, const bool equilibrate_matrix=true, const std::string &column_permutation="COLAMD", const std::string &iterative_refinement="NO")
AdditionalData(const std::string &solver_name="KLU2")