19 #ifndef LIBMESH_PARALLEL_ALGEBRA_H
20 #define LIBMESH_PARALLEL_ALGEBRA_H
28 #include "libmesh/libmesh_config.h"
29 #include "libmesh/point.h"
30 #include "libmesh/tensor_value.h"
31 #include "libmesh/vector_value.h"
32 #include "libmesh/auto_ptr.h"
64 std::unique_ptr<TypeVector<T>> temp;
69 temp = libmesh_make_unique<TypeVector<T>>();
73 #ifdef LIBMESH_HAVE_MPI
74 StandardType<T> T_type(&((*ex)(0)));
77 int blocklength = LIBMESH_DIM;
78 MPI_Aint displs, start;
79 MPI_Datatype tmptype, type = T_type;
82 (MPI_Get_address (ex, &start));
84 (MPI_Get_address (&((*ex)(0)), &displs));
91 (MPI_Type_create_struct (1, &blocklength, &displs, &type,
94 (MPI_Type_commit (&tmptype));
102 (MPI_Type_commit (&_datatype));
105 (MPI_Type_free (&tmptype));
106 #endif // #ifdef LIBMESH_HAVE_MPI
112 timpi_call_mpi (MPI_Type_dup (t._datatype, &_datatype));
119 template <
typename T>
127 std::unique_ptr<VectorValue<T>> temp;
132 temp = libmesh_make_unique<VectorValue<T>>();
136 #ifdef LIBMESH_HAVE_MPI
137 StandardType<T> T_type(&((*ex)(0)));
139 int blocklength = LIBMESH_DIM;
140 MPI_Aint displs, start;
141 MPI_Datatype tmptype, type = T_type;
144 (MPI_Get_address (ex, &start));
146 (MPI_Get_address (&((*ex)(0)), &displs));
153 (MPI_Type_create_struct (1, &blocklength, &displs, &type,
156 (MPI_Type_commit (&tmptype));
160 (MPI_Type_create_resized (tmptype, 0,
165 (MPI_Type_commit (&_datatype));
168 (MPI_Type_free (&tmptype));
169 #endif // #ifdef LIBMESH_HAVE_MPI
175 #ifdef LIBMESH_HAVE_MPI
176 timpi_call_mpi (MPI_Type_dup (t._datatype, &_datatype));
185 class StandardType<
Point> :
public DataType
194 #ifdef LIBMESH_HAVE_MPI
199 std::unique_ptr<Point> temp;
201 ex = const_cast<Point *>(example);
204 temp = libmesh_make_unique<Point>();
208 StandardType<libMesh::Real> T_type(&((*ex)(0)));
210 int blocklength = LIBMESH_DIM;
211 MPI_Aint displs, start;
212 MPI_Datatype tmptype, type = T_type;
215 (MPI_Get_address (ex, &start));
217 (MPI_Get_address (&((*ex)(0)), &displs));
224 (MPI_Type_create_struct (1, &blocklength, &displs, &type,
227 (MPI_Type_commit (&tmptype));
231 (MPI_Type_create_resized (tmptype, 0,
sizeof(
Point),
235 (MPI_Type_commit (&_datatype));
238 (MPI_Type_free (&tmptype));
239 #endif // #ifdef LIBMESH_HAVE_MPI
245 timpi_call_mpi (MPI_Type_dup (t._datatype, &_datatype));
263 template <
typename V>
267 #ifdef LIBMESH_HAVE_MPI
268 static void vector_max (
void * invec,
void * inoutvec,
int * len, MPI_Datatype *)
270 V *in = static_cast<V *>(invec);
271 V *inout = static_cast<V *>(inoutvec);
272 for (
int i=0; i != *len; ++i)
273 for (
int d=0; d != LIBMESH_DIM; ++d)
274 inout[i](d) = std::max(in[i](d), inout[i](d));
277 static void vector_min (
void * invec,
void * inoutvec,
int * len, MPI_Datatype *)
279 V *in = static_cast<V *>(invec);
280 V *inout = static_cast<V *>(inoutvec);
281 for (
int i=0; i != *len; ++i)
282 for (
int d=0; d != LIBMESH_DIM; ++d)
283 inout[i](d) = std::min(in[i](d), inout[i](d));
286 static void vector_sum (
void * invec,
void * inoutvec,
int * len, MPI_Datatype *)
288 V *in = static_cast<V *>(invec);
289 V *inout = static_cast<V *>(inoutvec);
290 for (
int i=0; i != *len; ++i)
291 for (
int d=0; d != LIBMESH_DIM; ++d)
292 inout[i](d) += in[i](d);
299 static MPI_Op _static_op;
316 static MPI_Op _static_op;
333 static MPI_Op _static_op;
347 #endif // LIBMESH_HAVE_MPI
350 template <
typename T>
353 template <
typename T>
363 template <
typename T>
369 DataType(StandardType<T>(example ? &((*example)(0,0)) : nullptr), LIBMESH_DIM*LIBMESH_DIM) {}
374 template <
typename T>
380 DataType(StandardType<T>(example ? &((*example)(0,0)) : nullptr), LIBMESH_DIM*LIBMESH_DIM) {}
386 #endif // LIBMESH_PARALLEL_ALGEBRA_H