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 &) override
 This method implements reading a mesh from a specified file. More...
 
virtual void write (const std::string &) 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=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_discontinuous_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
 This method implements writing a mesh with discontinuous 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 may be overridden by "parallel" output formats for writing nodal data. More...
 
virtual void write_nodal_data (const std::string &, const EquationSystems &, const std::set< std::string > *)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
virtual void write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 
const Parallel::Communicator & comm () 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
 
MeshBase_obj
 A pointer to a non-const object object. More...
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable. More...
 
unsigned int _ascii_precision
 Precision to use when writing ASCII files. More...
 

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

◆ new_header_id_type

Definition at line 63 of file xdr_io.h.

◆ old_header_id_type

Definition at line 60 of file xdr_io.h.

◆ xdr_id_type

Definition at line 57 of file xdr_io.h.

Constructor & Destructor Documentation

◆ XdrIO() [1/2]

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 76 of file xdr_io.C.

76  :
77  MeshInput<MeshBase> (mesh,/* is_parallel_format = */ true),
78  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
80  _binary (binary_in),
81  _legacy (false),
82  _write_serial (false),
83  _write_parallel (false),
84 #ifdef LIBMESH_ENABLE_UNIQUE_ID
85  _write_unique_id (true),
86 #else
87  _write_unique_id (false),
88 #endif
89  _field_width (4), // In 0.7.0, all fields are 4 bytes, in 0.9.2+ they can vary
90  _version ("libMesh-1.3.0"),
91  _bc_file_name ("n/a"),
92  _partition_map_file ("n/a"),
93  _subdomain_map_file ("n/a"),
94  _p_level_file ("n/a")
95 {
96 }

◆ XdrIO() [2/2]

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 100 of file xdr_io.C.

100  :
101  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
103  _binary (binary_in)
104 {
105 }

◆ ~XdrIO()

libMesh::XdrIO::~XdrIO ( )
virtual

Destructor.

Definition at line 109 of file xdr_io.C.

110 {
111 }

Member Function Documentation

◆ ascii_precision()

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

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

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

Definition at line 257 of file mesh_output.h.

258 {
259  return _ascii_precision;
260 }

◆ binary() [1/2]

bool& libMesh::XdrIO::binary ( )
inline

Definition at line 104 of file xdr_io.h.

104 { return _binary; }

References _binary.

◆ binary() [2/2]

bool libMesh::XdrIO::binary ( ) const
inline

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

Definition at line 103 of file xdr_io.h.

103 { return _binary; }

References _binary.

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

◆ boundary_condition_file_name() [1/2]

std::string& libMesh::XdrIO::boundary_condition_file_name ( )
inline

Definition at line 147 of file xdr_io.h.

147 { return _bc_file_name; }

References _bc_file_name.

◆ boundary_condition_file_name() [2/2]

const std::string& libMesh::XdrIO::boundary_condition_file_name ( ) const
inline

Get/Set the boundary condition file name.

Definition at line 146 of file xdr_io.h.

146 { return _bc_file_name; }

References _bc_file_name.

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

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 94 of file parallel_object.h.

95  { return _communicator; }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_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::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DynaIO::add_spline_constraints(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), 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::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), 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::RBConstruction::compute_residual_dual_norm_slow(), 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::ExodusII_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), 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::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::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_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), 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::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), 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(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), 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(), 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::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), FEMParameters::read(), libMesh::Nemesis_IO::read(), read(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), read_serialized_bc_names(), read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), read_serialized_connectivity(), read_serialized_nodes(), read_serialized_nodesets(), read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), SystemsTest::testBlockRestrictedVarNDofs(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), CheckpointIOTest::testSplitter(), 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::VTKIO::write_nodal_data(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), 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().

◆ legacy() [1/2]

bool& libMesh::XdrIO::legacy ( )
inline

Definition at line 110 of file xdr_io.h.

110 { return _legacy; }

References _legacy.

◆ legacy() [2/2]

bool libMesh::XdrIO::legacy ( ) const
inline

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

Definition at line 109 of file xdr_io.h.

109 { return _legacy; }

References _legacy.

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

◆ mesh() [1/2]

MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
inlineprotectedinherited
Returns
The object as a writable reference.

Definition at line 169 of file mesh_input.h.

170 {
171  if (_obj == nullptr)
172  libmesh_error_msg("ERROR: _obj should not be nullptr!");
173  return *_obj;
174 }

◆ mesh() [2/2]

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
inlineprotectedinherited
Returns
The object as a read-only reference.

Definition at line 247 of file mesh_output.h.

248 {
250  return *_obj;
251 }

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 100 of file parallel_object.h.

101  { return cast_int<processor_id_type>(_communicator.size()); }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), 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::EnsightIO::EnsightIO(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), 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::partition(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::VTKIO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), write_serialized_connectivity(), write_serialized_nodes(), and write_serialized_nodesets().

◆ pack_element()

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 2039 of file xdr_io.C.

2041 {
2042  libmesh_assert(elem);
2043  libmesh_assert_equal_to (elem->n_nodes(), Elem::type_to_n_nodes_map[elem->type()]);
2044 
2045  conn.push_back(elem->n_nodes());
2046 
2047  conn.push_back (elem->type());
2048 
2049  // In version 0.7.0+ "id" is stored but it not used. In version 0.9.2+
2050  // we will store unique_id instead, therefore there is no need to
2051  // check for the older version when writing the unique_id.
2052  conn.push_back (elem->unique_id());
2053 
2054  if (parent_id != DofObject::invalid_id)
2055  {
2056  conn.push_back (parent_id);
2057  libmesh_assert_not_equal_to (parent_pid, DofObject::invalid_id);
2058  conn.push_back (parent_pid);
2059  }
2060 
2061  conn.push_back (elem->processor_id());
2062  conn.push_back (elem->subdomain_id());
2063 
2064 #ifdef LIBMESH_ENABLE_AMR
2065  conn.push_back (elem->p_level());
2066 #endif
2067 
2068  for (auto n : elem->node_index_range())
2069  conn.push_back (elem->node_id(n));
2070 }

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 write_serialized_connectivity().

◆ partition_map_file_name() [1/2]

std::string& libMesh::XdrIO::partition_map_file_name ( )
inline

Definition at line 153 of file xdr_io.h.

153 { return _partition_map_file; }

References _partition_map_file.

◆ partition_map_file_name() [2/2]

const std::string& libMesh::XdrIO::partition_map_file_name ( ) const
inline

Get/Set the partitioning file name.

Definition at line 152 of file xdr_io.h.

152 { return _partition_map_file; }

References _partition_map_file.

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

◆ polynomial_level_file_name() [1/2]

std::string& libMesh::XdrIO::polynomial_level_file_name ( )
inline

Definition at line 165 of file xdr_io.h.

165 { return _p_level_file; }

References _p_level_file.

◆ polynomial_level_file_name() [2/2]

const std::string& libMesh::XdrIO::polynomial_level_file_name ( ) const
inline

Get/Set the polynomial degree file name.

Definition at line 164 of file xdr_io.h.

164 { return _p_level_file; }

References _p_level_file.

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

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 106 of file parallel_object.h.

107  { return cast_int<processor_id_type>(_communicator.rank()); }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), 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::ExodusII_IO::copy_scalar_solution(), 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::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), 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::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::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), HeatSystem::init_data(), 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::DofMap::last_dof(), 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_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), 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::DofMap::n_local_dofs(), 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::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), 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(), read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), read_serialized_bc_names(), read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), read_serialized_connectivity(), libMesh::System::read_serialized_data(), read_serialized_nodes(), read_serialized_nodesets(), read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), CheckpointIOTest::testSplitter(), 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::NameBasedIO::write(), write(), libMesh::CheckpointIO::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_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), 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::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), write_serialized_bc_names(), write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), write_serialized_connectivity(), libMesh::System::write_serialized_data(), write_serialized_nodes(), write_serialized_nodesets(), write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

◆ read()

void libMesh::XdrIO::read ( const std::string &  name)
overridevirtual

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 1210 of file xdr_io.C.

1211 {
1212  LOG_SCOPE("read()","XdrIO");
1213 
1214  // Only open the file on processor 0 -- this is especially important because
1215  // there may be an underlying bzip/bunzip going on, and multiple simultaneous
1216  // calls will produce a race condition.
1217  Xdr io (this->processor_id() == 0 ? name : "", this->binary() ? DECODE : READ);
1218 
1219  // convenient reference to our mesh
1220  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1221 
1222  // get the version string.
1223  if (this->processor_id() == 0)
1224  io.data (this->version());
1225  this->comm().broadcast (this->version());
1226 
1227  // note that for "legacy" files the first entry is an
1228  // integer -- not a string at all.
1229  this->legacy() = !(this->version().find("libMesh") < this->version().size());
1230 
1231  // Check for a legacy version format.
1232  if (this->legacy())
1233  libmesh_error_msg("We no longer support reading files in the legacy format.");
1234 
1235  // Read headers with the old id type if they're pre-1.3.0, or with
1236  // the new id type if they're post-1.3.0
1237  std::vector<new_header_id_type> meta_data(10, sizeof(xdr_id_type));
1238  if (this->version_at_least_1_3_0())
1239  {
1240  this->read_header(io, meta_data);
1241  }
1242  else
1243  {
1244  std::vector<old_header_id_type> old_data(10, sizeof(xdr_id_type));
1245 
1246  this->read_header(io, old_data);
1247 
1248  meta_data.assign(old_data.begin(), old_data.end());
1249  }
1250 
1251  const new_header_id_type & n_elem = meta_data[0];
1252  const new_header_id_type & n_nodes = meta_data[1];
1253 
1259  if (version_at_least_0_9_2())
1260  _field_width = cast_int<unsigned int>(meta_data[2]);
1261 
1262  // On systems where uint64_t==unsigned long, we were previously
1263  // writing 64-bit unsigned integers via xdr_u_long(), a function
1264  // which is literally less suited for that task than abort() would
1265  // have been, because at least abort() would have *known* it
1266  // couldn't write rather than truncating writes to 32 bits.
1267  //
1268  // If we have files with version < 1.3.0, then we'll continue to use
1269  // 32 bit field width, regardless of whether the file thinks we
1270  // should, whenever we're on a system where the problem would have
1271  // occurred.
1272  if ((_field_width == 4) ||
1273  (!version_at_least_1_3_0() &&
1275  {
1276  uint32_t type_size = 0;
1277 
1278  // read subdomain names
1280 
1281  // read connectivity
1282  this->read_serialized_connectivity (io, cast_int<dof_id_type>(n_elem), meta_data, type_size);
1283 
1284  // read the nodal locations
1285  this->read_serialized_nodes (io, cast_int<dof_id_type>(n_nodes));
1286 
1287  // read the side boundary conditions
1288  this->read_serialized_side_bcs (io, type_size);
1289 
1290  if (version_at_least_0_9_2())
1291  // read the nodesets
1292  this->read_serialized_nodesets (io, type_size);
1293 
1294  if (version_at_least_1_1_0())
1295  {
1296  // read the edge boundary conditions
1297  this->read_serialized_edge_bcs (io, type_size);
1298 
1299  // read the "shell face" boundary conditions
1300  this->read_serialized_shellface_bcs (io, type_size);
1301  }
1302  }
1303  else if (_field_width == 8)
1304  {
1305  uint64_t type_size = 0;
1306 
1307  // read subdomain names
1309 
1310  // read connectivity
1311  this->read_serialized_connectivity (io, cast_int<dof_id_type>(n_elem), meta_data, type_size);
1312 
1313  // read the nodal locations
1314  this->read_serialized_nodes (io, cast_int<dof_id_type>(n_nodes));
1315 
1316  // read the boundary conditions
1317  this->read_serialized_side_bcs (io, type_size);
1318 
1319  if (version_at_least_0_9_2())
1320  // read the nodesets
1321  this->read_serialized_nodesets (io, type_size);
1322 
1323  if (version_at_least_1_1_0())
1324  {
1325  // read the edge boundary conditions
1326  this->read_serialized_edge_bcs (io, type_size);
1327 
1328  // read the "shell face" boundary conditions
1329  this->read_serialized_shellface_bcs (io, type_size);
1330  }
1331  }
1332 
1333  // set the node processor ids
1335 }

References _field_width, binary(), 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().

◆ read_header()

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 1340 of file xdr_io.C.

1341 {
1342  LOG_SCOPE("read_header()","XdrIO");
1343 
1344  // convenient reference to our mesh
1345  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1346 
1347  if (this->processor_id() == 0)
1348  {
1349  unsigned int pos=0;
1350 
1351  io.data (meta_data[pos++]);
1352  io.data (meta_data[pos++]);
1353  io.data (this->boundary_condition_file_name()); // libMesh::out << "bc_file=" << this->boundary_condition_file_name() << std::endl;
1354  io.data (this->subdomain_map_file_name()); // libMesh::out << "sid_file=" << this->subdomain_map_file_name() << std::endl;
1355  io.data (this->partition_map_file_name()); // libMesh::out << "pid_file=" << this->partition_map_file_name() << std::endl;
1356  io.data (this->polynomial_level_file_name()); // libMesh::out << "pl_file=" << this->polynomial_level_file_name() << std::endl;
1357 
1358  if (version_at_least_0_9_2())
1359  {
1360  io.data (meta_data[pos++], "# type size");
1361  io.data (meta_data[pos++], "# uid size");
1362  io.data (meta_data[pos++], "# pid size");
1363  io.data (meta_data[pos++], "# sid size");
1364  io.data (meta_data[pos++], "# p-level size");
1365  // Boundary Condition sizes
1366  io.data (meta_data[pos++], "# eid size"); // elem id
1367  io.data (meta_data[pos++], "# side size"); // side number
1368  io.data (meta_data[pos++], "# bid size"); // boundary id
1369  }
1370  }
1371 
1372  // broadcast the n_elems, n_nodes, and size information
1373  this->comm().broadcast (meta_data);
1374 
1375  this->comm().broadcast (this->boundary_condition_file_name());
1376  this->comm().broadcast (this->subdomain_map_file_name());
1377  this->comm().broadcast (this->partition_map_file_name());
1378  this->comm().broadcast (this->polynomial_level_file_name());
1379 
1380  // Tell the mesh how many nodes/elements to expect. Depending on the mesh type,
1381  // this may allow for efficient adding of nodes/elements.
1382  const T & n_elem = meta_data[0];
1383  const T & n_nodes = meta_data[1];
1384 
1385  mesh.reserve_elem(cast_int<dof_id_type>(n_elem));
1386  mesh.reserve_nodes(cast_int<dof_id_type>(n_nodes));
1387 
1388  // Our mesh is pre-partitioned as it's created
1389  this->set_n_partitions(this->n_processors());
1390 
1396  if (version_at_least_0_9_2())
1397  _field_width = cast_int<unsigned int>(meta_data[2]);
1398 }

References _field_width, boundary_condition_file_name(), 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 read().

◆ read_serialized_bc_names()

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 1980 of file xdr_io.C.

1981 {
1982  const bool read_entity_info = version_at_least_0_9_2();
1983  const bool use_new_header_type (this->version_at_least_1_3_0());
1984  if (read_entity_info)
1985  {
1986  new_header_id_type n_boundary_names = 0;
1987  std::vector<new_header_id_type> boundary_ids;
1988  std::vector<std::string> boundary_names;
1989 
1990  // Read the sideset names
1991  if (this->processor_id() == 0)
1992  {
1993  if (use_new_header_type)
1994  io.data(n_boundary_names);
1995  else
1996  {
1997  old_header_id_type temp;
1998  io.data(temp);
1999  n_boundary_names = temp;
2000  }
2001 
2002  boundary_names.resize(n_boundary_names);
2003 
2004  if (n_boundary_names)
2005  {
2006  if (use_new_header_type)
2007  io.data(boundary_ids);
2008  else
2009  {
2010  std::vector<old_header_id_type> temp(n_boundary_names);
2011  io.data(temp);
2012  boundary_ids.assign(temp.begin(), temp.end());
2013  }
2014  io.data(boundary_names);
2015  }
2016  }
2017 
2018  // Broadcast the boundary names to all processors
2019  this->comm().broadcast(n_boundary_names);
2020  if (n_boundary_names == 0)
2021  return;
2022 
2023  boundary_ids.resize(n_boundary_names);
2024  boundary_names.resize(n_boundary_names);
2025  this->comm().broadcast(boundary_ids);
2026  this->comm().broadcast(boundary_names);
2027 
2028  // Reassemble the named boundary information
2029  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
2030  info.set_sideset_name_map() : info.set_nodeset_name_map();
2031 
2032  for (unsigned int i=0; i<n_boundary_names; ++i)
2033  boundary_map.insert(std::make_pair(cast_int<boundary_id_type>(boundary_ids[i]), boundary_names[i]));
2034  }
2035 }

References 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 read_serialized_bcs_helper(), and read_serialized_nodesets().

◆ read_serialized_bcs_helper()

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 1801 of file xdr_io.C.

1802 {
1803  if (this->boundary_condition_file_name() == "n/a") return;
1804 
1805  libmesh_assert (io.reading());
1806 
1807  // convenient reference to our mesh
1808  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1809 
1810  // and our boundary info object
1811  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1812 
1813  // Version 0.9.2+ introduces unique ids
1814  read_serialized_bc_names(io, boundary_info, true); // sideset names
1815 
1816  std::vector<T> input_buffer;
1817 
1818  new_header_id_type n_bcs=0;
1819  if (this->processor_id() == 0)
1820  {
1821  if (this->version_at_least_1_3_0())
1822  io.data (n_bcs);
1823  else
1824  {
1825  old_header_id_type temp;
1826  io.data (temp);
1827  n_bcs = temp;
1828  }
1829  }
1830  this->comm().broadcast (n_bcs);
1831 
1832  for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_bcs; blk++)
1833  {
1834  first_bc = blk*io_blksize;
1835  last_bc = std::min((blk+1)*io_blksize, std::size_t(n_bcs));
1836 
1837  input_buffer.resize (3*(last_bc - first_bc));
1838 
1839  if (this->processor_id() == 0)
1840  io.data_stream (input_buffer.empty() ? nullptr : input_buffer.data(),
1841  cast_int<unsigned int>(input_buffer.size()));
1842 
1843  this->comm().broadcast (input_buffer);
1844 
1845  // Look for BCs in this block for all the level-0 elements we have
1846  // (not just local ones). Do this by checking all entries for
1847  // IDs matching an element we can query.
1848  // We cannot rely on nullptr neighbors at this point since the neighbor
1849  // data structure has not been initialized.
1850  for (std::size_t idx=0, ibs=input_buffer.size(); idx<ibs; idx+=3)
1851  {
1852  const dof_id_type dof_id =
1853  cast_int<dof_id_type>(input_buffer[idx+0]);
1854  const unsigned short side =
1855  cast_int<unsigned short>(input_buffer[idx+1]);
1856  const boundary_id_type bc_id =
1857  cast_int<boundary_id_type>(input_buffer[idx+2]);
1858 
1859  const Elem * elem = mesh.query_elem_ptr(dof_id);
1860  if (!elem)
1861  continue;
1862 
1863  if (bc_type == "side")
1864  {
1865  libmesh_assert_less (side, elem->n_sides());
1866  boundary_info.add_side (elem, side, bc_id);
1867  }
1868  else if (bc_type == "edge")
1869  {
1870  libmesh_assert_less (side, elem->n_edges());
1871  boundary_info.add_edge (elem, side, bc_id);
1872  }
1873  else if (bc_type == "shellface")
1874  {
1875  // Shell face IDs can only be 0 or 1.
1876  libmesh_assert_less(side, 2);
1877 
1878  boundary_info.add_shellface (elem, side, bc_id);
1879  }
1880  else
1881  {
1882  libmesh_error_msg("bc_type not recognized: " + bc_type);
1883  }
1884  }
1885  input_buffer.clear();
1886  }
1887 }

References libMesh::BoundaryInfo::add_edge(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), boundary_condition_file_name(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshTools::Generation::Private::idx(), io_blksize, libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::Elem::n_edges(), libMesh::Elem::n_sides(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::query_elem_ptr(), read_serialized_bc_names(), libMesh::Xdr::reading(), and version_at_least_1_3_0().

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

◆ read_serialized_connectivity()

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 1464 of file xdr_io.C.

1465 {
1466  libmesh_assert (io.reading());
1467 
1468  if (!n_elem) return;
1469 
1470  const bool
1471  read_p_level = ("." == this->polynomial_level_file_name()),
1472  read_partitioning = ("." == this->partition_map_file_name()),
1473  read_subdomain_id = ("." == this->subdomain_map_file_name());
1474 
1475  // convenient reference to our mesh
1476  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1477 
1478  // Keep track of what kinds of elements this file contains
1479  elems_of_dimension.clear();
1480  elems_of_dimension.resize(4, false);
1481 
1482  std::vector<T> conn, input_buffer(100 /* oversized ! */);
1483 
1484  int level=-1;
1485 
1486  // Version 0.9.2+ introduces unique ids
1487  const size_t unique_id_size_index = 3;
1488 
1489  const bool read_unique_id =
1490  (version_at_least_0_9_2()) &&
1491  sizes[unique_id_size_index];
1492 
1493  T n_elem_at_level=0, n_processed_at_level=0;
1494  for (dof_id_type blk=0, first_elem=0, last_elem=0;
1495  last_elem<n_elem; blk++)
1496  {
1497  first_elem = cast_int<dof_id_type>(blk*io_blksize);
1498  last_elem = cast_int<dof_id_type>(std::min(cast_int<std::size_t>((blk+1)*io_blksize),
1499  cast_int<std::size_t>(n_elem)));
1500 
1501  conn.clear();
1502 
1503  if (this->processor_id() == 0)
1504  for (dof_id_type e=first_elem; e<last_elem; e++, n_processed_at_level++)
1505  {
1506  if (n_processed_at_level == n_elem_at_level)
1507  {
1508  // get the number of elements to read at this level
1509  io.data (n_elem_at_level);
1510  n_processed_at_level = 0;
1511  level++;
1512  }
1513 
1514  unsigned int pos = 0;
1515  // get the element type,
1516  io.data_stream (&input_buffer[pos++], 1);
1517 
1518  if (read_unique_id)
1519  io.data_stream (&input_buffer[pos++], 1);
1520  // Older versions won't have this field at all (no increment on pos)
1521 
1522  // maybe the parent
1523  if (level)
1524  io.data_stream (&input_buffer[pos++], 1);
1525  else
1526  // We can't always fit DofObject::invalid_id in an
1527  // xdr_id_type
1528  input_buffer[pos++] = static_cast<T>(-1);
1529 
1530  // maybe the processor id
1531  if (read_partitioning)
1532  io.data_stream (&input_buffer[pos++], 1);
1533  else
1534  input_buffer[pos++] = 0;
1535 
1536  // maybe the subdomain id
1537  if (read_subdomain_id)
1538  io.data_stream (&input_buffer[pos++], 1);
1539  else
1540  input_buffer[pos++] = 0;
1541 
1542  // maybe the p level
1543  if (read_p_level)
1544  io.data_stream (&input_buffer[pos++], 1);
1545  else
1546  input_buffer[pos++] = 0;
1547 
1548  // and all the nodes
1549  libmesh_assert_less (pos+Elem::type_to_n_nodes_map[input_buffer[0]], input_buffer.size());
1550  io.data_stream (&input_buffer[pos], Elem::type_to_n_nodes_map[input_buffer[0]]);
1551  conn.insert (conn.end(),
1552  input_buffer.begin(),
1553  input_buffer.begin() + pos + Elem::type_to_n_nodes_map[input_buffer[0]]);
1554  }
1555 
1556  std::size_t conn_size = conn.size();
1557  this->comm().broadcast(conn_size);
1558  conn.resize (conn_size);
1559  this->comm().broadcast (conn);
1560 
1561  // All processors now have the connectivity for this block.
1562  typename std::vector<T>::const_iterator it = conn.begin();
1563  for (dof_id_type e=first_elem; e<last_elem; e++)
1564  {
1565  const ElemType elem_type = static_cast<ElemType>(*it); ++it;
1566 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1567  // We are on all processors here, so we can easily assign
1568  // consistent unique ids if the file doesn't specify them
1569  // later.
1570  unique_id_type unique_id = e;
1571 #endif
1572  if (read_unique_id)
1573  {
1574 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1575  unique_id = cast_int<unique_id_type>(*it);
1576 #endif
1577  ++it;
1578  }
1579  const dof_id_type parent_id =
1580  (*it == static_cast<T>(-1)) ?
1582  cast_int<dof_id_type>(*it);
1583  ++it;
1584  const processor_id_type proc_id =
1585  cast_int<processor_id_type>(*it);
1586  ++it;
1587  const subdomain_id_type subdomain_id =
1588  cast_int<subdomain_id_type>(*it);
1589  ++it;
1590 #ifdef LIBMESH_ENABLE_AMR
1591  const unsigned int p_level =
1592  cast_int<unsigned int>(*it);
1593 #endif
1594  ++it;
1595 
1596  Elem * parent = (parent_id == DofObject::invalid_id) ?
1597  nullptr : mesh.elem_ptr(parent_id);
1598 
1599  Elem * elem = Elem::build (elem_type, parent).release();
1600 
1601  elem->set_id() = e;
1602 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1603  elem->set_unique_id() = unique_id;
1604 #endif
1605  elem->processor_id() = proc_id;
1606  elem->subdomain_id() = subdomain_id;
1607 #ifdef LIBMESH_ENABLE_AMR
1608  elem->hack_p_level(p_level);
1609 
1610  if (parent)
1611  {
1612  parent->add_child(elem);
1613  parent->set_refinement_flag (Elem::INACTIVE);
1614  elem->set_refinement_flag (Elem::JUST_REFINED);
1615  }
1616 #endif
1617 
1618  for (unsigned int n=0, n_n = elem->n_nodes(); n != n_n;
1619  n++, ++it)
1620  {
1621  const dof_id_type global_node_number =
1622  cast_int<dof_id_type>(*it);
1623 
1624  elem->set_node(n) =
1625  mesh.add_point (Point(), global_node_number);
1626  }
1627 
1628  elems_of_dimension[elem->dim()] = true;
1629  mesh.add_elem(elem);
1630  }
1631  }
1632 
1633  // Set the mesh dimension to the largest encountered for an element
1634  for (unsigned char i=0; i!=4; ++i)
1635  if (elems_of_dimension[i])
1637 
1638 #if LIBMESH_DIM < 3
1639  if (mesh.mesh_dimension() > LIBMESH_DIM)
1640  libmesh_error_msg("Cannot open dimension " \
1641  << mesh.mesh_dimension() \
1642  << " mesh file when configured without " \
1643  << mesh.mesh_dimension() \
1644  << "D support.");
1645 #endif
1646 }

References libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), 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::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::mesh_dimension(), 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 read().

◆ read_serialized_edge_bcs()

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 1900 of file xdr_io.C.

1901 {
1902  read_serialized_bcs_helper(io, value, "edge");
1903 }

References read_serialized_bcs_helper(), and value.

Referenced by read().

◆ read_serialized_nodes()

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 1650 of file xdr_io.C.

1651 {
1652  libmesh_assert (io.reading());
1653 
1654  // convenient reference to our mesh
1655  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1656 
1657  if (!mesh.n_nodes()) return;
1658 
1659  // At this point the elements have been read from file and placeholder nodes
1660  // have been assigned. These nodes, however, do not have the proper (x,y,z)
1661  // locations or unique_id values. This method will read all the
1662  // nodes from disk, and each processor can then grab the individual
1663  // values it needs.
1664 
1665  // If the file includes unique ids for nodes (as indicated by a
1666  // flag in 0.9.6+ files), those will be read next.
1667 
1668  // build up a list of the nodes contained in our local mesh. These are the nodes
1669  // stored on the local processor whose (x,y,z) and unique_id values
1670  // need to be corrected.
1671  std::vector<dof_id_type> needed_nodes; needed_nodes.reserve (mesh.n_nodes());
1672  {
1673  for (auto & node : mesh.node_ptr_range())
1674  needed_nodes.push_back(node->id());
1675 
1676  std::sort (needed_nodes.begin(), needed_nodes.end());
1677 
1678  // We should not have any duplicate node->id()s
1679  libmesh_assert (std::unique(needed_nodes.begin(), needed_nodes.end()) == needed_nodes.end());
1680  }
1681 
1682  // Get the nodes in blocks.
1683  std::vector<Real> coords;
1684  std::pair<std::vector<dof_id_type>::iterator,
1685  std::vector<dof_id_type>::iterator> pos;
1686  pos.first = needed_nodes.begin();
1687 
1688  // Broadcast node coordinates
1689  for (std::size_t blk=0, first_node=0, last_node=0; last_node<n_nodes; blk++)
1690  {
1691  first_node = blk*io_blksize;
1692  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
1693 
1694  coords.resize(3*(last_node - first_node));
1695 
1696  if (this->processor_id() == 0)
1697  io.data_stream (coords.empty() ? nullptr : coords.data(),
1698  cast_int<unsigned int>(coords.size()));
1699 
1700  // For large numbers of processors the majority of processors at any given
1701  // block may not actually need these data. It may be worth profiling this,
1702  // although it is expected that disk IO will be the bottleneck
1703  this->comm().broadcast (coords);
1704 
1705  for (std::size_t n=first_node, idx=0; n<last_node; n++, idx+=3)
1706  {
1707  // first see if we need this node. use pos.first as a smart lower
1708  // bound, this will ensure that the size of the searched range
1709  // decreases as we match nodes.
1710  pos = std::equal_range (pos.first, needed_nodes.end(), n);
1711 
1712  if (pos.first != pos.second) // we need this node.
1713  {
1714  libmesh_assert_equal_to (*pos.first, n);
1715  libmesh_assert(!libmesh_isnan(coords[idx+0]));
1716  libmesh_assert(!libmesh_isnan(coords[idx+1]));
1717  libmesh_assert(!libmesh_isnan(coords[idx+2]));
1718  mesh.node_ref(cast_int<dof_id_type>(n)) =
1719  Point (coords[idx+0],
1720  coords[idx+1],
1721  coords[idx+2]);
1722 
1723  }
1724  }
1725  }
1726 
1727  if (version_at_least_0_9_6())
1728  {
1729  // Check for node unique ids
1730  unsigned short read_unique_ids;
1731 
1732  if (this->processor_id() == 0)
1733  io.data (read_unique_ids);
1734 
1735  this->comm().broadcast (read_unique_ids);
1736 
1737  // If no unique ids are in the file, we're done.
1738  if (!read_unique_ids)
1739  return;
1740 
1741  std::vector<uint32_t> unique_32;
1742  std::vector<uint64_t> unique_64;
1743 
1744  // We're starting over from node 0 again
1745  pos.first = needed_nodes.begin();
1746 
1747  for (std::size_t blk=0, first_node=0, last_node=0; last_node<n_nodes; blk++)
1748  {
1749  first_node = blk*io_blksize;
1750  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
1751 
1752  libmesh_assert((_field_width == 8) || (_field_width == 4));
1753 
1754  if (_field_width == 8)
1755  unique_64.resize(last_node - first_node);
1756  else
1757  unique_32.resize(last_node - first_node);
1758 
1759  if (this->processor_id() == 0)
1760  {
1761  if (_field_width == 8)
1762  io.data_stream (unique_64.empty() ? nullptr : unique_64.data(),
1763  cast_int<unsigned int>(unique_64.size()));
1764  else
1765  io.data_stream (unique_32.empty() ? nullptr : unique_32.data(),
1766  cast_int<unsigned int>(unique_32.size()));
1767  }
1768 
1769 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1770  if (_field_width == 8)
1771  this->comm().broadcast (unique_64);
1772  else
1773  this->comm().broadcast (unique_32);
1774 
1775  for (std::size_t n=first_node, idx=0; n<last_node; n++, idx++)
1776  {
1777  // first see if we need this node. use pos.first as a smart lower
1778  // bound, this will ensure that the size of the searched range
1779  // decreases as we match nodes.
1780  pos = std::equal_range (pos.first, needed_nodes.end(), n);
1781 
1782  if (pos.first != pos.second) // we need this node.
1783  {
1784  libmesh_assert_equal_to (*pos.first, n);
1785  if (_field_width == 8)
1786  mesh.node_ref(cast_int<dof_id_type>(n)).set_unique_id()
1787  = unique_64[idx];
1788  else
1789  mesh.node_ref(cast_int<dof_id_type>(n)).set_unique_id()
1790  = unique_32[idx];
1791  }
1792  }
1793 #endif // LIBMESH_ENABLE_UNIQUE_ID
1794  }
1795  }
1796 }

References _field_width, libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshTools::Generation::Private::idx(), io_blksize, libMesh::libmesh_assert(), libMesh::libmesh_isnan(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::MeshBase::node_ptr_range(), libMesh::MeshBase::node_ref(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::DofObject::set_unique_id(), and version_at_least_0_9_6().

Referenced by read().

◆ read_serialized_nodesets()

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 1916 of file xdr_io.C.

1917 {
1918  if (this->boundary_condition_file_name() == "n/a") return;
1919 
1920  libmesh_assert (io.reading());
1921 
1922  // convenient reference to our mesh
1923  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1924 
1925  // and our boundary info object
1926  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1927 
1928  // Version 0.9.2+ introduces unique ids
1929  read_serialized_bc_names(io, boundary_info, false); // nodeset names
1930 
1931  std::vector<T> input_buffer;
1932 
1933  new_header_id_type n_nodesets=0;
1934  if (this->processor_id() == 0)
1935  {
1936  if (this->version_at_least_1_3_0())
1937  io.data (n_nodesets);
1938  else
1939  {
1940  old_header_id_type temp;
1941  io.data (temp);
1942  n_nodesets = temp;
1943  }
1944  }
1945  this->comm().broadcast (n_nodesets);
1946 
1947  for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_nodesets; blk++)
1948  {
1949  first_bc = blk*io_blksize;
1950  last_bc = std::min((blk+1)*io_blksize, std::size_t(n_nodesets));
1951 
1952  input_buffer.resize (2*(last_bc - first_bc));
1953 
1954  if (this->processor_id() == 0)
1955  io.data_stream (input_buffer.empty() ? nullptr : input_buffer.data(),
1956  cast_int<unsigned int>(input_buffer.size()));
1957 
1958  this->comm().broadcast (input_buffer);
1959 
1960  // Look for BCs in this block for all nodes we have (not just
1961  // local ones). Do this by checking all entries for
1962  // IDs matching a node we can query.
1963  for (std::size_t idx=0, ibs=input_buffer.size(); idx<ibs; idx+=2)
1964  {
1965  const dof_id_type dof_id =
1966  cast_int<dof_id_type>(input_buffer[idx+0]);
1967  const boundary_id_type bc_id =
1968  cast_int<boundary_id_type>(input_buffer[idx+1]);
1969 
1970  const Node * node = mesh.query_node_ptr(dof_id);
1971  if (node)
1972  boundary_info.add_node (node, bc_id);
1973  }
1974  input_buffer.clear();
1975  }
1976 }

References libMesh::BoundaryInfo::add_node(), boundary_condition_file_name(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshTools::Generation::Private::idx(), io_blksize, libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::query_node_ptr(), read_serialized_bc_names(), libMesh::Xdr::reading(), and version_at_least_1_3_0().

Referenced by read().

◆ read_serialized_shellface_bcs()

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 1908 of file xdr_io.C.

1909 {
1910  read_serialized_bcs_helper(io, value, "shellface");
1911 }

References read_serialized_bcs_helper(), and value.

Referenced by read().

◆ read_serialized_side_bcs()

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 1892 of file xdr_io.C.

1893 {
1894  read_serialized_bcs_helper(io, value, "side");
1895 }

References read_serialized_bcs_helper(), and value.

Referenced by read().

◆ read_serialized_subdomain_names()

void libMesh::XdrIO::read_serialized_subdomain_names ( Xdr io)
private

Read subdomain name information - NEW in 0.9.2 format.

Definition at line 1402 of file xdr_io.C.

1403 {
1404  const bool read_entity_info = version_at_least_0_9_2();
1405  const bool use_new_header_type (this->version_at_least_1_3_0());
1406  if (read_entity_info)
1407  {
1408  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1409 
1410  new_header_id_type n_subdomain_names = 0;
1411  std::vector<new_header_id_type> subdomain_ids;
1412  std::vector<std::string> subdomain_names;
1413 
1414  // Read the sideset names
1415  if (this->processor_id() == 0)
1416  {
1417  if (use_new_header_type)
1418  io.data(n_subdomain_names);
1419  else
1420  {
1421  old_header_id_type temp;
1422  io.data(temp);
1423  n_subdomain_names = temp;
1424  }
1425 
1426  subdomain_ids.resize(n_subdomain_names);
1427  subdomain_names.resize(n_subdomain_names);
1428 
1429  if (n_subdomain_names)
1430  {
1431  if (use_new_header_type)
1432  io.data(subdomain_ids);
1433  else
1434  {
1435  std::vector<old_header_id_type> temp;
1436  io.data(temp);
1437  subdomain_ids.assign(temp.begin(), temp.end());
1438  }
1439 
1440  io.data(subdomain_names);
1441  }
1442  }
1443 
1444  // Broadcast the subdomain names to all processors
1445  this->comm().broadcast(n_subdomain_names);
1446  if (n_subdomain_names == 0)
1447  return;
1448 
1449  subdomain_ids.resize(n_subdomain_names);
1450  subdomain_names.resize(n_subdomain_names);
1451  this->comm().broadcast(subdomain_ids);
1452  this->comm().broadcast(subdomain_names);
1453 
1454  // Reassemble the named subdomain information
1455  std::map<subdomain_id_type, std::string> & subdomain_map = mesh.set_subdomain_name_map();
1456 
1457  for (unsigned int i=0; i<n_subdomain_names; ++i)
1458  subdomain_map.insert(std::make_pair(subdomain_ids[i], subdomain_names[i]));
1459  }
1460 }

References 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 read().

◆ set_auto_parallel()

void libMesh::XdrIO::set_auto_parallel ( )
inline

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.

390 {
391  this->_write_serial = false;
392  this->_write_parallel = false;
393 }

References _write_parallel, and _write_serial.

◆ set_n_partitions()

void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
inlineprotectedinherited

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.

91 { this->mesh().set_n_partitions() = n_parts; }

◆ set_write_parallel()

void libMesh::XdrIO::set_write_parallel ( bool  do_parallel = true)
inline

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

Definition at line 379 of file xdr_io.h.

380 {
381  this->_write_parallel = do_parallel;
382 
383  this->_write_serial = !do_parallel;
384 }

References _write_parallel, and _write_serial.

◆ skip_comment_lines()

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.

Definition at line 179 of file mesh_input.h.

181 {
182  char c, line[256];
183 
184  while (in.get(c), c==comment_start)
185  in.getline (line, 255);
186 
187  // put back first character of
188  // first non-comment line
189  in.putback (c);
190 }

◆ subdomain_map_file_name() [1/2]

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

Definition at line 159 of file xdr_io.h.

159 { return _subdomain_map_file; }

References _subdomain_map_file.

◆ subdomain_map_file_name() [2/2]

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

Get/Set the subdomain file name.

Definition at line 158 of file xdr_io.h.

158 { return _subdomain_map_file; }

References _subdomain_map_file.

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

◆ version() [1/2]

std::string& libMesh::XdrIO::version ( )
inline

Definition at line 141 of file xdr_io.h.

141 { return _version; }

References _version.

◆ version() [2/2]

const std::string& libMesh::XdrIO::version ( ) const
inline

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.

140 { return _version; }

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().

◆ version_at_least_0_9_2()

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 2072 of file xdr_io.C.

2073 {
2074  return
2075  (this->version().find("0.9.2") != std::string::npos) ||
2076  (this->version().find("0.9.6") != std::string::npos) ||
2077  (this->version().find("1.1.0") != std::string::npos) ||
2078  (this->version().find("1.3.0") != std::string::npos);
2079 }

References version().

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

◆ version_at_least_0_9_6()

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 2081 of file xdr_io.C.

2082 {
2083  return
2084  (this->version().find("0.9.6") != std::string::npos) ||
2085  (this->version().find("1.1.0") != std::string::npos) ||
2086  (this->version().find("1.3.0") != std::string::npos);
2087 }

References version().

Referenced by read_serialized_nodes().

◆ version_at_least_1_1_0()

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 2089 of file xdr_io.C.

2090 {
2091  return
2092  (this->version().find("1.1.0") != std::string::npos) ||
2093  (this->version().find("1.3.0") != std::string::npos);
2094 }

References version().

Referenced by read().

◆ version_at_least_1_3_0()

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 2096 of file xdr_io.C.

2097 {
2098  return
2099  (this->version().find("1.3.0") != std::string::npos);
2100 }

References version().

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

◆ write()

void libMesh::XdrIO::write ( const std::string &  name)
overridevirtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 115 of file xdr_io.C.

116 {
117  if (this->legacy())
118  libmesh_error_msg("We don't support writing parallel files in the legacy format.");
119 
120  Xdr io ((this->processor_id() == 0) ? name : "", this->binary() ? ENCODE : WRITE);
121 
122  START_LOG("write()","XdrIO");
123 
124  // convenient reference to our mesh
125  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
126 
128  new_header_id_type max_node_id = mesh.max_node_id();
129 
134  unsigned int n_p_levels = MeshTools::n_p_levels (mesh);
135 
136  bool write_parallel_files = this->write_parallel();
137 
138  //-------------------------------------------------------------
139  // For all the optional files -- the default file name is "n/a".
140  // However, the user may specify an optional external file.
141 
142  // If there are BCs and the user has not already provided a
143  // file name then write to "."
144  if ((n_side_bcs || n_edge_bcs || n_shellface_bcs || n_nodesets) &&
145  this->boundary_condition_file_name() == "n/a")
146  this->boundary_condition_file_name() = ".";
147 
148  // If there are more than one subdomains and the user has not specified an
149  // external file then write the subdomain mapping to the default file "."
150  if ((mesh.n_subdomains() > 0) &&
151  (this->subdomain_map_file_name() == "n/a"))
152  this->subdomain_map_file_name() = ".";
153 
154  // In general we don't write the partition information.
155 
156  // If we have p levels and the user has not already provided
157  // a file name then write to "."
158  if ((n_p_levels > 1) &&
159  (this->polynomial_level_file_name() == "n/a"))
160  this->polynomial_level_file_name() = ".";
161 
162  // write the header
163  if (this->processor_id() == 0)
164  {
165  std::string full_ver = this->version() + (write_parallel_files ? " parallel" : "");
166  io.data (full_ver);
167 
168  io.data (n_elem, "# number of elements");
169  io.data (max_node_id, "# number of nodes"); // We'll write invalid coords into gaps
170 
171  io.data (this->boundary_condition_file_name(), "# boundary condition specification file");
172  io.data (this->subdomain_map_file_name(), "# subdomain id specification file");
173  io.data (this->partition_map_file_name(), "# processor id specification file");
174  io.data (this->polynomial_level_file_name(), "# p-level specification file");
175 
176  // Version 0.9.2+ introduces sizes for each type
177  new_header_id_type write_size = sizeof(xdr_id_type), zero_size = 0;
178 
179  const bool
180  write_p_level = ("." == this->polynomial_level_file_name()),
181  write_partitioning = ("." == this->partition_map_file_name()),
182  write_subdomain_id = ("." == this->subdomain_map_file_name()),
183  write_bcs = ("." == this->boundary_condition_file_name());
184 
185  io.data (write_size, "# type size");
186  io.data (_write_unique_id ? write_size : zero_size, "# uid size");
187  io.data (write_partitioning ? write_size : zero_size, "# pid size");
188  io.data (write_subdomain_id ? write_size : zero_size, "# sid size");
189  io.data (write_p_level ? write_size : zero_size, "# p-level size");
190  // Boundary Condition sizes
191  io.data (write_bcs ? write_size : zero_size, "# eid size"); // elem id
192  io.data (write_bcs ? write_size : zero_size, "# side size"); // side number
193  io.data (write_bcs ? write_size : zero_size, "# bid size"); // boundary id
194  }
195 
196  if (write_parallel_files)
197  {
198  // Parallel xdr mesh files aren't implemented yet; until they
199  // are we'll just warn the user and write a serial file.
200  libMesh::out << "Warning! Parallel xda/xdr is not yet implemented.\n";
201  libMesh::out << "Writing a serialized file instead." << std::endl;
202 
203  // write subdomain names
205 
206  // write connectivity
207  this->write_serialized_connectivity (io, cast_int<dof_id_type>(n_elem));
208 
209  // write the nodal locations
210  this->write_serialized_nodes (io, cast_int<dof_id_type>(max_node_id));
211 
212  // write the side boundary condition information
213  this->write_serialized_side_bcs (io, n_side_bcs);
214 
215  // write the nodeset information
216  this->write_serialized_nodesets (io, n_nodesets);
217 
218  // write the edge boundary condition information
219  this->write_serialized_edge_bcs (io, n_edge_bcs);
220 
221  // write the "shell face" boundary condition information
222  this->write_serialized_shellface_bcs (io, n_shellface_bcs);
223  }
224  else
225  {
226  // write subdomain names
228 
229  // write connectivity
230  this->write_serialized_connectivity (io, cast_int<dof_id_type>(n_elem));
231 
232  // write the nodal locations
233  this->write_serialized_nodes (io, cast_int<dof_id_type>(max_node_id));
234 
235  // write the side boundary condition information
236  this->write_serialized_side_bcs (io, n_side_bcs);
237 
238  // write the nodeset information
239  this->write_serialized_nodesets (io, n_nodesets);
240 
241  // write the edge boundary condition information
242  this->write_serialized_edge_bcs (io, n_edge_bcs);
243 
244  // write the "shell face" boundary condition information
245  this->write_serialized_shellface_bcs (io, n_shellface_bcs);
246  }
247 
248  STOP_LOG("write()","XdrIO");
249 
250  // pause all processes until the writing ends -- this will
251  // protect for the pathological case where a write is
252  // followed immediately by a read. The write must be
253  // guaranteed to complete first.
254  io.close();
255  this->comm().barrier();
256 }

References _write_unique_id, binary(), boundary_condition_file_name(), libMesh::Xdr::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::ENCODE, libMesh::MeshBase::get_boundary_info(), legacy(), libMesh::MeshBase::max_node_id(), 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(), 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().

◆ write_discontinuous_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = nullptr 
)
virtualinherited

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

Definition at line 87 of file mesh_output.C.

90 {
91  LOG_SCOPE("write_discontinuous_equation_systems()", "MeshOutput");
92 
93  // We may need to gather and/or renumber a DistributedMesh to output
94  // it, making that const qualifier in our constructor a dirty lie
95  MT & my_mesh = const_cast<MT &>(*_obj);
96 
97  // If we're asked to write data that's associated with a different
98  // mesh, output files full of garbage are the result.
99  libmesh_assert_equal_to(&es.get_mesh(), _obj);
100 
101  // A non-renumbered mesh may not have a contiguous numbering, and
102  // that needs to be fixed before we can build a solution vector.
103  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
104  my_mesh.max_node_id() != my_mesh.n_nodes())
105  {
106  // If we were allowed to renumber then we should have already
107  // been properly renumbered...
108  libmesh_assert(!my_mesh.allow_renumbering());
109 
110  libmesh_do_once(libMesh::out <<
111  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
112  << std::endl;);
113 
114  my_mesh.allow_renumbering(true);
115 
116  my_mesh.renumber_nodes_and_elements();
117 
118  // Not sure what good going back to false will do here, the
119  // renumbering horses have already left the barn...
120  my_mesh.allow_renumbering(false);
121  }
122 
123  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
124 
125  // Build the list of variable names that will be written.
126  std::vector<std::string> names;
127  es.build_variable_names (names, nullptr, system_names);
128 
129  if (!_is_parallel_format)
130  {
131  // Build the nodal solution values & get the variable
132  // names from the EquationSystems object
133  std::vector<Number> soln;
134  es.build_discontinuous_solution_vector (soln, system_names);
135 
136  this->write_nodal_data_discontinuous (fname, soln, names);
137  }
138  else // _is_parallel_format
139  {
140  libmesh_not_implemented();
141  }
142 }

◆ write_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = 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.

Definition at line 31 of file mesh_output.C.

34 {
35  LOG_SCOPE("write_equation_systems()", "MeshOutput");
36 
37  // We may need to gather and/or renumber a DistributedMesh to output
38  // it, making that const qualifier in our constructor a dirty lie
39  MT & my_mesh = const_cast<MT &>(*_obj);
40 
41  // If we're asked to write data that's associated with a different
42  // mesh, output files full of garbage are the result.
43  libmesh_assert_equal_to(&es.get_mesh(), _obj);
44 
45  // A non-renumbered mesh may not have a contiguous numbering, and
46  // that needs to be fixed before we can build a solution vector.
47  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
48  my_mesh.max_node_id() != my_mesh.n_nodes())
49  {
50  // If we were allowed to renumber then we should have already
51  // been properly renumbered...
52  libmesh_assert(!my_mesh.allow_renumbering());
53 
54  libmesh_do_once(libMesh::out <<
55  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
56  << std::endl;);
57 
58  my_mesh.allow_renumbering(true);
59 
60  my_mesh.renumber_nodes_and_elements();
61 
62  // Not sure what good going back to false will do here, the
63  // renumbering horses have already left the barn...
64  my_mesh.allow_renumbering(false);
65  }
66 
68  {
69  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
70 
71  // Build the list of variable names that will be written.
72  std::vector<std::string> names;
73  es.build_variable_names (names, nullptr, system_names);
74 
75  // Build the nodal solution values & get the variable
76  // names from the EquationSystems object
77  std::vector<Number> soln;
78  es.build_solution_vector (soln, system_names);
79 
80  this->write_nodal_data (fname, soln, names);
81  }
82  else // _is_parallel_format
83  this->write_nodal_data (fname, es, system_names);
84 }

◆ write_nodal_data() [1/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names 
)
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 directly uses EquationSystems current_local_solution vectors to look up nodal values.

If not implemented, reorders the solutions into a nodal-only NumericVector and calls the above version of this function.

Reimplemented in libMesh::Nemesis_IO.

Definition at line 158 of file mesh_output.C.

161 {
162  std::vector<std::string> names;
163  es.build_variable_names (names, nullptr, system_names);
164 
165  std::unique_ptr<NumericVector<Number>> parallel_soln =
166  es.build_parallel_solution_vector(system_names);
167 
168  this->write_nodal_data (fname, *parallel_soln, names);
169 }

◆ write_nodal_data() [2/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const NumericVector< Number > &  parallel_soln,
const std::vector< std::string > &  names 
)
virtualinherited

This method may 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.

Definition at line 145 of file mesh_output.C.

148 {
149  // This is the fallback implementation for parallel I/O formats that
150  // do not yet implement proper writing in parallel, and instead rely
151  // on the full solution vector being available on all processors.
152  std::vector<Number> soln;
153  parallel_soln.localize(soln);
154  this->write_nodal_data(fname, soln, names);
155 }

◆ write_nodal_data() [3/3]

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

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::Nemesis_IO, libMesh::UCDIO, libMesh::ExodusII_IO, libMesh::GmshIO, libMesh::NameBasedIO, libMesh::GMVIO, libMesh::VTKIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 105 of file mesh_output.h.

108  { libmesh_not_implemented(); }

◆ write_nodal_data_discontinuous()

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

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

Reimplemented in libMesh::ExodusII_IO.

Definition at line 114 of file mesh_output.h.

117  { libmesh_not_implemented(); }

◆ write_parallel()

bool libMesh::XdrIO::write_parallel ( ) const
inline

Report whether we should write parallel files.

Definition at line 358 of file xdr_io.h.

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 }

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

Referenced by write().

◆ write_serialized_bc_names()

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 1170 of file xdr_io.C.

1171 {
1172  if (this->processor_id() == 0)
1173  {
1174  const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1175  info.get_sideset_name_map() : info.get_nodeset_name_map();
1176 
1177  std::vector<new_header_id_type> boundary_ids;
1178  boundary_ids.reserve(boundary_map.size());
1179 
1180  std::vector<std::string> boundary_names;
1181  boundary_names.reserve(boundary_map.size());
1182 
1183  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
1184  // return writable references in boundary_info, it's possible for the user to leave some entity names
1185  // blank. We can't write those to the XDA file.
1186  new_header_id_type n_boundary_names = 0;
1187  for (const auto & pr : boundary_map)
1188  if (!pr.second.empty())
1189  {
1190  n_boundary_names++;
1191  boundary_ids.push_back(pr.first);
1192  boundary_names.push_back(pr.second);
1193  }
1194 
1195  if (is_sideset)
1196  io.data(n_boundary_names, "# sideset id to name map");
1197  else
1198  io.data(n_boundary_names, "# nodeset id to name map");
1199  // Write out the ids and names in two vectors
1200  if (n_boundary_names)
1201  {
1202  io.data(boundary_ids);
1203  io.data(boundary_names);
1204  }
1205  }
1206 }

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

Referenced by write_serialized_bcs_helper(), and write_serialized_nodesets().

◆ write_serialized_bcs_helper()

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 953 of file xdr_io.C.

954 {
955  libmesh_assert (io.writing());
956 
957  // convenient reference to our mesh
958  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
959 
960  // and our boundary info object
961  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
962 
963  // Version 0.9.2+ introduces entity names
964  write_serialized_bc_names(io, boundary_info, true); // sideset names
965 
966  new_header_id_type n_bcs_out = n_bcs;
967  if (this->processor_id() == 0)
968  {
969  std::stringstream comment_string;
970  comment_string << "# number of " << bc_type << " boundary conditions";
971  io.data (n_bcs_out, comment_string.str().c_str());
972  }
973  n_bcs_out = 0;
974 
975  if (!n_bcs) return;
976 
977  std::vector<xdr_id_type> xfer_bcs, recv_bcs;
978  std::vector<std::size_t> bc_sizes(this->n_processors());
979 
980  // Container to catch boundary IDs handed back by BoundaryInfo
981  std::vector<boundary_id_type> bc_ids;
982 
983  // Boundary conditions are only specified for level-0 elements
984  dof_id_type n_local_level_0_elem=0;
985  for (const auto & elem : as_range(mesh.local_level_elements_begin(0),
987  {
988  if (bc_type == "side")
989  {
990  for (auto s : elem->side_index_range())
991  {
992  boundary_info.boundary_ids (elem, s, bc_ids);
993  for (const auto & bc_id : bc_ids)
994  if (bc_id != BoundaryInfo::invalid_id)
995  {
996  xfer_bcs.push_back (n_local_level_0_elem);
997  xfer_bcs.push_back (s) ;
998  xfer_bcs.push_back (bc_id);
999  }
1000  }
1001  }
1002  else if (bc_type == "edge")
1003  {
1004  for (auto e : elem->edge_index_range())
1005  {
1006  boundary_info.edge_boundary_ids (elem, e, bc_ids);
1007  for (const auto & bc_id : bc_ids)
1008  if (bc_id != BoundaryInfo::invalid_id)
1009  {
1010  xfer_bcs.push_back (n_local_level_0_elem);
1011  xfer_bcs.push_back (e) ;
1012  xfer_bcs.push_back (bc_id);
1013  }
1014  }
1015  }
1016  else if (bc_type == "shellface")
1017  {
1018  for (unsigned short sf=0; sf<2; sf++)
1019  {
1020  boundary_info.shellface_boundary_ids (elem, sf, bc_ids);
1021  for (const auto & bc_id : bc_ids)
1022  if (bc_id != BoundaryInfo::invalid_id)
1023  {
1024  xfer_bcs.push_back (n_local_level_0_elem);
1025  xfer_bcs.push_back (sf) ;
1026  xfer_bcs.push_back (bc_id);
1027  }
1028  }
1029  }
1030  else
1031  {
1032  libmesh_error_msg("bc_type not recognized: " + bc_type);
1033  }
1034 
1035  // Increment the level-0 element counter.
1036  n_local_level_0_elem++;
1037  }
1038 
1039  xfer_bcs.push_back(n_local_level_0_elem);
1040  std::size_t my_size = xfer_bcs.size();
1041  this->comm().gather (0, my_size, bc_sizes);
1042 
1043  // All processors send their xfer buffers to processor 0
1044  // Processor 0 will receive all buffers and write out the bcs
1045  if (this->processor_id() == 0)
1046  {
1047  dof_id_type elem_offset = 0;
1048  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
1049  {
1050  recv_bcs.resize(bc_sizes[pid]);
1051  if (pid == 0)
1052  recv_bcs = xfer_bcs;
1053  else
1054  this->comm().receive (pid, recv_bcs);
1055 
1056  const dof_id_type my_n_local_level_0_elem
1057  = cast_int<dof_id_type>(recv_bcs.back());
1058  recv_bcs.pop_back();
1059 
1060  for (std::size_t idx=0, rbs=recv_bcs.size(); idx<rbs; idx += 3, n_bcs_out++)
1061  recv_bcs[idx+0] += elem_offset;
1062 
1063  io.data_stream (recv_bcs.empty() ? nullptr : recv_bcs.data(),
1064  cast_int<unsigned int>(recv_bcs.size()), 3);
1065  elem_offset += my_n_local_level_0_elem;
1066  }
1067  libmesh_assert_equal_to (n_bcs, n_bcs_out);
1068  }
1069  else
1070  this->comm().send (0, xfer_bcs);
1071 }

References libMesh::as_range(), libMesh::BoundaryInfo::boundary_ids(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::BoundaryInfo::edge_boundary_ids(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshTools::Generation::Private::idx(), libMesh::BoundaryInfo::invalid_id, libMesh::libmesh_assert(), libMesh::MeshBase::local_level_elements_begin(), libMesh::MeshBase::local_level_elements_end(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::BoundaryInfo::shellface_boundary_ids(), write_serialized_bc_names(), and libMesh::Xdr::writing().

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

◆ write_serialized_connectivity()

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 298 of file xdr_io.C.

299 {
300  libmesh_assert (io.writing());
301 
302  const bool
303  write_p_level = ("." == this->polynomial_level_file_name()),
304  write_partitioning = ("." == this->partition_map_file_name()),
305  write_subdomain_id = ("." == this->subdomain_map_file_name());
306 
307  // convenient reference to our mesh
308  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
309  libmesh_assert_equal_to (n_elem, mesh.n_elem());
310 
311  // We will only write active elements and their parents.
312  const unsigned int n_active_levels = MeshTools::n_active_levels (mesh);
313  std::vector<xdr_id_type> n_global_elem_at_level(n_active_levels);
314 
315  // Find the number of local and global elements at each level
316 #ifndef NDEBUG
317  xdr_id_type tot_n_elem = 0;
318 #endif
319  for (unsigned int level=0; level<n_active_levels; level++)
320  {
321  n_global_elem_at_level[level] =
324 
325  this->comm().sum(n_global_elem_at_level[level]);
326 #ifndef NDEBUG
327  tot_n_elem += n_global_elem_at_level[level];
328 #endif
329  libmesh_assert_less_equal (n_global_elem_at_level[level], n_elem);
330  libmesh_assert_less_equal (tot_n_elem, n_elem);
331  }
332 
333  std::vector<xdr_id_type>
334  xfer_conn, recv_conn;
335  std::vector<dof_id_type>
336  n_elem_on_proc(this->n_processors()), processor_offsets(this->n_processors());
337  std::vector<xdr_id_type> output_buffer;
338  std::vector<std::size_t>
339  xfer_buf_sizes(this->n_processors());
340 
341 #ifdef LIBMESH_ENABLE_AMR
342  typedef std::map<dof_id_type, std::pair<processor_id_type, dof_id_type>> id_map_type;
343  id_map_type parent_id_map, child_id_map;
344 #endif
345 
346  dof_id_type my_next_elem=0, next_global_elem=0;
347 
348  //-------------------------------------------
349  // First write the level-0 elements directly.
350  for (const auto & elem : as_range(mesh.local_level_elements_begin(0),
352  {
353  pack_element (xfer_conn, elem);
354 #ifdef LIBMESH_ENABLE_AMR
355  parent_id_map[elem->id()] = std::make_pair(this->processor_id(),
356  my_next_elem);
357 #endif
358  ++my_next_elem;
359  }
360  xfer_conn.push_back(my_next_elem); // toss in the number of elements transferred.
361 
362  std::size_t my_size = xfer_conn.size();
363  this->comm().gather (0, my_next_elem, n_elem_on_proc);
364  this->comm().gather (0, my_size, xfer_buf_sizes);
365 
366  processor_offsets[0] = 0;
367  for (auto pid : IntRange<processor_id_type>(1, this->n_processors()))
368  processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
369 
370  // All processors send their xfer buffers to processor 0.
371  // Processor 0 will receive the data and write out the elements.
372  if (this->processor_id() == 0)
373  {
374  // Write the number of elements at this level.
375  {
376  std::string comment = "# n_elem at level 0", legend = ", [ type ";
377  if (_write_unique_id)
378  legend += "uid ";
379  if (write_partitioning)
380  legend += "pid ";
381  if (write_subdomain_id)
382  legend += "sid ";
383  if (write_p_level)
384  legend += "p_level ";
385  legend += "(n0 ... nN-1) ]";
386  comment += legend;
387  io.data (n_global_elem_at_level[0], comment.c_str());
388  }
389 
390  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
391  {
392  recv_conn.resize(xfer_buf_sizes[pid]);
393  if (pid == 0)
394  recv_conn = xfer_conn;
395  else
396  this->comm().receive (pid, recv_conn);
397 
398  // at a minimum, the buffer should contain the number of elements,
399  // which could be 0.
400  libmesh_assert (!recv_conn.empty());
401 
402  {
403  const xdr_id_type n_elem_received = recv_conn.back();
404  std::vector<xdr_id_type>::const_iterator recv_conn_iter = recv_conn.begin();
405 
406  for (xdr_id_type elem=0; elem<n_elem_received; elem++, next_global_elem++)
407  {
408  output_buffer.clear();
409 
410  // n. nodes
411  const xdr_id_type n_nodes = *recv_conn_iter;
412  ++recv_conn_iter;
413 
414  // type
415  output_buffer.push_back(*recv_conn_iter);
416  ++recv_conn_iter;
417 
418  // unique_id
419  if (_write_unique_id)
420  output_buffer.push_back(*recv_conn_iter);
421  ++recv_conn_iter;
422 
423  // processor id
424  if (write_partitioning)
425  output_buffer.push_back(*recv_conn_iter);
426  ++recv_conn_iter;
427 
428  // subdomain id
429  if (write_subdomain_id)
430  output_buffer.push_back(*recv_conn_iter);
431  ++recv_conn_iter;
432 
433 #ifdef LIBMESH_ENABLE_AMR
434  // p level
435  if (write_p_level)
436  output_buffer.push_back(*recv_conn_iter);
437  ++recv_conn_iter;
438 #endif
439  for (dof_id_type node=0; node<n_nodes; node++, ++recv_conn_iter)
440  output_buffer.push_back(*recv_conn_iter);
441 
442  io.data_stream
443  (output_buffer.data(),
444  cast_int<unsigned int>(output_buffer.size()),
445  cast_int<unsigned int>(output_buffer.size()));
446  }
447  }
448  }
449  }
450  else
451  this->comm().send (0, xfer_conn);
452 
453 #ifdef LIBMESH_ENABLE_AMR
454  //--------------------------------------------------------------------
455  // Next write the remaining elements indirectly through their parents.
456  // This will insure that the children are written in the proper order
457  // so they can be reconstructed properly.
458  for (unsigned int level=1; level<n_active_levels; level++)
459  {
460  xfer_conn.clear();
461 
462  dof_id_type my_n_elem_written_at_level = 0;
463  for (const auto & parent : as_range(mesh.local_level_elements_begin(level-1),
464  mesh.local_level_elements_end(level-1)))
465  if (!parent->active()) // we only want the parents elements at this level, and
466  { // there is no direct iterator for this obscure use
467  id_map_type::iterator pos = parent_id_map.find(parent->id());
468  libmesh_assert (pos != parent_id_map.end());
469  const processor_id_type parent_pid = pos->second.first;
470  const dof_id_type parent_id = pos->second.second;
471  parent_id_map.erase(pos);
472 
473  for (auto & child : parent->child_ref_range())
474  {
475  pack_element (xfer_conn, &child, parent_id, parent_pid);
476 
477  // this aproach introduces the possibility that we write
478  // non-local elements. These elements may well be parents
479  // at the next step
480  child_id_map[child.id()] = std::make_pair (child.processor_id(),
481  my_n_elem_written_at_level++);
482  my_next_elem++;
483  }
484  }
485  xfer_conn.push_back(my_n_elem_written_at_level);
486  my_size = xfer_conn.size();
487  this->comm().gather (0, my_size, xfer_buf_sizes);
488 
489  // Processor 0 will receive the data and write the elements.
490  if (this->processor_id() == 0)
491  {
492  // Write the number of elements at this level.
493  {
494  char buf[80];
495  std::sprintf(buf, "# n_elem at level %u", level);
496  std::string comment(buf), legend = ", [ type ";
497 
498  if (_write_unique_id)
499  legend += "uid ";
500  legend += "parent ";
501  if (write_partitioning)
502  legend += "pid ";
503  if (write_subdomain_id)
504  legend += "sid ";
505  if (write_p_level)
506  legend += "p_level ";
507  legend += "(n0 ... nN-1) ]";
508  comment += legend;
509  io.data (n_global_elem_at_level[level], comment.c_str());
510  }
511 
512  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
513  {
514  recv_conn.resize(xfer_buf_sizes[pid]);
515  if (pid == 0)
516  recv_conn = xfer_conn;
517  else
518  this->comm().receive (pid, recv_conn);
519 
520  // at a minimum, the buffer should contain the number of elements,
521  // which could be 0.
522  libmesh_assert (!recv_conn.empty());
523 
524  {
525  const xdr_id_type n_elem_received = recv_conn.back();
526  std::vector<xdr_id_type>::const_iterator recv_conn_iter = recv_conn.begin();
527 
528  for (xdr_id_type elem=0; elem<n_elem_received; elem++, next_global_elem++)
529  {
530  output_buffer.clear();
531 
532  // n. nodes
533  const xdr_id_type n_nodes = *recv_conn_iter;
534  ++recv_conn_iter;
535 
536  // type
537  output_buffer.push_back(*recv_conn_iter);
538  ++recv_conn_iter;
539 
540  // unique_id
541  if (_write_unique_id)
542  output_buffer.push_back(*recv_conn_iter);
543  ++recv_conn_iter;
544 
545  // parent local id
546  const xdr_id_type parent_local_id = *recv_conn_iter;
547  ++recv_conn_iter;
548 
549  // parent processor id
550  const xdr_id_type parent_pid = *recv_conn_iter;
551  ++recv_conn_iter;
552 
553  output_buffer.push_back (parent_local_id+processor_offsets[parent_pid]);
554 
555  // processor id
556  if (write_partitioning)
557  output_buffer.push_back(*recv_conn_iter);
558  ++recv_conn_iter;
559 
560  // subdomain id
561  if (write_subdomain_id)
562  output_buffer.push_back(*recv_conn_iter);
563  ++recv_conn_iter;
564 
565  // p level
566  if (write_p_level)
567  output_buffer.push_back(*recv_conn_iter);
568  ++recv_conn_iter;
569 
570  for (xdr_id_type node=0; node<n_nodes; node++, ++recv_conn_iter)
571  output_buffer.push_back(*recv_conn_iter);
572 
573  io.data_stream
574  (output_buffer.data(),
575  cast_int<unsigned int>(output_buffer.size()),
576  cast_int<unsigned int>(output_buffer.size()));
577  }
578  }
579  }
580  }
581  else
582  this->comm().send (0, xfer_conn);
583 
584  // update the processor_offsets
585  processor_offsets[0] = processor_offsets.back() + n_elem_on_proc.back();
586  this->comm().gather (0, my_n_elem_written_at_level, n_elem_on_proc);
587  for (auto pid : IntRange<processor_id_type>(1, this->n_processors()))
588  processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
589 
590  // Now, at the next level we will again iterate over local parents. However,
591  // those parents may have been written by other processors (at this step),
592  // so we need to gather them into our *_id_maps.
593  {
594  std::map<processor_id_type, std::vector<dof_id_type>> requested_ids;
595 
596  for (const auto & elem : as_range(mesh.local_level_elements_begin(level),
598  if (!child_id_map.count(elem->id()))
599  {
600  libmesh_assert_not_equal_to (elem->parent()->processor_id(), this->processor_id());
601  const processor_id_type pid = elem->parent()->processor_id();
602  if (pid != this->processor_id())
603  requested_ids[pid].push_back(elem->id());
604  }
605 
606  auto gather_functor =
607  [& child_id_map]
608  (processor_id_type libmesh_dbg_var(pid),
609  const std::vector<dof_id_type> & ids,
610  std::vector<dof_id_type> & data)
611  {
612  const std::size_t ids_size = ids.size();
613  data.resize(ids_size);
614 
615  // Fill those requests by overwriting the requested ids
616  for (std::size_t i=0; i != ids_size; i++)
617  {
618  libmesh_assert (child_id_map.count(ids[i]));
619  libmesh_assert_equal_to (child_id_map[ids[i]].first, pid);
620 
621  data[i] = child_id_map[ids[i]].second;
622  }
623  };
624 
625  auto action_functor =
626  [& child_id_map]
627  (processor_id_type pid,
628  const std::vector<dof_id_type> & ids,
629  const std::vector<dof_id_type> & data)
630  {
631  std::size_t data_size = data.size();
632 
633  for (std::size_t i=0; i != data_size; i++)
634  child_id_map[ids[i]] =
635  std::make_pair (pid, data[i]);
636  };
637 
638  // Trade ids back and forth
639  const dof_id_type * ex = nullptr;
640  Parallel::pull_parallel_vector_data
641  (this->comm(), requested_ids, gather_functor, action_functor, ex);
642 
643  // overwrite the parent_id_map with the child_id_map, but
644  // use std::map::swap() for efficiency.
645  parent_id_map.swap(child_id_map);
646  child_id_map.clear();
647  }
648  }
649 #endif // LIBMESH_ENABLE_AMR
650  if (this->processor_id() == 0)
651  libmesh_assert_equal_to (next_global_elem, n_elem);
652 
653 }

References _write_unique_id, libMesh::as_range(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), data, libMesh::Xdr::data_stream(), libMesh::libmesh_assert(), 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(), subdomain_map_file_name(), and libMesh::Xdr::writing().

Referenced by write().

◆ write_serialized_edge_bcs()

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 1082 of file xdr_io.C.

1083 {
1084  write_serialized_bcs_helper(io, n_edge_bcs, "edge");
1085 }

References write_serialized_bcs_helper().

Referenced by write().

◆ write_serialized_nodes()

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 657 of file xdr_io.C.

658 {
659  // convenient reference to our mesh
660  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
661  libmesh_assert_equal_to (max_node_id, mesh.max_node_id());
662 
663  std::vector<dof_id_type> xfer_ids;
664  std::vector<Real> xfer_coords;
665  std::vector<Real> & coords=xfer_coords;
666 
667  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
668  std::vector<std::vector<Real>> recv_coords(this->n_processors());
669 
670 #ifdef LIBMESH_ENABLE_UNIQUE_ID
671  std::vector<xdr_id_type> xfer_unique_ids;
672  std::vector<xdr_id_type> & unique_ids=xfer_unique_ids;
673  std::vector<std::vector<xdr_id_type>> recv_unique_ids (this->n_processors());
674 #endif // LIBMESH_ENABLE_UNIQUE_ID
675 
676  std::size_t n_written=0;
677 
678  MeshBase::const_node_iterator node_iter = mesh.local_nodes_begin();
679  const MeshBase::const_node_iterator nodes_end = mesh.local_nodes_end();
680 
681  for (std::size_t blk=0, last_node=0; last_node<max_node_id; blk++)
682  {
683  const std::size_t first_node = blk*io_blksize;
684  last_node = std::min((blk+1)*io_blksize, std::size_t(max_node_id));
685 
686  const std::size_t tot_id_size = last_node - first_node;
687 
688  // Build up the xfer buffers on each processor
689  xfer_ids.clear();
690  xfer_coords.clear();
691 
692  for (; node_iter != nodes_end; ++node_iter)
693  {
694  const Node & node = **node_iter;
695  libmesh_assert_greater_equal(node.id(), first_node);
696  if (node.id() >= last_node)
697  break;
698 
699  xfer_ids.push_back(node.id());
700  xfer_coords.push_back(node(0));
701 #if LIBMESH_DIM > 1
702  xfer_coords.push_back(node(1));
703 #endif
704 #if LIBMESH_DIM > 2
705  xfer_coords.push_back(node(2));
706 #endif
707  }
708 
709  //-------------------------------------
710  // Send the xfer buffers to processor 0
711  std::vector<std::size_t> ids_size;
712 
713  const std::size_t my_ids_size = xfer_ids.size();
714 
715  // explicitly gather ids_size
716  this->comm().gather (0, my_ids_size, ids_size);
717 
718  // We will have lots of simultaneous receives if we are
719  // processor 0, so let's use nonblocking receives.
720  std::vector<Parallel::Request>
721  id_request_handles(this->n_processors()-1),
722  coord_request_handles(this->n_processors()-1);
723 
724  Parallel::MessageTag
725  id_tag = mesh.comm().get_unique_tag(),
726  coord_tag = mesh.comm().get_unique_tag();
727 
728  // Post the receives -- do this on processor 0 only.
729  if (this->processor_id() == 0)
730  {
731  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
732  {
733  recv_ids[pid].resize(ids_size[pid]);
734  recv_coords[pid].resize(ids_size[pid]*LIBMESH_DIM);
735 
736  if (pid == 0)
737  {
738  recv_ids[0] = xfer_ids;
739  recv_coords[0] = xfer_coords;
740  }
741  else
742  {
743  this->comm().receive (pid, recv_ids[pid],
744  id_request_handles[pid-1],
745  id_tag);
746  this->comm().receive (pid, recv_coords[pid],
747  coord_request_handles[pid-1],
748  coord_tag);
749  }
750  }
751  }
752  else
753  {
754  // Send -- do this on all other processors.
755  this->comm().send(0, xfer_ids, id_tag);
756  this->comm().send(0, xfer_coords, coord_tag);
757  }
758 
759  // -------------------------------------------------------
760  // Receive the messages and write the output on processor 0.
761  if (this->processor_id() == 0)
762  {
763  // Wait for all the receives to complete. We have no
764  // need for the statuses since we already know the
765  // buffer sizes.
766  Parallel::wait (id_request_handles);
767  Parallel::wait (coord_request_handles);
768 
769 #ifndef NDEBUG
770  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
771  libmesh_assert_equal_to(recv_coords[pid].size(),
772  recv_ids[pid].size()*LIBMESH_DIM);
773 #endif
774 
775  // Write the coordinates in this block.
776  // Some of these coordinates may correspond to ids for which
777  // no node exists, if we have a discontiguous node
778  // numbering!
779 
780  // Write invalid values for unused node ids
781  coords.clear();
782  coords.resize (3*tot_id_size, std::numeric_limits<Real>::quiet_NaN());
783 
784  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
785  for (auto idx : index_range(recv_ids[pid]))
786  {
787  libmesh_assert_less_equal(first_node, recv_ids[pid][idx]);
788  const std::size_t local_idx = recv_ids[pid][idx] - first_node;
789  libmesh_assert_less(local_idx, tot_id_size);
790 
791  libmesh_assert_less ((3*local_idx+2), coords.size());
792  libmesh_assert_less ((LIBMESH_DIM*idx+LIBMESH_DIM-1), recv_coords[pid].size());
793 
794  coords[3*local_idx+0] = recv_coords[pid][LIBMESH_DIM*idx+0];
795 #if LIBMESH_DIM > 1
796  coords[3*local_idx+1] = recv_coords[pid][LIBMESH_DIM*idx+1];
797 #else
798  coords[3*local_idx+1] = 0.;
799 #endif
800 #if LIBMESH_DIM > 2
801  coords[3*local_idx+2] = recv_coords[pid][LIBMESH_DIM*idx+2];
802 #else
803  coords[3*local_idx+2] = 0.;
804 #endif
805 
806  n_written++;
807  }
808 
809  io.data_stream (coords.empty() ? nullptr : coords.data(),
810  cast_int<unsigned int>(coords.size()), 3);
811  }
812  }
813 
814  if (this->processor_id() == 0)
815  libmesh_assert_less_equal (n_written, max_node_id);
816 
817 #ifdef LIBMESH_ENABLE_UNIQUE_ID
818  // XDR unsigned char doesn't work as anticipated
819  unsigned short write_unique_ids = 1;
820 #else
821  unsigned short write_unique_ids = 0;
822 #endif
823  if (this->processor_id() == 0)
824  io.data (write_unique_ids, "# presence of unique ids");
825 
826 #ifdef LIBMESH_ENABLE_UNIQUE_ID
827  n_written = 0;
828 
829  node_iter = mesh.local_nodes_begin();
830 
831  for (std::size_t blk=0, last_node=0; last_node<max_node_id; blk++)
832  {
833  const std::size_t first_node = blk*io_blksize;
834  last_node = std::min((blk+1)*io_blksize, std::size_t(max_node_id));
835 
836  const std::size_t tot_id_size = last_node - first_node;
837 
838  // Build up the xfer buffers on each processor
839  xfer_ids.clear();
840  xfer_ids.reserve(tot_id_size);
841  xfer_unique_ids.clear();
842  xfer_unique_ids.reserve(tot_id_size);
843 
844  for (; node_iter != nodes_end; ++node_iter)
845  {
846  const Node & node = **node_iter;
847  libmesh_assert_greater_equal(node.id(), first_node);
848  if (node.id() >= last_node)
849  break;
850 
851  xfer_ids.push_back(node.id());
852  xfer_unique_ids.push_back(node.unique_id());
853  }
854 
855  //-------------------------------------
856  // Send the xfer buffers to processor 0
857  std::vector<std::size_t> ids_size;
858 
859  const std::size_t my_ids_size = xfer_ids.size();
860 
861  // explicitly gather ids_size
862  this->comm().gather (0, my_ids_size, ids_size);
863 
864  // We will have lots of simultaneous receives if we are
865  // processor 0, so let's use nonblocking receives.
866  std::vector<Parallel::Request>
867  unique_id_request_handles(this->n_processors()-1),
868  id_request_handles(this->n_processors()-1);
869 
870  Parallel::MessageTag
871  unique_id_tag = mesh.comm().get_unique_tag(),
872  id_tag = mesh.comm().get_unique_tag();
873 
874  // Post the receives -- do this on processor 0 only.
875  if (this->processor_id() == 0)
876  {
877  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
878  {
879  recv_ids[pid].resize(ids_size[pid]);
880  recv_unique_ids[pid].resize(ids_size[pid]);
881 
882  if (pid == 0)
883  {
884  recv_ids[0] = xfer_ids;
885  recv_unique_ids[0] = xfer_unique_ids;
886  }
887  else
888  {
889  this->comm().receive (pid, recv_ids[pid],
890  id_request_handles[pid-1],
891  id_tag);
892  this->comm().receive (pid, recv_unique_ids[pid],
893  unique_id_request_handles[pid-1],
894  unique_id_tag);
895  }
896  }
897  }
898  else
899  {
900  // Send -- do this on all other processors.
901  this->comm().send(0, xfer_ids, id_tag);
902  this->comm().send(0, xfer_unique_ids, unique_id_tag);
903  }
904 
905  // -------------------------------------------------------
906  // Receive the messages and write the output on processor 0.
907  if (this->processor_id() == 0)
908  {
909  // Wait for all the receives to complete. We have no
910  // need for the statuses since we already know the
911  // buffer sizes.
912  Parallel::wait (id_request_handles);
913  Parallel::wait (unique_id_request_handles);
914 
915 #ifndef NDEBUG
916  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
917  libmesh_assert_equal_to
918  (recv_ids[pid].size(), recv_unique_ids[pid].size());
919 #endif
920 
921  libmesh_assert_less_equal
922  (tot_id_size, std::min(io_blksize, std::size_t(max_node_id)));
923 
924  // Write the unique ids in this block.
925  unique_ids.clear();
926  unique_ids.resize(tot_id_size, unique_id_type(-1));
927 
928  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
929  for (auto idx : index_range(recv_ids[pid]))
930  {
931  libmesh_assert_less_equal(first_node, recv_ids[pid][idx]);
932  const std::size_t local_idx = recv_ids[pid][idx] - first_node;
933  libmesh_assert_less (local_idx, unique_ids.size());
934 
935  unique_ids[local_idx] = recv_unique_ids[pid][idx];
936 
937  n_written++;
938  }
939 
940  io.data_stream (unique_ids.empty() ? nullptr : unique_ids.data(),
941  cast_int<unsigned int>(unique_ids.size()), 1);
942  }
943  }
944 
945  if (this->processor_id() == 0)
946  libmesh_assert_less_equal (n_written, max_node_id);
947 
948 #endif // LIBMESH_ENABLE_UNIQUE_ID
949 }

References libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::DofObject::id(), libMesh::MeshTools::Generation::Private::idx(), libMesh::index_range(), io_blksize, libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), libMesh::MeshBase::max_node_id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::unique_id().

Referenced by write().

◆ write_serialized_nodesets()

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 1096 of file xdr_io.C.

1097 {
1098  libmesh_assert (io.writing());
1099 
1100  // convenient reference to our mesh
1101  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
1102 
1103  // and our boundary info object
1104  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1105 
1106  // Version 0.9.2+ introduces entity names
1107  write_serialized_bc_names(io, boundary_info, false); // nodeset names
1108 
1109  new_header_id_type n_nodesets_out = n_nodesets;
1110  if (this->processor_id() == 0)
1111  io.data (n_nodesets_out, "# number of nodesets");
1112  n_nodesets_out = 0;
1113 
1114  if (!n_nodesets) return;
1115 
1116  std::vector<xdr_id_type> xfer_bcs, recv_bcs;
1117  std::vector<std::size_t> bc_sizes(this->n_processors());
1118 
1119  // Container to catch boundary IDs handed back by BoundaryInfo
1120  std::vector<boundary_id_type> nodeset_ids;
1121 
1122  dof_id_type n_node=0;
1123  for (const auto & node : mesh.local_node_ptr_range())
1124  {
1125  boundary_info.boundary_ids (node, nodeset_ids);
1126  for (const auto & bc_id : nodeset_ids)
1127  if (bc_id != BoundaryInfo::invalid_id)
1128  {
1129  xfer_bcs.push_back (node->id());
1130  xfer_bcs.push_back (bc_id);
1131  }
1132  }
1133 
1134  xfer_bcs.push_back(n_node);
1135  std::size_t my_size = xfer_bcs.size();
1136  this->comm().gather (0, my_size, bc_sizes);
1137 
1138  // All processors send their xfer buffers to processor 0
1139  // Processor 0 will receive all buffers and write out the bcs
1140  if (this->processor_id() == 0)
1141  {
1142  dof_id_type node_offset = 0;
1143  for (auto pid : IntRange<processor_id_type>(0, this->n_processors()))
1144  {
1145  recv_bcs.resize(bc_sizes[pid]);
1146  if (pid == 0)
1147  recv_bcs = xfer_bcs;
1148  else
1149  this->comm().receive (pid, recv_bcs);
1150 
1151  const dof_id_type my_n_node =
1152  cast_int<dof_id_type>(recv_bcs.back());
1153  recv_bcs.pop_back();
1154 
1155  for (std::size_t idx=0, rbs=recv_bcs.size(); idx<rbs; idx += 2, n_nodesets_out++)
1156  recv_bcs[idx+0] += node_offset;
1157 
1158  io.data_stream (recv_bcs.empty() ? nullptr : recv_bcs.data(),
1159  cast_int<unsigned int>(recv_bcs.size()), 2);
1160  node_offset += my_n_node;
1161  }
1162  libmesh_assert_equal_to (n_nodesets, n_nodesets_out);
1163  }
1164  else
1165  this->comm().send (0, xfer_bcs);
1166 }

References libMesh::BoundaryInfo::boundary_ids(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshTools::Generation::Private::idx(), libMesh::BoundaryInfo::invalid_id, libMesh::libmesh_assert(), libMesh::MeshBase::local_node_ptr_range(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), write_serialized_bc_names(), and libMesh::Xdr::writing().

Referenced by write().

◆ write_serialized_shellface_bcs()

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 1089 of file xdr_io.C.

1090 {
1091  write_serialized_bcs_helper(io, n_shellface_bcs, "shellface");
1092 }

References write_serialized_bcs_helper().

Referenced by write().

◆ write_serialized_side_bcs()

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 1075 of file xdr_io.C.

1076 {
1077  write_serialized_bcs_helper(io, n_side_bcs, "side");
1078 }

References write_serialized_bcs_helper().

Referenced by write().

◆ write_serialized_subdomain_names()

void libMesh::XdrIO::write_serialized_subdomain_names ( Xdr io) const
private

Write subdomain name information - NEW in 0.9.2 format.

Definition at line 260 of file xdr_io.C.

261 {
262  if (this->processor_id() == 0)
263  {
264  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
265 
266  const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
267 
268  std::vector<new_header_id_type> subdomain_ids;
269  subdomain_ids.reserve(subdomain_map.size());
270 
271  std::vector<std::string> subdomain_names;
272  subdomain_names.reserve(subdomain_map.size());
273 
274  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
275  // return writable references in mesh_base, it's possible for the user to leave some entity names
276  // blank. We can't write those to the XDA file.
277  new_header_id_type n_subdomain_names = 0;
278  for (const auto & pr : subdomain_map)
279  if (!pr.second.empty())
280  {
281  n_subdomain_names++;
282  subdomain_ids.push_back(pr.first);
283  subdomain_names.push_back(pr.second);
284  }
285 
286  io.data(n_subdomain_names, "# subdomain id to name map");
287  // Write out the ids and names in two vectors
288  if (n_subdomain_names)
289  {
290  io.data(subdomain_ids);
291  io.data(subdomain_names);
292  }
293  }
294 }

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 write().

Member Data Documentation

◆ _ascii_precision

unsigned int libMesh::MeshOutput< MeshBase >::_ascii_precision
privateinherited

Precision to use when writing ASCII files.

Definition at line 195 of file mesh_output.h.

◆ _bc_file_name

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

Definition at line 342 of file xdr_io.h.

Referenced by boundary_condition_file_name().

◆ _binary

bool libMesh::XdrIO::_binary
private

Definition at line 335 of file xdr_io.h.

Referenced by binary().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _field_width

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().

◆ _is_parallel_format [1/2]

const bool libMesh::MeshInput< MeshBase >::_is_parallel_format
privateinherited

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 121 of file mesh_input.h.

◆ _is_parallel_format [2/2]

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 172 of file mesh_output.h.

◆ _legacy

bool libMesh::XdrIO::_legacy
private

Definition at line 336 of file xdr_io.h.

Referenced by legacy().

◆ _obj

MeshBase * libMesh::MeshInput< MeshBase >::_obj
privateinherited

A pointer to a non-const object object.

This allows us to read the object from file.

Definition at line 114 of file mesh_input.h.

◆ _p_level_file

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

Definition at line 345 of file xdr_io.h.

Referenced by polynomial_level_file_name().

◆ _partition_map_file

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

Definition at line 343 of file xdr_io.h.

Referenced by partition_map_file_name().

◆ _serial_only_needed_on_proc_0

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 181 of file mesh_output.h.

◆ _subdomain_map_file

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

Definition at line 344 of file xdr_io.h.

Referenced by subdomain_map_file_name().

◆ _version

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

Definition at line 341 of file xdr_io.h.

Referenced by version().

◆ _write_parallel

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().

◆ _write_serial

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().

◆ _write_unique_id

bool libMesh::XdrIO::_write_unique_id
private

Definition at line 339 of file xdr_io.h.

Referenced by write(), and write_serialized_connectivity().

◆ elems_of_dimension

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited

A vector of bools describing what dimension elements have been encountered when reading a mesh.

Definition at line 97 of file mesh_input.h.

◆ io_blksize

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:
libMesh::XdrIO::write_serialized_subdomain_names
void write_serialized_subdomain_names(Xdr &io) const
Write subdomain name information - NEW in 0.9.2 format.
Definition: xdr_io.C:260
libMesh::XdrIO::io_blksize
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:350
libMesh::XdrIO::_subdomain_map_file
std::string _subdomain_map_file
Definition: xdr_io.h:344
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::XdrIO::xdr_id_type
largest_id_type xdr_id_type
Definition: xdr_io.h:57
libMesh::subdomain_id_type
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all....
Definition: id_types.h:43
libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero.
Definition: mesh_output.h:181
libMesh::MeshBase::set_n_partitions
unsigned int & set_n_partitions()
Definition: mesh_base.h:1667
libMesh::MeshBase::reserve_nodes
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
libMesh::MeshTools::n_elem
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:705
libMesh::Elem::JUST_REFINED
Definition: elem.h:1172
libMesh::unique_id_type
uint8_t unique_id_type
Definition: id_types.h:86
libMesh::XdrIO::version
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
libMesh::MeshBase::get_boundary_info
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:132
libMesh::XdrIO::binary
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: xdr_io.h:103
libMesh::MeshBase::is_serial
virtual bool is_serial() const
Definition: mesh_base.h:159
libMesh::XdrIO::read_serialized_edge_bcs
void read_serialized_edge_bcs(Xdr &io, T)
Read the edge boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1900
libMesh::XdrIO::boundary_condition_file_name
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
libMesh::XdrIO::write_serialized_bcs_helper
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:953
libMesh::BoundaryInfo::n_boundary_conds
std::size_t n_boundary_conds() const
Definition: boundary_info.C:1615
libMesh::XdrIO::_p_level_file
std::string _p_level_file
Definition: xdr_io.h:345
libMesh::XdrIO::_partition_map_file
std::string _partition_map_file
Definition: xdr_io.h:343
libMesh::MeshBase::local_nodes_begin
virtual node_iterator local_nodes_begin()=0
Iterate over local nodes (nodes whose processor_id() matches the current processor).
libMesh::MeshBase::n_elem
virtual dof_id_type n_elem() const =0
libMesh::index_range
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:106
libMesh::XdrIO::read_header
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:1340
libMesh::XdrIO::_write_serial
bool _write_serial
Definition: xdr_io.h:337
libMesh::XdrIO::subdomain_map_file_name
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::MeshBase::set_subdomain_name_map
std::map< subdomain_id_type, std::string > & set_subdomain_name_map()
Definition: mesh_base.h:1631
libMesh::BoundaryInfo::n_shellface_conds
std::size_t n_shellface_conds() const
Definition: boundary_info.C:1658
libMesh::MeshBase::local_level_elements_end
virtual element_iterator local_level_elements_end(unsigned int level)=0
libMesh::WRITE
Definition: enum_xdr_mode.h:40
libMesh::BoundaryInfo::n_edge_conds
std::size_t n_edge_conds() const
Definition: boundary_info.C:1636
libMesh::MeshBase::mesh_dimension
unsigned int mesh_dimension() const
Definition: mesh_base.C:135
libMesh::DofObject::set_unique_id
unique_id_type & set_unique_id()
Definition: dof_object.h:797
libMesh::MeshBase::max_node_id
virtual dof_id_type max_node_id() const =0
libMesh::XdrIO::write_serialized_connectivity
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:298
libMesh::XdrIO::read_serialized_side_bcs
void read_serialized_side_bcs(Xdr &io, T)
Read the side boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1892
libMesh::boundary_id_type
int8_t boundary_id_type
Definition: id_types.h:51
libMesh::MeshBase::elem_ptr
virtual const Elem * elem_ptr(const dof_id_type i) const =0
libMesh::MeshBase::local_level_elements_begin
virtual element_iterator local_level_elements_begin(unsigned int level)=0
libMesh::XdrIO::write_parallel
bool write_parallel() const
Report whether we should write parallel files.
Definition: xdr_io.h:358
libMesh::MeshBase::query_elem_ptr
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
libMesh::XdrIO::read_serialized_shellface_bcs
void read_serialized_shellface_bcs(Xdr &io, T)
Read the "shell face" boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1908
libMesh::MeshInput< MeshBase >::_obj
MeshBase * _obj
A pointer to a non-const object object.
Definition: mesh_input.h:114
libMesh::XdrIO::polynomial_level_file_name
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
libMesh::XdrIO::_legacy
bool _legacy
Definition: xdr_io.h:336
libMesh::XdrIO::_write_unique_id
bool _write_unique_id
Definition: xdr_io.h:339
libMesh::XdrIO::write_serialized_bc_names
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:1170
libMesh::XdrIO::version_at_least_1_1_0
bool version_at_least_1_1_0() const
Definition: xdr_io.C:2089
libMesh::XdrIO::_binary
bool _binary
Definition: xdr_io.h:335
libMesh::XdrIO::read_serialized_nodes
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:1650
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::XdrIO::_write_parallel
bool _write_parallel
Definition: xdr_io.h:338
libMesh::ParallelObject::ParallelObject
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
Definition: parallel_object.h:63
libMesh::NumericVector::localize
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
libMesh::ParallelObject::n_processors
processor_id_type n_processors() const
Definition: parallel_object.h:100
libMesh::XdrIO::partition_map_file_name
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
libMesh::XdrIO::version_at_least_0_9_2
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2072
libMesh::DECODE
Definition: enum_xdr_mode.h:39
libMesh::MeshBase::node_ptr_range
virtual SimpleRange< node_iterator > node_ptr_range()=0
libMesh::XdrIO::write_serialized_nodes
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:657
libMesh::libmesh_isnan
bool libmesh_isnan(T x)
Definition: libmesh_common.h:177
libMesh::MeshOutput< MeshBase >::_is_parallel_format
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:172
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::DofObject::invalid_id
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:421
libMesh::MeshBase::local_node_ptr_range
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
libMesh::BoundaryInfo::n_nodeset_conds
std::size_t n_nodeset_conds() const
Definition: boundary_info.C:1680
libMesh::ParallelObject::_communicator
const Parallel::Communicator & _communicator
Definition: parallel_object.h:112
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::XdrIO::version_at_least_0_9_6
bool version_at_least_0_9_6() const
Definition: xdr_io.C:2081
libMesh::MeshTools::n_active_levels
unsigned int n_active_levels(const MeshBase &mesh)
Definition: mesh_tools.C:626
libMesh::MeshTools::Generation::Private::idx
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.
Definition: mesh_generation.C:72
libMesh::as_range
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
n_nodes
const dof_id_type n_nodes
Definition: tecplot_io.C:68
libMesh::READ
Definition: enum_xdr_mode.h:41
libMesh::XdrIO::write_serialized_nodesets
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:1096
libMesh::XdrIO::read_serialized_bcs_helper
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:1801
libMesh::MeshBase::get_subdomain_name_map
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1633
libMesh::XdrIO::write_serialized_shellface_bcs
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:1089
libMesh::XdrIO::write_serialized_edge_bcs
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:1082
libMesh::MeshBase::node_ref
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:451
libMesh::XdrIO::read_serialized_bc_names
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:1980
libMesh::MeshBase::n_nodes
virtual dof_id_type n_nodes() const =0
libMesh::ENCODE
Definition: enum_xdr_mode.h:38
libMesh::MeshInput< MeshBase >::set_n_partitions
void set_n_partitions(unsigned int n_parts)
Sets the number of partitions in the mesh.
Definition: mesh_input.h:91
libMesh::XdrIO::_version
std::string _version
Definition: xdr_io.h:341
libMesh::MeshOutput< MeshBase >::write_nodal_data
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 va...
Definition: mesh_output.h:105
libMesh::MeshOutput::mesh
const MT & mesh() const
Definition: mesh_output.h:247
libMesh::Elem::type_to_n_nodes_map
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:576
value
static const bool value
Definition: xdr_io.C:56
libMesh::MeshBase::add_elem
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
libMesh::Partitioner::set_node_processor_ids
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:691
libMesh::XdrIO::read_serialized_connectivity
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:1464
libMesh::MeshTools::n_p_levels
unsigned int n_p_levels(const MeshBase &mesh)
Definition: mesh_tools.C:721
libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous
virtual void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with discontinuous data to a specified file where the nodal dat...
Definition: mesh_output.h:114
libMesh::XdrIO::write_serialized_side_bcs
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:1075
libMesh::XdrIO::legacy
bool legacy() const
Get/Set the flag indicating if we should read/write legacy.
Definition: xdr_io.h:109
data
IterBase * data
Ideally this private member data should have protected access.
Definition: variant_filter_iterator.h:337
libMesh::XdrIO::version_at_least_1_3_0
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2096
libMesh::MeshInput< MeshBase >::mesh
MeshBase & mesh()
Definition: mesh_input.h:169
libMesh::MeshOutput< MeshBase >::_obj
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:190
libMesh::MeshBase::add_point
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
libMesh::XdrIO::new_header_id_type
uint64_t new_header_id_type
Definition: xdr_io.h:63
libMesh::Elem::INACTIVE
Definition: elem.h:1174
libMesh::XdrIO::_bc_file_name
std::string _bc_file_name
Definition: xdr_io.h:342
libMesh::MeshBase::set_mesh_dimension
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:218
libMesh::Elem::build
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:246
libMesh::MeshBase::query_node_ptr
virtual const Node * query_node_ptr(const dof_id_type i) const =0
libMesh::XdrIO::read_serialized_subdomain_names
void read_serialized_subdomain_names(Xdr &io)
Read subdomain name information - NEW in 0.9.2 format.
Definition: xdr_io.C:1402
libMesh::XdrIO::_field_width
unsigned int _field_width
Definition: xdr_io.h:340
libMesh::BoundaryInfo::invalid_id
static const boundary_id_type invalid_id
Number used for internal use.
Definition: boundary_info.h:899
libMesh::out
OStreamProxy out
libMesh::MeshBase::local_nodes_end
virtual node_iterator local_nodes_end()=0
libMesh::XdrIO::old_header_id_type
uint32_t old_header_id_type
Definition: xdr_io.h:60
libMesh::XdrIO::pack_element
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:2039
libMesh::XdrIO::read_serialized_nodesets
void read_serialized_nodesets(Xdr &io, T)
Read the nodeset conditions for a parallel, distributed mesh.
Definition: xdr_io.C:1916
libMesh::MeshBase::reserve_elem
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
libMesh::MeshOutput< MeshBase >::_ascii_precision
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:195
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::MeshInput< MeshBase >::elems_of_dimension
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
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33