libMesh::Node::PackedNode Struct Reference

#include <node.h>

Public Member Functions

 PackedNode ()
 
Point build_point () const
 

Static Public Member Functions

static MPI_Datatype create_mpi_datatype ()
 
static void pack (std::vector< largest_id_type > &conn, const Node *node)
 
static void unpack (std::vector< largest_id_type >::const_iterator start, Node &node)
 

Public Attributes

dof_id_type id
 
processor_id_type pid
 
Real x
 
Real y
 
Real z
 
PackedNode(const Node &node) node processor_id () = pid
 
return node
 

Static Public Attributes

static const unsigned int header_size = 2
 

Detailed Description

Convenient way to communicate nodes. This struct defines a packed up node which can be easily communicated through a derived MPI datatype.

Author
Benjamin S. Kirk
Date
2008

Definition at line 147 of file node.h.

Constructor & Destructor Documentation

libMesh::Node::PackedNode::PackedNode ( )
inline

Definition at line 158 of file node.h.

158  :
159  id(0),
161  x(0.),
162  y(0.),
163  z(0.)
164  {}

Member Function Documentation

Point libMesh::Node::PackedNode::build_point ( ) const
inline

Definition at line 190 of file node.h.

References libMesh::Point::Point().

191  {
192  return Point(x,y,z);
193  }
MPI_Datatype libMesh::Node::PackedNode::create_mpi_datatype ( )
static

Definition at line 79 of file node.C.

References id, and x.

80 {
81  MPI_Datatype packed_node_type;
82  MPI_Datatype types[] = { MPI_UNSIGNED, MPI_REAL };
83  int blocklengths[] = { 2, 3 };
84  MPI_Aint displs[2];
85 
86  // create a Packed node and get the addresses of the elements.
87  // this will properly handle id/pid getting padded, for example,
88  // in which case id and x may not be 2*sizeof(unsigned int) apart.
89  Node::PackedNode pn;
90 
91 #if MPI_VERSION > 1
92  MPI_Get_address (&pn.id, &displs[0]);
93  MPI_Get_address (&pn.x, &displs[1]);
94 #else
95  MPI_Address (&pn.id, &displs[0]);
96  MPI_Address (&pn.x, &displs[1]);
97 #endif // #if MPI_VERSION > 1
98 
99  displs[1] -= displs[0];
100  displs[0] = 0;
101 
102 #if MPI_VERSION > 1
103  MPI_Type_create_struct (2, blocklengths, displs, types, &packed_node_type);
104 #else
105  MPI_Type_struct (2, blocklengths, displs, types, &packed_node_type);
106 #endif // #if MPI_VERSION > 1
107 
108  return packed_node_type;
109 }
void libMesh::Node::PackedNode::pack ( std::vector< largest_id_type > &  conn,
const Node node 
)
static

For each node the serialization is of the form [ processor_id self_ID x1 x2 y1 y2 z1 z2 dof_object_buffer_1 ...] There may be 1 or 3 or 4 ints per coordinate depending on machine architecture.

Definition at line 112 of file node.C.

References libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::DofObject::pack_indexing(), libMesh::Node::packed_size(), libMesh::DofObject::processor_id(), and libMesh::Real.

113 {
115 
116  conn.reserve (conn.size() + node->packed_size());
117 
118  conn.push_back (static_cast<largest_id_type>(node->processor_id()));
119  conn.push_back (static_cast<largest_id_type>(node->id()));
120 
121  // use "(a+b-1)/b" trick to get a/b to round up
122  static const unsigned int idtypes_per_Real =
123  (sizeof(Real) + sizeof(largest_id_type) - 1) / sizeof(largest_id_type);
124 
125  for (unsigned int i=0; i != LIBMESH_DIM; ++i)
126  {
127  const largest_id_type* Real_as_idtypes = reinterpret_cast<const largest_id_type*>(&((*node)(i)));
128  for (unsigned int j=0; j != idtypes_per_Real; ++j)
129  {
130  conn.push_back(Real_as_idtypes[j]);
131  }
132  }
133 
134  node->pack_indexing(std::back_inserter(conn));
135 }
void libMesh::Node::PackedNode::unpack ( std::vector< largest_id_type >::const_iterator  start,
Node node 
)
static

Definition at line 138 of file node.C.

References libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libMesh::n_processors(), libMesh::DofObject::processor_id(), libMesh::Real, libMesh::DofObject::set_id(), and libMesh::DofObject::unpack_indexing().

139 {
140  processor_id_type processor_id = static_cast<processor_id_type>(*start++);
142  processor_id < libMesh::n_processors());
143 
144  dof_id_type id = static_cast<dof_id_type>(*start++);
145 
146  // use "(a+b-1)/b" trick to get a/b to round up
147  static const unsigned int idtypes_per_Real =
148  (sizeof(Real) + sizeof(largest_id_type) - 1) / sizeof(largest_id_type);
149 
150  std::vector<Real> xyz(3,0.);
151 
152  for (unsigned int i=0; i != LIBMESH_DIM; ++i)
153  {
154  const Real* ints_as_Real = reinterpret_cast<const Real*>(&(*start));
155  node(i) = *ints_as_Real;
156  start += idtypes_per_Real;
157  }
158 
159  node.set_id() = id;
160  node.processor_id() = processor_id;
161 
162  node.unpack_indexing(start);
163 }

Member Data Documentation

const unsigned int libMesh::Node::PackedNode::header_size = 2
static

Definition at line 149 of file node.h.

Referenced by libMesh::Node::packed_size().

dof_id_type libMesh::Node::PackedNode::id

Definition at line 151 of file node.h.

Referenced by create_mpi_datatype().

return libMesh::Node::PackedNode::node

Definition at line 187 of file node.h.

processor_id_type libMesh::Node::PackedNode::pid

Definition at line 152 of file node.h.

PackedNode (const Node &node) node libMesh::Node::PackedNode::processor_id() = pid
explicit

Definition at line 186 of file node.h.

Real libMesh::Node::PackedNode::x

Definition at line 153 of file node.h.

Referenced by create_mpi_datatype().

Real libMesh::Node::PackedNode::y

Definition at line 155 of file node.h.

Real libMesh::Node::PackedNode::z

Definition at line 156 of file node.h.


The documentation for this struct was generated from the following files:

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:28 UTC

Hosted By:
SourceForge.net Logo