55 unsigned short int side_in=0,
63 bool operator < (
const DofBCData & other)
const 65 if (this->dof_id == other.dof_id)
66 return (this->side < other.side);
68 return this->dof_id < other.dof_id;
73 bool operator < (
const unsigned int & other_dof_id,
74 const DofBCData & dof_bc)
76 return other_dof_id < dof_bc.dof_id;
80 const unsigned int & other_dof_id)
83 return dof_bc.dof_id < other_dof_id;
90 #if defined(__SUNPRO_CC) || defined(__PGI) 91 struct CompareIntDofBCData
93 bool operator()(
const unsigned int & other_dof_id,
94 const DofBCData & dof_bc)
96 return other_dof_id < dof_bc.dof_id;
99 bool operator()(
const DofBCData & dof_bc,
100 const unsigned int & other_dof_id)
102 return dof_bc.dof_id < other_dof_id;
107 template <
class T,
class U>
108 struct libmesh_type_is_same {
113 struct libmesh_type_is_same<T, T> {
114 static const bool value =
true;
135 _write_serial (false),
136 _write_parallel (false),
137 #ifdef LIBMESH_ENABLE_UNIQUE_ID
138 _write_unique_id (true),
140 _write_unique_id (false),
143 _version (
"libMesh-1.3.0"),
144 _bc_file_name (
"n/a"),
145 _partition_map_file (
"n/a"),
146 _subdomain_map_file (
"n/a"),
147 _p_level_file (
"n/a")
171 libmesh_error_msg(
"We don't support writing parallel files in the legacy format.");
175 START_LOG(
"write()",
"XdrIO");
197 if ((n_side_bcs || n_edge_bcs || n_shellface_bcs || n_nodesets) &&
211 if ((n_p_levels > 1) &&
218 std::string full_ver = this->
version() + (write_parallel_files ?
" parallel" :
"");
222 io.
data (max_node_id,
"# number of nodes");
238 io.
data (write_size,
"# type size");
240 io.
data (write_partitioning ? write_size : zero_size,
"# pid size");
241 io.
data (write_subdomain_id ? write_size : zero_size,
"# sid size");
242 io.
data (write_p_level ? write_size : zero_size,
"# p-level size");
244 io.
data (write_bcs ? write_size : zero_size,
"# eid size");
245 io.
data (write_bcs ? write_size : zero_size,
"# side size");
246 io.
data (write_bcs ? write_size : zero_size,
"# bid size");
249 if (write_parallel_files)
253 libMesh::out <<
"Warning! Parallel xda/xdr is not yet implemented.\n";
254 libMesh::out <<
"Writing a serialized file instead." << std::endl;
301 STOP_LOG(
"write()",
"XdrIO");
321 std::vector<new_header_id_type> subdomain_ids;
322 subdomain_ids.reserve(subdomain_map.size());
324 std::vector<std::string> subdomain_names;
325 subdomain_names.reserve(subdomain_map.size());
331 for (
const auto & pr : subdomain_map)
332 if (!pr.second.empty())
335 subdomain_ids.push_back(pr.first);
336 subdomain_names.push_back(pr.second);
339 io.
data(n_subdomain_names,
"# subdomain id to name map");
341 if (n_subdomain_names)
343 io.
data(subdomain_ids);
344 io.
data(subdomain_names);
374 n_global_elem_at_level[level] =
378 this->
comm().
sum(n_global_elem_at_level[level]);
380 tot_n_elem += n_global_elem_at_level[level];
382 libmesh_assert_less_equal (n_global_elem_at_level[level],
n_elem);
383 libmesh_assert_less_equal (tot_n_elem,
n_elem);
386 std::vector<xdr_id_type>
387 xfer_conn, recv_conn;
388 std::vector<dof_id_type>
390 std::vector<xdr_id_type> output_buffer;
391 std::vector<std::size_t>
394 #ifdef LIBMESH_ENABLE_AMR 395 typedef std::map<dof_id_type, std::pair<processor_id_type, dof_id_type>> id_map_type;
396 id_map_type parent_id_map, child_id_map;
407 #ifdef LIBMESH_ENABLE_AMR 408 parent_id_map[elem->id()] = std::make_pair(this->
processor_id(),
413 xfer_conn.push_back(my_next_elem);
415 std::size_t my_size = xfer_conn.size();
416 this->
comm().
gather (0, my_next_elem, n_elem_on_proc);
417 this->
comm().
gather (0, my_size, xfer_buf_sizes);
419 processor_offsets[0] = 0;
420 for (
unsigned int pid=1; pid<this->
n_processors(); pid++)
421 processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
429 std::string comment =
"# n_elem at level 0", legend =
", [ type ";
432 if (write_partitioning)
434 if (write_subdomain_id)
437 legend +=
"p_level ";
438 legend +=
"(n0 ... nN-1) ]";
440 io.
data (n_global_elem_at_level[0], comment.c_str());
443 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
445 recv_conn.resize(xfer_buf_sizes[pid]);
447 recv_conn = xfer_conn;
453 libmesh_assert (!recv_conn.empty());
456 const xdr_id_type n_elem_received = recv_conn.back();
457 std::vector<xdr_id_type>::const_iterator recv_conn_iter = recv_conn.begin();
459 for (
xdr_id_type elem=0; elem<n_elem_received; elem++, next_global_elem++)
461 output_buffer.clear();
468 output_buffer.push_back(*recv_conn_iter);
473 output_buffer.push_back(*recv_conn_iter);
477 if (write_partitioning)
478 output_buffer.push_back(*recv_conn_iter);
482 if (write_subdomain_id)
483 output_buffer.push_back(*recv_conn_iter);
486 #ifdef LIBMESH_ENABLE_AMR 489 output_buffer.push_back(*recv_conn_iter);
493 output_buffer.push_back(*recv_conn_iter);
496 (output_buffer.data(),
497 cast_int<unsigned int>(output_buffer.size()),
498 cast_int<unsigned int>(output_buffer.size()));
506 #ifdef LIBMESH_ENABLE_AMR 518 if (!parent->active())
520 id_map_type::iterator pos = parent_id_map.find(parent->id());
521 libmesh_assert (pos != parent_id_map.end());
524 parent_id_map.erase(pos);
526 for (
auto & child : parent->child_ref_range())
528 pack_element (xfer_conn, &child, parent_id, parent_pid);
533 child_id_map[child.id()] = std::make_pair (child.processor_id(),
534 my_n_elem_written_at_level++);
538 xfer_conn.push_back(my_n_elem_written_at_level);
539 my_size = xfer_conn.size();
540 this->
comm().
gather (0, my_size, xfer_buf_sizes);
548 std::sprintf(buf,
"# n_elem at level %u", level);
549 std::string comment(buf), legend =
", [ type ";
554 if (write_partitioning)
556 if (write_subdomain_id)
559 legend +=
"p_level ";
560 legend +=
"(n0 ... nN-1) ]";
562 io.
data (n_global_elem_at_level[level], comment.c_str());
565 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
567 recv_conn.resize(xfer_buf_sizes[pid]);
569 recv_conn = xfer_conn;
575 libmesh_assert (!recv_conn.empty());
578 const xdr_id_type n_elem_received = recv_conn.back();
579 std::vector<xdr_id_type>::const_iterator recv_conn_iter = recv_conn.begin();
581 for (
xdr_id_type elem=0; elem<n_elem_received; elem++, next_global_elem++)
583 output_buffer.clear();
590 output_buffer.push_back(*recv_conn_iter);
595 output_buffer.push_back(*recv_conn_iter);
599 const xdr_id_type parent_local_id = *recv_conn_iter;
606 output_buffer.push_back (parent_local_id+processor_offsets[parent_pid]);
609 if (write_partitioning)
610 output_buffer.push_back(*recv_conn_iter);
614 if (write_subdomain_id)
615 output_buffer.push_back(*recv_conn_iter);
620 output_buffer.push_back(*recv_conn_iter);
624 output_buffer.push_back(*recv_conn_iter);
627 (output_buffer.data(),
628 cast_int<unsigned int>(output_buffer.size()),
629 cast_int<unsigned int>(output_buffer.size()));
638 processor_offsets[0] = processor_offsets.back() + n_elem_on_proc.back();
639 this->
comm().
gather (0, my_n_elem_written_at_level, n_elem_on_proc);
640 for (
unsigned int pid=1; pid<this->
n_processors(); pid++)
641 processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
647 std::map<processor_id_type, std::vector<dof_id_type>> requested_ids;
651 if (!child_id_map.count(elem->id()))
653 libmesh_assert_not_equal_to (elem->parent()->processor_id(), this->
processor_id());
656 requested_ids[pid].push_back(elem->id());
659 auto gather_functor =
662 const std::vector<dof_id_type> & ids,
663 std::vector<dof_id_type> &
data)
665 const std::size_t ids_size = ids.size();
666 data.resize(ids_size);
669 for (std::size_t i=0; i != ids_size; i++)
671 libmesh_assert (child_id_map.count(ids[i]));
672 libmesh_assert_equal_to (child_id_map[ids[i]].first, pid);
674 data[i] = child_id_map[ids[i]].second;
678 auto action_functor =
681 const std::vector<dof_id_type> & ids,
682 const std::vector<dof_id_type> &
data)
684 std::size_t data_size =
data.size();
686 for (std::size_t i=0; i != data_size; i++)
687 child_id_map[ids[i]] =
688 std::make_pair (pid,
data[i]);
694 (this->
comm(), requested_ids, gather_functor, action_functor, ex);
698 parent_id_map.swap(child_id_map);
699 child_id_map.clear();
702 #endif // LIBMESH_ENABLE_AMR 704 libmesh_assert_equal_to (next_global_elem,
n_elem);
716 std::vector<dof_id_type> xfer_ids;
717 std::vector<Real> xfer_coords;
718 std::vector<Real> & coords=xfer_coords;
720 std::vector<std::vector<dof_id_type>> recv_ids (this->
n_processors());
721 std::vector<std::vector<Real>> recv_coords(this->
n_processors());
723 #ifdef LIBMESH_ENABLE_UNIQUE_ID 724 std::vector<xdr_id_type> xfer_unique_ids;
725 std::vector<xdr_id_type> & unique_ids=xfer_unique_ids;
726 std::vector<std::vector<xdr_id_type>> recv_unique_ids (this->
n_processors());
727 #endif // LIBMESH_ENABLE_UNIQUE_ID 729 std::size_t n_written=0;
731 for (std::size_t blk=0, last_node=0; last_node<max_node_id; blk++)
733 const std::size_t first_node = blk*
io_blksize;
736 const std::size_t tot_id_size = last_node - first_node;
743 if ((node->id() >= first_node) &&
744 (node->id() < last_node))
746 xfer_ids.push_back(node->id());
747 xfer_coords.push_back((*node)(0));
749 xfer_coords.push_back((*node)(1));
752 xfer_coords.push_back((*node)(2));
758 std::vector<std::size_t> ids_size;
760 const std::size_t my_ids_size = xfer_ids.size();
763 this->
comm().
gather (0, my_ids_size, ids_size);
767 std::vector<Parallel::Request>
778 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
780 recv_ids[pid].resize(ids_size[pid]);
781 recv_coords[pid].resize(ids_size[pid]*LIBMESH_DIM);
785 recv_ids[0] = xfer_ids;
786 recv_coords[0] = xfer_coords;
791 id_request_handles[pid-1],
794 coord_request_handles[pid-1],
802 this->
comm().
send(0, xfer_ids, id_tag);
803 this->
comm().
send(0, xfer_coords, coord_tag);
816 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
817 libmesh_assert_equal_to(recv_coords[pid].size(),
818 recv_ids[pid].size()*LIBMESH_DIM);
827 coords.resize (3*tot_id_size, std::numeric_limits<Real>::quiet_NaN());
829 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
830 for (std::size_t
idx=0;
idx<recv_ids[pid].size();
idx++)
832 libmesh_assert_less_equal(first_node, recv_ids[pid][
idx]);
833 const std::size_t local_idx = recv_ids[pid][
idx] - first_node;
834 libmesh_assert_less(local_idx, tot_id_size);
836 libmesh_assert_less ((3*local_idx+2), coords.size());
837 libmesh_assert_less ((LIBMESH_DIM*
idx+LIBMESH_DIM-1), recv_coords[pid].size());
839 coords[3*local_idx+0] = recv_coords[pid][LIBMESH_DIM*
idx+0];
841 coords[3*local_idx+1] = recv_coords[pid][LIBMESH_DIM*
idx+1];
843 coords[3*local_idx+1] = 0.;
846 coords[3*local_idx+2] = recv_coords[pid][LIBMESH_DIM*
idx+2];
848 coords[3*local_idx+2] = 0.;
854 io.
data_stream (coords.empty() ? nullptr : coords.data(),
855 cast_int<unsigned int>(coords.size()), 3);
860 libmesh_assert_less_equal (n_written, max_node_id);
862 #ifdef LIBMESH_ENABLE_UNIQUE_ID 864 unsigned short write_unique_ids = 1;
866 unsigned short write_unique_ids = 0;
869 io.
data (write_unique_ids,
"# presence of unique ids");
871 #ifdef LIBMESH_ENABLE_UNIQUE_ID 874 for (std::size_t blk=0, last_node=0; last_node<max_node_id; blk++)
876 const std::size_t first_node = blk*
io_blksize;
879 const std::size_t tot_id_size = last_node - first_node;
883 xfer_ids.reserve(tot_id_size);
884 xfer_unique_ids.clear();
885 xfer_unique_ids.reserve(tot_id_size);
888 if ((node->id() >= first_node) &&
889 (node->id() < last_node))
891 xfer_ids.push_back(node->id());
892 xfer_unique_ids.push_back(node->unique_id());
897 std::vector<std::size_t> ids_size;
899 const std::size_t my_ids_size = xfer_ids.size();
902 this->
comm().
gather (0, my_ids_size, ids_size);
906 std::vector<Parallel::Request>
917 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
919 recv_ids[pid].resize(ids_size[pid]);
920 recv_unique_ids[pid].resize(ids_size[pid]);
924 recv_ids[0] = xfer_ids;
925 recv_unique_ids[0] = xfer_unique_ids;
930 id_request_handles[pid-1],
933 unique_id_request_handles[pid-1],
941 this->
comm().
send(0, xfer_ids, id_tag);
942 this->
comm().
send(0, xfer_unique_ids, unique_id_tag);
956 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
958 libmesh_assert_equal_to
959 (recv_ids[pid].size(), recv_unique_ids[pid].size());
962 libmesh_assert_less_equal
968 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
969 for (std::size_t
idx=0;
idx<recv_ids[pid].size();
idx++)
971 libmesh_assert_less_equal(first_node, recv_ids[pid][
idx]);
972 const std::size_t local_idx = recv_ids[pid][
idx] - first_node;
973 libmesh_assert_less (local_idx, unique_ids.size());
975 unique_ids[local_idx] = recv_unique_ids[pid][
idx];
980 io.
data_stream (unique_ids.empty() ? nullptr : unique_ids.data(),
981 cast_int<unsigned int>(unique_ids.size()), 1);
986 libmesh_assert_less_equal (n_written, max_node_id);
988 #endif // LIBMESH_ENABLE_UNIQUE_ID 1009 std::stringstream comment_string;
1010 comment_string <<
"# number of " << bc_type <<
" boundary conditions";
1011 io.
data (n_bcs_out, comment_string.str().c_str());
1017 std::vector<xdr_id_type> xfer_bcs, recv_bcs;
1018 std::vector<std::size_t> bc_sizes(this->
n_processors());
1021 std::vector<boundary_id_type> bc_ids;
1028 if (bc_type ==
"side")
1030 for (
auto s : elem->side_index_range())
1033 for (
const auto &
bc_id : bc_ids)
1036 xfer_bcs.push_back (n_local_level_0_elem);
1037 xfer_bcs.push_back (s) ;
1038 xfer_bcs.push_back (
bc_id);
1042 else if (bc_type ==
"edge")
1044 for (
auto e : elem->edge_index_range())
1047 for (
const auto &
bc_id : bc_ids)
1050 xfer_bcs.push_back (n_local_level_0_elem);
1051 xfer_bcs.push_back (e) ;
1052 xfer_bcs.push_back (
bc_id);
1056 else if (bc_type ==
"shellface")
1058 for (
unsigned short sf=0; sf<2; sf++)
1061 for (
const auto &
bc_id : bc_ids)
1064 xfer_bcs.push_back (n_local_level_0_elem);
1065 xfer_bcs.push_back (sf) ;
1066 xfer_bcs.push_back (
bc_id);
1072 libmesh_error_msg(
"bc_type not recognized: " + bc_type);
1076 n_local_level_0_elem++;
1079 xfer_bcs.push_back(n_local_level_0_elem);
1080 std::size_t my_size = xfer_bcs.size();
1088 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
1090 recv_bcs.resize(bc_sizes[pid]);
1092 recv_bcs = xfer_bcs;
1097 = cast_int<dof_id_type>(recv_bcs.back());
1098 recv_bcs.pop_back();
1100 for (std::size_t
idx=0;
idx<recv_bcs.size();
idx += 3, n_bcs_out++)
1101 recv_bcs[
idx+0] += elem_offset;
1103 io.
data_stream (recv_bcs.empty() ? nullptr : recv_bcs.data(),
1104 cast_int<unsigned int>(recv_bcs.size()), 3);
1105 elem_offset += my_n_local_level_0_elem;
1107 libmesh_assert_equal_to (n_bcs, n_bcs_out);
1138 libmesh_assert (io.
writing());
1151 io.
data (n_nodesets_out,
"# number of nodesets");
1154 if (!n_nodesets)
return;
1156 std::vector<xdr_id_type> xfer_bcs, recv_bcs;
1157 std::vector<std::size_t> bc_sizes(this->
n_processors());
1160 std::vector<boundary_id_type> nodeset_ids;
1166 for (
const auto &
bc_id : nodeset_ids)
1169 xfer_bcs.push_back (node->id());
1170 xfer_bcs.push_back (
bc_id);
1174 xfer_bcs.push_back(n_node);
1175 std::size_t my_size = xfer_bcs.size();
1183 for (
unsigned int pid=0; pid<this->
n_processors(); pid++)
1185 recv_bcs.resize(bc_sizes[pid]);
1187 recv_bcs = xfer_bcs;
1192 cast_int<dof_id_type>(recv_bcs.back());
1193 recv_bcs.pop_back();
1195 for (std::size_t
idx=0;
idx<recv_bcs.size();
idx += 2, n_nodesets_out++)
1196 recv_bcs[
idx+0] += node_offset;
1198 io.
data_stream (recv_bcs.empty() ? nullptr : recv_bcs.data(),
1199 cast_int<unsigned int>(recv_bcs.size()), 2);
1200 node_offset += my_n_node;
1202 libmesh_assert_equal_to (n_nodesets, n_nodesets_out);
1214 const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1217 std::vector<new_header_id_type> boundary_ids;
1218 boundary_ids.reserve(boundary_map.size());
1220 std::vector<std::string> boundary_names;
1221 boundary_names.reserve(boundary_map.size());
1227 for (
const auto & pr : boundary_map)
1228 if (!pr.second.empty())
1231 boundary_ids.push_back(pr.first);
1232 boundary_names.push_back(pr.second);
1236 io.
data(n_boundary_names,
"# sideset id to name map");
1238 io.
data(n_boundary_names,
"# nodeset id to name map");
1240 if (n_boundary_names)
1242 io.
data(boundary_ids);
1243 io.
data(boundary_names);
1252 LOG_SCOPE(
"read()",
"XdrIO");
1273 libmesh_error_msg(
"We no longer support reading files in the legacy format.");
1277 std::vector<new_header_id_type> meta_data(10,
sizeof(
xdr_id_type));
1284 std::vector<old_header_id_type> old_data(10,
sizeof(
xdr_id_type));
1288 meta_data.assign(old_data.begin(), old_data.end());
1316 uint32_t type_size = 0;
1345 uint64_t type_size = 0;
1379 template <
typename T>
1382 LOG_SCOPE(
"read_header()",
"XdrIO");
1391 io.
data (meta_data[pos++]);
1392 io.
data (meta_data[pos++]);
1400 io.
data (meta_data[pos++],
"# type size");
1401 io.
data (meta_data[pos++],
"# uid size");
1402 io.
data (meta_data[pos++],
"# pid size");
1403 io.
data (meta_data[pos++],
"# sid size");
1404 io.
data (meta_data[pos++],
"# p-level size");
1406 io.
data (meta_data[pos++],
"# eid size");
1407 io.
data (meta_data[pos++],
"# side size");
1408 io.
data (meta_data[pos++],
"# bid size");
1422 const T &
n_elem = meta_data[0];
1423 const T &
n_nodes = meta_data[1];
1446 if (read_entity_info)
1451 std::vector<new_header_id_type> subdomain_ids;
1452 std::vector<std::string> subdomain_names;
1457 if (use_new_header_type)
1458 io.
data(n_subdomain_names);
1463 n_subdomain_names = temp;
1466 subdomain_ids.resize(n_subdomain_names);
1467 subdomain_names.resize(n_subdomain_names);
1469 if (n_subdomain_names)
1471 if (use_new_header_type)
1472 io.
data(subdomain_ids);
1475 std::vector<old_header_id_type> temp;
1477 subdomain_ids.assign(temp.begin(), temp.end());
1480 io.
data(subdomain_names);
1486 if (n_subdomain_names == 0)
1489 subdomain_ids.resize(n_subdomain_names);
1490 subdomain_names.resize(n_subdomain_names);
1497 for (
unsigned int i=0; i<n_subdomain_names; ++i)
1498 subdomain_map.insert(std::make_pair(subdomain_ids[i], subdomain_names[i]));
1503 template <
typename T>
1506 libmesh_assert (io.
reading());
1522 std::vector<T> conn, input_buffer(100 );
1527 const size_t unique_id_size_index = 3;
1529 const bool read_unique_id =
1531 sizes[unique_id_size_index];
1533 T n_elem_at_level=0, n_processed_at_level=0;
1534 for (
dof_id_type blk=0, first_elem=0, last_elem=0;
1537 first_elem = cast_int<dof_id_type>(blk*
io_blksize);
1538 last_elem = cast_int<dof_id_type>(
std::min(cast_int<std::size_t>((blk+1)*
io_blksize),
1539 cast_int<std::size_t>(
n_elem)));
1544 for (
dof_id_type e=first_elem; e<last_elem; e++, n_processed_at_level++)
1546 if (n_processed_at_level == n_elem_at_level)
1549 io.
data (n_elem_at_level);
1550 n_processed_at_level = 0;
1554 unsigned int pos = 0;
1568 input_buffer[pos++] =
static_cast<T
>(-1);
1571 if (read_partitioning)
1574 input_buffer[pos++] = 0;
1577 if (read_subdomain_id)
1580 input_buffer[pos++] = 0;
1586 input_buffer[pos++] = 0;
1591 conn.insert (conn.end(),
1592 input_buffer.begin(),
1596 std::size_t conn_size = conn.size();
1598 conn.resize (conn_size);
1602 typename std::vector<T>::const_iterator it = conn.begin();
1606 #ifdef LIBMESH_ENABLE_UNIQUE_ID 1614 #ifdef LIBMESH_ENABLE_UNIQUE_ID 1615 unique_id = cast_int<unique_id_type>(*it);
1620 (*it ==
static_cast<T
>(-1)) ?
1622 cast_int<dof_id_type>(*it);
1625 cast_int<processor_id_type>(*it);
1628 cast_int<subdomain_id_type>(*it);
1630 #ifdef LIBMESH_ENABLE_AMR 1631 const unsigned int p_level =
1632 cast_int<unsigned int>(*it);
1642 #ifdef LIBMESH_ENABLE_UNIQUE_ID 1647 #ifdef LIBMESH_ENABLE_AMR 1658 for (
unsigned int n=0, n_n = elem->
n_nodes(); n != n_n;
1662 cast_int<dof_id_type>(*it);
1674 for (
unsigned char i=0; i!=4; ++i)
1680 libmesh_error_msg(
"Cannot open dimension " \
1682 <<
" mesh file when configured without " \
1692 libmesh_assert (io.
reading());
1711 std::vector<dof_id_type> needed_nodes; needed_nodes.reserve (
mesh.
n_nodes());
1714 needed_nodes.push_back(node->id());
1716 std::sort (needed_nodes.begin(), needed_nodes.end());
1719 libmesh_assert (std::unique(needed_nodes.begin(), needed_nodes.end()) == needed_nodes.end());
1723 std::vector<Real> coords;
1724 std::pair<std::vector<dof_id_type>::iterator,
1725 std::vector<dof_id_type>::iterator> pos;
1726 pos.first = needed_nodes.begin();
1729 for (std::size_t blk=0, first_node=0, last_node=0; last_node<
n_nodes; blk++)
1734 coords.resize(3*(last_node - first_node));
1737 io.
data_stream (coords.empty() ? nullptr : coords.data(),
1738 cast_int<unsigned int>(coords.size()));
1745 for (std::size_t n=first_node,
idx=0; n<last_node; n++,
idx+=3)
1750 pos = std::equal_range (pos.first, needed_nodes.end(), n);
1752 if (pos.first != pos.second)
1754 libmesh_assert_equal_to (*pos.first, n);
1770 unsigned short read_unique_ids;
1773 io.
data (read_unique_ids);
1778 if (!read_unique_ids)
1781 std::vector<uint32_t> unique_32;
1782 std::vector<uint64_t> unique_64;
1785 pos.first = needed_nodes.begin();
1787 for (std::size_t blk=0, first_node=0, last_node=0; last_node<
n_nodes; blk++)
1795 unique_64.resize(last_node - first_node);
1797 unique_32.resize(last_node - first_node);
1802 io.
data_stream (unique_64.empty() ? nullptr : unique_64.data(),
1803 cast_int<unsigned int>(unique_64.size()));
1805 io.
data_stream (unique_32.empty() ? nullptr : unique_32.data(),
1806 cast_int<unsigned int>(unique_32.size()));
1809 #ifdef LIBMESH_ENABLE_UNIQUE_ID 1815 for (std::size_t n=first_node,
idx=0; n<last_node; n++,
idx++)
1820 pos = std::equal_range (pos.first, needed_nodes.end(), n);
1822 if (pos.first != pos.second)
1824 libmesh_assert_equal_to (*pos.first, n);
1833 #endif // LIBMESH_ENABLE_UNIQUE_ID 1840 template <
typename T>
1845 libmesh_assert (io.
reading());
1856 std::vector<DofBCData> dof_bc_data;
1857 std::vector<T> input_buffer;
1873 for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_bcs; blk++)
1878 input_buffer.resize (3*(last_bc - first_bc));
1881 io.
data_stream (input_buffer.empty() ? nullptr : input_buffer.data(),
1882 cast_int<unsigned int>(input_buffer.size()));
1885 dof_bc_data.clear();
1886 dof_bc_data.reserve (input_buffer.size()/3);
1889 for (std::size_t
idx=0;
idx<input_buffer.size();
idx+=3)
1890 dof_bc_data.push_back
1891 (DofBCData(cast_int<dof_id_type>(input_buffer[
idx+0]),
1892 cast_int<unsigned short>(input_buffer[
idx+1]),
1893 cast_int<boundary_id_type>(input_buffer[
idx+2])));
1894 input_buffer.clear();
1897 std::sort (dof_bc_data.begin(), dof_bc_data.end());
1904 for (
const auto & elem :
1909 std::equal_range (dof_bc_data.begin(),
1912 #if defined(__SUNPRO_CC) || defined(__PGI) 1913 , CompareIntDofBCData()
1919 libmesh_assert_equal_to (
data.dof_id, elem->id());
1921 if (bc_type ==
"side")
1923 libmesh_assert_less (
data.side, elem->n_sides());
1926 else if (bc_type ==
"edge")
1928 libmesh_assert_less (
data.side, elem->n_edges());
1931 else if (bc_type ==
"shellface")
1934 libmesh_assert_less(
data.side, 2);
1940 libmesh_error_msg(
"bc_type not recognized: " + bc_type);
1949 template <
typename T>
1957 template <
typename T>
1965 template <
typename T>
1973 template <
typename T>
1978 libmesh_assert (io.
reading());
1990 std::vector<DofBCData> node_bc_data;
1991 std::vector<T> input_buffer;
1997 io.
data (n_nodesets);
2007 for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_nodesets; blk++)
2012 input_buffer.resize (2*(last_bc - first_bc));
2015 io.
data_stream (input_buffer.empty() ? nullptr : input_buffer.data(),
2016 cast_int<unsigned int>(input_buffer.size()));
2019 node_bc_data.clear();
2020 node_bc_data.reserve (input_buffer.size()/2);
2023 for (std::size_t
idx=0;
idx<input_buffer.size();
idx+=2)
2024 node_bc_data.push_back
2025 (DofBCData(cast_int<dof_id_type>(input_buffer[
idx+0]),
2027 cast_int<boundary_id_type>(input_buffer[
idx+1])));
2028 input_buffer.clear();
2031 std::sort (node_bc_data.begin(), node_bc_data.end());
2038 std::pair<std::vector<DofBCData>::iterator,
2039 std::vector<DofBCData>::iterator> bounds =
2040 std::equal_range (node_bc_data.begin(),
2043 #if defined(__SUNPRO_CC) || defined(__PGI) 2044 , CompareIntDofBCData()
2051 libmesh_assert_equal_to (
data.dof_id, node->id());
2065 if (read_entity_info)
2068 std::vector<new_header_id_type> boundary_ids;
2069 std::vector<std::string> boundary_names;
2074 if (use_new_header_type)
2075 io.
data(n_boundary_names);
2080 n_boundary_names = temp;
2083 boundary_names.resize(n_boundary_names);
2085 if (n_boundary_names)
2087 if (use_new_header_type)
2088 io.
data(boundary_ids);
2091 std::vector<old_header_id_type> temp(n_boundary_names);
2093 boundary_ids.assign(temp.begin(), temp.end());
2095 io.
data(boundary_names);
2101 if (n_boundary_names == 0)
2104 boundary_ids.resize(n_boundary_names);
2105 boundary_names.resize(n_boundary_names);
2110 std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
2113 for (
unsigned int i=0; i<n_boundary_names; ++i)
2114 boundary_map.insert(std::make_pair(cast_int<boundary_id_type>(boundary_ids[i]), boundary_names[i]));
2123 libmesh_assert(elem);
2126 conn.push_back(elem->
n_nodes());
2128 conn.push_back (elem->
type());
2137 conn.push_back (parent_id);
2139 conn.push_back (parent_pid);
2145 #ifdef LIBMESH_ENABLE_AMR 2146 conn.push_back (elem->
p_level());
2150 conn.push_back (elem->
node_id(n));
2156 (this->
version().find(
"0.9.2") != std::string::npos) ||
2157 (this->
version().find(
"0.9.6") != std::string::npos) ||
2158 (this->
version().find(
"1.1.0") != std::string::npos) ||
2159 (this->
version().find(
"1.3.0") != std::string::npos);
2165 (this->
version().find(
"0.9.6") != std::string::npos) ||
2166 (this->
version().find(
"1.1.0") != std::string::npos) ||
2167 (this->
version().find(
"1.3.0") != std::string::npos);
2173 (this->
version().find(
"1.1.0") != std::string::npos) ||
2174 (this->
version().find(
"1.3.0") != std::string::npos);
2180 (this->
version().find(
"1.3.0") != std::string::npos);
void read_serialized_connectivity(Xdr &io, const dof_id_type n_elem, std::vector< new_header_id_type > &sizes, T)
std::string name(const ElemQuality q)
void write_serialized_nodesets(Xdr &io, const new_header_id_type n_nodesets) const
void data(T &a, const char *comment="")
std::size_t n_boundary_conds() const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
XdrIO(MeshBase &, const bool=false)
void wait(std::vector< Request > &r)
unique_id_type & set_unique_id()
virtual void reserve_nodes(const dof_id_type nn)=0
void read_serialized_shellface_bcs(Xdr &io, T)
virtual Node *& set_node(const unsigned int i)
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
virtual element_iterator level_elements_begin(unsigned int level)=0
bool write_parallel() const
bool version_at_least_0_9_6() const
virtual element_iterator local_level_elements_end(unsigned int level)=0
std::size_t n_edge_conds() const
void write_serialized_nodes(Xdr &io, const dof_id_type n_nodes) const
bool operator<(const OrderWrapper &lhs, const OrderWrapper &rhs)
void write_serialized_side_bcs(Xdr &io, const new_header_id_type n_side_bcs) const
void read_serialized_subdomain_names(Xdr &io)
static void set_node_processor_ids(MeshBase &mesh)
std::size_t n_shellface_conds() const
void pack_element(std::vector< xdr_id_type > &conn, const Elem *elem, const dof_id_type parent_id=DofObject::invalid_id, const dof_id_type parent_pid=DofObject::invalid_id) const
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
The base class for all geometric element types.
uint8_t processor_id_type
uint32_t old_header_id_type
void add_child(Elem *elem)
void set_refinement_flag(const RefinementState rflag)
unique_id_type unique_id() const
void gather(const unsigned int root_id, const T &send, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
unsigned int p_level() const
void write_serialized_subdomain_names(Xdr &io) const
void shellface_boundary_ids(const Elem *const elem, const unsigned short int shellface, std::vector< boundary_id_type > &vec_to_fill) const
MessageTag get_unique_tag(int tagvalue) const
const BoundaryInfo & get_boundary_info() const
void read_serialized_bcs_helper(Xdr &io, T, const std::string bc_type)
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
static const unsigned int type_to_n_nodes_map[INVALID_ELEM]
virtual element_iterator local_level_elements_begin(unsigned int level)=0
void read_serialized_bc_names(Xdr &io, BoundaryInfo &info, bool is_sideset)
std::vector< boundary_id_type > boundary_ids(const Node *node) const
largest_id_type xdr_id_type
virtual element_iterator level_elements_end(unsigned int level)=0
std::map< boundary_id_type, std::string > & set_sideset_name_map()
processor_id_type n_processors() const
void add_node(const Node *node, const boundary_id_type id)
const dof_id_type n_nodes
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
static const boundary_id_type invalid_id
const std::string & boundary_condition_file_name() const
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
void pull_parallel_vector_data(const Communicator &comm, const MapToVectors &queries, RequestContainer &reqs, GatherFunctor &gather_data, ActionFunctor &act_on_data, const datum *example)
virtual unsigned int n_nodes() const =0
bool version_at_least_1_3_0() const
virtual Elem * add_elem(Elem *e)=0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
virtual void write(const std::string &) override
const std::string & subdomain_map_file_name() const
virtual SimpleRange< node_iterator > node_ptr_range()=0
Used by the Mesh to keep track of boundary nodes and elements.
SimpleRange< I > as_range(const std::pair< I, I > &p)
unsigned int _field_width
static const dof_id_type invalid_id
void read_serialized_nodesets(Xdr &io, T)
void read_header(Xdr &io, std::vector< T > &meta_data)
void set_mesh_dimension(unsigned char d)
void write_serialized_bc_names(Xdr &io, const BoundaryInfo &info, bool is_sideset) const
std::map< subdomain_id_type, std::string > & set_subdomain_name_map()
bool version_at_least_1_1_0() const
An object whose state is distributed along a set of processors.
uint64_t new_header_id_type
C++ interface for the XDR (eXternal Data Representation) format.
const std::string & partition_map_file_name() const
virtual const Elem * elem_ptr(const dof_id_type i) const =0
void read_serialized_nodes(Xdr &io, const dof_id_type n_nodes)
subdomain_id_type n_subdomains() const
void read_serialized_edge_bcs(Xdr &io, T)
const std::string & version() const
const std::string & polynomial_level_file_name() const
subdomain_id_type subdomain_id() const
static const std::size_t io_blksize
virtual unsigned short dim() const =0
bool libmesh_isnan(float a)
std::map< boundary_id_type, std::string > & set_nodeset_name_map()
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
unsigned int mesh_dimension() const
std::size_t n_nodeset_conds() const
IntRange< unsigned short > node_index_range() const
bool version_at_least_0_9_2() const
virtual const Node & node_ref(const dof_id_type i) const
void write_serialized_shellface_bcs(Xdr &io, const new_header_id_type n_shellface_bcs) const
void write_serialized_bcs_helper(Xdr &io, const new_header_id_type n_side_bcs, const std::string bc_type) const
virtual dof_id_type max_node_id() const =0
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
void data_stream(T *val, const unsigned int len, const unsigned int line_break=libMesh::invalid_uint)
OStreamProxy out(std::cout)
void hack_p_level(const unsigned int p)
processor_id_type processor_id() const
virtual ElemType type() const =0
long double min(long double a, double b)
void write_serialized_edge_bcs(Xdr &io, const new_header_id_type n_edge_bcs) const
A geometric point in (x,y,z) space.
dof_id_type node_id(const unsigned int i) const
virtual void reserve_elem(const dof_id_type ne)=0
void broadcast(T &data, const unsigned int root_id=0) const
void read_serialized_side_bcs(Xdr &io, T)
void write_serialized_connectivity(Xdr &io, const dof_id_type n_elem) const
virtual dof_id_type n_nodes() const =0
virtual void read(const std::string &) override
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
std::vector< boundary_id_type > edge_boundary_ids(const Elem *const elem, const unsigned short int edge) const