19 #ifndef LIBMESH_PARALLEL_ALGEBRA_H 20 #define LIBMESH_PARALLEL_ALGEBRA_H 24 #include "libmesh/libmesh_config.h" 25 #include "libmesh/point.h" 26 #include "libmesh/tensor_value.h" 27 #include "libmesh/vector_value.h" 37 #include <type_traits> 57 #ifdef LIBMESH_HAVE_MPI 58 static void vector_max (
void * invec,
void * inoutvec,
int * len, MPI_Datatype *)
60 V *in =
static_cast<V *
>(invec);
61 V *inout =
static_cast<V *
>(inoutvec);
62 for (
int i=0; i != *len; ++i)
63 for (
int d=0; d != LIBMESH_DIM; ++d)
64 inout[i](d) = std::max(in[i](d), inout[i](d));
67 static void vector_min (
void * invec,
void * inoutvec,
int * len, MPI_Datatype *)
69 V *in =
static_cast<V *
>(invec);
70 V *inout =
static_cast<V *
>(inoutvec);
71 for (
int i=0; i != *len; ++i)
72 for (
int d=0; d != LIBMESH_DIM; ++d)
73 inout[i](d) = std::min(in[i](d), inout[i](d));
76 static void vector_sum (
void * invec,
void * inoutvec,
int * len, MPI_Datatype *)
78 V *in =
static_cast<V *
>(invec);
79 V *inout =
static_cast<V *
>(inoutvec);
80 for (
int i=0; i != *len; ++i)
81 for (
int d=0; d != LIBMESH_DIM; ++d)
82 inout[i](d) += in[i](d);
89 static MPI_Op _static_op;
106 static MPI_Op _static_op;
123 static MPI_Op _static_op;
137 #endif // LIBMESH_HAVE_MPI 141 template <
typename V>
146 for (
int d=0; d != LIBMESH_DIM; ++d)
150 for (
int d=0; d != LIBMESH_DIM; ++d)
166 template <
typename T>
178 std::unique_ptr<TypeVector<T>> temp;
180 ex =
const_cast<TypeVector<T> *
>(example);
183 temp = std::make_unique<TypeVector<T>>();
187 #ifdef LIBMESH_HAVE_MPI 191 int blocklength = LIBMESH_DIM;
192 MPI_Aint displs, start;
193 MPI_Datatype tmptype, type = T_type;
196 (MPI_Get_address (ex, &start));
198 (MPI_Get_address (&((*ex)(0)), &displs));
205 (MPI_Type_create_struct (1, &blocklength, &displs, &type,
208 (MPI_Type_commit (&tmptype));
212 (MPI_Type_create_resized (tmptype, 0,
sizeof(TypeVector<T>),
216 (MPI_Type_commit (&_datatype));
219 (MPI_Type_free (&tmptype));
220 #endif // #ifdef LIBMESH_HAVE_MPI 226 timpi_call_mpi (MPI_Type_dup (t._datatype, &_datatype));
235 template <
typename T>
236 class StandardType<
libMesh::VectorValue<T>, typename std::enable_if<StandardType<T>::is_fixed_type>::type>
247 std::unique_ptr<VectorValue<T>> temp;
249 ex =
const_cast<VectorValue<T> *
>(example);
252 temp = std::make_unique<VectorValue<T>>();
256 #ifdef LIBMESH_HAVE_MPI 259 int blocklength = LIBMESH_DIM;
260 MPI_Aint displs, start;
261 MPI_Datatype tmptype, type = T_type;
264 (MPI_Get_address (ex, &start));
266 (MPI_Get_address (&((*ex)(0)), &displs));
273 (MPI_Type_create_struct (1, &blocklength, &displs, &type,
276 (MPI_Type_commit (&tmptype));
280 (MPI_Type_create_resized (tmptype, 0,
281 sizeof(VectorValue<T>),
285 (MPI_Type_commit (&_datatype));
288 (MPI_Type_free (&tmptype));
289 #endif // #ifdef LIBMESH_HAVE_MPI 295 #ifdef LIBMESH_HAVE_MPI 296 timpi_call_mpi (MPI_Type_dup (t._datatype, &_datatype));
317 #ifdef LIBMESH_HAVE_MPI 322 std::unique_ptr<Point> temp;
324 ex =
const_cast<Point *
>(example);
327 temp = std::make_unique<Point>();
333 int blocklength = LIBMESH_DIM;
334 MPI_Aint displs, start;
335 MPI_Datatype tmptype, type = T_type;
338 (MPI_Get_address (ex, &start));
340 (MPI_Get_address (&((*ex)(0)), &displs));
347 (MPI_Type_create_struct (1, &blocklength, &displs, &type,
350 (MPI_Type_commit (&tmptype));
354 (MPI_Type_create_resized (tmptype, 0,
sizeof(Point),
358 (MPI_Type_commit (&_datatype));
361 (MPI_Type_free (&tmptype));
362 #endif // #ifdef LIBMESH_HAVE_MPI 368 timpi_call_mpi (MPI_Type_dup (t._datatype, &_datatype));
376 template <
typename T>
379 template <
typename T>
386 template <
typename T>
389 template <
typename T>
400 template <
typename T>
414 template <
typename T>
415 class StandardType<
libMesh::TensorValue<T>, typename std::enable_if<StandardType<T>::is_fixed_type>::type>
429 #endif // LIBMESH_PARALLEL_ALGEBRA_H static void vector_min(void *invec, void *inoutvec, int *len, MPI_Datatype *)
static void set_lowest(V &x)
StandardType(const libMesh::TypeVector< T > *example=nullptr)
static void vector_sum(void *invec, void *inoutvec, int *len, MPI_Datatype *)
StandardType(const StandardType< libMesh::Point > &timpi_mpi_var(t))
static void set_highest(V &x)
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
This class defines a tensor in LIBMESH_DIM dimensional space of type T.
void libmesh_ignore(const Args &...)
StandardType(const StandardType< libMesh::VectorValue< T >> &timpi_mpi_var(t))
bool _is_initialized
Flag that tells if init() has been called.
StandardType(const StandardType< libMesh::TypeVector< T >> &timpi_mpi_var(t))
This class defines a vector in LIBMESH_DIM dimensional space of type T.
StandardType(const libMesh::TypeTensor< T > *example=nullptr)
static const bool is_fixed_type
StandardType(const libMesh::TensorValue< T > *example=nullptr)
StandardType(const libMesh::VectorValue< T > *example=nullptr)
StandardType(const libMesh::Point *example=nullptr)
static void vector_max(void *invec, void *inoutvec, int *len, MPI_Datatype *)
A Point defines a location in LIBMESH_DIM dimensional Real space.
static const bool has_min_max
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.