libMesh
Public Types | Public Member Functions | Static Public Member Functions | List of all members
libMesh::Parallel::Packing< Node * > Class Template Reference

#include <parallel_node.h>

Public Types

typedef largest_id_type buffer_type
 

Public Member Functions

template<>
Nodeunpack (std::vector< largest_id_type >::const_iterator in, MeshBase *mesh)
 
template<>
Nodeunpack (std::vector< largest_id_type >::const_iterator in, DistributedMesh *mesh)
 
template<>
Nodeunpack (std::vector< largest_id_type >::const_iterator in, ParallelMesh *mesh)
 

Static Public Member Functions

template<typename OutputIter , typename Context >
static void pack (Node *const &object, OutputIter data_out, const Context *context)
 
template<typename Context >
static unsigned int packable_size (Node *const &object, const Context *context)
 
template<typename BufferIter >
static unsigned int packed_size (BufferIter iter)
 
template<typename BufferIter , typename Context >
static Nodeunpack (BufferIter in, Context *ctx)
 

Detailed Description

template<>
class libMesh::Parallel::Packing< Node * >

Definition at line 57 of file parallel_node.h.

Member Typedef Documentation

Definition at line 60 of file parallel_node.h.

Member Function Documentation

template<typename OutputIter , typename Context >
static void libMesh::Parallel::Packing< Node * >::pack ( Node *const &  object,
OutputIter  data_out,
const Context *  context 
)
static

Definition at line 63 of file parallel_node.h.

References libMesh::Parallel::Packing< T >::pack().

66  { return Packing<const Node *>::pack(object, data_out, context); }
static void pack(const T &object, OutputIter data_out, const Context *context)
template<typename Context >
static unsigned int libMesh::Parallel::Packing< Node * >::packable_size ( Node *const &  object,
const Context *  context 
)
static

Definition at line 69 of file parallel_node.h.

References libMesh::Parallel::Packing< T >::packable_size().

71  { return Packing<const Node*>::packable_size(object, context); }
static unsigned int packable_size(const T &object, const Context *context)
template<typename BufferIter >
static unsigned int libMesh::Parallel::Packing< Node * >::packed_size ( BufferIter  iter)
static

Definition at line 74 of file parallel_node.h.

References libMesh::ctx, and libMesh::Parallel::Packing< T >::packed_size().

75  { return Packing<const Node *>::packed_size(iter); }
static unsigned int packed_size(BufferIter iter)
template<typename BufferIter , typename Context >
static Node* libMesh::Parallel::Packing< Node * >::unpack ( BufferIter  in,
Context *  ctx 
)
static
template<>
Node* libMesh::Parallel::Packing< Node * >::unpack ( std::vector< largest_id_type >::const_iterator  in,
MeshBase mesh 
)

Definition at line 214 of file parallel_node.C.

References libMesh::BoundaryInfo::add_node(), libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), std::max(), libMesh::n_processors(), libMesh::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::query_node_ptr(), libMesh::Real, libMesh::TOLERANCE, and libMesh::DofObject::unpackable_indexing_size().

216 {
217 #ifndef NDEBUG
218  const std::vector<largest_id_type>::const_iterator original_in = in;
219  const largest_id_type incoming_header = *in++;
220  libmesh_assert_equal_to (incoming_header, node_magic_header);
221 #endif
222 
223  const processor_id_type processor_id = cast_int<processor_id_type>(*in++);
225  processor_id < mesh->n_processors());
226 
227  const dof_id_type id = cast_int<dof_id_type>(*in++);
228 
229 #ifdef LIBMESH_ENABLE_UNIQUE_ID
230  const unique_id_type unique_id = cast_int<unique_id_type>(*in++);
231 #endif
232 
233  Node * node = mesh->query_node_ptr(id);
234 
235  if (node)
236  {
237  libmesh_assert_equal_to (node->processor_id(), processor_id);
238 
239  // We currently don't communicate mesh motion via packed Nodes,
240  // so it should usually be safe to assume (and assert) that Node
241  // locations are consistent between processors.
242  //
243  // There may be exceptions due to rounding in file I/O, so we'll
244  // only assert equality to within a tight tolerance, and we'll
245  // believe the sender's node locations over our own if we don't
246  // own the node.
247  for (unsigned int i=0; i != LIBMESH_DIM; ++i)
248  {
249  const Real & idtypes_as_Real = *(reinterpret_cast<const Real *>(&(*in)));
250  libmesh_assert_less_equal ((*node)(i), idtypes_as_Real + (std::max(Real(1),idtypes_as_Real)*TOLERANCE*TOLERANCE));
251  libmesh_assert_greater_equal ((*node)(i), idtypes_as_Real - (std::max(Real(1),idtypes_as_Real)*TOLERANCE*TOLERANCE));
252 
253  if (processor_id != mesh->processor_id())
254  (*node)(i) = idtypes_as_Real;
255  in += idtypes_per_Real;
256  }
257 
258  if (!node->has_dofs())
259  {
260  node->unpack_indexing(in);
261  libmesh_assert_equal_to (DofObject::unpackable_indexing_size(in),
262  node->packed_indexing_size());
263  in += node->packed_indexing_size();
264  }
265  else
266  {
267  // FIXME: We should add some debug mode tests to ensure that
268  // the encoded indexing is consistent
270  }
271  }
272  else
273  {
274  // If we don't already have it, we need to allocate it
275  node = new Node();
276 
277  for (unsigned int i=0; i != LIBMESH_DIM; ++i)
278  {
279  const Real * idtypes_as_Real = reinterpret_cast<const Real *>(&(*in));
280  (*node)(i) = *idtypes_as_Real;
281  in += idtypes_per_Real;
282  }
283 
284  node->set_id() = id;
285 #ifdef LIBMESH_ENABLE_UNIQUE_ID
286  node->set_unique_id() = unique_id;
287 #endif
288  node->processor_id() = processor_id;
289 
290  node->unpack_indexing(in);
291  libmesh_assert_equal_to (DofObject::unpackable_indexing_size(in),
292  node->packed_indexing_size());
293  in += node->packed_indexing_size();
294  }
295 
296  // FIXME: We should add some debug mode tests to ensure that the
297  // encoded boundary conditions are consistent
298 
299  // Add any nodal boundary condition ids
300  const largest_id_type num_bcs = *in++;
301  // libmesh_assert_greater_equal (num_bcs, 0);
302 
303  for (largest_id_type bc_it=0; bc_it < num_bcs; bc_it++)
305  (node, cast_int<boundary_id_type>(*in++));
306 
307 #ifndef NDEBUG
308  libmesh_assert (in - original_in ==
309  cast_int<int>
311 #endif
312 
313  return node;
314 }
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:117
A Node is like a Point, but with more information.
Definition: node.h:52
static unsigned int unpackable_indexing_size(std::vector< largest_id_type >::const_iterator begin)
If we have indices packed into an buffer for communications, how much of that buffer applies to this ...
Definition: dof_object.C:473
uint64_t largest_id_type
Definition: id_types.h:139
uint8_t processor_id_type
Definition: id_types.h:99
static const Real TOLERANCE
Define data types and (un)serialization functions for use when encoding a potentially-variable-size o...
Definition: parallel.h:582
long double max(long double a, double b)
libmesh_assert(j)
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
virtual const Node * query_node_ptr(const dof_id_type i) const =0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
processor_id_type processor_id()
Definition: libmesh_base.h:96
uint8_t unique_id_type
Definition: id_types.h:79
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type n_processors()
Definition: libmesh_base.h:88
template<>
Node* libMesh::Parallel::Packing< Node * >::unpack ( std::vector< largest_id_type >::const_iterator  in,
DistributedMesh mesh 
)

Definition at line 321 of file parallel_node.C.

References libMesh::Parallel::Packing< T >::unpack().

323 {
324  return unpack(in, static_cast<MeshBase*>(mesh));
325 }
static Node * unpack(BufferIter in, Context *ctx)
template<>
Node* libMesh::Parallel::Packing< Node * >::unpack ( std::vector< largest_id_type >::const_iterator  in,
ParallelMesh mesh 
)

Definition at line 332 of file parallel_node.C.

References libMesh::Parallel::Packing< T >::unpack().

334 {
335  return unpack(in, static_cast<MeshBase*>(mesh));
336 }
static Node * unpack(BufferIter in, Context *ctx)

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