$extrastylesheet
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 133 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 137 of file parallel_algebra.h.

References libMesh::Parallel::DataType::_datatype, and libMesh::libMeshPrivateData::_is_initialized.

                                                   {
    // We need an example for MPI_Address to use
    VectorValue<T> *ex;
    UniquePtr<VectorValue<T> > temp;
    if (example)
      ex = const_cast<VectorValue<T> *>(example);
    else
      {
        temp.reset(new VectorValue<T>());
        ex = temp.get();
      }

    // _static_type never gets freed, but it only gets committed once
    // per T, so it's not a *huge* memory leak...
    static data_type _static_type;
    static bool _is_initialized = false;
    if (!_is_initialized)
      {
#ifdef LIBMESH_HAVE_MPI
        StandardType<T> T_type(&((*ex)(0)));

#if MPI_VERSION == 1

        int blocklengths[LIBMESH_DIM+2];
        MPI_Aint displs[LIBMESH_DIM+2];
        MPI_Datatype types[LIBMESH_DIM+2];
        MPI_Aint start, later;

        MPI_Address(ex, &start);
        blocklengths[0] = 1;
        displs[0] = 0;
        types[0] = MPI_LB;
        for (unsigned int i=0; i != LIBMESH_DIM; ++i)
          {
            MPI_Address(&((*ex)(i)), &later);
            blocklengths[i+1] = 1;
            displs[i+1] = later - start;
            types[i+1] = T_type;
          }
        MPI_Address((ex+1), &later);
        blocklengths[LIBMESH_DIM+1] = 1;
        displs[LIBMESH_DIM+1] = later - start;
        types[LIBMESH_DIM+1] = MPI_UB;

        MPI_Type_struct (LIBMESH_DIM+2, blocklengths, displs, types, &_static_type);

#else // MPI_VERSION >= 2

        int blocklength = LIBMESH_DIM;
        MPI_Aint displs, start;
        MPI_Datatype tmptype, type = T_type;

        MPI_Get_address (ex,   &start);
        MPI_Get_address (&((*ex)(0)), &displs);

        // subtract off offset to first value from the beginning of the structure
        displs -= start;

        // create a prototype structure
        MPI_Type_create_struct (1, &blocklength, &displs, &type, &tmptype);

        // resize the structure type to account for padding, if any
        MPI_Type_create_resized (tmptype, 0, sizeof(VectorValue<T>), &_static_type);
#endif

        MPI_Type_commit (&_static_type);
#endif // #ifdef LIBMESH_HAVE_MPI

        _is_initialized = true;
      }
    _datatype = _static_type;
  }

Member Function Documentation

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

Definition at line 278 of file parallel.h.

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

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

  {
#ifdef LIBMESH_HAVE_MPI
    MPI_Type_commit (&_datatype);
#endif
  }
libMesh::Parallel::DataType::operator const data_type & ( ) const [inline, inherited]

Definition at line 266 of file parallel.h.

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

  { return _datatype; }
libMesh::Parallel::DataType::operator data_type & ( ) [inline, inherited]

Definition at line 269 of file parallel.h.

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

  { return _datatype; }

Member Data Documentation


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