Debian Codegraph @

include/deal.II/lac/trilinos_index_access.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2017 - 2024 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_index_access_h
16 #define dealii_trilinos_index_access_h
17
18 #include <deal.II/base/config.h>
19
20 #ifdef DEAL_II_WITH_TRILINOS
21
22 # include <deal.II/base/types.h>
23
24
25 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
26 # include <Epetra_BlockMap.h>
27 # include <Epetra_CrsGraph.h>
28 # include <Epetra_CrsMatrix.h>
29 # include <Epetra_MultiVector.h>
30 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
31
32 DEAL_II_NAMESPACE_OPEN
33
34 namespace TrilinosWrappers
35 {
36 /**
37 * A helper function that queries the size of an Epetra_BlockMap object. We
38 * always call the 64 bit function to get the number of global elements in the
39 * map.
40 */
41 inline TrilinosWrappers::types::int64_type
42 n_global_elements(const Epetra_BlockMap &map)
43 {
44 return map.NumGlobalElements64();
45 }
46
47 /**
48 * A helper function that finds the minimum global index value on the
49 * calling processor by calling either the 32 or 64 bit function.
50 */
51 inline TrilinosWrappers::types::int_type
52 min_my_gid(const Epetra_BlockMap &map)
53 {
54 # ifdef DEAL_II_WITH_64BIT_INDICES
55 return map.MinMyGID64();
56 # else
57 return map.MinMyGID();
58 # endif
59 }
60
61 /**
62 * A helper function that finds the maximum global index value on the
63 * calling processor by calling either the 32 or 64 bit function.
64 */
65 inline TrilinosWrappers::types::int_type
66 max_my_gid(const Epetra_BlockMap &map)
67 {
68 # ifdef DEAL_II_WITH_64BIT_INDICES
69 return map.MaxMyGID64();
70 # else
71 return map.MaxMyGID();
72 # endif
73 }
74
75 /**
76 * A helper function that converts a local index to a global one calling
77 * either the 32 or 64 bit function.
78 */
79 inline TrilinosWrappers::types::int_type
80 global_index(const Epetra_BlockMap &map,
81 const dealii::types::global_dof_index i)
82 {
83 # ifdef DEAL_II_WITH_64BIT_INDICES
84 return map.GID64(i);
85 # else
86 return map.GID(i);
87 # endif
88 }
89
90 /**
91 * A helper function that returns a pointer to the array containing the
92 * global indices assigned to the current process by calling either the 32
93 * or 64 bit function.
94 */
95 inline TrilinosWrappers::types::int_type *
96 my_global_elements(const Epetra_BlockMap &map)
97 {
98 # ifdef DEAL_II_WITH_64BIT_INDICES
99 return map.MyGlobalElements64();
100 # else
101 return map.MyGlobalElements();
102 # endif
103 }
104
105 /**
106 * A helper function that finds the global number of rows by calling
107 * either the 32 or 64 bit function.
108 */
109 inline TrilinosWrappers::types::int_type
110 n_global_rows(const Epetra_CrsGraph &graph)
111 {
112 # ifdef DEAL_II_WITH_64BIT_INDICES
113 return graph.NumGlobalRows64();
114 # else
115 return graph.NumGlobalRows();
116 # endif
117 }
118
119 /**
120 * A helper function that finds the global number of columns by calling
121 * either the 32 or 64 bit function.
122 */
123 inline TrilinosWrappers::types::int_type
124 n_global_cols(const Epetra_CrsGraph &graph)
125 {
126 # ifdef DEAL_II_WITH_64BIT_INDICES
127 return graph.NumGlobalCols64();
128 # else
129 return graph.NumGlobalCols();
130 # endif
131 }
132
133 /**
134 * A helper function that finds the number of global entries. We always call
135 * the 64 bit function.
136 */
137 inline TrilinosWrappers::types::int64_type
138 n_global_entries(const Epetra_CrsGraph &graph)
139 {
140 return graph.NumGlobalEntries64();
141 }
142
143 /**
144 * A helper function that finds the global row index by calling
145 * either the 32 or 64 bit function.
146 */
147 inline TrilinosWrappers::types::int_type
148 global_row_index(const Epetra_CrsMatrix &matrix,
149 const dealii::types::global_dof_index i)
150 {
151 # ifdef DEAL_II_WITH_64BIT_INDICES
152 return matrix.GRID64(i);
153 # else
154 return matrix.GRID(i);
155 # endif
156 }
157
158 /**
159 * A helper function that finds the global column index by calling
160 * either the 32 or 64 bit function.
161 */
162 inline TrilinosWrappers::types::int_type
163 global_column_index(const Epetra_CrsMatrix &matrix,
164 const dealii::types::global_dof_index i)
165 {
166 # ifdef DEAL_II_WITH_64BIT_INDICES
167 return matrix.GCID64(i);
168 # else
169 return matrix.GCID(i);
170 # endif
171 }
172
173 /**
174 * A helper function that finds the global length of a vector by calling
175 * either the 32 or 64 bit function.
176 */
177 inline TrilinosWrappers::types::int_type
178 global_length(const Epetra_MultiVector &vector)
179 {
180 # ifdef DEAL_II_WITH_64BIT_INDICES
181 return vector.GlobalLength64();
182 # else
183 return vector.GlobalLength();
184 # endif
185 }
186
187 /**
188 * A helper function that finds the global number of rows by calling
189 * either the 32 or 64 bit function.
190 */
191 inline TrilinosWrappers::types::int_type
192 n_global_rows(const Epetra_RowMatrix &matrix)
193 {
194 # ifdef DEAL_II_WITH_64BIT_INDICES
195 return matrix.NumGlobalRows64();
196 # else
197 return matrix.NumGlobalRows();
198 # endif
199 }
200 } // namespace TrilinosWrappers
201
202 DEAL_II_NAMESPACE_CLOSE
203
204 #else
205
206 // Make sure the scripts that create the C++20 module input files have
207 // something to latch on if the preprocessor #ifdef above would
208 // otherwise lead to an empty content of the file.
209 DEAL_II_NAMESPACE_OPEN
210 DEAL_II_NAMESPACE_CLOSE
211
212 #endif // DEAL_II_WITH_TRILINOS
213 #endif // dealii_trilinos_index_access_h