deal.II version 9.7.0
\(\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: LGPL-2.1-or-later
4// Copyright (C) 2024 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_trilinos_tpetra_solver_direct_h
16#define dealii_trilinos_tpetra_solver_direct_h
17
18#include <deal.II/base/config.h>
19
21
23
24#include <string>
25
26#ifdef DEAL_II_TRILINOS_WITH_TPETRA
27# ifdef DEAL_II_TRILINOS_WITH_AMESOS2
28
29# include <deal.II/base/types.h>
30
34
36# include <Amesos2.hpp>
37# include <Teuchos_ConfigDefs.hpp>
38# include <Teuchos_ParameterList.hpp>
39# include <Teuchos_RCPDecl.hpp>
41
43
44namespace LinearAlgebra
45{
46 namespace TpetraWrappers
47 {
48 // forward declarations
49# ifndef DOXYGEN
50 template <typename Number, typename MemorySpace>
51 class SparseMatrix;
52# endif
53
57 std::string,
58 << "You tried to select the solver type <" << arg1 << ">\n"
59 << "but this solver is not supported by Trilinos/Amesos2\n"
60 << "due to one of the following reasons:\n"
61 << "* This solver does not exist\n"
62 << "* This solver is not (yet) supported by Trilinos/Amesos2\n"
63 << "* Trilinos/Amesos2 was not configured for its use.");
64
65
72 template <typename Number, typename MemorySpace = ::MemorySpace::Host>
74 {
75 public:
79 virtual ~SolverDirectBase() = default;
80
87 void
89
95 void
98
105 void
109
110
115 control() const;
116
121 int,
122 << "An error with error number " << arg1
123 << " occurred while calling a Trilinos function");
124
125 protected:
135 void
137
145
149 Teuchos::RCP<
150 Amesos2::Solver<TpetraTypes::MatrixType<Number, MemorySpace>,
153
154 /*
155 * The set solver type to be handed to the solver factory of Amesos2.
156 */
157 std::string solver_type;
158
164 Teuchos::ParameterList parameter_list;
165 }; // Base
166
167
168
182 template <typename Number, typename MemorySpace = ::MemorySpace::Host>
183 class SolverDirect : public SolverDirectBase<Number, MemorySpace>
184 {
185 public:
192 {
193 AdditionalData(const std::string &solver_name);
194
195
219 std::string solver_name;
220 };
221
226 const AdditionalData &additional_data = AdditionalData());
227
234 void
235 set_pararameter_list(Teuchos::ParameterList &parameter_list);
236 }; // SolverDirect
237
238
249 template <typename Number, typename MemorySpace = ::MemorySpace::Host>
250 class SolverDirectKLU2 : public SolverDirectBase<Number, MemorySpace>
251 {
252 public:
259 {
260 AdditionalData(const std::string &transpose_mode = "NOTRANS",
261 const bool symmetric_mode = false,
262 const bool equilibrate_matrix = true,
263 const std::string &column_permutation = "COLAMD",
264 const std::string &iterative_refinement = "NO");
271 std::string transpose_mode;
272
277
282
291
300 };
301
306 SolverControl &cn,
307 const AdditionalData &additional_data = AdditionalData());
308 }; // KLU2
309
310 } // namespace TpetraWrappers
311} // namespace LinearAlgebra
312
314
315# endif // DEAL_II_TRILINOS_WITH_AMESOS2
316#else
317
318// Make sure the scripts that create the C++20 module input files have
319// something to latch on if the preprocessor #ifdef above would
320// otherwise lead to an empty content of the file.
323
324#endif // DEAL_II_TRILINOS_WITH_TPETRA
325
326#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:40
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition config.h:603
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:41
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition config.h:647
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")