BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
commtypes.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef COMMTYPES_HPP
13#define COMMTYPES_HPP
14
15#include <complex>
16
17#ifdef BELFEM_MPI
18#include <mpi.h>
19#endif
20
21namespace belfem
22{
23#ifdef BELFEM_MPI
24 typedef MPI_Datatype comm_t ;
25#else
26 // define fake type if there is no MPI
27 typedef int comm_t;
28#endif
29 typedef int proc_t ;
30
31//------------------------------------------------------------------------------
32
36 template<typename T> comm_t
38 {
39#ifdef BELFEM_MPI
40 BELFEM_ERROR( false, "Unknown datatype");
41 return MPI_DATATYPE_NULL;
42#else
43 return 0 ;
44#endif
45 }
46
47// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48#ifdef BELFEM_MPI
49// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50
51 template<> inline comm_t
53 {
54 return MPI_CHAR;
55 }
56
57// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58
59 template<> inline comm_t
61 {
62 return MPI_INT;
63 }
64
65// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
66
67 template<> inline comm_t
69 {
70 return MPI_LONG;
71 }
72
73// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74
75 template<> inline comm_t
77 {
78 return MPI_UNSIGNED_SHORT;
79 }
80
81// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
82
83 template<> inline comm_t
85 {
86 return MPI_UNSIGNED;
87 }
88
89// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90
91 template<> inline comm_t
93 {
94 return MPI_UNSIGNED_LONG;
95 }
96
97// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98
99 template<> inline comm_t
101 {
102 return MPI_DOUBLE ;
103 }
104
105// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106
107 template<> inline comm_t
109 {
110 return MPI_LONG_DOUBLE ;
111 }
112
113
114// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115
116 template<> inline comm_t
118 {
119 return MPI_SIGNED_CHAR;
120 }
121
122// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
123
124 template<> inline comm_t
126 {
127 return MPI_UNSIGNED_CHAR;
128 }
129
130// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131
132 template<> inline comm_t
134 {
135 return MPI_SHORT;
136 }
137
138// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139
140 template<> inline comm_t
142 {
143 return MPI_LONG_LONG;
144 }
145
146// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
147
148 template<> inline comm_t
150 {
151 return MPI_UNSIGNED_LONG_LONG;
152 }
153
154// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
155
156 template<> inline comm_t
158 {
159 return MPI_FLOAT;
160 }
161
162// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
163
164 template<> inline comm_t
166 {
167 return MPI_CXX_BOOL;
168 }
169
170// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
171
172#ifdef MPI_CXX_FLOAT_COMPLEX
173 template<> inline comm_t
175 {
176 return MPI_CXX_FLOAT_COMPLEX;
177 }
178#endif
179
180 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
181
182#ifdef MPI_CXX_DOUBLE_COMPLEX
183 template<> inline comm_t
185 {
186 return MPI_CXX_DOUBLE_COMPLEX ;
187 }
188#endif
189
190// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
191
192#ifdef MPI_CXX_LONG_DOUBLE_COMPLEX
193 template<> inline comm_t
195 {
196 return MPI_CXX_LONG_DOUBLE_COMPLEX ;
197 }
198#endif
199
200// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
201
202#endif // BELFEM_MPI
203//------------------------------------------------------------------------------
204}
205
206#endif //COMMTYPES_HPP
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
USER GUIDES:
Definition cl_Capacitor.cpp:16
comm_t comm_type()
returns the MPI datatype handle for T
Definition commtypes.hpp:37
int comm_t
Definition commtypes.hpp:27
int proc_t
Definition commtypes.hpp:29