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

#include <parallel_elem.h>

Public Types

typedef largest_id_type buffer_type
 

Public Member Functions

template<>
unsigned int packed_size (std::vector< largest_id_type >::const_iterator in)
 
template<>
unsigned int packed_size (std::vector< largest_id_type >::iterator in)
 
template<>
unsigned int packable_size (const Elem *const &elem, const MeshBase *mesh)
 
template<>
unsigned int packable_size (const Elem *const &elem, const DistributedMesh *mesh)
 
template<>
unsigned int packable_size (const Elem *const &elem, const ParallelMesh *mesh)
 
template<>
void pack (const Elem *const &elem, std::back_insert_iterator< std::vector< largest_id_type >> data_out, const MeshBase *mesh)
 
template<>
void pack (const Elem *const &elem, std::back_insert_iterator< std::vector< largest_id_type >> data_out, const DistributedMesh *mesh)
 
template<>
void pack (const Elem *const &elem, std::back_insert_iterator< std::vector< largest_id_type >> data_out, const ParallelMesh *mesh)
 

Static Public Member Functions

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

Detailed Description

template<>
class libMesh::Parallel::Packing< const Elem * >

Definition at line 34 of file parallel_elem.h.

Member Typedef Documentation

Definition at line 37 of file parallel_elem.h.

Member Function Documentation

template<typename OutputIter , typename Context >
static void libMesh::Parallel::Packing< const Elem * >::pack ( const Elem *const &  object,
OutputIter  data_out,
const Context *  context 
)
static
template<>
void libMesh::Parallel::Packing< const Elem * >::pack ( const Elem *const &  elem,
std::back_insert_iterator< std::vector< largest_id_type >>  data_out,
const MeshBase mesh 
)

Definition at line 205 of file parallel_elem.C.

References libMesh::BoundaryInfo::boundary_ids(), libMesh::Elem::dim(), libMesh::BoundaryInfo::edge_boundary_ids(), libMesh::Elem::edge_index_range(), libMesh::MeshBase::get_boundary_info(), libMesh::Elem::has_children(), libMesh::DofObject::id(), libMesh::Elem::interior_parent(), libMesh::DofObject::invalid_id, libMesh::Elem::INVALID_REFINEMENTSTATE, libMesh::DofObject::invalid_unique_id, libMesh::Elem::level(), libMesh::libmesh_assert(), libMesh::Elem::n_nodes(), libMesh::Elem::neighbor_ptr_range(), libMesh::Elem::node_id(), libMesh::Elem::p_level(), libMesh::Elem::p_refinement_flag(), libMesh::DofObject::pack_indexing(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::Elem::refinement_flag(), libMesh::BoundaryInfo::shellface_boundary_ids(), libMesh::Elem::side_index_range(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), libMesh::DofObject::unique_id(), libMesh::DofObject::valid_unique_id(), and libMesh::Elem::which_child_am_i().

208 {
209  libmesh_assert(elem);
210 
211 #ifndef NDEBUG
212  *data_out++ = elem_magic_header;
213 #endif
214 
215 #ifdef LIBMESH_ENABLE_AMR
216  *data_out++ = (static_cast<largest_id_type>(elem->level()));
217  *data_out++ = (static_cast<largest_id_type>(elem->p_level()));
218 
219  // Encode both the refinement flag and whether the element has
220  // children together. This coding is unambiguous because our
221  // refinement state encoding starts at 0 and ends at
222  // INVALID_REFINEMENTSTATE
223  largest_id_type refinement_info =
224  static_cast<largest_id_type>(elem->refinement_flag());
225  if (elem->has_children())
226  refinement_info +=
227  static_cast<largest_id_type>(Elem::INVALID_REFINEMENTSTATE) + 1;
228  *data_out++ = (refinement_info);
229 
230  *data_out++ = (static_cast<largest_id_type>(elem->p_refinement_flag()));
231 #else
232  *data_out++ = (0);
233  *data_out++ = (0);
234  *data_out++ = (0);
235  *data_out++ = (0);
236 #endif
237  *data_out++ = (static_cast<largest_id_type>(elem->type()));
238  *data_out++ = (elem->processor_id());
239  *data_out++ = (elem->subdomain_id());
240  *data_out++ = (elem->id());
241 
242 #ifdef LIBMESH_ENABLE_UNIQUE_ID
243  if (elem->valid_unique_id())
244  *data_out++ = (static_cast<largest_id_type>(elem->unique_id()));
245  else
246  // OK to send invalid unique id, we must not own this DOF
247  *data_out++ = (static_cast<largest_id_type>(DofObject::invalid_unique_id));
248 #endif
249 
250 #ifdef LIBMESH_ENABLE_AMR
251  // use parent_ID of invalid_id to indicate a level 0 element
252  if (elem->level() == 0)
253  {
254  *data_out++ =(DofObject::invalid_id);
255  *data_out++ =(DofObject::invalid_id);
256  }
257  else
258  {
259  *data_out++ =(elem->parent()->id());
260  *data_out++ =(elem->parent()->which_child_am_i(elem));
261  }
262 #else
263  *data_out++ = (DofObject::invalid_id);
264  *data_out++ = (DofObject::invalid_id);
265 #endif
266 
267  if ((elem->dim() < LIBMESH_DIM) &&
268  elem->interior_parent())
269  *data_out++ =(elem->interior_parent()->id());
270  else
271  *data_out++ =(DofObject::invalid_id);
272 
273  for (unsigned int n=0; n<elem->n_nodes(); n++)
274  *data_out++ = (elem->node_id(n));
275 
276  for (auto neigh : elem->neighbor_ptr_range())
277  {
278  if (neigh)
279  *data_out++ = (neigh->id());
280  else
281  *data_out++ = (DofObject::invalid_id);
282  }
283 
284  // Add any DofObject indices
285  elem->pack_indexing(data_out);
286 
287  // If this is a coarse element,
288  // Add any element side boundary condition ids
289  if (elem->level() == 0)
290  {
291  std::vector<boundary_id_type> bcs;
292  for (auto s : elem->side_index_range())
293  {
294  mesh->get_boundary_info().boundary_ids(elem, s, bcs);
295 
296  *data_out++ =(bcs.size());
297 
298  for (std::vector<boundary_id_type>::iterator bc_it=bcs.begin();
299  bc_it != bcs.end(); ++bc_it)
300  *data_out++ =(*bc_it);
301  }
302 
303  for (auto e : elem->edge_index_range())
304  {
305  mesh->get_boundary_info().edge_boundary_ids(elem, e, bcs);
306 
307  *data_out++ =(bcs.size());
308 
309  for (std::vector<boundary_id_type>::iterator bc_it=bcs.begin();
310  bc_it != bcs.end(); ++bc_it)
311  *data_out++ =(*bc_it);
312  }
313 
314  for (unsigned short sf=0; sf != 2; ++sf)
315  {
316  mesh->get_boundary_info().shellface_boundary_ids(elem, sf, bcs);
317 
318  *data_out++ =(bcs.size());
319 
320  for (std::vector<boundary_id_type>::iterator bc_it=bcs.begin();
321  bc_it != bcs.end(); ++bc_it)
322  *data_out++ =(*bc_it);
323  }
324  }
325 }
bool has_children() const
Definition: elem.h:2295
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:117
virtual ElemType type() const =0
unsigned int p_level() const
Definition: elem.h:2422
IntRange< unsigned short > side_index_range() const
Definition: elem.h:2083
const Elem * parent() const
Definition: elem.h:2346
const Elem * interior_parent() const
Definition: elem.C:951
uint64_t largest_id_type
Definition: id_types.h:139
IntRange< unsigned short > edge_index_range() const
Definition: elem.h:2074
bool valid_unique_id() const
Definition: dof_object.h:682
libmesh_assert(j)
virtual unsigned int n_nodes() const =0
std::vector< boundary_id_type > boundary_ids(const Node *node) const
void pack_indexing(std::back_insert_iterator< std::vector< largest_id_type >> target) const
A method for creating packed data from our index buffer - basically a copy with prepended size with o...
Definition: dof_object.C:532
void shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
static const unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
Definition: dof_object.h:329
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:324
RefinementState p_refinement_flag() const
Definition: elem.h:2521
subdomain_id_type subdomain_id() const
Definition: elem.h:1951
unsigned int which_child_am_i(const Elem *e) const
Definition: elem.h:2487
std::vector< boundary_id_type > edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
virtual unsigned int dim() const =0
unsigned int level() const
Definition: elem.h:2388
RefinementState refinement_flag() const
Definition: elem.h:2505
SimpleRange< NeighborPtrIter > neighbor_ptr_range()
Returns a range with all neighbors of an element, usable in range-based for loops.
Definition: elem.h:2855
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1831
dof_id_type id() const
Definition: dof_object.h:632
unique_id_type unique_id() const
Definition: dof_object.h:649
processor_id_type processor_id() const
Definition: dof_object.h:694
template<>
void libMesh::Parallel::Packing< const Elem * >::pack ( const Elem *const &  elem,
std::back_insert_iterator< std::vector< largest_id_type >>  data_out,
const DistributedMesh mesh 
)

Definition at line 332 of file parallel_elem.C.

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

335 {
336  pack(elem, data_out, static_cast<const MeshBase*>(mesh));
337 }
static void pack(const Elem *const &object, OutputIter data_out, const Context *context)
template<>
void libMesh::Parallel::Packing< const Elem * >::pack ( const Elem *const &  elem,
std::back_insert_iterator< std::vector< largest_id_type >>  data_out,
const ParallelMesh mesh 
)

Definition at line 344 of file parallel_elem.C.

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

347 {
348  pack(elem, data_out, static_cast<const MeshBase*>(mesh));
349 }
static void pack(const Elem *const &object, OutputIter data_out, const Context *context)
template<typename Context >
static unsigned int libMesh::Parallel::Packing< const Elem * >::packable_size ( const Elem *const &  object,
const Context *  context 
)
static
template<>
unsigned int libMesh::Parallel::Packing< const Elem * >::packable_size ( const Elem *const &  elem,
const MeshBase mesh 
)

Definition at line 145 of file parallel_elem.C.

References libMesh::MeshBase::get_boundary_info(), libMesh::Elem::level(), libMesh::BoundaryInfo::n_boundary_ids(), libMesh::BoundaryInfo::n_edge_boundary_ids(), libMesh::Elem::n_edges(), libMesh::Elem::n_nodes(), libMesh::BoundaryInfo::n_shellface_boundary_ids(), libMesh::Elem::n_sides(), and libMesh::DofObject::packed_indexing_size().

147 {
148  unsigned int total_packed_bcs = 0;
149  const unsigned short n_sides = elem->n_sides();
150 
151  if (elem->level() == 0)
152  {
153  total_packed_bcs += n_sides;
154  for (unsigned short s = 0; s != n_sides; ++s)
155  total_packed_bcs +=
156  mesh->get_boundary_info().n_boundary_ids(elem,s);
157 
158  const unsigned short n_edges = elem->n_edges();
159  total_packed_bcs += n_edges;
160  for (unsigned short e = 0; e != n_edges; ++e)
161  total_packed_bcs +=
162  mesh->get_boundary_info().n_edge_boundary_ids(elem,e);
163 
164  total_packed_bcs += 2; // shellfaces
165  for (unsigned short sf=0; sf != 2; ++sf)
166  total_packed_bcs +=
168  }
169 
170  return
171 #ifndef NDEBUG
172  1 + // add an int for the magic header when testing
173 #endif
174  header_size + elem->n_nodes() + n_sides +
175  elem->packed_indexing_size() + total_packed_bcs;
176 }
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:117
virtual unsigned int n_edges() const =0
unsigned int n_shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface) const
virtual unsigned int n_nodes() const =0
unsigned int n_edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
virtual unsigned int n_sides() const =0
unsigned int packed_indexing_size() const
If we pack our indices into an buffer for communications, how many ints do we need?
Definition: dof_object.C:457
std::size_t n_boundary_ids() const
unsigned int level() const
Definition: elem.h:2388
template<>
unsigned int libMesh::Parallel::Packing< const Elem * >::packable_size ( const Elem *const &  elem,
const DistributedMesh mesh 
)

Definition at line 183 of file parallel_elem.C.

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

185 {
186  return packable_size(elem, static_cast<const MeshBase *>(mesh));
187 }
static unsigned int packable_size(const Elem *const &object, const Context *context)
template<>
unsigned int libMesh::Parallel::Packing< const Elem * >::packable_size ( const Elem *const &  elem,
const ParallelMesh mesh 
)

Definition at line 194 of file parallel_elem.C.

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

196 {
197  return packable_size(elem, static_cast<const MeshBase *>(mesh));
198 }
static unsigned int packable_size(const Elem *const &object, const Context *context)
template<typename BufferIter >
static unsigned int libMesh::Parallel::Packing< const Elem * >::packed_size ( BufferIter  iter)
static
template<>
unsigned int libMesh::Parallel::Packing< const Elem * >::packed_size ( std::vector< largest_id_type >::const_iterator  in)

Definition at line 59 of file parallel_elem.C.

References libMesh::INVALID_ELEM, n_nodes, libMesh::Elem::type_to_n_edges_map, libMesh::Elem::type_to_n_nodes_map, libMesh::Elem::type_to_n_sides_map, and libMesh::DofObject::unpackable_indexing_size().

60 {
61 #ifndef NDEBUG
62  const largest_id_type packed_header = *in++;
63  libmesh_assert_equal_to (packed_header, elem_magic_header);
64 #endif
65 
66  // int 0: level
67  const unsigned int level =
68  cast_int<unsigned int>(*in);
69 
70  // int 4: element type
71  const int typeint = cast_int<int>(*(in+4));
72  libmesh_assert_greater_equal (typeint, 0);
73  libmesh_assert_less (typeint, INVALID_ELEM);
74  const ElemType type =
75  cast_int<ElemType>(typeint);
76 
77  const unsigned int n_nodes =
79 
80  const unsigned int n_sides =
82 
83  const unsigned int n_edges =
85 
86  const unsigned int pre_indexing_size =
87  header_size + n_nodes + n_sides;
88 
89  const unsigned int indexing_size =
90  DofObject::unpackable_indexing_size(in+pre_indexing_size);
91 
92  unsigned int total_packed_bc_data = 0;
93  if (level == 0)
94  {
95  for (unsigned int s = 0; s != n_sides; ++s)
96  {
97  const int n_bcs = cast_int<int>
98  (*(in + pre_indexing_size + indexing_size +
99  total_packed_bc_data++));
100  libmesh_assert_greater_equal (n_bcs, 0);
101  total_packed_bc_data += n_bcs;
102  }
103 
104  for (unsigned int e = 0; e != n_edges; ++e)
105  {
106  const int n_bcs = cast_int<int>
107  (*(in + pre_indexing_size + indexing_size +
108  total_packed_bc_data++));
109  libmesh_assert_greater_equal (n_bcs, 0);
110  total_packed_bc_data += n_bcs;
111  }
112 
113  for (unsigned short sf=0; sf != 2; ++sf)
114  {
115  const int n_bcs = cast_int<int>
116  (*(in + pre_indexing_size + indexing_size +
117  total_packed_bc_data++));
118  libmesh_assert_greater_equal (n_bcs, 0);
119  total_packed_bc_data += n_bcs;
120  }
121  }
122 
123  return
124 #ifndef NDEBUG
125  1 + // Account for magic header
126 #endif
127  pre_indexing_size + indexing_size + total_packed_bc_data;
128 }
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
static const unsigned int type_to_n_sides_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of sides on the element...
Definition: elem.h:589
ElemType
Defines an enum for geometric element types.
uint64_t largest_id_type
Definition: id_types.h:139
static const unsigned int type_to_n_nodes_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of nodes in the element...
Definition: elem.h:564
const dof_id_type n_nodes
Definition: tecplot_io.C:67
static const unsigned int type_to_n_edges_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of edges on the element...
Definition: elem.h:638
template<>
unsigned int libMesh::Parallel::Packing< const Elem * >::packed_size ( std::vector< largest_id_type >::iterator  in)

Definition at line 135 of file parallel_elem.C.

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

136 {
137  return packed_size(std::vector<largest_id_type>::const_iterator(in));
138 }
static unsigned int packed_size(BufferIter iter)
template<typename BufferIter , typename Context >
const Elem * libMesh::Parallel::Packing< const Elem * >::unpack ( BufferIter  in,
Context *  ctx 
)
static

Definition at line 84 of file parallel_elem.h.

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

85 { return Packing<Elem*>::unpack(in, ctx); }
PetscErrorCode Vec Mat Mat void * ctx
static T unpack(BufferIter in, Context *ctx)

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