19 #ifndef LIBMESH_STANDARD_TYPE_H 20 #define LIBMESH_STANDARD_TYPE_H 35 #include <type_traits> 68 "Only specializations of StandardType may be used, did you forget to include a header file (e.g. parallel_algebra.h)?");
85 #ifdef LIBMESH_HAVE_MPI 87 #define LIBMESH_STANDARD_TYPE(cxxtype,mpitype) \ 89 class StandardType<cxxtype> : public DataType \ 93 StandardType(const cxxtype * = nullptr) : DataType(mpitype) {} \ 98 #define LIBMESH_STANDARD_TYPE(cxxtype,mpitype) \ 100 class StandardType<cxxtype> : public DataType \ 104 StandardType(const cxxtype * = nullptr) : DataType() {} \ 124 template<
typename T1,
typename T2>
131 static const std::pair<T1, T2> p;
135 #ifdef LIBMESH_HAVE_MPI 143 int blocklengths[] = {1,1};
144 MPI_Aint displs[2], start;
147 (MPI_Get_address (
const_cast<std::pair<T1,T2> *
>(example),
150 (MPI_Get_address (const_cast<T1*>(&example->first),
153 (MPI_Get_address (const_cast<T2*>(&example->second),
159 MPI_Datatype tmptype;
161 (MPI_Type_create_struct (2, blocklengths, displs, types,
164 (MPI_Type_commit (&tmptype));
168 (MPI_Type_create_resized (tmptype, 0,
169 sizeof(std::pair<T1,T2>),
172 (MPI_Type_free (&tmptype));
176 #endif // LIBMESH_HAVE_MPI 183 (MPI_Type_dup (t._datatype, &
_datatype));
193 template<std::
size_t n_minus_i>
196 template<
typename... Types>
197 static void build(std::vector<std::unique_ptr<DataType>> & out_vec,
198 const std::tuple<Types...> & example);
204 template<
typename... Types>
205 static void build(std::vector<std::unique_ptr<DataType>> & ,
206 const std::tuple<Types...> & ) {}
209 template<std::
size_t n_minus_i>
210 template<
typename... Types>
212 (std::vector<std::unique_ptr<DataType>> & out_vec,
213 const std::tuple<Types...> & example)
216 std::tuple_element<
sizeof...(Types)-n_minus_i, std::tuple<Types...>>::type
220 (libmesh_make_unique<
222 >(&
std::get<
sizeof...(Types)-n_minus_i>(example)));
228 template<std::
size_t n_minus_i>
231 template <
typename OutArray,
class... Types>
232 static void fill(OutArray &
out,
233 const std::tuple<Types...> & example);
239 template <
typename OutArray,
typename... Types>
241 const std::tuple<Types...> & ) {}
245 template<std::
size_t n_minus_i>
246 template<
typename OutArray,
typename... Types>
249 const std::tuple<Types...> & example)
253 (&
std::get<
sizeof...(Types)-n_minus_i>(example),
254 &out_vec[
sizeof...(Types)-n_minus_i]));
260 template<
typename... Types>
267 static const std::tuple<Types...> t;
271 #ifdef LIBMESH_HAVE_MPI 275 (MPI_Get_address (example, &start));
277 const std::size_t tuplesize =
sizeof...(Types);
279 std::vector<std::unique_ptr<DataType>> subtypes;
282 std::array<MPI_Aint,
sizeof...(Types)> displs;
285 std::array<MPI_Datatype,
sizeof...(Types)> types;
286 std::array<int,
sizeof...(Types)> blocklengths;
288 for (std::size_t i = 0; i != tuplesize; ++i)
296 MPI_Datatype tmptype;
298 (MPI_Type_create_struct (tuplesize, blocklengths.data(), displs.data(), types.data(),
301 (MPI_Type_commit (&tmptype));
305 (MPI_Type_create_resized (tmptype, 0,
306 sizeof(std::tuple<Types...>),
309 (MPI_Type_free (&tmptype));
313 #endif // LIBMESH_HAVE_MPI 320 (MPI_Type_dup (t._datatype, &
_datatype));
344 #endif // LIBMESH_STANDARD_TYPE_H StandardType(const std::complex< T > *=nullptr)
static void build(std::vector< std::unique_ptr< DataType >> &out_vec, const std::tuple< Types... > &example)
LIBMESH_STANDARD_TYPE(char, MPI_CHAR)
static void fill(OutArray &out, const std::tuple< Types... > &example)
StandardType(const StandardType< std::tuple< Types... >> &t)
StandardType(const StandardType< std::pair< T1, T2 >> &t)
static void build(std::vector< std::unique_ptr< DataType >> &, const std::tuple< Types... > &)
StandardType(const std::tuple< Types... > *example=nullptr)
StandardType(const std::pair< T1, T2 > *example=nullptr)
StandardType(const T *example=nullptr)
static void fill(OutArray &, const std::tuple< Types... > &)
OStreamProxy out(std::cout)
const Elem & get(const ElemType type_in)