libMesh::Parallel::StandardType< TypeVector< T > > Class Template Reference

#include <parallel_algebra.h>

Inheritance diagram for libMesh::Parallel::StandardType< TypeVector< T > >:

Public Member Functions

 StandardType (const TypeVector< T > *example=nullptr)
 
 StandardType (const StandardType< TypeVector< T >> &libmesh_mpi_var(t))
 
 ~StandardType ()
 
 operator const data_type & () const
 
 operator data_type & ()
 
void commit ()
 
void free ()
 

Protected Attributes

data_type _datatype
 

Detailed Description

template<typename T>
class libMesh::Parallel::StandardType< TypeVector< T > >

Definition at line 48 of file parallel_algebra.h.

Constructor & Destructor Documentation

◆ StandardType() [1/2]

template<typename T >
libMesh::Parallel::StandardType< TypeVector< T > >::StandardType ( const TypeVector< T > *  example = nullptr)
inlineexplicit

Definition at line 52 of file parallel_algebra.h.

References libMesh::Parallel::DataType::_datatype.

52  {
53  // We need an example for MPI_Address to use
54  TypeVector<T> * ex;
55  std::unique_ptr<TypeVector<T>> temp;
56  if (example)
57  ex = const_cast<TypeVector<T> *>(example);
58  else
59  {
60  temp.reset(new TypeVector<T>());
61  ex = temp.get();
62  }
63 
64 #ifdef LIBMESH_HAVE_MPI
65  StandardType<T> T_type(&((*ex)(0)));
66 
67  // We require MPI-2 here:
68  int blocklength = LIBMESH_DIM;
69  MPI_Aint displs, start;
70  MPI_Datatype tmptype, type = T_type;
71 
72  libmesh_call_mpi
73  (MPI_Get_address (ex, &start));
74  libmesh_call_mpi
75  (MPI_Get_address (&((*ex)(0)), &displs));
76 
77  // subtract off offset to first value from the beginning of the structure
78  displs -= start;
79 
80  // create a prototype structure
81  libmesh_call_mpi
82  (MPI_Type_create_struct (1, &blocklength, &displs, &type,
83  &tmptype));
84  libmesh_call_mpi
85  (MPI_Type_commit (&tmptype));
86 
87  // resize the structure type to account for padding, if any
88  libmesh_call_mpi
89  (MPI_Type_create_resized (tmptype, 0, sizeof(TypeVector<T>),
90  &_datatype));
91 
92  libmesh_call_mpi
93  (MPI_Type_commit (&_datatype));
94 
95  libmesh_call_mpi
96  (MPI_Type_free (&tmptype));
97 #endif // #ifdef LIBMESH_HAVE_MPI
98  }

◆ StandardType() [2/2]

template<typename T >
libMesh::Parallel::StandardType< TypeVector< T > >::StandardType ( const StandardType< TypeVector< T >> &  libmesh_mpi_vart)
inline

Definition at line 100 of file parallel_algebra.h.

References libMesh::Parallel::DataType::_datatype.

101  : DataType()
102  {
103  libmesh_call_mpi (MPI_Type_dup (t._datatype, &_datatype));
104  }

◆ ~StandardType()

template<typename T >
libMesh::Parallel::StandardType< TypeVector< T > >::~StandardType ( )
inline

Definition at line 106 of file parallel_algebra.h.

References libMesh::Parallel::DataType::free().

106 { this->free(); }

Member Function Documentation

◆ commit()

void libMesh::Parallel::DataType::commit ( )
inlineinherited

◆ free()

◆ operator const data_type &()

libMesh::Parallel::DataType::operator const data_type & ( ) const
inlineinherited

Definition at line 91 of file data_type.h.

References libMesh::Parallel::DataType::_datatype.

92  { return _datatype; }

◆ operator data_type &()

libMesh::Parallel::DataType::operator data_type & ( )
inlineinherited

Definition at line 94 of file data_type.h.

References libMesh::Parallel::DataType::_datatype.

95  { return _datatype; }

Member Data Documentation

◆ _datatype


The documentation for this class was generated from the following file: