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

#include <parallel_algebra.h>

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

List of all members.

Public Member Functions

 StandardType (const TypeVector< 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< TypeVector< T > >

Definition at line 54 of file parallel_algebra.h.


Constructor & Destructor Documentation

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

Definition at line 58 of file parallel_algebra.h.

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

00058                                                     {
00059       // We need an example for MPI_Address to use
00060       TypeVector<T> *ex;
00061       AutoPtr<TypeVector<T> > temp;
00062       if (example)
00063         ex = const_cast<TypeVector<T> *>(example);
00064       else
00065         {
00066           temp.reset(new TypeVector<T>());
00067           ex = temp.get();
00068         }
00069 
00070       // _static_type never gets freed, but it only gets committed once
00071       // per T, so it's not a *huge* memory leak...
00072       static data_type _static_type;
00073       static bool _is_initialized = false;
00074       if (!_is_initialized)
00075         {
00076 #ifdef LIBMESH_HAVE_MPI
00077           StandardType<T> T_type(&((*ex)(0)));
00078           int blocklengths[LIBMESH_DIM+2];
00079           MPI_Aint displs[LIBMESH_DIM+2];
00080           MPI_Datatype types[LIBMESH_DIM+2];
00081           MPI_Aint start, later;
00082 
00083           MPI_Address(ex, &start);
00084           blocklengths[0] = 1;
00085           displs[0] = 0;
00086           types[0] = MPI_LB;
00087           for (unsigned int i=0; i != LIBMESH_DIM; ++i)
00088             {
00089               MPI_Address(&((*ex)(i)), &later);
00090               blocklengths[i+1] = 1;
00091               displs[i+1] = later - start;
00092               types[i+1] = T_type;
00093             }
00094           MPI_Address((ex+1), &later);
00095           blocklengths[LIBMESH_DIM+1] = 1;
00096           displs[LIBMESH_DIM+1] = later - start;
00097           types[LIBMESH_DIM+1] = MPI_UB;
00098 
00099 #if MPI_VERSION > 1
00100           MPI_Type_create_struct (LIBMESH_DIM+2, blocklengths, displs, types, &_static_type);
00101 #else
00102           MPI_Type_struct (LIBMESH_DIM+2, blocklengths, displs, types, &_static_type);
00103 #endif // #if MPI_VERSION > 1
00104 
00105           MPI_Type_commit (&_static_type);
00106 #endif
00107           _is_initialized = true;
00108         }
00109       _datatype = _static_type;
00110     }


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