$extrastylesheet
libMesh::Parallel::StandardType< Point > Class Template Reference

#include <parallel_algebra.h>

Inheritance diagram for libMesh::Parallel::StandardType< Point >:

List of all members.

Public Member Functions

 StandardType (const Point *example=NULL)
 operator const data_type & () const
 operator data_type & ()
void commit ()
void free ()

Protected Attributes

data_type _datatype

Detailed Description

template<>
class libMesh::Parallel::StandardType< Point >

Definition at line 212 of file parallel_algebra.h.


Constructor & Destructor Documentation

libMesh::Parallel::StandardType< Point >::StandardType ( const Point example = NULL) [inline, explicit]

Definition at line 216 of file parallel_algebra.h.

References libMesh::Parallel::DataType::_datatype, libMesh::libMeshPrivateData::_is_initialized, and libMesh::libmesh_ignore().

  {
    // Prevent unused variable warnings when !LIBMESH_HAVE_MPI
    libmesh_ignore(example);

    // _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

        // We need an example for MPI_Address to use
        Point *ex;

        UniquePtr<Point> temp;
        if (example)
          ex = const_cast<Point *>(example);
        else
          {
            temp.reset(new Point());
            ex = temp.get();
          }

        StandardType<Real> 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(Point), &_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: