23 #include "libmesh/boundary_info.h" 24 #include "libmesh/distributed_mesh.h" 25 #include "libmesh/elem.h" 26 #include "libmesh/mesh_base.h" 27 #include "libmesh/parallel_elem.h" 28 #include "libmesh/parallel_mesh.h" 29 #include "libmesh/remote_elem.h" 37 #ifdef LIBMESH_ENABLE_UNIQUE_ID 38 static const unsigned int header_size = 12;
40 static const unsigned int header_size = 11;
62 libmesh_assert_equal_to (packed_header, elem_magic_header);
66 const unsigned int level =
67 cast_int<unsigned int>(*in);
70 const int typeint = cast_int<int>(*(in+4));
71 libmesh_assert_greater_equal (typeint, 0);
74 cast_int<ElemType>(typeint);
80 libmesh_not_implemented_msg(
"Support for Polygons/Polyhedra not yet implemented");
82 const unsigned int n_sides =
85 const unsigned int n_edges =
88 const unsigned int pre_indexing_size =
89 header_size +
n_nodes + n_sides*2;
91 const unsigned int indexing_size =
95 unsigned int total_packed_bc_data = 1;
96 largest_id_type on_boundary = *(in + pre_indexing_size + indexing_size);
101 total_packed_bc_data++;
102 largest_id_type allow_children_on_boundary = *(in + pre_indexing_size + indexing_size + 1);
106 if (level == 0 || allow_children_on_boundary)
108 for (
unsigned int s = 0; s != n_sides; ++s)
110 const int n_bcs = cast_int<int>
111 (*(in + pre_indexing_size + indexing_size +
112 total_packed_bc_data++));
113 libmesh_assert_greater_equal (n_bcs, 0);
114 total_packed_bc_data += n_bcs;
120 for (
unsigned int e = 0; e != n_edges; ++e)
122 const int n_bcs = cast_int<int>
123 (*(in + pre_indexing_size + indexing_size +
124 total_packed_bc_data++));
125 libmesh_assert_greater_equal (n_bcs, 0);
126 total_packed_bc_data += n_bcs;
129 for (
unsigned short sf=0; sf != 2; ++sf)
131 const int n_bcs = cast_int<int>
132 (*(in + pre_indexing_size + indexing_size +
133 total_packed_bc_data++));
134 libmesh_assert_greater_equal (n_bcs, 0);
135 total_packed_bc_data += n_bcs;
143 pre_indexing_size + indexing_size + total_packed_bc_data;
152 return packed_size(std::vector<largest_id_type>::const_iterator(in));
163 unsigned int total_packed_bcs = 1;
164 const unsigned short n_sides = elem->
n_sides();
182 total_packed_bcs += n_sides;
183 for (
unsigned short s = 0; s != n_sides; ++s)
189 if (elem->
level() == 0)
191 const unsigned short n_edges = elem->
n_edges();
192 total_packed_bcs += n_edges;
193 for (
unsigned short e = 0; e != n_edges; ++e)
197 total_packed_bcs += 2;
198 for (
unsigned short sf=0; sf != 2; ++sf)
207 header_size + elem->
n_nodes() + n_sides*2 +
236 std::back_insert_iterator<std::vector<largest_id_type>> data_out,
242 *data_out++ = elem_magic_header;
245 #ifdef LIBMESH_ENABLE_AMR 258 *data_out++ = (refinement_info);
270 *data_out++ = (elem->
id());
272 #ifdef LIBMESH_ENABLE_UNIQUE_ID 274 *data_out++ = (static_cast<largest_id_type>(elem->
unique_id()));
280 #ifdef LIBMESH_ENABLE_AMR 282 if (elem->
level() == 0)
289 *data_out++ =(elem->
parent()->
id());
297 if ((elem->
dim() < LIBMESH_DIM) &&
304 *data_out++ = node.id();
311 *data_out++ = (neigh->id());
315 *data_out++ = neigh->which_neighbor_am_i(elem);
338 *data_out++ = on_boundary;
347 std::vector<boundary_id_type> bcs;
352 *data_out++ =(bcs.size());
354 for (
const auto & bid : bcs)
362 if (elem->
level() == 0)
364 std::vector<boundary_id_type> bcs;
369 *data_out++ =(bcs.size());
371 for (
const auto & bid : bcs)
375 for (
unsigned short sf=0; sf != 2; ++sf)
379 *data_out++ =(bcs.size());
381 for (
const auto & bid : bcs)
392 std::back_insert_iterator<std::vector<largest_id_type>> data_out,
395 pack(elem, data_out, static_cast<const MeshBase*>(
mesh));
403 std::back_insert_iterator<std::vector<largest_id_type>> data_out,
406 pack(elem, data_out, static_cast<const MeshBase*>(
mesh));
418 const std::vector<largest_id_type>::const_iterator original_in = in;
421 libmesh_assert_equal_to (incoming_header, elem_magic_header);
425 const unsigned int level =
426 cast_int<unsigned int>(*in++);
428 #ifdef LIBMESH_ENABLE_AMR 430 const unsigned int p_level =
431 cast_int<unsigned int>(*in++);
434 const int rflag = cast_int<int>(*in++);
435 const int invalid_rflag =
437 libmesh_assert_greater_equal (rflag, 0);
439 libmesh_assert_less (rflag, invalid_rflag*2+1);
441 const bool has_children = (rflag > invalid_rflag);
444 cast_int<Elem::RefinementState>(rflag - invalid_rflag - 1) :
445 cast_int<Elem::RefinementState>(rflag);
448 const int pflag = cast_int<int>(*in++);
449 libmesh_assert_greater_equal (pflag, 0);
452 cast_int<Elem::RefinementState>(pflag);
455 #endif // LIBMESH_ENABLE_AMR 458 const int typeint = cast_int<int>(*in++);
459 libmesh_assert_greater_equal (typeint, 0);
462 cast_int<ElemType>(typeint);
469 cast_int<processor_id_type>(*in++);
475 cast_int<subdomain_id_type>(*in++);
479 cast_int<dof_id_type>(*in++);
482 #ifdef LIBMESH_ENABLE_UNIQUE_ID 485 cast_int<unique_id_type>(*in++);
488 #ifdef LIBMESH_ENABLE_AMR 496 ? static_cast<dof_id_type>(*in++)
497 : cast_int<dof_id_type>(*in++);
504 const unsigned int which_child_am_i =
506 ? static_cast<unsigned int>(*in++)
507 : cast_int<unsigned int>(*in++);
510 #endif // LIBMESH_ENABLE_AMR 517 libmesh_assert_equal_to (in - original_in, header_size + 1);
526 libmesh_assert_equal_to (elem->
level(), level);
527 libmesh_assert_equal_to (elem->
id(), id);
531 libmesh_assert_equal_to (elem->
processor_id(), processor_id);
532 libmesh_assert_equal_to (elem->
subdomain_id(), subdomain_id);
533 libmesh_assert_equal_to (elem->
type(), type);
538 for (
unsigned int i=0; i !=
n_nodes; ++i)
540 cast_int<dof_id_type>(*in++));
545 #ifdef LIBMESH_ENABLE_AMR 547 libmesh_assert_equal_to (elem->
has_children(), has_children);
552 libmesh_assert_equal_to (elem->
p_level(), p_level);
569 if (elem->
dim() < LIBMESH_DIM)
620 cast_int<dof_id_type>(*in++);
623 cast_int<dof_id_type>(*in++);
698 #ifdef LIBMESH_ENABLE_AMR 707 #endif // LIBMESH_ENABLE_AMR 717 Elem * parent =
nullptr;
718 #ifdef LIBMESH_ENABLE_AMR 733 libmesh_assert_equal_to (level, 0);
739 #ifdef LIBMESH_ENABLE_AMR 746 parent->
add_child(elem, which_child_am_i);
753 libmesh_assert_equal_to (elem->
level(), level);
761 for (
unsigned int c=0; c != nc; ++c)
765 #endif // LIBMESH_ENABLE_AMR 771 #ifdef LIBMESH_ENABLE_UNIQUE_ID 778 for (
unsigned int n=0; n !=
n_nodes; n++)
780 (cast_int<dof_id_type>(*in++)));
811 cast_int<dof_id_type>(*in++);
814 cast_int<dof_id_type>(*in++);
855 auto on_boundary = *in++;
861 auto children_on_boundary = *in++;
862 if (elem->
level() == 0 || children_on_boundary)
867 cast_int<boundary_id_type>(*in++);
871 (elem, s, cast_int<boundary_id_type>(*in++));
883 cast_int<boundary_id_type>(*in++);
887 (elem, e, cast_int<boundary_id_type>(*in++));
890 for (
unsigned short sf=0; sf != 2; ++sf)
893 cast_int<boundary_id_type>(*in++);
897 (elem, sf, cast_int<boundary_id_type>(*in++));
912 return unpack(in, static_cast<MeshBase*>(
mesh));
922 return unpack(in, static_cast<MeshBase*>(
mesh));
void set_p_level(const unsigned int p)
Sets the value of the p-refinement level for the element.
RefinementState refinement_flag() const
ElemType
Defines an enum for geometric element types.
unique_id_type & set_unique_id()
const Elem * parent() const
void raw_boundary_ids(const Elem *const elem, const unsigned short int side, std::vector< boundary_id_type > &vec_to_fill) const
virtual Node *& set_node(const unsigned int i)
A Node is like a Point, but with more information.
const MeshBase & interior_mesh() const
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 ...
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
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...
const Elem * interior_parent() const
IntRange< unsigned short > side_index_range() const
unsigned int n_shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface) const
RefinementState p_refinement_flag() const
This is the base class from which all geometric element types are derived.
void add_child(Elem *elem)
Adds a child pointer to the array of children of this element.
RefinementState
Enumeration of possible element refinement states.
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
unique_id_type unique_id() const
virtual unsigned int n_children() const =0
unsigned int p_level() const
void shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
The libMesh namespace provides an interface to certain functionality in the library.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
static T unpack(BufferIter in, Context *ctx)
void set_interior_parent(Elem *p)
Sets the pointer to the element's interior_parent.
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...
static unsigned int packable_size(const T &object, const Context *context)
This is the MeshBase class.
IntRange< unsigned short > edge_index_range() const
uint8_t processor_id_type
const dof_id_type n_nodes
unsigned int n_raw_boundary_ids(const Elem *const elem, const unsigned short int side) const
void make_links_to_me_local(unsigned int n, unsigned int neighbor_side)
Resets the neighbor_side pointers of our nth neighbor (and its descendants, if appropriate) to point ...
virtual unsigned int n_nodes() const =0
static const unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
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...
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
static unsigned int packed_size(BufferIter iter)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
bool valid_unique_id() const
virtual unsigned int n_edges() const =0
void hack_p_level_and_refinement_flag(const unsigned int p, RefinementState pflag)
Sets the value of the p-refinement level for the element without altering the p-level of its ancestor...
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
static void pack(const T &object, OutputIter data_out, const Context *context)
unsigned int which_child_am_i(const Elem *e) const
SimpleRange< NodeRefIter > node_ref_range()
Returns a range with all nodes of an element, usable in range-based for loops.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual unsigned int n_sides() const =0
const Elem * neighbor_ptr(unsigned int i) const
unsigned int level() const
unsigned int n_edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
subdomain_id_type subdomain_id() const
unsigned int packed_indexing_size() const
If we pack our indices into an buffer for communications, how many ints do we need?
virtual unsigned short dim() const =0
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...
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
Add shell face shellface of element number elem with boundary id id to the boundary information data ...
void unpack_indexing(std::vector< largest_id_type >::const_iterator begin)
A method for creating our index buffer from packed data - basically with our current implementation w...
void edge_boundary_ids(const Elem *const elem, const unsigned short int edge, std::vector< boundary_id_type > &vec_to_fill) const
bool is_children_on_boundary_side() const
SimpleRange< NeighborPtrIter > neighbor_ptr_range()
Returns a range with all neighbors of an element, usable in range-based for loops.
void set_p_refinement_flag(const RefinementState pflag)
Sets the value of the p-refinement flag for the element.
virtual const Node * node_ptr(const dof_id_type i) const =0
processor_id_type processor_id() const
processor_id_type processor_id() const
virtual ElemType type() const =0
dof_id_type node_id(const unsigned int i) const
bool has_children() const
const Elem * child_ptr(unsigned int i) const
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
Add edge edge of element number elem with boundary id id to the boundary information data structure...
const RemoteElem * remote_elem