Debian Codegraph @

include/deal.II/lac/trilinos_tpetra_types.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2018 - 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_types_h
16 #define dealii_trilinos_tpetra_types_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/base/types.h>
21
22 #ifdef DEAL_II_TRILINOS_WITH_TPETRA
23
24 # include <deal.II/base/memory_space.h>
25
26 # include <Kokkos_DualView.hpp>
27 # include <Tpetra_Details_DefaultTypes.hpp>
28
29
30 // Forward declarations
31 # ifndef DOXYGEN
32 # ifdef DEAL_II_TRILINOS_WITH_IFPACK2
33 # include <Ifpack2_Preconditioner.hpp>
34 # endif
35 # include <Tpetra_CrsGraph_fwd.hpp>
36 # include <Tpetra_CrsMatrix_fwd.hpp>
37 # include <Tpetra_Export_fwd.hpp>
38 # include <Tpetra_Import_fwd.hpp>
39 # include <Tpetra_Map_fwd.hpp>
40 # include <Tpetra_MultiVector_fwd.hpp>
41 # include <Tpetra_Operator_fwd.hpp>
42 # include <Tpetra_RowMatrix_fwd.hpp>
43 # include <Tpetra_Vector_fwd.hpp>
44 # endif
45
46 DEAL_II_NAMESPACE_OPEN
47
48 namespace LinearAlgebra
49 {
50 namespace TpetraWrappers
51 {
52
53 namespace TpetraTypes
54 {
55 /**
56 * local ordinate (processor local indices).
57 */
58 using LO = int;
59
60
61 /**
62 * global ordinate (global indices).
63 */
64 using GO = types::signed_global_dof_index;
65
66
67 # if DEAL_II_TRILINOS_VERSION_GTE(14, 2, 0)
68 /**
69 * Where and how calculations should be executed,
70 * i.e. Host (Serial,OpenMP) or Device (GPU)
71 */
72 //
73 template <typename MemorySpace>
74 using NodeType = Tpetra::KokkosCompat::KokkosDeviceWrapperNode<
75 typename MemorySpace::kokkos_space::execution_space,
76 typename MemorySpace::kokkos_space>;
77 # else
78 template <typename MemorySpace>
79 using NodeType = Kokkos::Compat::KokkosDeviceWrapperNode<
80 typename MemorySpace::kokkos_space::execution_space,
81 typename MemorySpace::kokkos_space>;
82 # endif
83
84 /**
85 * Communication between processors.
86 */
87 template <typename MemorySpace>
88 using ExportType = Tpetra::Export<LO, GO, NodeType<MemorySpace>>;
89
90 /**
91 * Communication between processors.
92 */
93 template <typename MemorySpace>
94 using ImportType = Tpetra::Import<LO, GO, NodeType<MemorySpace>>;
95
96 /**
97 * Tpetra equivalent of IndexSet.
98 */
99 template <typename MemorySpace>
100 using MapType = Tpetra::Map<LO, GO, NodeType<MemorySpace>>;
101
102 /**
103 * Tpetra sparsity pattern type.
104 */
105 template <typename MemorySpace>
106 using GraphType = Tpetra::CrsGraph<LO, GO, NodeType<MemorySpace>>;
107
108 /**
109 * Tpetra Vector type.
110 */
111 template <typename Number, typename MemorySpace>
112 using VectorType = Tpetra::Vector<Number, LO, GO, NodeType<MemorySpace>>;
113
114 /**
115 * Tpetra type for a row column vectors.
116 */
117 template <typename Number, typename MemorySpace>
118 using MultiVectorType =
119 Tpetra::MultiVector<Number, LO, GO, NodeType<MemorySpace>>;
120
121
122 /**
123 * General Tpetra class for a linear operator,
124 * e.g. a Matrix or Preconditioner.
125 *
126 */
127 template <typename Number, typename MemorySpace>
128 using LinearOperator =
129 Tpetra::Operator<Number, LO, GO, NodeType<MemorySpace>>;
130
131
132 /**
133 * Tpetra type for a parallel distributed sparse matrix in Crs or CSR
134 * format.
135 */
136 template <typename Number, typename MemorySpace>
137 using MatrixType =
138 Tpetra::CrsMatrix<Number, LO, GO, NodeType<MemorySpace>>;
139
140
141 /**
142 * Tpetra type for a parallel distributed row matrix.
143 */
144 template <typename Number, typename MemorySpace>
145 using RowMatrixType =
146 Tpetra::RowMatrix<Number, LO, GO, NodeType<MemorySpace>>;
147
148 /**
149 * @brief Typedef for the Kokkos::DualView type.
150 * This is needed for shallow copies of deal.II LA structures
151 * to Trilinos LA structures.
152 */
153 template <typename Number, typename MemorySpace>
154 using DualViewType =
155 typename VectorType<Number, MemorySpace>::dual_view_type;
156
157 /**
158 * @brief Typedef for the Kokkos::View type.
159 * This is needed for shallow copies of deal.II LA structures
160 * to Trilinos LA structures.
161 *
162 */
163 template <typename Number>
164 using HostViewType =
165 typename DualViewType<Number, dealii::MemorySpace::Host>::t_host;
166
167 # ifdef DEAL_II_TRILINOS_WITH_IFPACK2
168 /**
169 * Type for a Trilinos preconditioner from the Ifpack2 package.
170 */
171 template <typename Number, typename MemorySpace>
172 using Ifpack2PreconType =
173 Ifpack2::Preconditioner<Number, LO, GO, NodeType<MemorySpace>>;
174 # endif
175
176 } // namespace TpetraTypes
177 } // namespace TpetraWrappers
178 } // namespace LinearAlgebra
179 DEAL_II_NAMESPACE_CLOSE
180
181 #else
182
183 // Make sure the scripts that create the C++20 module input files have
184 // something to latch on if the preprocessor #ifdef above would
185 // otherwise lead to an empty content of the file.
186 DEAL_II_NAMESPACE_OPEN
187 DEAL_II_NAMESPACE_CLOSE
188
189 #endif
190
191 #endif