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

#include <parallel_algebra.h>

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

Public Member Functions

 StandardType (const VectorValue< T > *example=NULL)
 
 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< VectorValue< T > >

Definition at line 133 of file parallel_algebra.h.

Constructor & Destructor Documentation

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

Definition at line 137 of file parallel_algebra.h.

References libMesh::Parallel::DataType::_datatype, libMesh::libMeshPrivateData::_is_initialized, libMesh::AutoPtr< Tp >::get(), and libMesh::AutoPtr< Tp >::reset().

137  {
138  // We need an example for MPI_Address to use
139  VectorValue<T> *ex;
140  AutoPtr<VectorValue<T> > temp;
141  if (example)
142  ex = const_cast<VectorValue<T> *>(example);
143  else
144  {
145  temp.reset(new VectorValue<T>());
146  ex = temp.get();
147  }
148 
149  // _static_type never gets freed, but it only gets committed once
150  // per T, so it's not a *huge* memory leak...
151  static data_type _static_type;
152  static bool _is_initialized = false;
153  if (!_is_initialized)
154  {
155 #ifdef LIBMESH_HAVE_MPI
156  StandardType<T> T_type(&((*ex)(0)));
157 
158 #if MPI_VERSION == 1
159 
160  int blocklengths[LIBMESH_DIM+2];
161  MPI_Aint displs[LIBMESH_DIM+2];
162  MPI_Datatype types[LIBMESH_DIM+2];
163  MPI_Aint start, later;
164 
165  MPI_Address(ex, &start);
166  blocklengths[0] = 1;
167  displs[0] = 0;
168  types[0] = MPI_LB;
169  for (unsigned int i=0; i != LIBMESH_DIM; ++i)
170  {
171  MPI_Address(&((*ex)(i)), &later);
172  blocklengths[i+1] = 1;
173  displs[i+1] = later - start;
174  types[i+1] = T_type;
175  }
176  MPI_Address((ex+1), &later);
177  blocklengths[LIBMESH_DIM+1] = 1;
178  displs[LIBMESH_DIM+1] = later - start;
179  types[LIBMESH_DIM+1] = MPI_UB;
180 
181  MPI_Type_struct (LIBMESH_DIM+2, blocklengths, displs, types, &_static_type);
182 
183 #else // MPI_VERSION >= 2
184 
185  int blocklength = LIBMESH_DIM;
186  MPI_Aint displs, start;
187  MPI_Datatype tmptype, type = T_type;
188 
189  MPI_Get_address (ex, &start);
190  MPI_Get_address (&((*ex)(0)), &displs);
191 
192  // subtract off offset to first value from the beginning of the structure
193  displs -= start;
194 
195  // create a prototype structure
196  MPI_Type_create_struct (1, &blocklength, &displs, &type, &tmptype);
197 
198  // resize the structure type to account for padding, if any
199  MPI_Type_create_resized (tmptype, 0, sizeof(VectorValue<T>), &_static_type);
200 #endif
201 
202  MPI_Type_commit (&_static_type);
203 #endif // #ifdef LIBMESH_HAVE_MPI
204 
205  _is_initialized = true;
206  }
207  _datatype = _static_type;
208  }

Member Function Documentation

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

Definition at line 277 of file parallel.h.

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

Referenced by libMesh::Parallel::DataType::DataType().

278  {
279 #ifdef LIBMESH_HAVE_MPI
280  MPI_Type_commit (&_datatype);
281 #endif
282  }
libMesh::Parallel::DataType::operator const data_type & ( ) const
inlineinherited

Definition at line 265 of file parallel.h.

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

266  { return _datatype; }
libMesh::Parallel::DataType::operator data_type & ( )
inlineinherited

Definition at line 268 of file parallel.h.

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

269  { return _datatype; }

Member Data Documentation


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:02 UTC

Hosted By:
SourceForge.net Logo