libMesh
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
libMesh::XdrIO Class Reference

MeshIO class used for writing XDR (eXternal Data Representation) and XDA mesh files. More...

#include <xdr_io.h>

Inheritance diagram for libMesh::XdrIO:
[legend]

Public Types

typedef largest_id_type xdr_id_type
 
typedef uint32_t old_header_id_type
 
typedef uint64_t new_header_id_type
 

Public Member Functions

 XdrIO (MeshBase &, const bool=false)
 Constructor. More...
 
 XdrIO (const MeshBase &, const bool=false)
 Constructor. More...
 
virtual ~XdrIO ()
 Destructor. More...
 
virtual void read (const std::string &) libmesh_override
 This method implements reading a mesh from a specified file. More...
 
virtual void write (const std::string &) libmesh_override
 This method implements writing a mesh to a specified file. More...
 
bool binary () const
 Get/Set the flag indicating if we should read/write binary. More...
 
bool & binary ()
 
bool legacy () const
 Get/Set the flag indicating if we should read/write legacy. More...
 
bool & legacy ()
 
bool write_parallel () const
 Report whether we should write parallel files. More...
 
void set_write_parallel (bool do_parallel=true)
 Insist that we should/shouldn't write parallel files. More...
 
void set_auto_parallel ()
 Insist that we should write parallel files if and only if the mesh is an already distributed DistributedMesh. More...
 
const std::string & version () const
 Get/Set the version string. More...
 
std::string & version ()
 
const std::string & boundary_condition_file_name () const
 Get/Set the boundary condition file name. More...
 
std::string & boundary_condition_file_name ()
 
const std::string & partition_map_file_name () const
 Get/Set the partitioning file name. More...
 
std::string & partition_map_file_name ()
 
const std::string & subdomain_map_file_name () const
 Get/Set the subdomain file name. More...
 
std::string & subdomain_map_file_name ()
 
const std::string & polynomial_level_file_name () const
 Get/Set the polynomial degree file name. More...
 
std::string & polynomial_level_file_name ()
 
bool version_at_least_0_9_2 () const
 
bool version_at_least_0_9_6 () const
 
bool version_at_least_1_1_0 () const
 
bool version_at_least_1_3_0 () const
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
 This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided. More...
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

MeshBasemesh ()
 
void set_n_partitions (unsigned int n_parts)
 Sets the number of partitions in the mesh. More...
 
void skip_comment_lines (std::istream &in, const char comment_start)
 Reads input from in, skipping all the lines that start with the character comment_start. More...
 
const MeshBasemesh () const
 

Protected Attributes

std::vector< bool > elems_of_dimension
 A vector of bools describing what dimension elements have been encountered when reading a mesh. More...
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable. More...
 
const bool _serial_only_needed_on_proc_0
 Flag specifying whether this format can be written by only serializing the mesh to processor zero. More...
 
const Parallel::Communicator_communicator
 

Private Member Functions

void write_serialized_subdomain_names (Xdr &io) const
 Write subdomain name information - NEW in 0.9.2 format. More...
 
void write_serialized_connectivity (Xdr &io, const dof_id_type n_elem) const
 Write the connectivity for a parallel, distributed mesh. More...
 
void write_serialized_nodes (Xdr &io, const dof_id_type n_nodes) const
 Write the nodal locations for a parallel, distributed mesh. More...
 
void write_serialized_bcs_helper (Xdr &io, const new_header_id_type n_side_bcs, const std::string bc_type) const
 Helper function used in write_serialized_side_bcs, write_serialized_edge_bcs, and write_serialized_shellface_bcs. More...
 
void write_serialized_side_bcs (Xdr &io, const new_header_id_type n_side_bcs) const
 Write the side boundary conditions for a parallel, distributed mesh. More...
 
void write_serialized_edge_bcs (Xdr &io, const new_header_id_type n_edge_bcs) const
 Write the edge boundary conditions for a parallel, distributed mesh. More...
 
void write_serialized_shellface_bcs (Xdr &io, const new_header_id_type n_shellface_bcs) const
 Write the "shell face" boundary conditions for a parallel, distributed mesh. More...
 
void write_serialized_nodesets (Xdr &io, const new_header_id_type n_nodesets) const
 Write the boundary conditions for a parallel, distributed mesh. More...
 
void write_serialized_bc_names (Xdr &io, const BoundaryInfo &info, bool is_sideset) const
 Write boundary names information (sideset and nodeset) - NEW in 0.9.2 format. More...
 
template<typename T >
void read_header (Xdr &io, std::vector< T > &meta_data)
 Read header information - templated to handle old (4-byte) or new (8-byte) header id types. More...
 
void read_serialized_subdomain_names (Xdr &io)
 Read subdomain name information - NEW in 0.9.2 format. More...
 
template<typename T >
void read_serialized_connectivity (Xdr &io, const dof_id_type n_elem, std::vector< new_header_id_type > &sizes, T)
 Read the connectivity for a parallel, distributed mesh. More...
 
void read_serialized_nodes (Xdr &io, const dof_id_type n_nodes)
 Read the nodal locations for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_bcs_helper (Xdr &io, T, const std::string bc_type)
 Helper function used in read_serialized_side_bcs, read_serialized_edge_bcs, and read_serialized_shellface_bcs. More...
 
template<typename T >
void read_serialized_side_bcs (Xdr &io, T)
 Read the side boundary conditions for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_edge_bcs (Xdr &io, T)
 Read the edge boundary conditions for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_shellface_bcs (Xdr &io, T)
 Read the "shell face" boundary conditions for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_nodesets (Xdr &io, T)
 Read the nodeset conditions for a parallel, distributed mesh. More...
 
void read_serialized_bc_names (Xdr &io, BoundaryInfo &info, bool is_sideset)
 Read boundary names information (sideset and nodeset) - NEW in 0.9.2 format. More...
 
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
 Pack an element into a transfer buffer for parallel communication. More...
 

Private Attributes

bool _binary
 
bool _legacy
 
bool _write_serial
 
bool _write_parallel
 
bool _write_unique_id
 
unsigned int _field_width
 
std::string _version
 
std::string _bc_file_name
 
std::string _partition_map_file
 
std::string _subdomain_map_file
 
std::string _p_level_file
 

Static Private Attributes

static const std::size_t io_blksize = 128000
 Define the block size to use for chunked IO. More...
 

Detailed Description

MeshIO class used for writing XDR (eXternal Data Representation) and XDA mesh files.

XDR/XDA is libmesh's internal data format, and allows the full refinement tree structure of the mesh to be written to file.

Author
Benjamin Kirk
John Peterson
Date
2004

Definition at line 51 of file xdr_io.h.

Member Typedef Documentation

Definition at line 63 of file xdr_io.h.

Definition at line 60 of file xdr_io.h.

Definition at line 57 of file xdr_io.h.

Constructor & Destructor Documentation

libMesh::XdrIO::XdrIO ( MeshBase mesh,
const bool  binary_in = false 
)
explicit

Constructor.

Takes a writable reference to a mesh object. This is the constructor required to read a mesh. The optional parameter binary can be used to switch between ASCII (false, the default) or binary (true) files.

Definition at line 128 of file xdr_io.C.

128  :
129  MeshInput<MeshBase> (mesh,/* is_parallel_format = */ true),
130  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
132  _binary (binary_in),
133  _legacy (false),
134  _write_serial (false),
135  _write_parallel (false),
136 #ifdef LIBMESH_ENABLE_UNIQUE_ID
137  _write_unique_id (true),
138 #else
139  _write_unique_id (false),
140 #endif
141  _field_width (4), // In 0.7.0, all fields are 4 bytes, in 0.9.2+ they can vary
142  _version ("libMesh-1.3.0"),
143  _bc_file_name ("n/a"),
144  _partition_map_file ("n/a"),
145  _subdomain_map_file ("n/a"),
146  _p_level_file ("n/a")
147 {
148 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _binary
Definition: xdr_io.h:335
bool _write_parallel
Definition: xdr_io.h:338
std::string _partition_map_file
Definition: xdr_io.h:343
unsigned int _field_width
Definition: xdr_io.h:340
std::string _bc_file_name
Definition: xdr_io.h:342
bool _write_unique_id
Definition: xdr_io.h:339
std::string _subdomain_map_file
Definition: xdr_io.h:344
std::string _p_level_file
Definition: xdr_io.h:345
bool _write_serial
Definition: xdr_io.h:337
std::string _version
Definition: xdr_io.h:341
bool _legacy
Definition: xdr_io.h:336
libMesh::XdrIO::XdrIO ( const MeshBase mesh,
const bool  binary_in = false 
)
explicit

Constructor.

Takes a reference to a constant mesh object. This constructor will only allow us to write the mesh. The optional parameter binary can be used to switch between ASCII (false, the default) or binary (true) files.

Definition at line 152 of file xdr_io.C.

152  :
153  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
155  _binary (binary_in)
156 {
157 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _binary
Definition: xdr_io.h:335
libMesh::XdrIO::~XdrIO ( )
virtual

Destructor.

Definition at line 161 of file xdr_io.C.

162 {
163 }

Member Function Documentation

unsigned int& libMesh::MeshOutput< MeshBase >::ascii_precision ( )
inherited

Return/set the precision to use when writing ASCII files.

By default we use numeric_limits<Real>::digits10 + 2, which should be enough to write out to ASCII and get the exact same Real back when reading in.

Referenced by libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

bool libMesh::XdrIO::binary ( ) const

Get/Set the flag indicating if we should read/write binary.

Definition at line 103 of file xdr_io.h.

References _binary.

Referenced by libMesh::NameBasedIO::read(), read(), and write().

103 { return _binary; }
bool _binary
Definition: xdr_io.h:335
bool& libMesh::XdrIO::binary ( )

Definition at line 104 of file xdr_io.h.

References _binary.

104 { return _binary; }
bool _binary
Definition: xdr_io.h:335
const std::string& libMesh::XdrIO::boundary_condition_file_name ( ) const

Get/Set the boundary condition file name.

Definition at line 146 of file xdr_io.h.

References _bc_file_name.

Referenced by read_header(), read_serialized_bcs_helper(), read_serialized_nodesets(), and write().

146 { return _bc_file_name; }
std::string _bc_file_name
Definition: xdr_io.h:342
std::string& libMesh::XdrIO::boundary_condition_file_name ( )

Definition at line 147 of file xdr_io.h.

References _bc_file_name.

147 { return _bc_file_name; }
std::string _bc_file_name
Definition: xdr_io.h:342
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_preconditioner_apply(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), add_cube_convex_hull_to_mesh(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), new_function_base(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), read(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), read_serialized_bc_names(), read_serialized_bcs_helper(), read_serialized_connectivity(), read_serialized_nodes(), read_serialized_nodesets(), read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), libMesh::MeshRefinement::test_unflagged(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), write(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), write_serialized_bcs_helper(), write_serialized_connectivity(), write_serialized_nodes(), write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

88  { return _communicator; }
const Parallel::Communicator & _communicator
bool libMesh::XdrIO::legacy ( ) const

Get/Set the flag indicating if we should read/write legacy.

Definition at line 109 of file xdr_io.h.

References _legacy.

Referenced by libMesh::NameBasedIO::read(), read(), and write().

109 { return _legacy; }
bool _legacy
Definition: xdr_io.h:336
bool& libMesh::XdrIO::legacy ( )

Definition at line 110 of file xdr_io.h.

References _legacy, set_auto_parallel(), set_write_parallel(), and write_parallel().

110 { return _legacy; }
bool _legacy
Definition: xdr_io.h:336
MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited
Returns
The object as a writable reference.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::UNVIO::elements_out(), libMesh::UNVIO::groups_in(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::UNVIO::nodes_out(), libMesh::GMVIO::read(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read(), read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::CheckpointIO::read_remote_elem(), read_serialized_bcs_helper(), read_serialized_connectivity(), read_serialized_nodes(), read_serialized_nodesets(), read_serialized_subdomain_names(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::UCDIO::UCDIO(), libMesh::VTKIO::VTKIO(), libMesh::TetGenIO::write(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::CheckpointIO::write_bcs(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::UCDIO::write_implementation(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::CheckpointIO::write_nodesets(), write_parallel(), libMesh::GmshIO::write_post(), write_serialized_bcs_helper(), write_serialized_connectivity(), write_serialized_nodes(), write_serialized_nodesets(), write_serialized_subdomain_names(), and libMesh::CheckpointIO::write_subdomain_names().

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
protectedinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), write_serialized_bcs_helper(), write_serialized_connectivity(), write_serialized_nodes(), and write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:726
const Parallel::Communicator & _communicator
void libMesh::XdrIO::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
private

Pack an element into a transfer buffer for parallel communication.

Definition at line 2184 of file xdr_io.C.

References libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), libMesh::Elem::node_index_range(), libMesh::Elem::p_level(), libMesh::DofObject::processor_id(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), libMesh::Elem::type_to_n_nodes_map, and libMesh::DofObject::unique_id().

Referenced by polynomial_level_file_name(), and write_serialized_connectivity().

2186 {
2187  libmesh_assert(elem);
2188  libmesh_assert_equal_to (elem->n_nodes(), Elem::type_to_n_nodes_map[elem->type()]);
2189 
2190  conn.push_back(elem->n_nodes());
2191 
2192  conn.push_back (elem->type());
2193 
2194  // In version 0.7.0+ "id" is stored but it not used. In version 0.9.2+
2195  // we will store unique_id instead, therefore there is no need to
2196  // check for the older version when writing the unique_id.
2197  conn.push_back (elem->unique_id());
2198 
2199  if (parent_id != DofObject::invalid_id)
2200  {
2201  conn.push_back (parent_id);
2202  libmesh_assert_not_equal_to (parent_pid, DofObject::invalid_id);
2203  conn.push_back (parent_pid);
2204  }
2205 
2206  conn.push_back (elem->processor_id());
2207  conn.push_back (elem->subdomain_id());
2208 
2209 #ifdef LIBMESH_ENABLE_AMR
2210  conn.push_back (elem->p_level());
2211 #endif
2212 
2213  for (auto n : elem->node_index_range())
2214  conn.push_back (elem->node_id(n));
2215 }
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
libmesh_assert(j)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:324
const std::string& libMesh::XdrIO::partition_map_file_name ( ) const

Get/Set the partitioning file name.

Definition at line 152 of file xdr_io.h.

References _partition_map_file.

Referenced by read_header(), read_serialized_connectivity(), write(), and write_serialized_connectivity().

152 { return _partition_map_file; }
std::string _partition_map_file
Definition: xdr_io.h:343
std::string& libMesh::XdrIO::partition_map_file_name ( )

Definition at line 153 of file xdr_io.h.

References _partition_map_file.

153 { return _partition_map_file; }
std::string _partition_map_file
Definition: xdr_io.h:343
const std::string& libMesh::XdrIO::polynomial_level_file_name ( ) const

Get/Set the polynomial degree file name.

Definition at line 164 of file xdr_io.h.

References _p_level_file.

Referenced by read_header(), read_serialized_connectivity(), write(), and write_serialized_connectivity().

164 { return _p_level_file; }
std::string _p_level_file
Definition: xdr_io.h:345
std::string& libMesh::XdrIO::polynomial_level_file_name ( )
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited
Returns
The rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::EquationSystems::get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), read_serialized_bc_names(), read_serialized_bcs_helper(), read_serialized_connectivity(), read_serialized_nodes(), read_serialized_nodesets(), read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), BoundaryInfoTest::testShellFaceConstraints(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), write_output_solvedata(), libMesh::RBConstruction::write_riesz_representors_to_files(), write_serialized_bc_names(), write_serialized_bcs_helper(), write_serialized_connectivity(), write_serialized_nodes(), write_serialized_nodesets(), write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:724
void libMesh::XdrIO::read ( const std::string &  name)
virtual

This method implements reading a mesh from a specified file.

We are future proofing the layout of this file by adding in size information for all stored types. TODO: All types are stored as the same size. Use the size information to pack things efficiently. For now we will assume that "type size" is how the entire file will be encoded.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 1314 of file xdr_io.C.

References _field_width, binary(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, legacy(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::ParallelObject::processor_id(), libMesh::READ, read_header(), read_serialized_connectivity(), read_serialized_edge_bcs(), read_serialized_nodes(), read_serialized_nodesets(), read_serialized_shellface_bcs(), read_serialized_side_bcs(), read_serialized_subdomain_names(), libMesh::Partitioner::set_node_processor_ids(), value, version(), version_at_least_0_9_2(), version_at_least_1_1_0(), and version_at_least_1_3_0().

Referenced by libMesh::NameBasedIO::read().

1315 {
1316  LOG_SCOPE("read()","XdrIO");
1317 
1318  // Only open the file on processor 0 -- this is especially important because
1319  // there may be an underlying bzip/bunzip going on, and multiple simultaneous
1320  // calls will produce a race condition.
1321  Xdr io (this->processor_id() == 0 ? name : "", this->binary() ? DECODE : READ);
1322 
1323  // convenient reference to our mesh
1324  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1325 
1326  // get the version string.
1327  if (this->processor_id() == 0)
1328  io.data (this->version());
1329  this->comm().broadcast (this->version());
1330 
1331  // note that for "legacy" files the first entry is an
1332  // integer -- not a string at all.
1333  this->legacy() = !(this->version().find("libMesh") < this->version().size());
1334 
1335  // Check for a legacy version format.
1336  if (this->legacy())
1337  libmesh_error_msg("We no longer support reading files in the legacy format.");
1338 
1339  // Read headers with the old id type if they're pre-1.3.0, or with
1340  // the new id type if they're post-1.3.0
1341  std::vector<new_header_id_type> meta_data(10, sizeof(xdr_id_type));
1342  if (this->version_at_least_1_3_0())
1343  {
1344  this->read_header(io, meta_data);
1345  }
1346  else
1347  {
1348  std::vector<old_header_id_type> old_data(10, sizeof(xdr_id_type));
1349 
1350  this->read_header(io, old_data);
1351 
1352  meta_data.assign(old_data.begin(), old_data.end());
1353  }
1354 
1355  const new_header_id_type & n_elem = meta_data[0];
1356  const new_header_id_type & n_nodes = meta_data[1];
1357 
1363  if (version_at_least_0_9_2())
1364  _field_width = meta_data[2];
1365 
1366  // On systems where uint64_t==unsigned long, we were previously
1367  // writing 64-bit unsigned integers via xdr_u_long(), a function
1368  // which is literally less suited for that task than abort() would
1369  // have been, because at least abort() would have *known* it
1370  // couldn't write rather than truncating writes to 32 bits.
1371  //
1372  // If we have files with version < 1.3.0, then we'll continue to use
1373  // 32 bit field width, regardless of whether the file thinks we
1374  // should, whenever we're on a system where the problem would have
1375  // occurred.
1376  if ((_field_width == 4) ||
1377  (!version_at_least_1_3_0() &&
1379  {
1380  uint32_t type_size = 0;
1381 
1382  // read subdomain names
1384 
1385  // read connectivity
1386  this->read_serialized_connectivity (io, n_elem, meta_data, type_size);
1387 
1388  // read the nodal locations
1389  this->read_serialized_nodes (io, n_nodes);
1390 
1391  // read the side boundary conditions
1392  this->read_serialized_side_bcs (io, type_size);
1393 
1394  if (version_at_least_0_9_2())
1395  // read the nodesets
1396  this->read_serialized_nodesets (io, type_size);
1397 
1398  if (version_at_least_1_1_0())
1399  {
1400  // read the edge boundary conditions
1401  this->read_serialized_edge_bcs (io, type_size);
1402 
1403  // read the "shell face" boundary conditions
1404  this->read_serialized_shellface_bcs (io, type_size);
1405  }
1406  }
1407  else if (_field_width == 8)
1408  {
1409  uint64_t type_size = 0;
1410 
1411  // read subdomain names
1413 
1414  // read connectivity
1415  this->read_serialized_connectivity (io, n_elem, meta_data, type_size);
1416 
1417  // read the nodal locations
1418  this->read_serialized_nodes (io, n_nodes);
1419 
1420  // read the boundary conditions
1421  this->read_serialized_side_bcs (io, type_size);
1422 
1423  if (version_at_least_0_9_2())
1424  // read the nodesets
1425  this->read_serialized_nodesets (io, type_size);
1426 
1427  if (version_at_least_1_1_0())
1428  {
1429  // read the edge boundary conditions
1430  this->read_serialized_edge_bcs (io, type_size);
1431 
1432  // read the "shell face" boundary conditions
1433  this->read_serialized_shellface_bcs (io, type_size);
1434  }
1435  }
1436 
1437  // set the node processor ids
1439 }
void read_serialized_connectivity(Xdr &io, const dof_id_type n_elem, std::vector< new_header_id_type > &sizes, T)
Read the connectivity for a parallel, distributed mesh.
Definition: xdr_io.C:1568
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
void read_serialized_shellface_bcs(Xdr &io, T)
Read the "shell face" boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2030
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: xdr_io.h:103
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:656
void read_serialized_subdomain_names(Xdr &io)
Read subdomain name information - NEW in 0.9.2 format.
Definition: xdr_io.C:1506
static void set_node_processor_ids(MeshBase &mesh)
This function is called after partitioning to set the processor IDs for the nodes.
Definition: partitioner.C:416
bool version_at_least_1_1_0() const
Definition: xdr_io.C:2234
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2217
largest_id_type xdr_id_type
Definition: xdr_io.h:57
const dof_id_type n_nodes
Definition: tecplot_io.C:67
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2241
unsigned int _field_width
Definition: xdr_io.h:340
void read_serialized_nodesets(Xdr &io, T)
Read the nodeset conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2038
void read_header(Xdr &io, std::vector< T > &meta_data)
Read header information - templated to handle old (4-byte) or new (8-byte) header id types...
Definition: xdr_io.C:1444
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
uint64_t new_header_id_type
Definition: xdr_io.h:63
void read_serialized_nodes(Xdr &io, const dof_id_type n_nodes)
Read the nodal locations for a parallel, distributed mesh.
Definition: xdr_io.C:1754
void read_serialized_edge_bcs(Xdr &io, T)
Read the edge boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2022
const Parallel::Communicator & comm() const
static const bool value
Definition: xdr_io.C:108
bool legacy() const
Get/Set the flag indicating if we should read/write legacy.
Definition: xdr_io.h:109
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
void read_serialized_side_bcs(Xdr &io, T)
Read the side boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2014
processor_id_type processor_id() const
template<typename T >
void libMesh::XdrIO::read_header ( Xdr io,
std::vector< T > &  meta_data 
)
private

Read header information - templated to handle old (4-byte) or new (8-byte) header id types.

We are future proofing the layout of this file by adding in size information for all stored types. TODO: All types are stored as the same size. Use the size information to pack things efficiently. For now we will assume that "type size" is how the entire file will be encoded.

Definition at line 1444 of file xdr_io.C.

References _field_width, boundary_condition_file_name(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::ParallelObject::n_processors(), partition_map_file_name(), polynomial_level_file_name(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::reserve_elem(), libMesh::MeshBase::reserve_nodes(), libMesh::MeshInput< MeshBase >::set_n_partitions(), subdomain_map_file_name(), and version_at_least_0_9_2().

Referenced by polynomial_level_file_name(), and read().

1445 {
1446  LOG_SCOPE("read_header()","XdrIO");
1447 
1448  // convenient reference to our mesh
1449  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1450 
1451  if (this->processor_id() == 0)
1452  {
1453  unsigned int pos=0;
1454 
1455  io.data (meta_data[pos++]);
1456  io.data (meta_data[pos++]);
1457  io.data (this->boundary_condition_file_name()); // libMesh::out << "bc_file=" << this->boundary_condition_file_name() << std::endl;
1458  io.data (this->subdomain_map_file_name()); // libMesh::out << "sid_file=" << this->subdomain_map_file_name() << std::endl;
1459  io.data (this->partition_map_file_name()); // libMesh::out << "pid_file=" << this->partition_map_file_name() << std::endl;
1460  io.data (this->polynomial_level_file_name()); // libMesh::out << "pl_file=" << this->polynomial_level_file_name() << std::endl;
1461 
1462  if (version_at_least_0_9_2())
1463  {
1464  io.data (meta_data[pos++], "# type size");
1465  io.data (meta_data[pos++], "# uid size");
1466  io.data (meta_data[pos++], "# pid size");
1467  io.data (meta_data[pos++], "# sid size");
1468  io.data (meta_data[pos++], "# p-level size");
1469  // Boundary Condition sizes
1470  io.data (meta_data[pos++], "# eid size"); // elem id
1471  io.data (meta_data[pos++], "# side size"); // side number
1472  io.data (meta_data[pos++], "# bid size"); // boundary id
1473  }
1474  }
1475 
1476  // broadcast the n_elems, n_nodes, and size information
1477  this->comm().broadcast (meta_data);
1478 
1479  this->comm().broadcast (this->boundary_condition_file_name());
1480  this->comm().broadcast (this->subdomain_map_file_name());
1481  this->comm().broadcast (this->partition_map_file_name());
1482  this->comm().broadcast (this->polynomial_level_file_name());
1483 
1484  // Tell the mesh how many nodes/elements to expect. Depending on the mesh type,
1485  // this may allow for efficient adding of nodes/elements.
1486  const T & n_elem = meta_data[0];
1487  const T & n_nodes = meta_data[1];
1488 
1489  mesh.reserve_elem(n_elem);
1490  mesh.reserve_nodes(n_nodes);
1491 
1492  // Our mesh is pre-partitioned as it's created
1493  this->set_n_partitions(this->n_processors());
1494 
1500  if (version_at_least_0_9_2())
1501  _field_width = meta_data[2];
1502 }
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:656
processor_id_type n_processors() const
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2217
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
const dof_id_type n_nodes
Definition: tecplot_io.C:67
unsigned int _field_width
Definition: xdr_io.h:340
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
const Parallel::Communicator & comm() const
void set_n_partitions(unsigned int n_parts)
Sets the number of partitions in the mesh.
Definition: mesh_input.h:91
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
processor_id_type processor_id() const
void libMesh::XdrIO::read_serialized_bc_names ( Xdr io,
BoundaryInfo info,
bool  is_sideset 
)
private

Read boundary names information (sideset and nodeset) - NEW in 0.9.2 format.

Definition at line 2125 of file xdr_io.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::ParallelObject::processor_id(), libMesh::BoundaryInfo::set_nodeset_name_map(), libMesh::BoundaryInfo::set_sideset_name_map(), version_at_least_0_9_2(), and version_at_least_1_3_0().

Referenced by polynomial_level_file_name(), read_serialized_bcs_helper(), and read_serialized_nodesets().

2126 {
2127  const bool read_entity_info = version_at_least_0_9_2();
2128  const bool use_new_header_type (this->version_at_least_1_3_0());
2129  if (read_entity_info)
2130  {
2131  new_header_id_type n_boundary_names = 0;
2132  std::vector<new_header_id_type> boundary_ids;
2133  std::vector<std::string> boundary_names;
2134 
2135  // Read the sideset names
2136  if (this->processor_id() == 0)
2137  {
2138  if (use_new_header_type)
2139  io.data(n_boundary_names);
2140  else
2141  {
2142  old_header_id_type temp;
2143  io.data(temp);
2144  n_boundary_names = temp;
2145  }
2146 
2147  boundary_names.resize(n_boundary_names);
2148 
2149  if (n_boundary_names)
2150  {
2151  if (use_new_header_type)
2152  io.data(boundary_ids);
2153  else
2154  {
2155  std::vector<old_header_id_type> temp(n_boundary_names);
2156  io.data(temp);
2157  boundary_ids.assign(temp.begin(), temp.end());
2158  }
2159  io.data(boundary_names);
2160  }
2161  }
2162 
2163  // Broadcast the boundary names to all processors
2164  this->comm().broadcast(n_boundary_names);
2165  if (n_boundary_names == 0)
2166  return;
2167 
2168  boundary_ids.resize(n_boundary_names);
2169  boundary_names.resize(n_boundary_names);
2170  this->comm().broadcast(boundary_ids);
2171  this->comm().broadcast(boundary_names);
2172 
2173  // Reassemble the named boundary information
2174  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
2175  info.set_sideset_name_map() : info.set_nodeset_name_map();
2176 
2177  for (unsigned int i=0; i<n_boundary_names; ++i)
2178  boundary_map.insert(std::make_pair(cast_int<boundary_id_type>(boundary_ids[i]), boundary_names[i]));
2179  }
2180 }
uint32_t old_header_id_type
Definition: xdr_io.h:60
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2217
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2241
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
uint64_t new_header_id_type
Definition: xdr_io.h:63
const Parallel::Communicator & comm() const
processor_id_type processor_id() const
template<typename T >
void libMesh::XdrIO::read_serialized_bcs_helper ( Xdr io,
,
const std::string  bc_type 
)
private

Helper function used in read_serialized_side_bcs, read_serialized_edge_bcs, and read_serialized_shellface_bcs.

Definition at line 1902 of file xdr_io.C.

References libMesh::BoundaryInfo::add_edge(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), libMesh::as_range(), boundary_condition_file_name(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), data, libMesh::Xdr::data_stream(), end, libMesh::MeshTools::Generation::Private::idx(), io_blksize, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), std::min(), libMesh::ParallelObject::processor_id(), read_serialized_bc_names(), libMesh::Xdr::reading(), and version_at_least_1_3_0().

Referenced by polynomial_level_file_name(), read_serialized_edge_bcs(), read_serialized_shellface_bcs(), and read_serialized_side_bcs().

1903 {
1904  if (this->boundary_condition_file_name() == "n/a") return;
1905 
1906  libmesh_assert (io.reading());
1907 
1908  // convenient reference to our mesh
1909  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1910 
1911  // and our boundary info object
1912  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1913 
1914  // Version 0.9.2+ introduces unique ids
1915  read_serialized_bc_names(io, boundary_info, true); // sideset names
1916 
1917  std::vector<DofBCData> dof_bc_data;
1918  std::vector<T> input_buffer;
1919 
1920  new_header_id_type n_bcs=0;
1921  if (this->processor_id() == 0)
1922  {
1923  if (this->version_at_least_1_3_0())
1924  io.data (n_bcs);
1925  else
1926  {
1927  old_header_id_type temp;
1928  io.data (temp);
1929  n_bcs = temp;
1930  }
1931  }
1932  this->comm().broadcast (n_bcs);
1933 
1934  for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_bcs; blk++)
1935  {
1936  first_bc = blk*io_blksize;
1937  last_bc = std::min((blk+1)*io_blksize, std::size_t(n_bcs));
1938 
1939  input_buffer.resize (3*(last_bc - first_bc));
1940 
1941  if (this->processor_id() == 0)
1942  io.data_stream (input_buffer.empty() ? libmesh_nullptr : &input_buffer[0],
1943  cast_int<unsigned int>(input_buffer.size()));
1944 
1945  this->comm().broadcast (input_buffer);
1946  dof_bc_data.clear();
1947  dof_bc_data.reserve (input_buffer.size()/3);
1948 
1949  // convert the input_buffer to DofBCData to facilitate searching
1950  for (std::size_t idx=0; idx<input_buffer.size(); idx+=3)
1951  dof_bc_data.push_back
1952  (DofBCData(cast_int<dof_id_type>(input_buffer[idx+0]),
1953  cast_int<unsigned short>(input_buffer[idx+1]),
1954  cast_int<boundary_id_type>(input_buffer[idx+2])));
1955  input_buffer.clear();
1956  // note that while the files *we* write should already be sorted by
1957  // element id this is not necessarily guaranteed.
1958  std::sort (dof_bc_data.begin(), dof_bc_data.end());
1959 
1960  MeshBase::const_element_iterator
1961  it = mesh.level_elements_begin(0),
1962  end = mesh.level_elements_end(0);
1963 
1964  // Look for BCs in this block for all the level-0 elements we have
1965  // (not just local ones). Do this by finding all the entries
1966  // in dof_bc_data whose elem_id match the ID of the current element.
1967  // We cannot rely on libmesh_nullptr neighbors at this point since the neighbor
1968  // data structure has not been initialized.
1969  for (; it!=end; ++it)
1970  {
1971  std::pair<std::vector<DofBCData>::iterator,
1972  std::vector<DofBCData>::iterator> bounds =
1973  std::equal_range (dof_bc_data.begin(),
1974  dof_bc_data.end(),
1975  (*it)->id()
1976 #if defined(__SUNPRO_CC) || defined(__PGI)
1977  , CompareIntDofBCData()
1978 #endif
1979  );
1980 
1981  for (const auto & data : as_range(bounds))
1982  {
1983  libmesh_assert_equal_to (data.dof_id, (*it)->id());
1984 
1985  if (bc_type == "side")
1986  {
1987  libmesh_assert_less (data.side, (*it)->n_sides());
1988  boundary_info.add_side (*it, data.side, data.bc_id);
1989  }
1990  else if (bc_type == "edge")
1991  {
1992  libmesh_assert_less (data.side, (*it)->n_edges());
1993  boundary_info.add_edge (*it, data.side, data.bc_id);
1994  }
1995  else if (bc_type == "shellface")
1996  {
1997  // Shell face IDs can only be 0 or 1.
1998  libmesh_assert_less(data.side, 2);
1999 
2000  boundary_info.add_shellface (*it, data.side, data.bc_id);
2001  }
2002  else
2003  {
2004  libmesh_error_msg("bc_type not recognized: " + bc_type);
2005  }
2006  }
2007  }
2008  }
2009 }
uint32_t old_header_id_type
Definition: xdr_io.h:60
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
void read_serialized_bc_names(Xdr &io, BoundaryInfo &info, bool is_sideset)
Read boundary names information (sideset and nodeset) - NEW in 0.9.2 format.
Definition: xdr_io.C:2125
libmesh_assert(j)
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2241
SimpleRange< I > as_range(const std::pair< I, I > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
uint64_t new_header_id_type
Definition: xdr_io.h:63
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:350
const Parallel::Communicator & comm() const
IterBase * data
Ideally this private member data should have protected access.
long double min(long double a, double b)
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
processor_id_type processor_id() const
template<typename T >
void libMesh::XdrIO::read_serialized_connectivity ( Xdr io,
const dof_id_type  n_elem,
std::vector< new_header_id_type > &  sizes,
 
)
private

Read the connectivity for a parallel, distributed mesh.

Definition at line 1568 of file xdr_io.C.

References libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::Parallel::Communicator::broadcast(), libMesh::Elem::build(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::Elem::dim(), libMesh::MeshBase::elem_ptr(), libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::Elem::hack_p_level(), libMesh::Elem::INACTIVE, libMesh::DofObject::invalid_id, io_blksize, libMesh::Elem::JUST_REFINED, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), std::min(), libMesh::MeshTools::n_elem(), libMesh::Elem::n_nodes(), partition_map_file_name(), polynomial_level_file_name(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Xdr::reading(), libMesh::DofObject::set_id(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::Elem::set_refinement_flag(), libMesh::DofObject::set_unique_id(), libMesh::Elem::subdomain_id(), subdomain_map_file_name(), libMesh::Elem::type_to_n_nodes_map, and version_at_least_0_9_2().

Referenced by polynomial_level_file_name(), and read().

1569 {
1570  libmesh_assert (io.reading());
1571 
1572  if (!n_elem) return;
1573 
1574  const bool
1575  read_p_level = ("." == this->polynomial_level_file_name()),
1576  read_partitioning = ("." == this->partition_map_file_name()),
1577  read_subdomain_id = ("." == this->subdomain_map_file_name());
1578 
1579  // convenient reference to our mesh
1580  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1581 
1582  // Keep track of what kinds of elements this file contains
1583  elems_of_dimension.clear();
1584  elems_of_dimension.resize(4, false);
1585 
1586  std::vector<T> conn, input_buffer(100 /* oversized ! */);
1587 
1588  int level=-1;
1589 
1590  // Version 0.9.2+ introduces unique ids
1591  const size_t unique_id_size_index = 3;
1592 
1593  const bool read_unique_id =
1594  (version_at_least_0_9_2()) &&
1595  sizes[unique_id_size_index];
1596 
1597  T n_elem_at_level=0, n_processed_at_level=0;
1598  for (dof_id_type blk=0, first_elem=0, last_elem=0;
1599  last_elem<n_elem; blk++)
1600  {
1601  first_elem = cast_int<dof_id_type>(blk*io_blksize);
1602  last_elem = cast_int<dof_id_type>(std::min(cast_int<std::size_t>((blk+1)*io_blksize),
1603  cast_int<std::size_t>(n_elem)));
1604 
1605  conn.clear();
1606 
1607  if (this->processor_id() == 0)
1608  for (dof_id_type e=first_elem; e<last_elem; e++, n_processed_at_level++)
1609  {
1610  if (n_processed_at_level == n_elem_at_level)
1611  {
1612  // get the number of elements to read at this level
1613  io.data (n_elem_at_level);
1614  n_processed_at_level = 0;
1615  level++;
1616  }
1617 
1618  unsigned int pos = 0;
1619  // get the element type,
1620  io.data_stream (&input_buffer[pos++], 1);
1621 
1622  if (read_unique_id)
1623  io.data_stream (&input_buffer[pos++], 1);
1624  // Older versions won't have this field at all (no increment on pos)
1625 
1626  // maybe the parent
1627  if (level)
1628  io.data_stream (&input_buffer[pos++], 1);
1629  else
1630  // We can't always fit DofObject::invalid_id in an
1631  // xdr_id_type
1632  input_buffer[pos++] = static_cast<T>(-1);
1633 
1634  // maybe the processor id
1635  if (read_partitioning)
1636  io.data_stream (&input_buffer[pos++], 1);
1637  else
1638  input_buffer[pos++] = 0;
1639 
1640  // maybe the subdomain id
1641  if (read_subdomain_id)
1642  io.data_stream (&input_buffer[pos++], 1);
1643  else
1644  input_buffer[pos++] = 0;
1645 
1646  // maybe the p level
1647  if (read_p_level)
1648  io.data_stream (&input_buffer[pos++], 1);
1649  else
1650  input_buffer[pos++] = 0;
1651 
1652  // and all the nodes
1653  libmesh_assert_less (pos+Elem::type_to_n_nodes_map[input_buffer[0]], input_buffer.size());
1654  io.data_stream (&input_buffer[pos], Elem::type_to_n_nodes_map[input_buffer[0]]);
1655  conn.insert (conn.end(),
1656  input_buffer.begin(),
1657  input_buffer.begin() + pos + Elem::type_to_n_nodes_map[input_buffer[0]]);
1658  }
1659 
1660  std::size_t conn_size = conn.size();
1661  this->comm().broadcast(conn_size);
1662  conn.resize (conn_size);
1663  this->comm().broadcast (conn);
1664 
1665  // All processors now have the connectivity for this block.
1666  typename std::vector<T>::const_iterator it = conn.begin();
1667  for (dof_id_type e=first_elem; e<last_elem; e++)
1668  {
1669  const ElemType elem_type = static_cast<ElemType>(*it); ++it;
1670 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1671  // We are on all processors here, so we can easily assign
1672  // consistent unique ids if the file doesn't specify them
1673  // later.
1674  unique_id_type unique_id = e;
1675 #endif
1676  if (read_unique_id)
1677  {
1678 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1679  unique_id = cast_int<unique_id_type>(*it);
1680 #endif
1681  ++it;
1682  }
1683  const dof_id_type parent_id =
1684  (*it == static_cast<T>(-1)) ?
1686  cast_int<dof_id_type>(*it);
1687  ++it;
1688  const processor_id_type proc_id =
1689  cast_int<processor_id_type>(*it);
1690  ++it;
1691  const subdomain_id_type subdomain_id =
1692  cast_int<subdomain_id_type>(*it);
1693  ++it;
1694 #ifdef LIBMESH_ENABLE_AMR
1695  const unsigned int p_level =
1696  cast_int<unsigned int>(*it);
1697 #endif
1698  ++it;
1699 
1700  Elem * parent = (parent_id == DofObject::invalid_id) ?
1701  libmesh_nullptr : mesh.elem_ptr(parent_id);
1702 
1703  Elem * elem = Elem::build (elem_type, parent).release();
1704 
1705  elem->set_id() = e;
1706 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1707  elem->set_unique_id() = unique_id;
1708 #endif
1709  elem->processor_id() = proc_id;
1710  elem->subdomain_id() = subdomain_id;
1711 #ifdef LIBMESH_ENABLE_AMR
1712  elem->hack_p_level(p_level);
1713 
1714  if (parent)
1715  {
1716  parent->add_child(elem);
1717  parent->set_refinement_flag (Elem::INACTIVE);
1718  elem->set_refinement_flag (Elem::JUST_REFINED);
1719  }
1720 #endif
1721 
1722  for (unsigned int n=0, n_n = elem->n_nodes(); n != n_n;
1723  n++, ++it)
1724  {
1725  const dof_id_type global_node_number =
1726  cast_int<dof_id_type>(*it);
1727 
1728  elem->set_node(n) =
1729  mesh.add_point (Point(), global_node_number);
1730  }
1731 
1732  elems_of_dimension[elem->dim()] = true;
1733  mesh.add_elem(elem);
1734  }
1735  }
1736 
1737  // Set the mesh dimension to the largest encountered for an element
1738  for (unsigned char i=0; i!=4; ++i)
1739  if (elems_of_dimension[i])
1740  mesh.set_mesh_dimension(i);
1741 
1742 #if LIBMESH_DIM < 3
1743  if (mesh.mesh_dimension() > LIBMESH_DIM)
1744  libmesh_error_msg("Cannot open dimension " \
1745  << mesh.mesh_dimension() \
1746  << " mesh file when configured without " \
1747  << mesh.mesh_dimension() \
1748  << "D support.");
1749 #endif
1750 }
static UniquePtr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:238
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:656
std::vector< bool > elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh...
Definition: mesh_input.h:97
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
ElemType
Defines an enum for geometric element types.
uint8_t processor_id_type
Definition: id_types.h:99
const class libmesh_nullptr_t libmesh_nullptr
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
libmesh_assert(j)
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2217
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:324
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:350
const Parallel::Communicator & comm() const
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
long double min(long double a, double b)
uint8_t unique_id_type
Definition: id_types.h:79
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
template<typename T >
void libMesh::XdrIO::read_serialized_edge_bcs ( Xdr io,
value 
)
private

Read the edge boundary conditions for a parallel, distributed mesh.

NEW in 1.1.0 format.

Returns
The number of bcs read

Definition at line 2022 of file xdr_io.C.

References read_serialized_bcs_helper().

Referenced by polynomial_level_file_name(), and read().

2023 {
2024  read_serialized_bcs_helper(io, value, "edge");
2025 }
void read_serialized_bcs_helper(Xdr &io, T, const std::string bc_type)
Helper function used in read_serialized_side_bcs, read_serialized_edge_bcs, and read_serialized_shell...
Definition: xdr_io.C:1902
static const bool value
Definition: xdr_io.C:108
void libMesh::XdrIO::read_serialized_nodes ( Xdr io,
const dof_id_type  n_nodes 
)
private

Read the nodal locations for a parallel, distributed mesh.

Definition at line 1754 of file xdr_io.C.

References _field_width, libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshTools::Generation::Private::idx(), io_blksize, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), std::min(), n_nodes, libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), and version_at_least_0_9_6().

Referenced by polynomial_level_file_name(), and read().

1755 {
1756  libmesh_assert (io.reading());
1757 
1758  // convenient reference to our mesh
1759  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1760 
1761  if (!mesh.n_nodes()) return;
1762 
1763  // At this point the elements have been read from file and placeholder nodes
1764  // have been assigned. These nodes, however, do not have the proper (x,y,z)
1765  // locations or unique_id values. This method will read all the
1766  // nodes from disk, and each processor can then grab the individual
1767  // values it needs.
1768 
1769  // If the file includes unique ids for nodes (as indicated by a
1770  // flag in 0.9.6+ files), those will be read next.
1771 
1772  // build up a list of the nodes contained in our local mesh. These are the nodes
1773  // stored on the local processor whose (x,y,z) and unique_id values
1774  // need to be corrected.
1775  std::vector<dof_id_type> needed_nodes; needed_nodes.reserve (mesh.n_nodes());
1776  {
1777  for (auto & node : mesh.node_ptr_range())
1778  needed_nodes.push_back(node->id());
1779 
1780  std::sort (needed_nodes.begin(), needed_nodes.end());
1781 
1782  // We should not have any duplicate node->id()s
1783  libmesh_assert (std::unique(needed_nodes.begin(), needed_nodes.end()) == needed_nodes.end());
1784  }
1785 
1786  // Get the nodes in blocks.
1787  std::vector<Real> coords;
1788  std::pair<std::vector<dof_id_type>::iterator,
1789  std::vector<dof_id_type>::iterator> pos;
1790  pos.first = needed_nodes.begin();
1791 
1792  // Broadcast node coordinates
1793  for (std::size_t blk=0, first_node=0, last_node=0; last_node<n_nodes; blk++)
1794  {
1795  first_node = blk*io_blksize;
1796  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
1797 
1798  coords.resize(3*(last_node - first_node));
1799 
1800  if (this->processor_id() == 0)
1801  io.data_stream (coords.empty() ? libmesh_nullptr : &coords[0],
1802  cast_int<unsigned int>(coords.size()));
1803 
1804  // For large numbers of processors the majority of processors at any given
1805  // block may not actually need these data. It may be worth profiling this,
1806  // although it is expected that disk IO will be the bottleneck
1807  this->comm().broadcast (coords);
1808 
1809  for (std::size_t n=first_node, idx=0; n<last_node; n++, idx+=3)
1810  {
1811  // first see if we need this node. use pos.first as a smart lower
1812  // bound, this will ensure that the size of the searched range
1813  // decreases as we match nodes.
1814  pos = std::equal_range (pos.first, needed_nodes.end(), n);
1815 
1816  if (pos.first != pos.second) // we need this node.
1817  {
1818  libmesh_assert_equal_to (*pos.first, n);
1819  mesh.node_ref(cast_int<dof_id_type>(n)) =
1820  Point (coords[idx+0],
1821  coords[idx+1],
1822  coords[idx+2]);
1823 
1824  }
1825  }
1826  }
1827 
1828  if (version_at_least_0_9_6())
1829  {
1830  // Check for node unique ids
1831  unsigned short read_unique_ids;
1832 
1833  if (this->processor_id() == 0)
1834  io.data (read_unique_ids);
1835 
1836  this->comm().broadcast (read_unique_ids);
1837 
1838  // If no unique ids are in the file, we're done.
1839  if (!read_unique_ids)
1840  return;
1841 
1842  std::vector<uint32_t> unique_32;
1843  std::vector<uint64_t> unique_64;
1844 
1845  // We're starting over from node 0 again
1846  pos.first = needed_nodes.begin();
1847 
1848  for (std::size_t blk=0, first_node=0, last_node=0; last_node<n_nodes; blk++)
1849  {
1850  first_node = blk*io_blksize;
1851  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
1852 
1853  libmesh_assert((_field_width == 8) || (_field_width == 4));
1854 
1855  if (_field_width == 8)
1856  unique_64.resize(last_node - first_node);
1857  else
1858  unique_32.resize(last_node - first_node);
1859 
1860  if (this->processor_id() == 0)
1861  {
1862  if (_field_width == 8)
1863  io.data_stream (unique_64.empty() ? libmesh_nullptr : &unique_64[0],
1864  cast_int<unsigned int>(unique_64.size()));
1865  else
1866  io.data_stream (unique_32.empty() ? libmesh_nullptr : &unique_32[0],
1867  cast_int<unsigned int>(unique_32.size()));
1868  }
1869 
1870 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1871  if (_field_width == 8)
1872  this->comm().broadcast (unique_64);
1873  else
1874  this->comm().broadcast (unique_32);
1875 
1876  for (std::size_t n=first_node, idx=0; n<last_node; n++, idx++)
1877  {
1878  // first see if we need this node. use pos.first as a smart lower
1879  // bound, this will ensure that the size of the searched range
1880  // decreases as we match nodes.
1881  pos = std::equal_range (pos.first, needed_nodes.end(), n);
1882 
1883  if (pos.first != pos.second) // we need this node.
1884  {
1885  libmesh_assert_equal_to (*pos.first, n);
1886  if (_field_width == 8)
1887  mesh.node_ref(cast_int<dof_id_type>(n)).set_unique_id()
1888  = unique_64[idx];
1889  else
1890  mesh.node_ref(cast_int<dof_id_type>(n)).set_unique_id()
1891  = unique_32[idx];
1892  }
1893  }
1894 #endif // LIBMESH_ENABLE_UNIQUE_ID
1895  }
1896  }
1897 }
const class libmesh_nullptr_t libmesh_nullptr
bool version_at_least_0_9_6() const
Definition: xdr_io.C:2226
libmesh_assert(j)
const dof_id_type n_nodes
Definition: tecplot_io.C:67
unsigned int _field_width
Definition: xdr_io.h:340
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:350
const Parallel::Communicator & comm() const
long double min(long double a, double b)
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
processor_id_type processor_id() const
template<typename T >
void libMesh::XdrIO::read_serialized_nodesets ( Xdr io,
 
)
private

Read the nodeset conditions for a parallel, distributed mesh.

Returns
The number of nodesets read

Definition at line 2038 of file xdr_io.C.

References libMesh::BoundaryInfo::add_node(), libMesh::as_range(), boundary_condition_file_name(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), data, libMesh::Xdr::data_stream(), libMesh::MeshTools::Generation::Private::idx(), io_blksize, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), std::min(), libMesh::ParallelObject::processor_id(), read_serialized_bc_names(), libMesh::Xdr::reading(), and version_at_least_1_3_0().

Referenced by polynomial_level_file_name(), and read().

2039 {
2040  if (this->boundary_condition_file_name() == "n/a") return;
2041 
2042  libmesh_assert (io.reading());
2043 
2044  // convenient reference to our mesh
2045  MeshBase & mesh = MeshInput<MeshBase>::mesh();
2046 
2047  // and our boundary info object
2048  BoundaryInfo & boundary_info = mesh.get_boundary_info();
2049 
2050  // Version 0.9.2+ introduces unique ids
2051  read_serialized_bc_names(io, boundary_info, false); // nodeset names
2052 
2053  // TODO: Make a data object that works with both the element and nodal bcs
2054  std::vector<DofBCData> node_bc_data;
2055  std::vector<T> input_buffer;
2056 
2057  new_header_id_type n_nodesets=0;
2058  if (this->processor_id() == 0)
2059  {
2060  if (this->version_at_least_1_3_0())
2061  io.data (n_nodesets);
2062  else
2063  {
2064  old_header_id_type temp;
2065  io.data (temp);
2066  n_nodesets = temp;
2067  }
2068  }
2069  this->comm().broadcast (n_nodesets);
2070 
2071  for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_nodesets; blk++)
2072  {
2073  first_bc = blk*io_blksize;
2074  last_bc = std::min((blk+1)*io_blksize, std::size_t(n_nodesets));
2075 
2076  input_buffer.resize (2*(last_bc - first_bc));
2077 
2078  if (this->processor_id() == 0)
2079  io.data_stream (input_buffer.empty() ? libmesh_nullptr : &input_buffer[0],
2080  cast_int<unsigned int>(input_buffer.size()));
2081 
2082  this->comm().broadcast (input_buffer);
2083  node_bc_data.clear();
2084  node_bc_data.reserve (input_buffer.size()/2);
2085 
2086  // convert the input_buffer to DofBCData to facilitate searching
2087  for (std::size_t idx=0; idx<input_buffer.size(); idx+=2)
2088  node_bc_data.push_back
2089  (DofBCData(cast_int<dof_id_type>(input_buffer[idx+0]),
2090  0,
2091  cast_int<boundary_id_type>(input_buffer[idx+1])));
2092  input_buffer.clear();
2093  // note that while the files *we* write should already be sorted by
2094  // node id this is not necessarily guaranteed.
2095  std::sort (node_bc_data.begin(), node_bc_data.end());
2096 
2097  // Look for BCs in this block for all nodes we have
2098  // (not just local ones). Do this by finding all the entries
2099  // in node_bc_data whose dof_id(node_id) match the ID of the current node.
2100  for (auto & node : mesh.node_ptr_range())
2101  {
2102  std::pair<std::vector<DofBCData>::iterator,
2103  std::vector<DofBCData>::iterator> bounds =
2104  std::equal_range (node_bc_data.begin(),
2105  node_bc_data.end(),
2106  node->id()
2107 #if defined(__SUNPRO_CC) || defined(__PGI)
2108  , CompareIntDofBCData()
2109 #endif
2110  );
2111 
2112  for (const auto & data : as_range(bounds))
2113  {
2114  // Note: dof_id from ElmeBCData is being used to hold node_id here
2115  libmesh_assert_equal_to (data.dof_id, node->id());
2116 
2117  boundary_info.add_node (node, data.bc_id);
2118  }
2119  }
2120  }
2121 }
uint32_t old_header_id_type
Definition: xdr_io.h:60
const class libmesh_nullptr_t libmesh_nullptr
void read_serialized_bc_names(Xdr &io, BoundaryInfo &info, bool is_sideset)
Read boundary names information (sideset and nodeset) - NEW in 0.9.2 format.
Definition: xdr_io.C:2125
libmesh_assert(j)
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2241
SimpleRange< I > as_range(const std::pair< I, I > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
uint64_t new_header_id_type
Definition: xdr_io.h:63
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:350
const Parallel::Communicator & comm() const
IterBase * data
Ideally this private member data should have protected access.
long double min(long double a, double b)
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
processor_id_type processor_id() const
template<typename T >
void libMesh::XdrIO::read_serialized_shellface_bcs ( Xdr io,
value 
)
private

Read the "shell face" boundary conditions for a parallel, distributed mesh.

NEW in 1.1.0 format.

Returns
The number of bcs read

Definition at line 2030 of file xdr_io.C.

References read_serialized_bcs_helper().

Referenced by polynomial_level_file_name(), and read().

2031 {
2032  read_serialized_bcs_helper(io, value, "shellface");
2033 }
void read_serialized_bcs_helper(Xdr &io, T, const std::string bc_type)
Helper function used in read_serialized_side_bcs, read_serialized_edge_bcs, and read_serialized_shell...
Definition: xdr_io.C:1902
static const bool value
Definition: xdr_io.C:108
template<typename T >
void libMesh::XdrIO::read_serialized_side_bcs ( Xdr io,
value 
)
private

Read the side boundary conditions for a parallel, distributed mesh.

Returns
The number of bcs read

Definition at line 2014 of file xdr_io.C.

References read_serialized_bcs_helper().

Referenced by polynomial_level_file_name(), and read().

2015 {
2016  read_serialized_bcs_helper(io, value, "side");
2017 }
void read_serialized_bcs_helper(Xdr &io, T, const std::string bc_type)
Helper function used in read_serialized_side_bcs, read_serialized_edge_bcs, and read_serialized_shell...
Definition: xdr_io.C:1902
static const bool value
Definition: xdr_io.C:108
void libMesh::XdrIO::read_serialized_subdomain_names ( Xdr io)
private

Read subdomain name information - NEW in 0.9.2 format.

Definition at line 1506 of file xdr_io.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::set_subdomain_name_map(), version_at_least_0_9_2(), and version_at_least_1_3_0().

Referenced by polynomial_level_file_name(), and read().

1507 {
1508  const bool read_entity_info = version_at_least_0_9_2();
1509  const bool use_new_header_type (this->version_at_least_1_3_0());
1510  if (read_entity_info)
1511  {
1512  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1513 
1514  new_header_id_type n_subdomain_names = 0;
1515  std::vector<new_header_id_type> subdomain_ids;
1516  std::vector<std::string> subdomain_names;
1517 
1518  // Read the sideset names
1519  if (this->processor_id() == 0)
1520  {
1521  if (use_new_header_type)
1522  io.data(n_subdomain_names);
1523  else
1524  {
1525  old_header_id_type temp;
1526  io.data(temp);
1527  n_subdomain_names = temp;
1528  }
1529 
1530  subdomain_ids.resize(n_subdomain_names);
1531  subdomain_names.resize(n_subdomain_names);
1532 
1533  if (n_subdomain_names)
1534  {
1535  if (use_new_header_type)
1536  io.data(subdomain_ids);
1537  else
1538  {
1539  std::vector<old_header_id_type> temp;
1540  io.data(temp);
1541  subdomain_ids.assign(temp.begin(), temp.end());
1542  }
1543 
1544  io.data(subdomain_names);
1545  }
1546  }
1547 
1548  // Broadcast the subdomain names to all processors
1549  this->comm().broadcast(n_subdomain_names);
1550  if (n_subdomain_names == 0)
1551  return;
1552 
1553  subdomain_ids.resize(n_subdomain_names);
1554  subdomain_names.resize(n_subdomain_names);
1555  this->comm().broadcast(subdomain_ids);
1556  this->comm().broadcast(subdomain_names);
1557 
1558  // Reassemble the named subdomain information
1559  std::map<subdomain_id_type, std::string> & subdomain_map = mesh.set_subdomain_name_map();
1560 
1561  for (unsigned int i=0; i<n_subdomain_names; ++i)
1562  subdomain_map.insert(std::make_pair(subdomain_ids[i], subdomain_names[i]));
1563  }
1564 }
uint32_t old_header_id_type
Definition: xdr_io.h:60
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2217
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2241
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
uint64_t new_header_id_type
Definition: xdr_io.h:63
const Parallel::Communicator & comm() const
processor_id_type processor_id() const
void libMesh::XdrIO::set_auto_parallel ( )

Insist that we should write parallel files if and only if the mesh is an already distributed DistributedMesh.

Definition at line 389 of file xdr_io.h.

References _write_parallel, and _write_serial.

Referenced by legacy().

390 {
391  this->_write_serial = false;
392  this->_write_parallel = false;
393 }
bool _write_parallel
Definition: xdr_io.h:338
bool _write_serial
Definition: xdr_io.h:337
void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
protectedinherited

Sets the number of partitions in the mesh.

Typically this gets done by the partitioner, but some parallel file formats begin "pre-partitioned".

Definition at line 91 of file mesh_input.h.

References libMesh::MeshInput< MT >::mesh().

Referenced by libMesh::Nemesis_IO::read(), and read_header().

91 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1329
void libMesh::XdrIO::set_write_parallel ( bool  do_parallel = true)

Insist that we should/shouldn't write parallel files.

Definition at line 379 of file xdr_io.h.

References _write_parallel, and _write_serial.

Referenced by legacy().

380 {
381  this->_write_parallel = do_parallel;
382 
383  this->_write_serial = !do_parallel;
384 }
bool _write_parallel
Definition: xdr_io.h:338
bool _write_serial
Definition: xdr_io.h:337
void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
)
protectedinherited

Reads input from in, skipping all the lines that start with the character comment_start.

Referenced by libMesh::TetGenIO::read(), and libMesh::UCDIO::read_implementation().

const std::string& libMesh::XdrIO::subdomain_map_file_name ( ) const

Get/Set the subdomain file name.

Definition at line 158 of file xdr_io.h.

References _subdomain_map_file.

Referenced by read_header(), read_serialized_connectivity(), write(), and write_serialized_connectivity().

158 { return _subdomain_map_file; }
std::string _subdomain_map_file
Definition: xdr_io.h:344
std::string& libMesh::XdrIO::subdomain_map_file_name ( )

Definition at line 159 of file xdr_io.h.

References _subdomain_map_file.

159 { return _subdomain_map_file; }
std::string _subdomain_map_file
Definition: xdr_io.h:344
const std::string& libMesh::XdrIO::version ( ) const

Get/Set the version string.

Valid version strings:

* "libMesh-0.7.0+"
* "libMesh-0.7.0+ parallel"
* 

If "libMesh" is not detected in the version string the LegacyXdrIO class will be used to read older (pre version 0.7.0) mesh files.

Definition at line 140 of file xdr_io.h.

References _version.

Referenced by read(), version_at_least_0_9_2(), version_at_least_0_9_6(), version_at_least_1_1_0(), version_at_least_1_3_0(), and write().

140 { return _version; }
std::string _version
Definition: xdr_io.h:341
std::string& libMesh::XdrIO::version ( )

Definition at line 141 of file xdr_io.h.

References _version.

141 { return _version; }
std::string _version
Definition: xdr_io.h:341
bool libMesh::XdrIO::version_at_least_0_9_2 ( ) const
Returns
true if the current file has an XDR/XDA version that matches or exceeds 0.9.2.

As of this version we encode integer field widths, nodesets, subdomain names, boundary names, and element unique_id values (if they exist) into our files.

Definition at line 2217 of file xdr_io.C.

References version().

Referenced by polynomial_level_file_name(), read(), read_header(), read_serialized_bc_names(), read_serialized_connectivity(), and read_serialized_subdomain_names().

2218 {
2219  return
2220  (this->version().find("0.9.2") != std::string::npos) ||
2221  (this->version().find("0.9.6") != std::string::npos) ||
2222  (this->version().find("1.1.0") != std::string::npos) ||
2223  (this->version().find("1.3.0") != std::string::npos);
2224 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
bool libMesh::XdrIO::version_at_least_0_9_6 ( ) const
Returns
true if the current file has an XDR/XDA version that matches or exceeds 0.9.6.

In this version we add node unique_id values to our files, if they exist.

Definition at line 2226 of file xdr_io.C.

References version().

Referenced by polynomial_level_file_name(), and read_serialized_nodes().

2227 {
2228  return
2229  (this->version().find("0.9.6") != std::string::npos) ||
2230  (this->version().find("1.1.0") != std::string::npos) ||
2231  (this->version().find("1.3.0") != std::string::npos);
2232 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
bool libMesh::XdrIO::version_at_least_1_1_0 ( ) const
Returns
true if the current file has an XDR/XDA version that matches or exceeds 1.1.0.

In this version we add edge and shellface boundary conditions to our files.

Definition at line 2234 of file xdr_io.C.

References version().

Referenced by polynomial_level_file_name(), and read().

2235 {
2236  return
2237  (this->version().find("1.1.0") != std::string::npos) ||
2238  (this->version().find("1.3.0") != std::string::npos);
2239 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
bool libMesh::XdrIO::version_at_least_1_3_0 ( ) const
Returns
true if the current file has an XDR/XDA version that matches or exceeds 1.3.0.

In this version we fix handling of uint64_t binary values on Linux, which were previously miswritten as 32 bit via xdr_long.

Definition at line 2241 of file xdr_io.C.

References version().

Referenced by polynomial_level_file_name(), read(), read_serialized_bc_names(), read_serialized_bcs_helper(), read_serialized_nodesets(), and read_serialized_subdomain_names().

2242 {
2243  return
2244  (this->version().find("1.3.0") != std::string::npos);
2245 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
void libMesh::XdrIO::write ( const std::string &  name)
virtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 167 of file xdr_io.C.

References _write_unique_id, libMesh::Parallel::Communicator::barrier(), binary(), boundary_condition_file_name(), libMesh::Xdr::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::ENCODE, libMesh::MeshBase::get_boundary_info(), legacy(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::MeshBase::n_subdomains(), libMesh::out, partition_map_file_name(), polynomial_level_file_name(), libMesh::ParallelObject::processor_id(), subdomain_map_file_name(), version(), libMesh::WRITE, write_parallel(), write_serialized_connectivity(), write_serialized_edge_bcs(), write_serialized_nodes(), write_serialized_nodesets(), write_serialized_shellface_bcs(), write_serialized_side_bcs(), and write_serialized_subdomain_names().

Referenced by libMesh::ErrorVector::plot_error(), and libMesh::NameBasedIO::write().

168 {
169  if (this->legacy())
170  libmesh_error_msg("We don't support writing parallel files in the legacy format.");
171 
172  Xdr io ((this->processor_id() == 0) ? name : "", this->binary() ? ENCODE : WRITE);
173 
174  START_LOG("write()","XdrIO");
175 
176  // convenient reference to our mesh
177  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
178 
179  new_header_id_type n_elem = mesh.n_elem();
180  new_header_id_type n_nodes = mesh.n_nodes();
181 
182  libmesh_assert(n_elem == mesh.n_elem());
183  libmesh_assert(n_nodes == mesh.n_nodes());
184 
185  new_header_id_type n_side_bcs = mesh.get_boundary_info().n_boundary_conds();
186  new_header_id_type n_edge_bcs = mesh.get_boundary_info().n_edge_conds();
187  new_header_id_type n_shellface_bcs = mesh.get_boundary_info().n_shellface_conds();
188  new_header_id_type n_nodesets = mesh.get_boundary_info().n_nodeset_conds();
189  unsigned int n_p_levels = MeshTools::n_p_levels (mesh);
190 
191  bool write_parallel_files = this->write_parallel();
192 
193  //-------------------------------------------------------------
194  // For all the optional files -- the default file name is "n/a".
195  // However, the user may specify an optional external file.
196 
197  // If there are BCs and the user has not already provided a
198  // file name then write to "."
199  if ((n_side_bcs || n_edge_bcs || n_shellface_bcs || n_nodesets) &&
200  this->boundary_condition_file_name() == "n/a")
201  this->boundary_condition_file_name() = ".";
202 
203  // If there are more than one subdomains and the user has not specified an
204  // external file then write the subdomain mapping to the default file "."
205  if ((mesh.n_subdomains() > 0) &&
206  (this->subdomain_map_file_name() == "n/a"))
207  this->subdomain_map_file_name() = ".";
208 
209  // In general we don't write the partition information.
210 
211  // If we have p levels and the user has not already provided
212  // a file name then write to "."
213  if ((n_p_levels > 1) &&
214  (this->polynomial_level_file_name() == "n/a"))
215  this->polynomial_level_file_name() = ".";
216 
217  // write the header
218  if (this->processor_id() == 0)
219  {
220  std::string full_ver = this->version() + (write_parallel_files ? " parallel" : "");
221  io.data (full_ver);
222 
223  io.data (n_elem, "# number of elements");
224  io.data (n_nodes, "# number of nodes");
225 
226  io.data (this->boundary_condition_file_name(), "# boundary condition specification file");
227  io.data (this->subdomain_map_file_name(), "# subdomain id specification file");
228  io.data (this->partition_map_file_name(), "# processor id specification file");
229  io.data (this->polynomial_level_file_name(), "# p-level specification file");
230 
231  // Version 0.9.2+ introduces sizes for each type
232  new_header_id_type write_size = sizeof(xdr_id_type), zero_size = 0;
233 
234  const bool
235  write_p_level = ("." == this->polynomial_level_file_name()),
236  write_partitioning = ("." == this->partition_map_file_name()),
237  write_subdomain_id = ("." == this->subdomain_map_file_name()),
238  write_bcs = ("." == this->boundary_condition_file_name());
239 
240  io.data (write_size, "# type size");
241  io.data (_write_unique_id ? write_size : zero_size, "# uid size");
242  io.data (write_partitioning ? write_size : zero_size, "# pid size");
243  io.data (write_subdomain_id ? write_size : zero_size, "# sid size");
244  io.data (write_p_level ? write_size : zero_size, "# p-level size");
245  // Boundary Condition sizes
246  io.data (write_bcs ? write_size : zero_size, "# eid size"); // elem id
247  io.data (write_bcs ? write_size : zero_size, "# side size"); // side number
248  io.data (write_bcs ? write_size : zero_size, "# bid size"); // boundary id
249  }
250 
251  if (write_parallel_files)
252  {
253  // Parallel xdr mesh files aren't implemented yet; until they
254  // are we'll just warn the user and write a serial file.
255  libMesh::out << "Warning! Parallel xda/xdr is not yet implemented.\n";
256  libMesh::out << "Writing a serialized file instead." << std::endl;
257 
258  // write subdomain names
260 
261  // write connectivity
262  this->write_serialized_connectivity (io, n_elem);
263 
264  // write the nodal locations
265  this->write_serialized_nodes (io, n_nodes);
266 
267  // write the side boundary condition information
268  this->write_serialized_side_bcs (io, n_side_bcs);
269 
270  // write the nodeset information
271  this->write_serialized_nodesets (io, n_nodesets);
272 
273  // write the edge boundary condition information
274  this->write_serialized_edge_bcs (io, n_edge_bcs);
275 
276  // write the "shell face" boundary condition information
277  this->write_serialized_shellface_bcs (io, n_shellface_bcs);
278  }
279  else
280  {
281  // write subdomain names
283 
284  // write connectivity
285  this->write_serialized_connectivity (io, n_elem);
286 
287  // write the nodal locations
288  this->write_serialized_nodes (io, n_nodes);
289 
290  // write the side boundary condition information
291  this->write_serialized_side_bcs (io, n_side_bcs);
292 
293  // write the nodeset information
294  this->write_serialized_nodesets (io, n_nodesets);
295 
296  // write the edge boundary condition information
297  this->write_serialized_edge_bcs (io, n_edge_bcs);
298 
299  // write the "shell face" boundary condition information
300  this->write_serialized_shellface_bcs (io, n_shellface_bcs);
301  }
302 
303  STOP_LOG("write()","XdrIO");
304 
305  // pause all processes until the writing ends -- this will
306  // protect for the pathological case where a write is
307  // followed immediately by a read. The write must be
308  // guaranteed to complete first.
309  io.close();
310  this->comm().barrier();
311 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: xdr_io.h:103
bool write_parallel() const
Report whether we should write parallel files.
Definition: xdr_io.h:358
void write_serialized_nodesets(Xdr &io, const new_header_id_type n_nodesets) const
Write the boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1194
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:656
void write_serialized_edge_bcs(Xdr &io, const new_header_id_type n_edge_bcs) const
Write the edge boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1180
void write_serialized_side_bcs(Xdr &io, const new_header_id_type n_side_bcs) const
Write the side boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1173
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
largest_id_type xdr_id_type
Definition: xdr_io.h:57
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
const dof_id_type n_nodes
Definition: tecplot_io.C:67
void write_serialized_connectivity(Xdr &io, const dof_id_type n_elem) const
Write the connectivity for a parallel, distributed mesh.
Definition: xdr_io.C:356
void write_serialized_nodes(Xdr &io, const dof_id_type n_nodes) const
Write the nodal locations for a parallel, distributed mesh.
Definition: xdr_io.C:719
void barrier() const
Pause execution until all processors reach a certain point.
uint64_t new_header_id_type
Definition: xdr_io.h:63
bool _write_unique_id
Definition: xdr_io.h:339
void write_serialized_shellface_bcs(Xdr &io, const new_header_id_type n_shellface_bcs) const
Write the "shell face" boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1187
void write_serialized_subdomain_names(Xdr &io) const
Write subdomain name information - NEW in 0.9.2 format.
Definition: xdr_io.C:315
const Parallel::Communicator & comm() const
OStreamProxy out
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
bool legacy() const
Get/Set the flag indicating if we should read/write legacy.
Definition: xdr_io.h:109
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
unsigned int n_p_levels(const MeshBase &mesh)
Definition: mesh_tools.C:672
processor_id_type processor_id() const
virtual void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = libmesh_nullptr 
)
virtualinherited

This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object.

Reimplemented in libMesh::NameBasedIO.

Referenced by libMesh::Nemesis_IO::write_timestep(), and libMesh::ExodusII_IO::write_timestep().

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
virtualinherited

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided.

Reimplemented in libMesh::ExodusII_IO, libMesh::NameBasedIO, libMesh::GmshIO, libMesh::Nemesis_IO, libMesh::VTKIO, libMesh::UCDIO, libMesh::GMVIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 96 of file mesh_output.h.

References libMesh::MeshOutput< MT >::ascii_precision(), libMesh::MeshOutput< MT >::mesh(), and libMesh::MeshOutput< MT >::write_nodal_data().

99  { libmesh_not_implemented(); }
virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const NumericVector< Number > &  ,
const std::vector< std::string > &   
)
virtualinherited

This method should be overridden by "parallel" output formats for writing nodal data.

Instead of getting a localized copy of the nodal solution vector, it is passed a NumericVector of type=PARALLEL which is in node-major order i.e. (u0,v0,w0, u1,v1,w1, u2,v2,w2, u3,v3,w3, ...) and contains n_nodes*n_vars total entries. Then, it is up to the individual I/O class to extract the required solution values from this vector and write them in parallel.

If not implemented, localizes the parallel vector into a std::vector and calls the other version of this function.

Reimplemented in libMesh::Nemesis_IO.

bool libMesh::XdrIO::write_parallel ( ) const

Report whether we should write parallel files.

Definition at line 358 of file xdr_io.h.

References _write_parallel, _write_serial, libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshOutput< MT >::mesh().

Referenced by legacy(), and write().

359 {
360  // We can't insist on both serial and parallel
361  libmesh_assert (!this->_write_serial || !this->_write_parallel);
362 
363  // If we insisted on serial, do that
364  if (this->_write_serial)
365  return false;
366 
367  // If we insisted on parallel, do that
368  if (this->_write_parallel)
369  return true;
370 
371  // If we're doing things automatically, check the mesh
372  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
373  return !mesh.is_serial();
374 }
bool _write_parallel
Definition: xdr_io.h:338
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
bool _write_serial
Definition: xdr_io.h:337
void libMesh::XdrIO::write_serialized_bc_names ( Xdr io,
const BoundaryInfo info,
bool  is_sideset 
) const
private

Write boundary names information (sideset and nodeset) - NEW in 0.9.2 format.

Definition at line 1271 of file xdr_io.C.

References libMesh::Xdr::data(), libMesh::BoundaryInfo::get_nodeset_name_map(), libMesh::BoundaryInfo::get_sideset_name_map(), and libMesh::ParallelObject::processor_id().

Referenced by polynomial_level_file_name(), write_serialized_bcs_helper(), and write_serialized_nodesets().

1272 {
1273  if (this->processor_id() == 0)
1274  {
1275  const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1276  info.get_sideset_name_map() : info.get_nodeset_name_map();
1277 
1278  std::vector<new_header_id_type> boundary_ids;
1279  boundary_ids.reserve(boundary_map.size());
1280 
1281  std::vector<std::string> boundary_names;
1282  boundary_names.reserve(boundary_map.size());
1283 
1284  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
1285  // return writable references in boundary_info, it's possible for the user to leave some entity names
1286  // blank. We can't write those to the XDA file.
1287  new_header_id_type n_boundary_names = 0;
1288  std::map<boundary_id_type, std::string>::const_iterator it_end = boundary_map.end();
1289  for (std::map<boundary_id_type, std::string>::const_iterator it = boundary_map.begin(); it != it_end; ++it)
1290  {
1291  if (!it->second.empty())
1292  {
1293  n_boundary_names++;
1294  boundary_ids.push_back(it->first);
1295  boundary_names.push_back(it->second);
1296  }
1297  }
1298 
1299  if (is_sideset)
1300  io.data(n_boundary_names, "# sideset id to name map");
1301  else
1302  io.data(n_boundary_names, "# nodeset id to name map");
1303  // Write out the ids and names in two vectors
1304  if (n_boundary_names)
1305  {
1306  io.data(boundary_ids);
1307  io.data(boundary_names);
1308  }
1309  }
1310 }
uint64_t new_header_id_type
Definition: xdr_io.h:63
processor_id_type processor_id() const
void libMesh::XdrIO::write_serialized_bcs_helper ( Xdr io,
const new_header_id_type  n_side_bcs,
const std::string  bc_type 
) const
private

Helper function used in write_serialized_side_bcs, write_serialized_edge_bcs, and write_serialized_shellface_bcs.

Definition at line 1040 of file xdr_io.C.

References bc_id, libMesh::BoundaryInfo::boundary_ids(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::BoundaryInfo::edge_boundary_ids(), libMesh::Elem::edge_index_range(), end, libMesh::Parallel::Communicator::gather(), libMesh::MeshTools::Generation::Private::idx(), libMesh::BoundaryInfo::invalid_id, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), libMesh::BoundaryInfo::shellface_boundary_ids(), libMesh::Elem::side_index_range(), write_serialized_bc_names(), and libMesh::Xdr::writing().

Referenced by polynomial_level_file_name(), write_serialized_edge_bcs(), write_serialized_shellface_bcs(), and write_serialized_side_bcs().

1041 {
1042  libmesh_assert (io.writing());
1043 
1044  // convenient reference to our mesh
1045  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
1046 
1047  // and our boundary info object
1048  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1049 
1050  // Version 0.9.2+ introduces entity names
1051  write_serialized_bc_names(io, boundary_info, true); // sideset names
1052 
1053  new_header_id_type n_bcs_out = n_bcs;
1054  if (this->processor_id() == 0)
1055  {
1056  std::stringstream comment_string;
1057  comment_string << "# number of " << bc_type << " boundary conditions";
1058  io.data (n_bcs_out, comment_string.str().c_str());
1059  }
1060  n_bcs_out = 0;
1061 
1062  if (!n_bcs) return;
1063 
1064  std::vector<xdr_id_type> xfer_bcs, recv_bcs;
1065  std::vector<std::size_t> bc_sizes(this->n_processors());
1066 
1067  // Boundary conditions are only specified for level-0 elements
1068  MeshBase::const_element_iterator
1069  it = mesh.local_level_elements_begin(0),
1070  end = mesh.local_level_elements_end(0);
1071 
1072  // Container to catch boundary IDs handed back by BoundaryInfo
1073  std::vector<boundary_id_type> bc_ids;
1074 
1075  dof_id_type n_local_level_0_elem=0;
1076  for (; it!=end; ++it, n_local_level_0_elem++)
1077  {
1078  const Elem * elem = *it;
1079 
1080  if (bc_type == "side")
1081  {
1082  for (auto s : elem->side_index_range())
1083  {
1084  boundary_info.boundary_ids (elem, s, bc_ids);
1085  for (std::vector<boundary_id_type>::const_iterator id_it=bc_ids.begin(); id_it!=bc_ids.end(); ++id_it)
1086  {
1087  const boundary_id_type bc_id = *id_it;
1088  if (bc_id != BoundaryInfo::invalid_id)
1089  {
1090  xfer_bcs.push_back (n_local_level_0_elem);
1091  xfer_bcs.push_back (s) ;
1092  xfer_bcs.push_back (bc_id);
1093  }
1094  }
1095  }
1096  }
1097  else if (bc_type == "edge")
1098  {
1099  for (auto e : elem->edge_index_range())
1100  {
1101  boundary_info.edge_boundary_ids (elem, e, bc_ids);
1102  for (std::vector<boundary_id_type>::const_iterator id_it=bc_ids.begin(); id_it!=bc_ids.end(); ++id_it)
1103  {
1104  const boundary_id_type bc_id = *id_it;
1105  if (bc_id != BoundaryInfo::invalid_id)
1106  {
1107  xfer_bcs.push_back (n_local_level_0_elem);
1108  xfer_bcs.push_back (e) ;
1109  xfer_bcs.push_back (bc_id);
1110  }
1111  }
1112  }
1113  }
1114  else if (bc_type == "shellface")
1115  {
1116  for (unsigned short sf=0; sf<2; sf++)
1117  {
1118  boundary_info.shellface_boundary_ids (elem, sf, bc_ids);
1119  for (std::vector<boundary_id_type>::const_iterator id_it=bc_ids.begin(); id_it!=bc_ids.end(); ++id_it)
1120  {
1121  const boundary_id_type bc_id = *id_it;
1122  if (bc_id != BoundaryInfo::invalid_id)
1123  {
1124  xfer_bcs.push_back (n_local_level_0_elem);
1125  xfer_bcs.push_back (sf) ;
1126  xfer_bcs.push_back (bc_id);
1127  }
1128  }
1129  }
1130  }
1131  else
1132  {
1133  libmesh_error_msg("bc_type not recognized: " + bc_type);
1134  }
1135  }
1136 
1137  xfer_bcs.push_back(n_local_level_0_elem);
1138  std::size_t my_size = xfer_bcs.size();
1139  this->comm().gather (0, my_size, bc_sizes);
1140 
1141  // All processors send their xfer buffers to processor 0
1142  // Processor 0 will receive all buffers and write out the bcs
1143  if (this->processor_id() == 0)
1144  {
1145  dof_id_type elem_offset = 0;
1146  for (unsigned int pid=0; pid<this->n_processors(); pid++)
1147  {
1148  recv_bcs.resize(bc_sizes[pid]);
1149  if (pid == 0)
1150  recv_bcs = xfer_bcs;
1151  else
1152  this->comm().receive (pid, recv_bcs);
1153 
1154  const dof_id_type my_n_local_level_0_elem
1155  = cast_int<dof_id_type>(recv_bcs.back());
1156  recv_bcs.pop_back();
1157 
1158  for (std::size_t idx=0; idx<recv_bcs.size(); idx += 3, n_bcs_out++)
1159  recv_bcs[idx+0] += elem_offset;
1160 
1161  io.data_stream (recv_bcs.empty() ? libmesh_nullptr : &recv_bcs[0],
1162  cast_int<unsigned int>(recv_bcs.size()), 3);
1163  elem_offset += my_n_local_level_0_elem;
1164  }
1165  libmesh_assert_equal_to (n_bcs, n_bcs_out);
1166  }
1167  else
1168  this->comm().send (0, xfer_bcs);
1169 }
processor_id_type n_processors() const
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
const MT & mesh() const
Definition: mesh_output.h:216
boundary_id_type bc_id
Definition: xdr_io.C:50
libmesh_assert(j)
int8_t boundary_id_type
Definition: id_types.h:51
static const boundary_id_type invalid_id
Number used for internal use.
void write_serialized_bc_names(Xdr &io, const BoundaryInfo &info, bool is_sideset) const
Write boundary names information (sideset and nodeset) - NEW in 0.9.2 format.
Definition: xdr_io.C:1271
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
Blocking-send to one processor with data-defined type.
uint64_t new_header_id_type
Definition: xdr_io.h:63
void gather(const unsigned int root_id, const T &send, std::vector< T > &recv) const
Take a vector of length comm.size(), and on processor root_id fill in recv[processor_id] = the value ...
const Parallel::Communicator & comm() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
Blocking-receive from one processor with data-defined type.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
void libMesh::XdrIO::write_serialized_connectivity ( Xdr io,
const dof_id_type  n_elem 
) const
private

Write the connectivity for a parallel, distributed mesh.

Definition at line 356 of file xdr_io.C.

References _write_unique_id, libMesh::Elem::child_ref_range(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), end, libMesh::Parallel::Communicator::gather(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::MeshBase::local_elements_end(), libMesh::MeshBase::local_level_elements_begin(), libMesh::MeshBase::local_level_elements_end(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshTools::n_active_levels(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::ParallelObject::n_processors(), pack_element(), partition_map_file_name(), polynomial_level_file_name(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), libMesh::Parallel::Communicator::send_receive(), subdomain_map_file_name(), libMesh::Parallel::Communicator::sum(), and libMesh::Xdr::writing().

Referenced by polynomial_level_file_name(), and write().

357 {
358  libmesh_assert (io.writing());
359 
360  const bool
361  write_p_level = ("." == this->polynomial_level_file_name()),
362  write_partitioning = ("." == this->partition_map_file_name()),
363  write_subdomain_id = ("." == this->subdomain_map_file_name());
364 
365  // convenient reference to our mesh
366  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
367  libmesh_assert_equal_to (n_elem, mesh.n_elem());
368 
369  // We will only write active elements and their parents.
370  const unsigned int n_active_levels = MeshTools::n_active_levels (mesh);
371  std::vector<xdr_id_type> n_global_elem_at_level(n_active_levels);
372 
373  MeshBase::const_element_iterator it = mesh.local_elements_end(), end=it;
374 
375  // Find the number of local and global elements at each level
376 #ifndef NDEBUG
377  xdr_id_type tot_n_elem = 0;
378 #endif
379  for (unsigned int level=0; level<n_active_levels; level++)
380  {
381  it = mesh.local_level_elements_begin(level);
382  end = mesh.local_level_elements_end(level);
383 
384  n_global_elem_at_level[level] = MeshTools::n_elem(it, end);
385 
386  this->comm().sum(n_global_elem_at_level[level]);
387 #ifndef NDEBUG
388  tot_n_elem += n_global_elem_at_level[level];
389 #endif
390  libmesh_assert_less_equal (n_global_elem_at_level[level], n_elem);
391  libmesh_assert_less_equal (tot_n_elem, n_elem);
392  }
393 
394  std::vector<xdr_id_type>
395  xfer_conn, recv_conn;
396  std::vector<dof_id_type>
397  n_elem_on_proc(this->n_processors()), processor_offsets(this->n_processors());
398  std::vector<xdr_id_type> output_buffer;
399  std::vector<std::size_t>
400  xfer_buf_sizes(this->n_processors());
401 
402 #ifdef LIBMESH_ENABLE_AMR
403  typedef std::map<dof_id_type, std::pair<processor_id_type, dof_id_type>> id_map_type;
404  id_map_type parent_id_map, child_id_map;
405 #endif
406 
407  dof_id_type my_next_elem=0, next_global_elem=0;
408 
409  //-------------------------------------------
410  // First write the level-0 elements directly.
411  it = mesh.local_level_elements_begin(0);
412  end = mesh.local_level_elements_end(0);
413  for (; it != end; ++it, ++my_next_elem)
414  {
415  pack_element (xfer_conn, *it);
416 #ifdef LIBMESH_ENABLE_AMR
417  parent_id_map[(*it)->id()] = std::make_pair(this->processor_id(),
418  my_next_elem);
419 #endif
420  }
421  xfer_conn.push_back(my_next_elem); // toss in the number of elements transferred.
422 
423  std::size_t my_size = xfer_conn.size();
424  this->comm().gather (0, my_next_elem, n_elem_on_proc);
425  this->comm().gather (0, my_size, xfer_buf_sizes);
426 
427  processor_offsets[0] = 0;
428  for (unsigned int pid=1; pid<this->n_processors(); pid++)
429  processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
430 
431  // All processors send their xfer buffers to processor 0.
432  // Processor 0 will receive the data and write out the elements.
433  if (this->processor_id() == 0)
434  {
435  // Write the number of elements at this level.
436  {
437  std::string comment = "# n_elem at level 0", legend = ", [ type ";
438  if (_write_unique_id)
439  legend += "uid ";
440  if (write_partitioning)
441  legend += "pid ";
442  if (write_subdomain_id)
443  legend += "sid ";
444  if (write_p_level)
445  legend += "p_level ";
446  legend += "(n0 ... nN-1) ]";
447  comment += legend;
448  io.data (n_global_elem_at_level[0], comment.c_str());
449  }
450 
451  for (unsigned int pid=0; pid<this->n_processors(); pid++)
452  {
453  recv_conn.resize(xfer_buf_sizes[pid]);
454  if (pid == 0)
455  recv_conn = xfer_conn;
456  else
457  this->comm().receive (pid, recv_conn);
458 
459  // at a minimum, the buffer should contain the number of elements,
460  // which could be 0.
461  libmesh_assert (!recv_conn.empty());
462 
463  {
464  const xdr_id_type n_elem_received = recv_conn.back();
465  std::vector<xdr_id_type>::const_iterator recv_conn_iter = recv_conn.begin();
466 
467  for (xdr_id_type elem=0; elem<n_elem_received; elem++, next_global_elem++)
468  {
469  output_buffer.clear();
470 
471  // n. nodes
472  const xdr_id_type n_nodes = *recv_conn_iter;
473  ++recv_conn_iter;
474 
475  // type
476  output_buffer.push_back(*recv_conn_iter);
477  ++recv_conn_iter;
478 
479  // unique_id
480  if (_write_unique_id)
481  output_buffer.push_back(*recv_conn_iter);
482  ++recv_conn_iter;
483 
484  // processor id
485  if (write_partitioning)
486  output_buffer.push_back(*recv_conn_iter);
487  ++recv_conn_iter;
488 
489  // subdomain id
490  if (write_subdomain_id)
491  output_buffer.push_back(*recv_conn_iter);
492  ++recv_conn_iter;
493 
494 #ifdef LIBMESH_ENABLE_AMR
495  // p level
496  if (write_p_level)
497  output_buffer.push_back(*recv_conn_iter);
498  ++recv_conn_iter;
499 #endif
500  for (dof_id_type node=0; node<n_nodes; node++, ++recv_conn_iter)
501  output_buffer.push_back(*recv_conn_iter);
502 
503  io.data_stream
504  (&output_buffer[0],
505  cast_int<unsigned int>(output_buffer.size()),
506  cast_int<unsigned int>(output_buffer.size()));
507  }
508  }
509  }
510  }
511  else
512  this->comm().send (0, xfer_conn);
513 
514 #ifdef LIBMESH_ENABLE_AMR
515  //--------------------------------------------------------------------
516  // Next write the remaining elements indirectly through their parents.
517  // This will insure that the children are written in the proper order
518  // so they can be reconstructed properly.
519  for (unsigned int level=1; level<n_active_levels; level++)
520  {
521  xfer_conn.clear();
522 
523  it = mesh.local_level_elements_begin(level-1);
524  end = mesh.local_level_elements_end (level-1);
525 
526  dof_id_type my_n_elem_written_at_level = 0;
527  for (; it != end; ++it)
528  if (!(*it)->active()) // we only want the parents elements at this level, and
529  { // there is no direct iterator for this obscure use
530  const Elem * parent = *it;
531  id_map_type::iterator pos = parent_id_map.find(parent->id());
532  libmesh_assert (pos != parent_id_map.end());
533  const processor_id_type parent_pid = pos->second.first;
534  const dof_id_type parent_id = pos->second.second;
535  parent_id_map.erase(pos);
536 
537  for (auto & child : parent->child_ref_range())
538  {
539  pack_element (xfer_conn, &child, parent_id, parent_pid);
540 
541  // this aproach introduces the possibility that we write
542  // non-local elements. These elements may well be parents
543  // at the next step
544  child_id_map[child.id()] = std::make_pair (child.processor_id(),
545  my_n_elem_written_at_level++);
546  my_next_elem++;
547  }
548  }
549  xfer_conn.push_back(my_n_elem_written_at_level);
550  my_size = xfer_conn.size();
551  this->comm().gather (0, my_size, xfer_buf_sizes);
552 
553  // Processor 0 will receive the data and write the elements.
554  if (this->processor_id() == 0)
555  {
556  // Write the number of elements at this level.
557  {
558  char buf[80];
559  std::sprintf(buf, "# n_elem at level %u", level);
560  std::string comment(buf), legend = ", [ type ";
561 
562  if (_write_unique_id)
563  legend += "uid ";
564  legend += "parent ";
565  if (write_partitioning)
566  legend += "pid ";
567  if (write_subdomain_id)
568  legend += "sid ";
569  if (write_p_level)
570  legend += "p_level ";
571  legend += "(n0 ... nN-1) ]";
572  comment += legend;
573  io.data (n_global_elem_at_level[level], comment.c_str());
574  }
575 
576  for (unsigned int pid=0; pid<this->n_processors(); pid++)
577  {
578  recv_conn.resize(xfer_buf_sizes[pid]);
579  if (pid == 0)
580  recv_conn = xfer_conn;
581  else
582  this->comm().receive (pid, recv_conn);
583 
584  // at a minimum, the buffer should contain the number of elements,
585  // which could be 0.
586  libmesh_assert (!recv_conn.empty());
587 
588  {
589  const xdr_id_type n_elem_received = recv_conn.back();
590  std::vector<xdr_id_type>::const_iterator recv_conn_iter = recv_conn.begin();
591 
592  for (xdr_id_type elem=0; elem<n_elem_received; elem++, next_global_elem++)
593  {
594  output_buffer.clear();
595 
596  // n. nodes
597  const xdr_id_type n_nodes = *recv_conn_iter;
598  ++recv_conn_iter;
599 
600  // type
601  output_buffer.push_back(*recv_conn_iter);
602  ++recv_conn_iter;
603 
604  // unique_id
605  if (_write_unique_id)
606  output_buffer.push_back(*recv_conn_iter);
607  ++recv_conn_iter;
608 
609  // parent local id
610  const xdr_id_type parent_local_id = *recv_conn_iter;
611  ++recv_conn_iter;
612 
613  // parent processor id
614  const xdr_id_type parent_pid = *recv_conn_iter;
615  ++recv_conn_iter;
616 
617  output_buffer.push_back (parent_local_id+processor_offsets[parent_pid]);
618 
619  // processor id
620  if (write_partitioning)
621  output_buffer.push_back(*recv_conn_iter);
622  ++recv_conn_iter;
623 
624  // subdomain id
625  if (write_subdomain_id)
626  output_buffer.push_back(*recv_conn_iter);
627  ++recv_conn_iter;
628 
629  // p level
630  if (write_p_level)
631  output_buffer.push_back(*recv_conn_iter);
632  ++recv_conn_iter;
633 
634  for (xdr_id_type node=0; node<n_nodes; node++, ++recv_conn_iter)
635  output_buffer.push_back(*recv_conn_iter);
636 
637  io.data_stream
638  (&output_buffer[0],
639  cast_int<unsigned int>(output_buffer.size()),
640  cast_int<unsigned int>(output_buffer.size()));
641  }
642  }
643  }
644  }
645  else
646  this->comm().send (0, xfer_conn);
647 
648  // update the processor_offsets
649  processor_offsets[0] = processor_offsets.back() + n_elem_on_proc.back();
650  this->comm().gather (0, my_n_elem_written_at_level, n_elem_on_proc);
651  for (unsigned int pid=1; pid<this->n_processors(); pid++)
652  processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
653 
654  // Now, at the next level we will again iterate over local parents. However,
655  // those parents may have been written by other processors (at this step),
656  // so we need to gather them into our *_id_maps.
657  {
658  std::vector<std::vector<dof_id_type>> requested_ids(this->n_processors());
659  std::vector<dof_id_type> request_to_fill;
660 
661  it = mesh.local_level_elements_begin(level);
662  end = mesh.local_level_elements_end(level);
663 
664  for (; it!=end; ++it)
665  if (!child_id_map.count((*it)->id()))
666  {
667  libmesh_assert_not_equal_to ((*it)->parent()->processor_id(), this->processor_id());
668  requested_ids[(*it)->parent()->processor_id()].push_back((*it)->id());
669  }
670 
671  // Next set the child_ids
672  for (unsigned int p=1; p != this->n_processors(); ++p)
673  {
674  // Trade my requests with processor procup and procdown
675  unsigned int procup = (this->processor_id() + p) %
676  this->n_processors();
677  unsigned int procdown = (this->n_processors() +
678  this->processor_id() - p) %
679  this->n_processors();
680 
681  this->comm().send_receive(procup, requested_ids[procup],
682  procdown, request_to_fill);
683 
684  // Fill those requests by overwriting the requested ids
685  for (std::size_t i=0; i<request_to_fill.size(); i++)
686  {
687  libmesh_assert (child_id_map.count(request_to_fill[i]));
688  libmesh_assert_equal_to (child_id_map[request_to_fill[i]].first, procdown);
689 
690  request_to_fill[i] = child_id_map[request_to_fill[i]].second;
691  }
692 
693  // Trade back the results
694  std::vector<dof_id_type> filled_request;
695  this->comm().send_receive(procdown, request_to_fill,
696  procup, filled_request);
697 
698  libmesh_assert_equal_to (filled_request.size(), requested_ids[procup].size());
699 
700  for (std::size_t i=0; i<filled_request.size(); i++)
701  child_id_map[requested_ids[procup][i]] =
702  std::make_pair (procup,
703  filled_request[i]);
704  }
705  // overwrite the parent_id_map with the child_id_map, but
706  // use std::map::swap() for efficiency.
707  parent_id_map.swap(child_id_map);
708  child_id_map.clear();
709  }
710  }
711 #endif // LIBMESH_ENABLE_AMR
712  if (this->processor_id() == 0)
713  libmesh_assert_equal_to (next_global_elem, n_elem);
714 
715 }
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:656
processor_id_type n_processors() const
uint8_t processor_id_type
Definition: id_types.h:99
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
largest_id_type xdr_id_type
Definition: xdr_io.h:57
void send_receive(const unsigned int dest_processor_id, const T1 &send, const unsigned int source_processor_id, T2 &recv, const MessageTag &send_tag=no_tag, const MessageTag &recv_tag=any_tag) const
Send data send to one processor while simultaneously receiving other data recv from a (potentially di...
const dof_id_type n_nodes
Definition: tecplot_io.C:67
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
Pack an element into a transfer buffer for parallel communication.
Definition: xdr_io.C:2184
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
Blocking-send to one processor with data-defined type.
bool _write_unique_id
Definition: xdr_io.h:339
void gather(const unsigned int root_id, const T &send, std::vector< T > &recv) const
Take a vector of length comm.size(), and on processor root_id fill in recv[processor_id] = the value ...
const Parallel::Communicator & comm() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
Blocking-receive from one processor with data-defined type.
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
void sum(T &r) const
Take a local variable and replace it with the sum of it&#39;s values on all processors.
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int n_active_levels(const MeshBase &mesh)
Definition: mesh_tools.C:567
void libMesh::XdrIO::write_serialized_edge_bcs ( Xdr io,
const new_header_id_type  n_edge_bcs 
) const
private

Write the edge boundary conditions for a parallel, distributed mesh.

NEW in 1.1.0 format.

Definition at line 1180 of file xdr_io.C.

References write_serialized_bcs_helper().

Referenced by polynomial_level_file_name(), and write().

1181 {
1182  write_serialized_bcs_helper(io, n_edge_bcs, "edge");
1183 }
void write_serialized_bcs_helper(Xdr &io, const new_header_id_type n_side_bcs, const std::string bc_type) const
Helper function used in write_serialized_side_bcs, write_serialized_edge_bcs, and write_serialized_sh...
Definition: xdr_io.C:1040
void libMesh::XdrIO::write_serialized_nodes ( Xdr io,
const dof_id_type  n_nodes 
) const
private

Write the nodal locations for a parallel, distributed mesh.

Definition at line 719 of file xdr_io.C.

References libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::Parallel::Communicator::gather(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::MeshTools::Generation::Private::idx(), io_blksize, libmesh_nullptr, libMesh::MeshBase::local_node_ptr_range(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), std::min(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), and libMesh::Parallel::wait().

Referenced by polynomial_level_file_name(), and write().

720 {
721  // convenient reference to our mesh
722  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
723  libmesh_assert_equal_to (n_nodes, mesh.n_nodes());
724 
725  std::vector<dof_id_type> xfer_ids;
726  std::vector<Real> xfer_coords;
727  std::vector<Real> & coords=xfer_coords;
728 
729  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
730  std::vector<std::vector<Real>> recv_coords(this->n_processors());
731 
732 #ifdef LIBMESH_ENABLE_UNIQUE_ID
733  std::vector<xdr_id_type> xfer_unique_ids;
734  std::vector<xdr_id_type> & unique_ids=xfer_unique_ids;
735  std::vector<std::vector<xdr_id_type>> recv_unique_ids (this->n_processors());
736 #endif // LIBMESH_ENABLE_UNIQUE_ID
737 
738  std::size_t n_written=0;
739 
740  for (std::size_t blk=0, last_node=0; last_node<n_nodes; blk++)
741  {
742  const std::size_t first_node = blk*io_blksize;
743  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
744 
745  // Build up the xfer buffers on each processor
746  xfer_ids.clear();
747  xfer_coords.clear();
748 #ifdef LIBMESH_ENABLE_UNIQUE_ID
749  xfer_unique_ids.clear();
750 #endif // LIBMESH_ENABLE_UNIQUE_ID
751 
752  for (const auto & node : mesh.local_node_ptr_range())
753  if ((node->id() >= first_node) && // node in [first_node, last_node)
754  (node->id() < last_node))
755  {
756  xfer_ids.push_back(node->id());
757 #ifdef LIBMESH_ENABLE_UNIQUE_ID
758  xfer_unique_ids.push_back(node->unique_id());
759 #endif // LIBMESH_ENABLE_UNIQUE_ID
760  xfer_coords.push_back((*node)(0));
761 #if LIBMESH_DIM > 1
762  xfer_coords.push_back((*node)(1));
763 #endif
764 #if LIBMESH_DIM > 2
765  xfer_coords.push_back((*node)(2));
766 #endif
767  }
768 
769  //-------------------------------------
770  // Send the xfer buffers to processor 0
771  std::vector<std::size_t> ids_size;
772 
773  const std::size_t my_ids_size = xfer_ids.size();
774 
775  // explicitly gather ids_size
776  this->comm().gather (0, my_ids_size, ids_size);
777 
778  // We will have lots of simultaneous receives if we are
779  // processor 0, so let's use nonblocking receives.
780  std::vector<Parallel::Request>
781 #ifdef LIBMESH_ENABLE_UNIQUE_ID
782  unique_id_request_handles(this->n_processors()-1),
783 #endif // LIBMESH_ENABLE_UNIQUE_ID
784  id_request_handles(this->n_processors()-1),
785  coord_request_handles(this->n_processors()-1);
786 
787  Parallel::MessageTag
788 #ifdef LIBMESH_ENABLE_UNIQUE_ID
789  unique_id_tag = mesh.comm().get_unique_tag(1233),
790 #endif // LIBMESH_ENABLE_UNIQUE_ID
791  id_tag = mesh.comm().get_unique_tag(1234),
792  coord_tag = mesh.comm().get_unique_tag(1235);
793 
794  // Post the receives -- do this on processor 0 only.
795  if (this->processor_id() == 0)
796  {
797  for (unsigned int pid=0; pid<this->n_processors(); pid++)
798  {
799  recv_ids[pid].resize(ids_size[pid]);
800  recv_coords[pid].resize(ids_size[pid]*LIBMESH_DIM);
801 #ifdef LIBMESH_ENABLE_UNIQUE_ID
802  recv_unique_ids[pid].resize(ids_size[pid]);
803 #endif // LIBMESH_ENABLE_UNIQUE_ID
804 
805  if (pid == 0)
806  {
807  recv_ids[0] = xfer_ids;
808  recv_coords[0] = xfer_coords;
809 #ifdef LIBMESH_ENABLE_UNIQUE_ID
810  recv_unique_ids[0] = xfer_unique_ids;
811 #endif // LIBMESH_ENABLE_UNIQUE_ID
812  }
813  else
814  {
815  this->comm().receive (pid, recv_ids[pid],
816  id_request_handles[pid-1],
817  id_tag);
818  this->comm().receive (pid, recv_coords[pid],
819  coord_request_handles[pid-1],
820  coord_tag);
821 #ifdef LIBMESH_ENABLE_UNIQUE_ID
822  this->comm().receive (pid, recv_unique_ids[pid],
823  unique_id_request_handles[pid-1],
824  unique_id_tag);
825 #endif // LIBMESH_ENABLE_UNIQUE_ID
826  }
827  }
828  }
829  else
830  {
831  // Send -- do this on all other processors.
832  this->comm().send(0, xfer_ids, id_tag);
833  this->comm().send(0, xfer_coords, coord_tag);
834 #ifdef LIBMESH_ENABLE_UNIQUE_ID
835  this->comm().send(0, xfer_unique_ids, unique_id_tag);
836 #endif // LIBMESH_ENABLE_UNIQUE_ID
837  }
838 
839  // -------------------------------------------------------
840  // Receive the messages and write the output on processor 0.
841  if (this->processor_id() == 0)
842  {
843  // Wait for all the receives to complete. We have no
844  // need for the statuses since we already know the
845  // buffer sizes.
846  Parallel::wait (id_request_handles);
847  Parallel::wait (coord_request_handles);
848 #ifdef LIBMESH_ENABLE_UNIQUE_ID
849  Parallel::wait (unique_id_request_handles);
850 #endif // LIBMESH_ENABLE_UNIQUE_ID
851 
852  // Write the coordinates in this block.
853  std::size_t tot_id_size=0;
854 
855  for (unsigned int pid=0; pid<this->n_processors(); pid++)
856  {
857  tot_id_size += recv_ids[pid].size();
858  libmesh_assert_equal_to(recv_coords[pid].size(),
859  recv_ids[pid].size()*LIBMESH_DIM);
860 #ifdef LIBMESH_ENABLE_UNIQUE_ID
861  libmesh_assert_equal_to
862  (recv_ids[pid].size(), recv_unique_ids[pid].size());
863 #endif // LIBMESH_ENABLE_UNIQUE_ID
864  }
865 
866  libmesh_assert_less_equal
867  (tot_id_size, std::min(io_blksize, std::size_t(n_nodes)));
868 
869  coords.resize (3*tot_id_size);
870 #ifdef LIBMESH_ENABLE_UNIQUE_ID
871  unique_ids.resize(tot_id_size);
872 #endif
873 
874  for (unsigned int pid=0; pid<this->n_processors(); pid++)
875  for (std::size_t idx=0; idx<recv_ids[pid].size(); idx++)
876  {
877  const std::size_t local_idx = recv_ids[pid][idx] - first_node;
878 
879 #ifdef LIBMESH_ENABLE_UNIQUE_ID
880  libmesh_assert_less (local_idx, unique_ids.size());
881 
882  unique_ids[local_idx] = recv_unique_ids[pid][idx];
883 #endif
884 
885  libmesh_assert_less ((3*local_idx+2), coords.size());
886  libmesh_assert_less ((LIBMESH_DIM*idx+LIBMESH_DIM-1), recv_coords[pid].size());
887 
888  coords[3*local_idx+0] = recv_coords[pid][LIBMESH_DIM*idx+0];
889 #if LIBMESH_DIM > 1
890  coords[3*local_idx+1] = recv_coords[pid][LIBMESH_DIM*idx+1];
891 #else
892  coords[3*local_idx+1] = 0.;
893 #endif
894 #if LIBMESH_DIM > 2
895  coords[3*local_idx+2] = recv_coords[pid][LIBMESH_DIM*idx+2];
896 #else
897  coords[3*local_idx+2] = 0.;
898 #endif
899 
900  n_written++;
901  }
902 
903  io.data_stream (coords.empty() ? libmesh_nullptr : &coords[0],
904  cast_int<unsigned int>(coords.size()), 3);
905  }
906  }
907 
908  if (this->processor_id() == 0)
909  libmesh_assert_equal_to (n_written, n_nodes);
910 
911 #ifdef LIBMESH_ENABLE_UNIQUE_ID
912  // XDR unsigned char doesn't work as anticipated
913  unsigned short write_unique_ids = 1;
914 #else
915  unsigned short write_unique_ids = 0;
916 #endif
917  if (this->processor_id() == 0)
918  io.data (write_unique_ids, "# presence of unique ids");
919 
920 #ifdef LIBMESH_ENABLE_UNIQUE_ID
921  n_written = 0;
922 
923  for (std::size_t blk=0, last_node=0; last_node<n_nodes; blk++)
924  {
925  const std::size_t first_node = blk*io_blksize;
926  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
927 
928  // Build up the xfer buffers on each processor
929  xfer_ids.clear();
930  xfer_unique_ids.clear();
931 
932  for (const auto & node : mesh.local_node_ptr_range())
933  if ((node->id() >= first_node) && // node in [first_node, last_node)
934  (node->id() < last_node))
935  {
936  xfer_ids.push_back(node->id());
937  xfer_unique_ids.push_back(node->unique_id());
938  }
939 
940  //-------------------------------------
941  // Send the xfer buffers to processor 0
942  std::vector<std::size_t> ids_size;
943 
944  const std::size_t my_ids_size = xfer_ids.size();
945 
946  // explicitly gather ids_size
947  this->comm().gather (0, my_ids_size, ids_size);
948 
949  // We will have lots of simultaneous receives if we are
950  // processor 0, so let's use nonblocking receives.
951  std::vector<Parallel::Request>
952  unique_id_request_handles(this->n_processors()-1),
953  id_request_handles(this->n_processors()-1);
954 
955  Parallel::MessageTag
956  unique_id_tag = mesh.comm().get_unique_tag(1236),
957  id_tag = mesh.comm().get_unique_tag(1237);
958 
959  // Post the receives -- do this on processor 0 only.
960  if (this->processor_id() == 0)
961  {
962  for (unsigned int pid=0; pid<this->n_processors(); pid++)
963  {
964  recv_ids[pid].resize(ids_size[pid]);
965  recv_unique_ids[pid].resize(ids_size[pid]);
966 
967  if (pid == 0)
968  {
969  recv_ids[0] = xfer_ids;
970  recv_unique_ids[0] = xfer_unique_ids;
971  }
972  else
973  {
974  this->comm().receive (pid, recv_ids[pid],
975  id_request_handles[pid-1],
976  id_tag);
977  this->comm().receive (pid, recv_unique_ids[pid],
978  unique_id_request_handles[pid-1],
979  unique_id_tag);
980  }
981  }
982  }
983  else
984  {
985  // Send -- do this on all other processors.
986  this->comm().send(0, xfer_ids, id_tag);
987  this->comm().send(0, xfer_unique_ids, unique_id_tag);
988  }
989 
990  // -------------------------------------------------------
991  // Receive the messages and write the output on processor 0.
992  if (this->processor_id() == 0)
993  {
994  // Wait for all the receives to complete. We have no
995  // need for the statuses since we already know the
996  // buffer sizes.
997  Parallel::wait (id_request_handles);
998  Parallel::wait (unique_id_request_handles);
999 
1000  // Write the unique ids in this block.
1001  std::size_t tot_id_size=0;
1002 
1003  for (unsigned int pid=0; pid<this->n_processors(); pid++)
1004  {
1005  tot_id_size += recv_ids[pid].size();
1006  libmesh_assert_equal_to
1007  (recv_ids[pid].size(), recv_unique_ids[pid].size());
1008  }
1009 
1010  libmesh_assert_less_equal
1011  (tot_id_size, std::min(io_blksize, std::size_t(n_nodes)));
1012 
1013  unique_ids.resize(tot_id_size);
1014 
1015  for (unsigned int pid=0; pid<this->n_processors(); pid++)
1016  for (std::size_t idx=0; idx<recv_ids[pid].size(); idx++)
1017  {
1018  const std::size_t local_idx = recv_ids[pid][idx] - first_node;
1019 
1020  libmesh_assert_less (local_idx, unique_ids.size());
1021 
1022  unique_ids[local_idx] = recv_unique_ids[pid][idx];
1023 
1024  n_written++;
1025  }
1026 
1027  io.data_stream (unique_ids.empty() ? libmesh_nullptr : &unique_ids[0],
1028  cast_int<unsigned int>(unique_ids.size()), 1);
1029  }
1030  }
1031 
1032  if (this->processor_id() == 0)
1033  libmesh_assert_equal_to (n_written, n_nodes);
1034 
1035 #endif // LIBMESH_ENABLE_UNIQUE_ID
1036 }
Status wait(Request &r)
Wait for a non-blocking send or receive to finish.
Definition: parallel.h:565
processor_id_type n_processors() const
const class libmesh_nullptr_t libmesh_nullptr
const MT & mesh() const
Definition: mesh_output.h:216
const dof_id_type n_nodes
Definition: tecplot_io.C:67
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
Blocking-send to one processor with data-defined type.
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:350
void gather(const unsigned int root_id, const T &send, std::vector< T > &recv) const
Take a vector of length comm.size(), and on processor root_id fill in recv[processor_id] = the value ...
const Parallel::Communicator & comm() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
Blocking-receive from one processor with data-defined type.
long double min(long double a, double b)
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
processor_id_type processor_id() const
void libMesh::XdrIO::write_serialized_nodesets ( Xdr io,
const new_header_id_type  n_nodesets 
) const
private

Write the boundary conditions for a parallel, distributed mesh.

Definition at line 1194 of file xdr_io.C.

References bc_id, libMesh::BoundaryInfo::boundary_ids(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::Parallel::Communicator::gather(), libMesh::MeshTools::Generation::Private::idx(), libMesh::BoundaryInfo::invalid_id, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), write_serialized_bc_names(), and libMesh::Xdr::writing().

Referenced by polynomial_level_file_name(), and write().

1195 {
1196  libmesh_assert (io.writing());
1197 
1198  // convenient reference to our mesh
1199  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
1200 
1201  // and our boundary info object
1202  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1203 
1204  // Version 0.9.2+ introduces entity names
1205  write_serialized_bc_names(io, boundary_info, false); // nodeset names
1206 
1207  new_header_id_type n_nodesets_out = n_nodesets;
1208  if (this->processor_id() == 0)
1209  io.data (n_nodesets_out, "# number of nodesets");
1210  n_nodesets_out = 0;
1211 
1212  if (!n_nodesets) return;
1213 
1214  std::vector<xdr_id_type> xfer_bcs, recv_bcs;
1215  std::vector<std::size_t> bc_sizes(this->n_processors());
1216 
1217  // Container to catch boundary IDs handed back by BoundaryInfo
1218  std::vector<boundary_id_type> nodeset_ids;
1219 
1220  dof_id_type n_node=0;
1221  for (const auto & node : mesh.local_node_ptr_range())
1222  {
1223  boundary_info.boundary_ids (node, nodeset_ids);
1224  for (std::vector<boundary_id_type>::const_iterator id_it=nodeset_ids.begin(); id_it!=nodeset_ids.end(); ++id_it)
1225  {
1226  const boundary_id_type bc_id = *id_it;
1227  if (bc_id != BoundaryInfo::invalid_id)
1228  {
1229  xfer_bcs.push_back (node->id());
1230  xfer_bcs.push_back (bc_id);
1231  }
1232  }
1233  }
1234 
1235  xfer_bcs.push_back(n_node);
1236  std::size_t my_size = xfer_bcs.size();
1237  this->comm().gather (0, my_size, bc_sizes);
1238 
1239  // All processors send their xfer buffers to processor 0
1240  // Processor 0 will receive all buffers and write out the bcs
1241  if (this->processor_id() == 0)
1242  {
1243  dof_id_type node_offset = 0;
1244  for (unsigned int pid=0; pid<this->n_processors(); pid++)
1245  {
1246  recv_bcs.resize(bc_sizes[pid]);
1247  if (pid == 0)
1248  recv_bcs = xfer_bcs;
1249  else
1250  this->comm().receive (pid, recv_bcs);
1251 
1252  const dof_id_type my_n_node =
1253  cast_int<dof_id_type>(recv_bcs.back());
1254  recv_bcs.pop_back();
1255 
1256  for (std::size_t idx=0; idx<recv_bcs.size(); idx += 2, n_nodesets_out++)
1257  recv_bcs[idx+0] += node_offset;
1258 
1259  io.data_stream (recv_bcs.empty() ? libmesh_nullptr : &recv_bcs[0],
1260  cast_int<unsigned int>(recv_bcs.size()), 2);
1261  node_offset += my_n_node;
1262  }
1263  libmesh_assert_equal_to (n_nodesets, n_nodesets_out);
1264  }
1265  else
1266  this->comm().send (0, xfer_bcs);
1267 }
processor_id_type n_processors() const
const class libmesh_nullptr_t libmesh_nullptr
const MT & mesh() const
Definition: mesh_output.h:216
boundary_id_type bc_id
Definition: xdr_io.C:50
libmesh_assert(j)
int8_t boundary_id_type
Definition: id_types.h:51
static const boundary_id_type invalid_id
Number used for internal use.
void write_serialized_bc_names(Xdr &io, const BoundaryInfo &info, bool is_sideset) const
Write boundary names information (sideset and nodeset) - NEW in 0.9.2 format.
Definition: xdr_io.C:1271
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
Blocking-send to one processor with data-defined type.
uint64_t new_header_id_type
Definition: xdr_io.h:63
void gather(const unsigned int root_id, const T &send, std::vector< T > &recv) const
Take a vector of length comm.size(), and on processor root_id fill in recv[processor_id] = the value ...
const Parallel::Communicator & comm() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
Blocking-receive from one processor with data-defined type.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
void libMesh::XdrIO::write_serialized_shellface_bcs ( Xdr io,
const new_header_id_type  n_shellface_bcs 
) const
private

Write the "shell face" boundary conditions for a parallel, distributed mesh.

NEW in 1.1.0 format.

Definition at line 1187 of file xdr_io.C.

References write_serialized_bcs_helper().

Referenced by polynomial_level_file_name(), and write().

1188 {
1189  write_serialized_bcs_helper(io, n_shellface_bcs, "shellface");
1190 }
void write_serialized_bcs_helper(Xdr &io, const new_header_id_type n_side_bcs, const std::string bc_type) const
Helper function used in write_serialized_side_bcs, write_serialized_edge_bcs, and write_serialized_sh...
Definition: xdr_io.C:1040
void libMesh::XdrIO::write_serialized_side_bcs ( Xdr io,
const new_header_id_type  n_side_bcs 
) const
private

Write the side boundary conditions for a parallel, distributed mesh.

Definition at line 1173 of file xdr_io.C.

References write_serialized_bcs_helper().

Referenced by polynomial_level_file_name(), and write().

1174 {
1175  write_serialized_bcs_helper(io, n_side_bcs, "side");
1176 }
void write_serialized_bcs_helper(Xdr &io, const new_header_id_type n_side_bcs, const std::string bc_type) const
Helper function used in write_serialized_side_bcs, write_serialized_edge_bcs, and write_serialized_sh...
Definition: xdr_io.C:1040
void libMesh::XdrIO::write_serialized_subdomain_names ( Xdr io) const
private

Write subdomain name information - NEW in 0.9.2 format.

Definition at line 315 of file xdr_io.C.

References libMesh::Xdr::data(), libMesh::MeshBase::get_subdomain_name_map(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), and libMesh::ParallelObject::processor_id().

Referenced by polynomial_level_file_name(), and write().

316 {
317  if (this->processor_id() == 0)
318  {
319  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
320 
321  const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
322 
323  std::vector<new_header_id_type> subdomain_ids;
324  subdomain_ids.reserve(subdomain_map.size());
325 
326  std::vector<std::string> subdomain_names;
327  subdomain_names.reserve(subdomain_map.size());
328 
329  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
330  // return writable references in mesh_base, it's possible for the user to leave some entity names
331  // blank. We can't write those to the XDA file.
332  new_header_id_type n_subdomain_names = 0;
333  std::map<subdomain_id_type, std::string>::const_iterator it_end = subdomain_map.end();
334  for (std::map<subdomain_id_type, std::string>::const_iterator it = subdomain_map.begin(); it != it_end; ++it)
335  {
336  if (!it->second.empty())
337  {
338  n_subdomain_names++;
339  subdomain_ids.push_back(it->first);
340  subdomain_names.push_back(it->second);
341  }
342  }
343 
344  io.data(n_subdomain_names, "# subdomain id to name map");
345  // Write out the ids and names in two vectors
346  if (n_subdomain_names)
347  {
348  io.data(subdomain_ids);
349  io.data(subdomain_names);
350  }
351  }
352 }
const MT & mesh() const
Definition: mesh_output.h:216
uint64_t new_header_id_type
Definition: xdr_io.h:63
processor_id_type processor_id() const

Member Data Documentation

std::string libMesh::XdrIO::_bc_file_name
private

Definition at line 342 of file xdr_io.h.

Referenced by boundary_condition_file_name().

bool libMesh::XdrIO::_binary
private

Definition at line 335 of file xdr_io.h.

Referenced by binary().

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited
unsigned int libMesh::XdrIO::_field_width
private

Definition at line 340 of file xdr_io.h.

Referenced by read(), read_header(), and read_serialized_nodes().

const bool libMesh::MeshOutput< MeshBase >::_is_parallel_format
protectedinherited

Flag specifying whether this format is parallel-capable.

If this is false (default) I/O is only permitted when the mesh has been serialized.

Definition at line 141 of file mesh_output.h.

Referenced by libMesh::FroIO::write(), libMesh::PostscriptIO::write(), and libMesh::EnsightIO::write().

bool libMesh::XdrIO::_legacy
private

Definition at line 336 of file xdr_io.h.

Referenced by legacy().

std::string libMesh::XdrIO::_p_level_file
private

Definition at line 345 of file xdr_io.h.

Referenced by polynomial_level_file_name().

std::string libMesh::XdrIO::_partition_map_file
private

Definition at line 343 of file xdr_io.h.

Referenced by partition_map_file_name().

const bool libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
protectedinherited

Flag specifying whether this format can be written by only serializing the mesh to processor zero.

If this is false (default) the mesh will be serialized to all processors

Definition at line 150 of file mesh_output.h.

std::string libMesh::XdrIO::_subdomain_map_file
private

Definition at line 344 of file xdr_io.h.

Referenced by subdomain_map_file_name().

std::string libMesh::XdrIO::_version
private

Definition at line 341 of file xdr_io.h.

Referenced by version().

bool libMesh::XdrIO::_write_parallel
private

Definition at line 338 of file xdr_io.h.

Referenced by set_auto_parallel(), set_write_parallel(), and write_parallel().

bool libMesh::XdrIO::_write_serial
private

Definition at line 337 of file xdr_io.h.

Referenced by set_auto_parallel(), set_write_parallel(), and write_parallel().

bool libMesh::XdrIO::_write_unique_id
private

Definition at line 339 of file xdr_io.h.

Referenced by write(), and write_serialized_connectivity().

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited
const std::size_t libMesh::XdrIO::io_blksize = 128000
staticprivate

Define the block size to use for chunked IO.

Definition at line 350 of file xdr_io.h.

Referenced by read_serialized_bcs_helper(), read_serialized_connectivity(), read_serialized_nodes(), read_serialized_nodesets(), and write_serialized_nodes().


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