libMesh
Public Member Functions | Protected Attributes | List of all members
libMesh::Parallel::StandardType< std::pair< T1, T2 > > Class Template Reference

#include <standard_type.h>

Inheritance diagram for libMesh::Parallel::StandardType< std::pair< T1, T2 > >:
[legend]

Public Member Functions

 StandardType (const std::pair< T1, T2 > *example=nullptr)
 
 StandardType (const StandardType< std::pair< T1, T2 >> &t)
 
 ~StandardType ()
 
 operator const data_type & () const
 
 operator data_type & ()
 
void commit ()
 
void free ()
 

Protected Attributes

data_type _datatype
 

Detailed Description

template<typename T1, typename T2>
class libMesh::Parallel::StandardType< std::pair< T1, T2 > >

Definition at line 125 of file standard_type.h.

Constructor & Destructor Documentation

◆ StandardType() [1/2]

template<typename T1 , typename T2 >
libMesh::Parallel::StandardType< std::pair< T1, T2 > >::StandardType ( const std::pair< T1, T2 > *  example = nullptr)
explicit

Definition at line 129 of file standard_type.h.

References libMesh::Parallel::DataType::_datatype, and libMesh::Parallel::DataType::commit().

129  {
130  // We need an example for MPI_Address to use
131  static const std::pair<T1, T2> p;
132  if (!example)
133  example = &p;
134 
135 #ifdef LIBMESH_HAVE_MPI
136 
137  // Get the sub-data-types, and make sure they live long enough
138  // to construct the derived type
139  StandardType<T1> d1(&example->first);
140  StandardType<T2> d2(&example->second);
141 
142  MPI_Datatype types[] = { (data_type)d1, (data_type)d2 };
143  int blocklengths[] = {1,1};
144  MPI_Aint displs[2], start;
145 
146  libmesh_call_mpi
147  (MPI_Get_address (const_cast<std::pair<T1,T2> *>(example),
148  &start));
149  libmesh_call_mpi
150  (MPI_Get_address (const_cast<T1*>(&example->first),
151  &displs[0]));
152  libmesh_call_mpi
153  (MPI_Get_address (const_cast<T2*>(&example->second),
154  &displs[1]));
155  displs[0] -= start;
156  displs[1] -= start;
157 
158  // create a prototype structure
159  MPI_Datatype tmptype;
160  libmesh_call_mpi
161  (MPI_Type_create_struct (2, blocklengths, displs, types,
162  &tmptype));
163  libmesh_call_mpi
164  (MPI_Type_commit (&tmptype));
165 
166  // resize the structure type to account for padding, if any
167  libmesh_call_mpi
168  (MPI_Type_create_resized (tmptype, 0,
169  sizeof(std::pair<T1,T2>),
170  &_datatype));
171  libmesh_call_mpi
172  (MPI_Type_free (&tmptype));
173 
174  this->commit();
175 
176 #endif // LIBMESH_HAVE_MPI
177 
178  }
MPI_Datatype data_type
Data types for communication.
Definition: data_type.h:46

◆ StandardType() [2/2]

template<typename T1 , typename T2 >
libMesh::Parallel::StandardType< std::pair< T1, T2 > >::StandardType ( const StandardType< std::pair< T1, T2 >> &  t)

Definition at line 180 of file standard_type.h.

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

181  {
182  libmesh_call_mpi
183  (MPI_Type_dup (t._datatype, &_datatype));
184  }

◆ ~StandardType()

template<typename T1 , typename T2 >
libMesh::Parallel::StandardType< std::pair< T1, T2 > >::~StandardType ( )

Definition at line 186 of file standard_type.h.

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

186 { this->free(); }

Member Function Documentation

◆ commit()

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

Definition at line 103 of file data_type.h.

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

Referenced by libMesh::Parallel::DataType::DataType(), StandardType(), and libMesh::Parallel::StandardType< std::tuple< Types... > >::StandardType().

104  {
105  libmesh_call_mpi
106  (MPI_Type_commit (&_datatype));
107  }

◆ free()

void libMesh::Parallel::DataType::free ( )
inherited

◆ operator const data_type &()

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

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 & ( )
inherited

Definition at line 94 of file data_type.h.

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

95  { return _datatype; }

Member Data Documentation

◆ _datatype

data_type libMesh::Parallel::DataType::_datatype
protectedinherited

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