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);
 
   79   const unsigned int n_sides =
 
   82   const unsigned int n_edges =
 
   85   const unsigned int pre_indexing_size =
 
   86     header_size + 
n_nodes + n_sides*2;
 
   88   const unsigned int indexing_size =
 
   91   unsigned int total_packed_bc_data = 0;
 
   94       for (
unsigned int s = 0; s != n_sides; ++s)
 
   96           const int n_bcs = cast_int<int>
 
   97             (*(in + pre_indexing_size + indexing_size +
 
   98                total_packed_bc_data++));
 
   99           libmesh_assert_greater_equal (n_bcs, 0);
 
  100           total_packed_bc_data += n_bcs;
 
  103       for (
unsigned int e = 0; e != n_edges; ++e)
 
  105           const int n_bcs = cast_int<int>
 
  106             (*(in + pre_indexing_size + indexing_size +
 
  107                total_packed_bc_data++));
 
  108           libmesh_assert_greater_equal (n_bcs, 0);
 
  109           total_packed_bc_data += n_bcs;
 
  112       for (
unsigned short sf=0; sf != 2; ++sf)
 
  114           const int n_bcs = cast_int<int>
 
  115             (*(in + pre_indexing_size + indexing_size +
 
  116                total_packed_bc_data++));
 
  117           libmesh_assert_greater_equal (n_bcs, 0);
 
  118           total_packed_bc_data += n_bcs;
 
  126     pre_indexing_size + indexing_size + total_packed_bc_data;
 
  135   return packed_size(std::vector<largest_id_type>::const_iterator(in));
 
  145   unsigned int total_packed_bcs = 0;
 
  146   const unsigned short n_sides = elem->
n_sides();
 
  148   if (elem->
level() == 0)
 
  150       total_packed_bcs += n_sides;
 
  151       for (
unsigned short s = 0; s != n_sides; ++s)
 
  155       const unsigned short n_edges = elem->
n_edges();
 
  156       total_packed_bcs += n_edges;
 
  157       for (
unsigned short e = 0; e != n_edges; ++e)
 
  161       total_packed_bcs += 2; 
 
  162       for (
unsigned short sf=0; sf != 2; ++sf)
 
  171     header_size + elem->
n_nodes() + n_sides*2 +
 
  182   return packable_size(elem, static_cast<const MeshBase *>(
mesh));
 
  192   return packable_size(elem, static_cast<const MeshBase *>(
mesh));
 
  200                              std::back_insert_iterator<std::vector<largest_id_type>> data_out,
 
  206   *data_out++ = elem_magic_header;
 
  209 #ifdef LIBMESH_ENABLE_AMR 
  210   *data_out++ = (static_cast<largest_id_type>(elem->
level()));
 
  211   *data_out++ = (static_cast<largest_id_type>(elem->
p_level()));
 
  222   *data_out++ = (refinement_info);
 
  231   *data_out++ = (static_cast<largest_id_type>(elem->
type()));
 
  234   *data_out++ = (elem->
id());
 
  236 #ifdef LIBMESH_ENABLE_UNIQUE_ID 
  238     *data_out++ = (static_cast<largest_id_type>(elem->
unique_id()));
 
  244 #ifdef LIBMESH_ENABLE_AMR 
  246   if (elem->
level() == 0)
 
  253       *data_out++ =(elem->
parent()->
id());
 
  261   if ((elem->
dim() < LIBMESH_DIM) &&
 
  268     *data_out++ = node.id();
 
  275         *data_out++ = (neigh->id());
 
  279           *data_out++ = neigh->which_neighbor_am_i(elem);
 
  293   if (elem->
level() == 0)
 
  295       std::vector<boundary_id_type> bcs;
 
  300           *data_out++ =(bcs.size());
 
  302           for (
const auto & bid : bcs)
 
  310           *data_out++ =(bcs.size());
 
  312           for (
const auto & bid : bcs)
 
  316       for (
unsigned short sf=0; sf != 2; ++sf)
 
  320           *data_out++ =(bcs.size());
 
  322           for (
const auto & bid : bcs)
 
  333                              std::back_insert_iterator<std::vector<largest_id_type>> data_out,
 
  336   pack(elem, data_out, static_cast<const MeshBase*>(
mesh));
 
  344                              std::back_insert_iterator<std::vector<largest_id_type>> data_out,
 
  347   pack(elem, data_out, static_cast<const MeshBase*>(
mesh));
 
  359   const std::vector<largest_id_type>::const_iterator original_in = in;
 
  362   libmesh_assert_equal_to (incoming_header, elem_magic_header);
 
  366   const unsigned int level =
 
  367     cast_int<unsigned int>(*in++);
 
  369 #ifdef LIBMESH_ENABLE_AMR 
  371   const unsigned int p_level =
 
  372     cast_int<unsigned int>(*in++);
 
  375   const int rflag = cast_int<int>(*in++);
 
  376   const int invalid_rflag =
 
  378   libmesh_assert_greater_equal (rflag, 0);
 
  380   libmesh_assert_less (rflag, invalid_rflag*2+1);
 
  382   const bool has_children = (rflag > invalid_rflag);
 
  385     cast_int<Elem::RefinementState>(rflag - invalid_rflag - 1) :
 
  386     cast_int<Elem::RefinementState>(rflag);
 
  389   const int pflag = cast_int<int>(*in++);
 
  390   libmesh_assert_greater_equal (pflag, 0);
 
  393     cast_int<Elem::RefinementState>(pflag);
 
  396 #endif // LIBMESH_ENABLE_AMR 
  399   const int typeint = cast_int<int>(*in++);
 
  400   libmesh_assert_greater_equal (typeint, 0);
 
  403     cast_int<ElemType>(typeint);
 
  410     cast_int<processor_id_type>(*in++);
 
  416     cast_int<subdomain_id_type>(*in++);
 
  420     cast_int<dof_id_type>(*in++);
 
  423 #ifdef LIBMESH_ENABLE_UNIQUE_ID 
  426     cast_int<unique_id_type>(*in++);
 
  429 #ifdef LIBMESH_ENABLE_AMR 
  437     ? static_cast<dof_id_type>(*in++)
 
  438     : cast_int<dof_id_type>(*in++);
 
  445   const unsigned int which_child_am_i =
 
  447     ? static_cast<unsigned int>(*in++)
 
  448     : cast_int<unsigned int>(*in++);
 
  451 #endif // LIBMESH_ENABLE_AMR 
  454     static_cast<dof_id_type>(*in++);
 
  458   libmesh_assert_equal_to (in - original_in, header_size + 1);
 
  467       libmesh_assert_equal_to (elem->
level(), level);
 
  468       libmesh_assert_equal_to (elem->
id(), id);
 
  472       libmesh_assert_equal_to (elem->
processor_id(), processor_id);
 
  473       libmesh_assert_equal_to (elem->
subdomain_id(), subdomain_id);
 
  474       libmesh_assert_equal_to (elem->
type(), type);
 
  479       for (
unsigned int i=0; i != 
n_nodes; ++i)
 
  481                        cast_int<dof_id_type>(*in++));
 
  486 #ifdef LIBMESH_ENABLE_AMR 
  488       libmesh_assert_equal_to (elem->
has_children(), has_children);
 
  493           libmesh_assert_equal_to (elem->
p_level(), p_level);
 
  510             if (elem->
dim() < LIBMESH_DIM)
 
  560               cast_int<dof_id_type>(*in++);
 
  563               cast_int<dof_id_type>(*in++);
 
  623 #ifdef LIBMESH_ENABLE_AMR 
  629 #endif // LIBMESH_ENABLE_AMR 
  639       Elem * parent = 
nullptr;
 
  640 #ifdef LIBMESH_ENABLE_AMR 
  655       libmesh_assert_equal_to (level, 0);
 
  661 #ifdef LIBMESH_ENABLE_AMR 
  668           parent->
add_child(elem, which_child_am_i);
 
  675       libmesh_assert_equal_to (elem->
level(), level);
 
  683           for (
unsigned int c=0; c != nc; ++c)
 
  687 #endif // LIBMESH_ENABLE_AMR 
  693 #ifdef LIBMESH_ENABLE_UNIQUE_ID 
  700       for (
unsigned int n=0; n != 
n_nodes; n++)
 
  703           (cast_int<dof_id_type>(*in++));
 
  733             cast_int<dof_id_type>(*in++);
 
  736               cast_int<dof_id_type>(*in++);
 
  781             cast_int<boundary_id_type>(*in++);
 
  785               (elem, s, cast_int<boundary_id_type>(*in++));
 
  791             cast_int<boundary_id_type>(*in++);
 
  795               (elem, e, cast_int<boundary_id_type>(*in++));
 
  798       for (
unsigned short sf=0; sf != 2; ++sf)
 
  801             cast_int<boundary_id_type>(*in++);
 
  805               (elem, sf, cast_int<boundary_id_type>(*in++));
 
  820   return unpack(in, static_cast<MeshBase*>(
mesh));
 
  830   return unpack(in, static_cast<MeshBase*>(
mesh));