468{
469#ifndef NDEBUG
470 const std::vector<largest_id_type>::const_iterator original_in = in;
471
473 libmesh_assert_equal_to (incoming_header, elem_magic_header);
474#endif
475
476
477 const unsigned int level =
478 cast_int<unsigned int>(*in++);
479
480#ifdef LIBMESH_ENABLE_AMR
481
482 const unsigned int p_level =
483 cast_int<unsigned int>(*in++);
484
485
486 const int rflag = cast_int<int>(*in++);
487 const int invalid_rflag =
489 libmesh_assert_greater_equal (rflag, 0);
490
491 libmesh_assert_less (rflag, invalid_rflag*2+1);
492
493 const bool has_children = (rflag > invalid_rflag);
494
496 cast_int<Elem::RefinementState>(rflag - invalid_rflag - 1) :
498
499
500 const int pflag = cast_int<int>(*in++);
501 libmesh_assert_greater_equal (pflag, 0);
504 cast_int<Elem::RefinementState>(pflag);
505#else
506 in += 3;
507#endif
508
509
510 const int typeint = cast_int<int>(*in++);
511 libmesh_assert_greater_equal (typeint, 0);
514 cast_int<ElemType>(typeint);
515
519
520
522
523
525 cast_int<processor_id_type>(*in++);
528
529
531 cast_int<subdomain_id_type>(*in++);
532
533
535 cast_int<dof_id_type>(*in++);
537
538#ifdef LIBMESH_ENABLE_UNIQUE_ID
539
541 cast_int<unique_id_type>(*in++);
542#endif
543
544#ifdef LIBMESH_ENABLE_AMR
545
546
547
548
549
551 (level == 0)
553 : cast_int<dof_id_type>(*in++);
556
557
558
559
560 const unsigned int which_child_am_i =
561 (level == 0)
562 ? static_cast<unsigned int>(*in++)
563 : cast_int<unsigned int>(*in++);
564#else
565 in += 2;
566#endif
567
570
571
572
573 libmesh_assert_equal_to (in - original_in, header_size + 1);
574
575 if (has_runtime_topology)
576 {
577 n_nodes = cast_int<unsigned int>(*in++);
578 n_sides = cast_int<unsigned int>(*in++);
579 n_edges = cast_int<unsigned int>(*in++);
580
582 {
583 libmesh_assert_less (2, n_sides);
584 libmesh_assert_equal_to (
n_nodes % n_sides, 0);
585 libmesh_assert_equal_to (n_edges, n_sides);
586 }
588 {
589 libmesh_assert_less (3,
n_nodes);
590 libmesh_assert_less (3, n_sides);
591 }
592 }
594
595 const auto node_ids_in = in;
597
598 std::vector<std::vector<unsigned int>> polyhedron_side_nodes;
600 {
601 polyhedron_side_nodes.resize(n_sides);
602#ifndef NDEBUG
603 std::vector<bool> node_seen(
n_nodes,
false);
604 unsigned int next_new_node = 0;
605#endif
606 for (auto & side_nodes : polyhedron_side_nodes)
607 {
608 const unsigned int n_side_nodes =
609 cast_int<unsigned int>(*in++);
610 libmesh_assert_less (2, n_side_nodes);
611 side_nodes.resize(n_side_nodes);
612 for (auto & node : side_nodes)
613 {
614 node = cast_int<unsigned int>(*in++);
615 libmesh_assert_less (node,
n_nodes);
616
617#ifndef NDEBUG
619 {
620 libmesh_assert_equal_to (node, next_new_node);
621 node_seen[node] = true;
622 ++next_new_node;
623 }
624#endif
625 }
626 }
627
628#ifndef NDEBUG
632#endif
633 }
634
636
637
638
639
640 if (elem)
641 {
642 libmesh_assert_equal_to (elem->
level(), level);
643 libmesh_assert_equal_to (elem->
id(),
id);
644
645
646
647 libmesh_assert_equal_to (elem->
processor_id(), processor_id);
648 libmesh_assert_equal_to (elem->
subdomain_id(), subdomain_id);
649 libmesh_assert_equal_to (elem->
type(), type);
651 libmesh_assert_equal_to (elem->
n_sides(), n_sides);
652 libmesh_assert_equal_to (elem->
n_edges(), n_edges);
653
654#ifndef NDEBUG
656 for (auto s : elem->side_index_range())
658 polyhedron_side_nodes[s]);
659#endif
660
661#ifndef NDEBUG
662
663 for (
unsigned int i=0; i !=
n_nodes; ++i)
664 libmesh_assert_equal_to
666 cast_int<dof_id_type>(*(node_ids_in + i)));
667#endif
668
669#ifdef LIBMESH_ENABLE_AMR
671 libmesh_assert_equal_to (elem->
has_children(), has_children);
672
673#ifdef DEBUG
675 {
676 libmesh_assert_equal_to (elem->
p_level(), p_level);
678 }
679#endif
680
684#endif
685
686
687
688 {
689
690
692 {
693 if (elem->
dim() < LIBMESH_DIM)
695 }
696
697
698
699
701 {
703 }
704 else
705 {
708
709
710
711
712 if (!ip)
714 else
715 {
716
717
718
719
720
723
724
726 {
728 }
729 }
730 }
731 }
732
733
734
735
736
737
738
739
740 for (auto n : elem->side_index_range())
741 {
743 cast_int<dof_id_type>(*in++);
744
746 cast_int<dof_id_type>(*in++);
747
748
749
750
751
753 {
757 else
759 continue;
760 }
761
762
763
764
765
767 {
768
769
770
771
772
773 continue;
774 }
775
777
778
779
780
781 if (!neigh)
782 {
784 continue;
785 }
786
787
788
789
790
791
794
795
796
797
799 {
801 }
802 else
806
809 }
810
811
812
813
814
815
816
817
818
819#ifdef LIBMESH_ENABLE_AMR
821 {
822
823
824
825
827 }
828#endif
829
830
831
832 }
833 else
834 {
835
836
837
838 Elem * parent =
nullptr;
839#ifdef LIBMESH_ENABLE_AMR
840
841 if (level > 0)
842 {
843
844
845
846
848 }
849
850 else
852#else
853
854 libmesh_assert_equal_to (level, 0);
855#endif
856
858 elem = std::make_unique<C0Polygon>(
n_nodes, parent).release();
860 {
861 std::vector<std::shared_ptr<Polygon>> sides(n_sides);
863 {
864 const auto & side_nodes = polyhedron_side_nodes[s];
865 auto side = std::make_shared<C0Polygon>
866 (cast_int<unsigned int>(side_nodes.size()));
868 {
870 cast_int<dof_id_type>
871 (*(node_ids_in + side_nodes[n]));
873 }
874 sides[s] = std::move(side);
875 }
876
877 std::unique_ptr<Node> generated_mid_node;
878 auto polyhedron = std::make_unique<C0Polyhedron>
879 (sides, generated_mid_node, parent);
880
881 libmesh_assert_equal_to (polyhedron->n_nodes(),
n_nodes);
882
883 if (generated_mid_node)
884 {
886 cast_int<dof_id_type>(*(node_ids_in +
n_nodes - 1));
887 polyhedron->set_node(
n_nodes - 1,
889 }
890
891 elem = polyhedron.release();
892 }
893 else
896
897#ifdef LIBMESH_ENABLE_AMR
898 if (level != 0)
899 {
900
901
903
904 parent->
add_child(elem, which_child_am_i);
905 }
906
907
911 libmesh_assert_equal_to (elem->
level(), level);
912
913
914
915
916 if (has_children)
917 {
919 for (unsigned int c=0; c != nc; ++c)
921 }
922
923#endif
924
925
929#ifdef LIBMESH_ENABLE_UNIQUE_ID
931#endif
932
933
935 libmesh_assert_equal_to (elem->
n_sides(), n_sides);
936 libmesh_assert_equal_to (elem->
n_edges(), n_edges);
937
939 for (
unsigned int n=0; n !=
n_nodes; n++)
942 (cast_int<dof_id_type>(*(node_ids_in + n))));
943
944#ifndef NDEBUG
945 for (
unsigned int n = 0; n !=
n_nodes; ++n)
946 libmesh_assert_equal_to
948 cast_int<dof_id_type>(*(node_ids_in + n)));
949#endif
950
951
952 {
953
954
955
956
957
959 {
962 }
964 {
965
966
969 if (!ip )
972 else
974 }
975 }
976
977 for (auto n : elem->side_index_range())
978 {
980 cast_int<dof_id_type>(*in++);
981
983 cast_int<dof_id_type>(*in++);
984
986 continue;
987
988
989
990
991
992
994 {
996 continue;
997 }
998
999
1000
1002 if (!neigh)
1003 {
1005 continue;
1006 }
1007
1008
1009
1010
1012
1015 }
1016
1018
1020 }
1021
1023
1024
1025 auto on_boundary = *in++;
1026 if (on_boundary)
1027 {
1028
1029
1030
1031 auto children_on_boundary = *in++;
1032 if (elem->
level() == 0 || children_on_boundary)
1033 {
1034 for (auto s : elem->side_index_range())
1035 {
1037 cast_int<boundary_id_type>(*in++);
1038
1041 (elem, s, cast_int<boundary_id_type>(*in++));
1042 }
1043 }
1044 }
1045
1046
1047
1048 if (level == 0)
1049 {
1050 for (auto e : elem->edge_index_range())
1051 {
1053 cast_int<boundary_id_type>(*in++);
1054
1057 (elem, e, cast_int<boundary_id_type>(*in++));
1058 }
1059
1060 for (unsigned short sf=0; sf != 2; ++sf)
1061 {
1063 cast_int<boundary_id_type>(*in++);
1064
1067 (elem, sf, cast_int<boundary_id_type>(*in++));
1068 }
1069 }
1070
1071
1072 return elem;
1073}
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 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.
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.
processor_id_type processor_id() const
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
void set_unique_id(unique_id_type new_id)
Sets the unique_id for this DofObject.
unsigned int packed_indexing_size() const
If we pack our indices into an buffer for communications, how many ints do we need?
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...
This is the base class from which all geometric element types are derived.
virtual Node *& set_node(const unsigned int i)
void set_p_refinement_flag(const RefinementState pflag)
Sets the value of the p-refinement flag for the element.
RefinementState refinement_flag() const
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...
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...
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...
bool has_children() const
virtual unsigned int n_nodes() const =0
const Elem * parent() 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 ...
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
const Elem * child_ptr(unsigned int i) const
RefinementState
Enumeration of possible element refinement states.
@ INVALID_REFINEMENTSTATE
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
void set_interior_parent(Elem *p)
Sets the pointer to the element's interior_parent.
virtual unsigned short dim() const =0
subdomain_id_type subdomain_id() const
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
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...
unsigned int level() const
virtual bool runtime_topology() const
void add_child(Elem *elem)
Adds a child pointer to the array of children of this element.
virtual unsigned int n_children() const =0
virtual ElemType type() const =0
const Elem * interior_parent() const
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
virtual unsigned int n_edges() const =0
virtual unsigned int n_sides() const =0
dof_id_type node_id(const unsigned int i) const
unsigned int p_level() const
RefinementState p_refinement_flag() const
void set_p_level(const unsigned int p)
Sets the value of the p-refinement level for the element.
const Elem * neighbor_ptr(unsigned int i) const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const MeshBase & interior_mesh() const
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
processor_id_type processor_id() const
In parallel meshes where a ghost element has neighbors which do not exist on the local processor,...
Tnew cast_int(Told oldvar)
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
ElemType
Defines an enum for geometric element types.
void libmesh_ignore(const Args &...)
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
const RemoteElem * remote_elem
uint8_t processor_id_type
const dof_id_type n_nodes