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

#include <parallel_algebra.h>

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

List of all members.

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 114 of file parallel_algebra.h.


Constructor & Destructor Documentation

template<typename T >
libMesh::Parallel::StandardType< VectorValue< T > >::StandardType ( const VectorValue< T > *  example = NULL  )  [inline, explicit]

Definition at line 118 of file parallel_algebra.h.

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

00118                                                      {
00119       // We need an example for MPI_Address to use
00120       VectorValue<T> *ex;
00121       AutoPtr<VectorValue<T> > temp;
00122       if (example)
00123         ex = const_cast<VectorValue<T> *>(example);
00124       else
00125         {
00126           temp.reset(new VectorValue<T>());
00127           ex = temp.get();
00128         }
00129 
00130       // _static_type never gets freed, but it only gets committed once
00131       // per T, so it's not a *huge* memory leak...
00132       static data_type _static_type;
00133       static bool _is_initialized = false;
00134       if (!_is_initialized)
00135         {
00136 #ifdef LIBMESH_HAVE_MPI
00137           StandardType<T> T_type(&((*ex)(0)));
00138           int blocklengths[LIBMESH_DIM+2];
00139           MPI_Aint displs[LIBMESH_DIM+2];
00140           MPI_Datatype types[LIBMESH_DIM+2];
00141           MPI_Aint start, later;
00142 
00143           MPI_Address(ex, &start);
00144           blocklengths[0] = 1;
00145           displs[0] = 0;
00146           types[0] = MPI_LB;
00147           for (unsigned int i=0; i != LIBMESH_DIM; ++i)
00148             {
00149               MPI_Address(&((*ex)(i)), &later);
00150               blocklengths[i+1] = 1;
00151               displs[i+1] = later - start;
00152               types[i+1] = T_type;
00153             }
00154           MPI_Address((ex+1), &later);
00155           blocklengths[LIBMESH_DIM+1] = 1;
00156           displs[LIBMESH_DIM+1] = later - start;
00157           types[LIBMESH_DIM+1] = MPI_UB;
00158 
00159 #if MPI_VERSION > 1
00160           MPI_Type_create_struct (LIBMESH_DIM+2, blocklengths, displs, types, &_static_type);
00161 #else
00162           MPI_Type_struct (LIBMESH_DIM+2, blocklengths, displs, types, &_static_type);
00163 #endif // #if MPI_VERSION > 1
00164 
00165           MPI_Type_commit (&_static_type);
00166 #endif
00167           _is_initialized = true;
00168         }
00169       _datatype = _static_type;
00170     }


Member Function Documentation

void libMesh::Parallel::DataType::commit (  )  [inline, inherited]

Definition at line 255 of file parallel.h.

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

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

00256     {
00257 #ifdef LIBMESH_HAVE_MPI
00258       MPI_Type_commit (&_datatype);
00259 #endif
00260     }

libMesh::Parallel::DataType::operator const data_type & (  )  const [inline, inherited]

Definition at line 243 of file parallel.h.

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

00244     { return _datatype; }

libMesh::Parallel::DataType::operator data_type & (  )  [inline, inherited]

Definition at line 246 of file parallel.h.

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

00247     { return _datatype; }


Member Data Documentation


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:45 UTC

Hosted By:
SourceForge.net Logo