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
 
bool version_at_least_1_8_0 () const
 
bool is_parallel_format () const
 Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once. More...
 
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::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

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

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 new_header_id_type n_elem_integers) const
 Write the connectivity for a parallel, distributed mesh. More...
 
void write_serialized_nodes (Xdr &io, const dof_id_type n_nodes, const new_header_id_type n_node_integers) 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, const std::vector< new_header_id_type > &meta_data, T type_size)
 Read the connectivity for a parallel, distributed mesh. More...
 
void read_serialized_nodes (Xdr &io, const dof_id_type n_nodes, const std::vector< new_header_id_type > &meta_data)
 Read the nodal locations for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_bcs_helper (Xdr &io, T type_size, 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 type_size)
 Read the side boundary conditions for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_edge_bcs (Xdr &io, T type_size)
 Read the edge boundary conditions for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_shellface_bcs (Xdr &io, T type_size)
 Read the "shell face" boundary conditions for a parallel, distributed mesh. More...
 
template<typename T >
void read_serialized_nodesets (Xdr &io, T type_size)
 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, const dof_id_type parent_pid, const new_header_id_type n_elem_integers) const
 Pack an element into a transfer buffer for parallel communication. More...
 

Private Attributes

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

Static Private Attributes

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

Detailed Description

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

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

Author
Benjamin Kirk
John Peterson
Date
2004

Definition at line 51 of file xdr_io.h.

Member Typedef Documentation

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

74  :
75  MeshInput<MeshBase> (mesh,/* is_parallel_format = */ true),
76  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
78  _binary (binary_in),
79  _legacy (false),
80  _write_serial (false),
81  _write_parallel (false),
82 #ifdef LIBMESH_ENABLE_UNIQUE_ID
83  _write_unique_id (true),
84 #else
85  _write_unique_id (false),
86 #endif
87  _field_width (4), // In 0.7.0, all fields are 4 bytes, in 0.9.2+ they can vary
88  _version ("libMesh-1.8.0"),
89  _bc_file_name ("n/a"),
90  _partition_map_file ("n/a"),
91  _subdomain_map_file ("n/a"),
92  _p_level_file ("n/a")
93 {
94 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _binary
Definition: xdr_io.h:356
bool _write_parallel
Definition: xdr_io.h:359
template class LIBMESH_EXPORT MeshOutput< MeshBase >
Definition: mesh_output.C:180
std::string _partition_map_file
Definition: xdr_io.h:364
unsigned int _field_width
Definition: xdr_io.h:361
std::string _bc_file_name
Definition: xdr_io.h:363
bool _write_unique_id
Definition: xdr_io.h:360
std::string _subdomain_map_file
Definition: xdr_io.h:365
std::string _p_level_file
Definition: xdr_io.h:366
bool _write_serial
Definition: xdr_io.h:358
std::string _version
Definition: xdr_io.h:362
bool _legacy
Definition: xdr_io.h:357

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

98  :
99  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
101  _binary (binary_in)
102 {
103 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
bool _binary
Definition: xdr_io.h:356
template class LIBMESH_EXPORT MeshOutput< MeshBase >
Definition: mesh_output.C:180

◆ ~XdrIO()

libMesh::XdrIO::~XdrIO ( )
virtualdefault

Destructor.

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

Referenced by libMesh::UNVIO::nodes_out(), libMesh::FroIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

270 {
271  return _ascii_precision;
272 }
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:207

◆ binary() [1/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.

References _binary.

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

103 { return _binary; }
bool _binary
Definition: xdr_io.h:356

◆ binary() [2/2]

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

Definition at line 104 of file xdr_io.h.

References _binary.

104 { return _binary; }
bool _binary
Definition: xdr_io.h:356

◆ boundary_condition_file_name() [1/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.

References _bc_file_name.

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

146 { return _bc_file_name; }
std::string _bc_file_name
Definition: xdr_io.h:363

◆ boundary_condition_file_name() [2/2]

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

Definition at line 147 of file xdr_io.h.

References _bc_file_name.

147 { return _bc_file_name; }
std::string _bc_file_name
Definition: xdr_io.h:363

◆ comm()

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

Definition at line 97 of file parallel_object.h.

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::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), 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::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::add_vector(), 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::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), 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::MeshBase::cache_elem_data(), 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::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_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::PetscMatrix< libMesh::Number >::create_submatrix_nosort(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::RBEIMEvaluation::distribute_bfs(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), 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::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::MeshBase::get_info(), libMesh::System::get_info(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), 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_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), 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_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), 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(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), 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_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), 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(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SparsityPattern::Build::n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::MeshBase::operator==(), 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::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), FEMParameters::read(), libMesh::Nemesis_IO::read(), read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), 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::Nemesis_IO_Helper::read_var_names_impl(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), 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::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), 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().

98  { return _communicator; }
const Parallel::Communicator & _communicator

◆ get_add_sides()

virtual bool libMesh::MeshOutput< MeshBase >::get_add_sides ( )
inlineprotectedvirtualinherited
Returns
Whether or not added sides are expected to be output, to plot SIDE_DISCONTINUOUS data. Subclasses should override this if they are capable of plotting such data.

Reimplemented in libMesh::ExodusII_IO.

Definition at line 176 of file mesh_output.h.

176 { return false; }

◆ is_parallel_format()

bool libMesh::MeshInput< MeshBase >::is_parallel_format ( ) const
inlineinherited

Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once.

Definition at line 87 of file mesh_input.h.

References libMesh::MeshInput< MT >::_is_parallel_format.

87 { return this->_is_parallel_format; }
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_input.h:130

◆ legacy() [1/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.

References _legacy.

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

109 { return _legacy; }
bool _legacy
Definition: xdr_io.h:357

◆ legacy() [2/2]

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

Definition at line 110 of file xdr_io.h.

References _legacy.

110 { return _legacy; }
bool _legacy
Definition: xdr_io.h:357

◆ mesh() [1/2]

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

Definition at line 178 of file mesh_input.h.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::VTKIO::cells_to_vtk(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::UNVIO::elements_out(), libMesh::VTKIO::get_local_node_values(), libMesh::ExodusII_IO::get_sideset_data_indices(), libMesh::UNVIO::groups_in(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::UNVIO::nodes_out(), libMesh::VTKIO::nodes_to_vtk(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), read(), libMesh::CheckpointIO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::CheckpointIO::read_remote_elem(), read_serialized_bcs_helper(), read_serialized_connectivity(), read_serialized_nodes(), read_serialized_nodesets(), read_serialized_subdomain_names(), libMesh::ExodusII_IO::read_sideset_data(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::TetGenIO::write(), libMesh::Nemesis_IO::write(), write(), libMesh::CheckpointIO::write(), libMesh::ExodusII_IO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::Nemesis_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_elemsets(), libMesh::UCDIO::write_header(), libMesh::UCDIO::write_implementation(), libMesh::UCDIO::write_interior_elems(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::UCDIO::write_nodes(), libMesh::CheckpointIO::write_nodesets(), write_parallel(), libMesh::GmshIO::write_post(), write_serialized_bcs_helper(), write_serialized_connectivity(), write_serialized_nodes(), write_serialized_nodesets(), write_serialized_subdomain_names(), libMesh::ExodusII_IO::write_sideset_data(), libMesh::UCDIO::write_soln(), and libMesh::CheckpointIO::write_subdomain_names().

179 {
180  libmesh_error_msg_if(_obj == nullptr, "ERROR: _obj should not be nullptr!");
181  return *_obj;
182 }
MeshBase * _obj
A pointer to a non-const object object.
Definition: mesh_input.h:123

◆ mesh() [2/2]

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
inlineprotectedinherited

◆ n_processors()

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

Definition at line 103 of file parallel_object.h.

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

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), 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::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_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::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), 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(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::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().

104  {
105  processor_id_type returnval =
106  cast_int<processor_id_type>(_communicator.size());
107  libmesh_assert(returnval); // We never have an empty comm
108  return returnval;
109  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ pack_element()

void libMesh::XdrIO::pack_element ( std::vector< xdr_id_type > &  conn,
const Elem elem,
const dof_id_type  parent_id,
const dof_id_type  parent_pid,
const new_header_id_type  n_elem_integers 
) const
private

Pack an element into a transfer buffer for parallel communication.

Definition at line 2430 of file xdr_io.C.

References libMesh::DofObject::get_extra_integer(), 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().

2435 {
2436  libmesh_assert(elem);
2437  libmesh_assert_equal_to (elem->n_nodes(), Elem::type_to_n_nodes_map[elem->type()]);
2438 
2439  conn.push_back(elem->n_nodes());
2440 
2441  conn.push_back (elem->type());
2442 
2443  // In version 0.7.0+ "id" is stored but is not used. In version 0.9.2+
2444  // we will store unique_id instead, therefore there is no need to
2445  // check for the older version when writing the unique_id.
2446  conn.push_back (elem->unique_id());
2447 
2448  if (parent_id != DofObject::invalid_id)
2449  {
2450  conn.push_back (parent_id);
2451  libmesh_assert_not_equal_to (parent_pid, DofObject::invalid_id);
2452  conn.push_back (parent_pid);
2453  }
2454 
2455  conn.push_back (elem->processor_id());
2456  conn.push_back (elem->subdomain_id());
2457 
2458 #ifdef LIBMESH_ENABLE_AMR
2459  conn.push_back (elem->p_level());
2460 #endif
2461 
2462  for (auto n : elem->node_index_range())
2463  conn.push_back (elem->node_id(n));
2464 
2465  // Write extra elem integers to connectivity array
2466  for (unsigned int i=0; i != n_elem_integers; ++i)
2467  conn.push_back(elem->get_extra_integer(i));
2468 }
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:610
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477

◆ partition_map_file_name() [1/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.

References _partition_map_file.

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

152 { return _partition_map_file; }
std::string _partition_map_file
Definition: xdr_io.h:364

◆ partition_map_file_name() [2/2]

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

Definition at line 153 of file xdr_io.h.

References _partition_map_file.

153 { return _partition_map_file; }
std::string _partition_map_file
Definition: xdr_io.h:364

◆ polynomial_level_file_name() [1/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.

References _p_level_file.

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

164 { return _p_level_file; }
std::string _p_level_file
Definition: xdr_io.h:366

◆ polynomial_level_file_name() [2/2]

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

Definition at line 165 of file xdr_io.h.

References _p_level_file.

165 { return _p_level_file; }
std::string _p_level_file
Definition: xdr_io.h:366

◆ processor_id()

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

Definition at line 114 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), 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::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), 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_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::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::LaplaceMeshSmoother::init(), 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::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), 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::TriangulatorInterface::MeshedHole::MeshedHole(), 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::RBEIMEvaluation::node_gather_bfs(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), 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::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::DynaIO::read_mesh(), 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::Nemesis_IO_Helper::read_var_names_impl(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), 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_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), 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::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), 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().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

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

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

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

1421 {
1422  LOG_SCOPE("read()","XdrIO");
1423 
1424  // Only open the file on processor 0 -- this is especially important because
1425  // there may be an underlying bzip/bunzip going on, and multiple simultaneous
1426  // calls will produce a race condition.
1427  Xdr io (this->processor_id() == 0 ? name : "", this->binary() ? DECODE : READ);
1428 
1429  // convenient reference to our mesh
1430  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1431 
1432  // get the version string.
1433  if (this->processor_id() == 0)
1434  io.data (this->version());
1435  this->comm().broadcast (this->version());
1436 
1437  // note that for "legacy" files the first entry is an
1438  // integer -- not a string at all.
1439  this->legacy() = !(this->version().find("libMesh") < this->version().size());
1440 
1441  // Check for a legacy version format.
1442  libmesh_error_msg_if(this->legacy(), "We no longer support reading files in the legacy format.");
1443 
1444  // Read headers with the old id type if they're pre-1.3.0, or with
1445  // the new id type if they're post-1.3.0
1446  const unsigned int n_header_metadata_values = 13;
1447  std::vector<new_header_id_type> meta_data(n_header_metadata_values, sizeof(xdr_id_type));
1448  if (this->version_at_least_1_3_0())
1449  {
1450  this->read_header(io, meta_data);
1451  }
1452  else
1453  {
1454  // In pre-1.3.0 format there were only 10 metadata values in the header, but
1455  // in newer versions there are more. The unread values will be set to 0.
1456  std::vector<old_header_id_type> old_data(n_header_metadata_values, sizeof(xdr_id_type));
1457 
1458  this->read_header(io, old_data);
1459 
1460  meta_data.assign(old_data.begin(), old_data.end());
1461  }
1462 
1463  const new_header_id_type & n_elem = meta_data[0];
1464  const new_header_id_type & n_nodes = meta_data[1];
1465 
1471  if (version_at_least_0_9_2())
1472  _field_width = cast_int<unsigned int>(meta_data[2]);
1473 
1474  // On systems where uint64_t==unsigned long, we were previously
1475  // writing 64-bit unsigned integers via xdr_u_long(), a function
1476  // which is literally less suited for that task than abort() would
1477  // have been, because at least abort() would have *known* it
1478  // couldn't write rather than truncating writes to 32 bits.
1479  //
1480  // If we have files with version < 1.3.0, then we'll continue to use
1481  // 32 bit field width, regardless of whether the file thinks we
1482  // should, whenever we're on a system where the problem would have
1483  // occurred.
1484  if ((_field_width == 4) ||
1485  (!version_at_least_1_3_0() &&
1487  {
1488  uint32_t type_size = 0;
1489 
1490  // read subdomain names
1492 
1493  // read connectivity
1494  this->read_serialized_connectivity (io, cast_int<dof_id_type>(n_elem), meta_data, type_size);
1495 
1496  // read the nodal locations
1497  this->read_serialized_nodes (io, cast_int<dof_id_type>(n_nodes), meta_data);
1498 
1499  // read the side boundary conditions
1500  this->read_serialized_side_bcs (io, type_size);
1501 
1502  if (version_at_least_0_9_2())
1503  // read the nodesets
1504  this->read_serialized_nodesets (io, type_size);
1505 
1506  if (version_at_least_1_1_0())
1507  {
1508  // read the edge boundary conditions
1509  this->read_serialized_edge_bcs (io, type_size);
1510 
1511  // read the "shell face" boundary conditions
1512  this->read_serialized_shellface_bcs (io, type_size);
1513  }
1514  }
1515  else if (_field_width == 8)
1516  {
1517  uint64_t type_size = 0;
1518 
1519  // read subdomain names
1521 
1522  // read connectivity
1523  this->read_serialized_connectivity (io, cast_int<dof_id_type>(n_elem), meta_data, type_size);
1524 
1525  // read the nodal locations
1526  this->read_serialized_nodes (io, cast_int<dof_id_type>(n_nodes), meta_data);
1527 
1528  // read the boundary conditions
1529  this->read_serialized_side_bcs (io, type_size);
1530 
1531  if (version_at_least_0_9_2())
1532  // read the nodesets
1533  this->read_serialized_nodesets (io, type_size);
1534 
1535  if (version_at_least_1_1_0())
1536  {
1537  // read the edge boundary conditions
1538  this->read_serialized_edge_bcs (io, type_size);
1539 
1540  // read the "shell face" boundary conditions
1541  this->read_serialized_shellface_bcs (io, type_size);
1542  }
1543  }
1544 
1545  // set the node processor ids
1547 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
void read_serialized_nodes(Xdr &io, const dof_id_type n_nodes, const std::vector< new_header_id_type > &meta_data)
Read the nodal locations for a parallel, distributed mesh.
Definition: xdr_io.C:1968
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:850
void read_serialized_subdomain_names(Xdr &io)
Read subdomain name information - NEW in 0.9.2 format.
Definition: xdr_io.C:1664
bool legacy() const
Get/Set the flag indicating if we should read/write legacy.
Definition: xdr_io.h:109
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:851
void read_serialized_nodesets(Xdr &io, T type_size)
Read the nodeset conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2307
const Parallel::Communicator & comm() const
void read_serialized_side_bcs(Xdr &io, T type_size)
Read the side boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2283
void read_serialized_shellface_bcs(Xdr &io, T type_size)
Read the "shell face" boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2299
largest_id_type xdr_id_type
Definition: xdr_io.h:57
void read_serialized_edge_bcs(Xdr &io, T type_size)
Read the edge boundary conditions for a parallel, distributed mesh.
Definition: xdr_io.C:2291
const dof_id_type n_nodes
Definition: tecplot_io.C:67
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2497
unsigned int _field_width
Definition: xdr_io.h:361
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:1552
bool version_at_least_1_1_0() const
Definition: xdr_io.C:2489
uint64_t new_header_id_type
Definition: xdr_io.h:63
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
static const bool value
Definition: xdr_io.C:54
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2470
void read_serialized_connectivity(Xdr &io, const dof_id_type n_elem, const std::vector< new_header_id_type > &meta_data, T type_size)
Read the connectivity for a parallel, distributed mesh.
Definition: xdr_io.C:1727
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: xdr_io.h:103
processor_id_type processor_id() const

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

References _field_width, libMesh::MeshBase::add_elem_integers(), libMesh::MeshBase::add_elemset_code(), libMesh::MeshBase::add_node_integers(), boundary_condition_file_name(), TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::index_range(), 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(), version_at_least_0_9_2(), and version_at_least_1_8_0().

Referenced by read().

1553 {
1554  LOG_SCOPE("read_header()","XdrIO");
1555 
1556  // convenient reference to our mesh
1557  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1558 
1559  // Header information to be read on processor 0 and broadcast to
1560  // other procs.
1561  std::vector<std::string> node_integer_names;
1562  std::vector<std::string> elem_integer_names;
1563  std::vector<dof_id_type> elemset_codes;
1564  std::vector<std::vector<dof_id_type>> elemset_id_vecs;
1565 
1566  if (this->processor_id() == 0)
1567  {
1568  io.data (meta_data[0]);
1569  io.data (meta_data[1]);
1570  io.data (this->boundary_condition_file_name()); // libMesh::out << "bc_file=" << this->boundary_condition_file_name() << std::endl;
1571  io.data (this->subdomain_map_file_name()); // libMesh::out << "sid_file=" << this->subdomain_map_file_name() << std::endl;
1572  io.data (this->partition_map_file_name()); // libMesh::out << "pid_file=" << this->partition_map_file_name() << std::endl;
1573  io.data (this->polynomial_level_file_name()); // libMesh::out << "pl_file=" << this->polynomial_level_file_name() << std::endl;
1574 
1575  if (version_at_least_0_9_2())
1576  {
1577  // Make sure there's enough room in meta_data
1578  libmesh_assert_greater_equal(meta_data.size(), 10);
1579 
1580  io.data (meta_data[2], "# type size");
1581  io.data (meta_data[3], "# uid size");
1582  io.data (meta_data[4], "# pid size");
1583  io.data (meta_data[5], "# sid size");
1584  io.data (meta_data[6], "# p-level size");
1585  // Boundary Condition sizes
1586  io.data (meta_data[7], "# eid size"); // elem id
1587  io.data (meta_data[8], "# side size"); // side number
1588  io.data (meta_data[9], "# bid size"); // boundary id
1589  }
1590 
1591  if (version_at_least_1_8_0())
1592  {
1593  // Make sure there's enough room in meta_data
1594  libmesh_assert_greater_equal(meta_data.size(), 13);
1595 
1596  io.data (meta_data[10], "# extra integer size"); // extra integer size
1597 
1598  // Read in the node integer names and store the count in meta_data
1599  io.data(node_integer_names, "# node integer names");
1600  meta_data[11] = node_integer_names.size();
1601 
1602  // Read in the elem integer names and store the count in meta_data
1603  io.data(elem_integer_names, "# elem integer names");
1604  meta_data[12] = elem_integer_names.size();
1605 
1606  // Read in vector of elemset codes from file
1607  io.data(elemset_codes, "# elemset codes");
1608 
1609  // For each elemset code, read in the associated elemset ids from file
1610  elemset_id_vecs.resize(elemset_codes.size());
1611  for (auto i : index_range(elemset_codes))
1612  io.data(elemset_id_vecs[i]);
1613  }
1614  }
1615 
1616  // broadcast the n_elems, n_nodes, and size information
1617  this->comm().broadcast (meta_data);
1618 
1619  this->comm().broadcast (this->boundary_condition_file_name());
1620  this->comm().broadcast (this->subdomain_map_file_name());
1621  this->comm().broadcast (this->partition_map_file_name());
1622  this->comm().broadcast (this->polynomial_level_file_name());
1623  this->comm().broadcast(node_integer_names);
1624  this->comm().broadcast(elem_integer_names);
1625  this->comm().broadcast(elemset_codes);
1626  this->comm().broadcast(elemset_id_vecs);
1627 
1628  // Tell the mesh how many nodes/elements to expect. Depending on the mesh type,
1629  // this may allow for efficient adding of nodes/elements.
1630  const T & n_elem = meta_data[0];
1631  const T & n_nodes = meta_data[1];
1632 
1633  mesh.reserve_elem(cast_int<dof_id_type>(n_elem));
1634  mesh.reserve_nodes(cast_int<dof_id_type>(n_nodes));
1635 
1636  // Our mesh is pre-partitioned as it's created
1637  this->set_n_partitions(this->n_processors());
1638 
1644  if (version_at_least_0_9_2())
1645  _field_width = cast_int<unsigned int>(meta_data[2]);
1646 
1647  // Add extra node and elem integers on all procs. Note that adding
1648  // an extra node/elem "datum" of type T is implemented via repeated
1649  // calls to MeshBase::add_elem_integer(), so we only need to call
1650  // MeshBase::add_node/elem_integers() here in order to restore the
1651  // the data that we had on the Mesh previously.
1652  mesh.add_node_integers(node_integer_names);
1653  mesh.add_elem_integers(elem_integer_names);
1654 
1655  // Store the elemset_code -> {elemset ids} mapping on the Mesh
1656  for (auto i : index_range(elemset_codes))
1657  mesh.add_elemset_code(elemset_codes[i],
1658  MeshBase::elemset_type(elemset_id_vecs[i].begin(),
1659  elemset_id_vecs[i].end()));
1660 }
std::vector< unsigned int > add_elem_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each element in the mesh, one string name for each new integer.
Definition: mesh_base.C:535
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
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:850
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set...
Definition: mesh_base.C:350
const Parallel::Communicator & comm() const
std::vector< unsigned int > add_node_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each node in the mesh. ...
Definition: mesh_base.C:624
processor_id_type n_processors() const
const dof_id_type n_nodes
Definition: tecplot_io.C:67
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
unsigned int _field_width
Definition: xdr_io.h:361
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition: mesh_base.h:297
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
void set_n_partitions(unsigned int n_parts)
Sets the number of partitions in the mesh.
Definition: mesh_input.h:101
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2470
processor_id_type processor_id() const
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
bool version_at_least_1_8_0() const
Definition: xdr_io.C:2504

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

References TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::ParallelObject::processor_id(), version_at_least_0_9_2(), and version_at_least_1_3_0().

Referenced by read_serialized_bcs_helper(), and read_serialized_nodesets().

2372 {
2373  const bool read_entity_info = version_at_least_0_9_2();
2374  const bool use_new_header_type (this->version_at_least_1_3_0());
2375  if (read_entity_info)
2376  {
2377  new_header_id_type n_boundary_names = 0;
2378  std::vector<new_header_id_type> boundary_ids;
2379  std::vector<std::string> boundary_names;
2380 
2381  // Read the sideset names
2382  if (this->processor_id() == 0)
2383  {
2384  if (use_new_header_type)
2385  io.data(n_boundary_names);
2386  else
2387  {
2388  old_header_id_type temp;
2389  io.data(temp);
2390  n_boundary_names = temp;
2391  }
2392 
2393  boundary_names.resize(n_boundary_names);
2394 
2395  if (n_boundary_names)
2396  {
2397  if (use_new_header_type)
2398  io.data(boundary_ids);
2399  else
2400  {
2401  std::vector<old_header_id_type> temp(n_boundary_names);
2402  io.data(temp);
2403  boundary_ids.assign(temp.begin(), temp.end());
2404  }
2405  io.data(boundary_names);
2406  }
2407  }
2408 
2409  // Broadcast the boundary names to all processors
2410  this->comm().broadcast(n_boundary_names);
2411  if (n_boundary_names == 0)
2412  return;
2413 
2414  boundary_ids.resize(n_boundary_names);
2415  boundary_names.resize(n_boundary_names);
2416  this->comm().broadcast(boundary_ids);
2417  this->comm().broadcast(boundary_names);
2418 
2419  // Reassemble the named boundary information
2420  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
2421  info.set_sideset_name_map() : info.set_nodeset_name_map();
2422 
2423  for (unsigned int i=0; i<n_boundary_names; ++i)
2424  boundary_map.emplace(cast_int<boundary_id_type>(boundary_ids[i]), boundary_names[i]);
2425  }
2426 }
MPI_Info info
uint32_t old_header_id_type
Definition: xdr_io.h:60
const Parallel::Communicator & comm() const
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2497
uint64_t new_header_id_type
Definition: xdr_io.h:63
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2470
processor_id_type processor_id() const

◆ read_serialized_bcs_helper()

template<typename T >
void libMesh::XdrIO::read_serialized_bcs_helper ( Xdr io,
type_size,
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 2192 of file xdr_io.C.

References libMesh::BoundaryInfo::add_edge(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), boundary_condition_file_name(), TIMPI::Communicator::broadcast(), 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_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().

2193 {
2194  if (this->boundary_condition_file_name() == "n/a") return;
2195 
2196  libmesh_assert (io.reading());
2197 
2198  // convenient reference to our mesh
2199  MeshBase & mesh = MeshInput<MeshBase>::mesh();
2200 
2201  // and our boundary info object
2202  BoundaryInfo & boundary_info = mesh.get_boundary_info();
2203 
2204  // Version 0.9.2+ introduces unique ids
2205  read_serialized_bc_names(io, boundary_info, true); // sideset names
2206 
2207  std::vector<T> input_buffer;
2208 
2209  new_header_id_type n_bcs=0;
2210  if (this->processor_id() == 0)
2211  {
2212  if (this->version_at_least_1_3_0())
2213  io.data (n_bcs);
2214  else
2215  {
2216  old_header_id_type temp;
2217  io.data (temp);
2218  n_bcs = temp;
2219  }
2220  }
2221  this->comm().broadcast (n_bcs);
2222 
2223  for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_bcs; blk++)
2224  {
2225  first_bc = blk*io_blksize;
2226  last_bc = std::min((blk+1)*io_blksize, std::size_t(n_bcs));
2227 
2228  input_buffer.resize (3*(last_bc - first_bc));
2229 
2230  if (this->processor_id() == 0)
2231  io.data_stream (input_buffer.empty() ? nullptr : input_buffer.data(),
2232  cast_int<unsigned int>(input_buffer.size()));
2233 
2234  this->comm().broadcast (input_buffer);
2235 
2236  // Look for BCs in this block for all the level-0 elements we have
2237  // (not just local ones). Do this by checking all entries for
2238  // IDs matching an element we can query.
2239  // We cannot rely on nullptr neighbors at this point since the neighbor
2240  // data structure has not been initialized.
2241  for (std::size_t idx=0, ibs=input_buffer.size(); idx<ibs; idx+=3)
2242  {
2243  const dof_id_type dof_id =
2244  cast_int<dof_id_type>(input_buffer[idx+0]);
2245  const unsigned short side =
2246  cast_int<unsigned short>(input_buffer[idx+1]);
2247  const boundary_id_type bc_id =
2248  cast_int<boundary_id_type>(input_buffer[idx+2]);
2249 
2250  const Elem * elem = mesh.query_elem_ptr(dof_id);
2251  if (!elem)
2252  continue;
2253 
2254  if (bc_type == "side")
2255  {
2256  libmesh_assert_less (side, elem->n_sides());
2257  boundary_info.add_side (elem, side, bc_id);
2258  }
2259  else if (bc_type == "edge")
2260  {
2261  libmesh_assert_less (side, elem->n_edges());
2262  boundary_info.add_edge (elem, side, bc_id);
2263  }
2264  else if (bc_type == "shellface")
2265  {
2266  // Shell face IDs can only be 0 or 1.
2267  libmesh_assert_less(side, 2);
2268 
2269  boundary_info.add_shellface (elem, side, bc_id);
2270  }
2271  else
2272  {
2273  libmesh_error_msg("bc_type not recognized: " + bc_type);
2274  }
2275  }
2276  input_buffer.clear();
2277  }
2278 }
uint32_t old_header_id_type
Definition: xdr_io.h:60
const Parallel::Communicator & comm() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
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:2371
int8_t boundary_id_type
Definition: id_types.h:51
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2497
libmesh_assert(ctx)
uint64_t new_header_id_type
Definition: xdr_io.h:63
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:371
processor_id_type processor_id() const
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_serialized_connectivity()

template<typename T >
void libMesh::XdrIO::read_serialized_connectivity ( Xdr io,
const dof_id_type  n_elem,
const std::vector< new_header_id_type > &  meta_data,
type_size 
)
private

Read the connectivity for a parallel, distributed mesh.

Definition at line 1727 of file xdr_io.C.

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_node(), TIMPI::Communicator::broadcast(), libMesh::Node::build(), libMesh::Elem::build(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshBase::elem_ptr(), libMesh::MeshInput< MeshBase >::elems_of_dimension, 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::DofObject::n_extra_integers(), partition_map_file_name(), polynomial_level_file_name(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::query_node_ptr(), libMesh::Xdr::reading(), libMesh::DofObject::set_extra_integer(), libMesh::MeshBase::set_mesh_dimension(), subdomain_map_file_name(), libMesh::Elem::type_to_n_nodes_map, version_at_least_0_9_2(), and version_at_least_1_8_0().

Referenced by read().

1731 {
1732  libmesh_assert (io.reading());
1733 
1734  if (!n_elem) return;
1735 
1736  const bool
1737  read_p_level = ("." == this->polynomial_level_file_name()),
1738  read_partitioning = ("." == this->partition_map_file_name()),
1739  read_subdomain_id = ("." == this->subdomain_map_file_name());
1740 
1741  // convenient reference to our mesh
1742  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1743 
1744  // Keep track of what kinds of elements this file contains
1745  elems_of_dimension.clear();
1746  elems_of_dimension.resize(4, false);
1747 
1748  std::vector<T> conn, input_buffer(100 /* oversized ! */);
1749 
1750  int level=-1;
1751 
1752  // Version 0.9.2+ introduces unique ids
1753  const size_t unique_id_size_index = 3;
1754 
1755  const bool read_unique_id =
1756  (version_at_least_0_9_2()) &&
1757  meta_data[unique_id_size_index];
1758 
1759  // Version 1.8.0+ introduces elem integers
1760  const std::size_t n_elem_integers_index = 12;
1761  new_header_id_type n_elem_integers = 0;
1762  if (version_at_least_1_8_0())
1763  {
1764  libmesh_assert_greater_equal(meta_data.size(), 13);
1765  n_elem_integers = meta_data[n_elem_integers_index];
1766  }
1767 
1768  T n_elem_at_level=0, n_processed_at_level=0;
1769  for (dof_id_type blk=0, first_elem=0, last_elem=0;
1770  last_elem<n_elem; blk++)
1771  {
1772  first_elem = cast_int<dof_id_type>(blk*io_blksize);
1773  last_elem = cast_int<dof_id_type>(std::min(cast_int<std::size_t>((blk+1)*io_blksize),
1774  cast_int<std::size_t>(n_elem)));
1775 
1776  conn.clear();
1777 
1778  if (this->processor_id() == 0)
1779  for (dof_id_type e=first_elem; e<last_elem; e++, n_processed_at_level++)
1780  {
1781  if (n_processed_at_level == n_elem_at_level)
1782  {
1783  // get the number of elements to read at this level
1784  io.data (n_elem_at_level);
1785  n_processed_at_level = 0;
1786  level++;
1787  }
1788 
1789  // "pos" is a cursor into input_buffer
1790  unsigned int pos = 0;
1791 
1792  // get the element type,
1793  io.data_stream (&input_buffer[pos++], 1);
1794 
1795  if (read_unique_id)
1796  io.data_stream (&input_buffer[pos++], 1);
1797  // Older versions won't have this field at all (no increment on pos)
1798 
1799  // maybe the parent
1800  if (level)
1801  io.data_stream (&input_buffer[pos++], 1);
1802  else
1803  // We can't always fit DofObject::invalid_id in an
1804  // xdr_id_type
1805  input_buffer[pos++] = static_cast<T>(-1);
1806 
1807  // maybe the processor id
1808  if (read_partitioning)
1809  io.data_stream (&input_buffer[pos++], 1);
1810  else
1811  input_buffer[pos++] = 0;
1812 
1813  // maybe the subdomain id
1814  if (read_subdomain_id)
1815  io.data_stream (&input_buffer[pos++], 1);
1816  else
1817  input_buffer[pos++] = 0;
1818 
1819  // maybe the p level
1820  if (read_p_level)
1821  io.data_stream (&input_buffer[pos++], 1);
1822  else
1823  input_buffer[pos++] = 0;
1824 
1825  // and all the nodes
1826  libmesh_assert_less (pos+Elem::type_to_n_nodes_map[input_buffer[0]], input_buffer.size());
1827  io.data_stream (&input_buffer[pos], Elem::type_to_n_nodes_map[input_buffer[0]]);
1828 
1829  // Advance input_buffer cursor by number of nodes in this element
1830  pos += Elem::type_to_n_nodes_map[input_buffer[0]];
1831 
1832  // and all the elem "extra" integers
1833  libmesh_assert_less (pos + n_elem_integers, input_buffer.size());
1834  io.data_stream (&input_buffer[pos], n_elem_integers);
1835 
1836  // Advance input_buffer cursor by number of extra integers read
1837  pos += n_elem_integers;
1838 
1839  // Insert input_buffer at end of "conn"
1840  conn.insert (conn.end(), input_buffer.begin(), input_buffer.begin() + pos);
1841  }
1842 
1843  std::size_t conn_size = conn.size();
1844  this->comm().broadcast(conn_size);
1845  conn.resize (conn_size);
1846  this->comm().broadcast (conn);
1847 
1848  // All processors now have the connectivity for this block.
1849  for (auto [e, it] = std::tuple{first_elem, conn.begin()}; e<last_elem; e++)
1850  {
1851  // Temporary variable for reading connectivity array
1852  // entries.
1853  T tmp;
1854 
1855  const ElemType elem_type = static_cast<ElemType>(*it++);
1856 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1857  // We are on all processors here, so the mesh can easily
1858  // assign consistent unique ids if the file doesn't specify
1859  // them later. We'll use element ids for elements and start
1860  // past those for nodes.
1861  unique_id_type unique_id = e;
1862 #endif
1863  if (read_unique_id)
1864  {
1865  tmp = *it++;
1866 
1867 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1868  unique_id = cast_int<unique_id_type>(tmp);
1869 #endif
1870  }
1871 
1872  tmp = *it++;
1873  const dof_id_type parent_id =
1874  (tmp == static_cast<T>(-1)) ? DofObject::invalid_id : cast_int<dof_id_type>(tmp);
1875 
1876  const processor_id_type proc_id =
1877  cast_int<processor_id_type>(*it++);
1878 
1879  const subdomain_id_type subdomain_id =
1880  cast_int<subdomain_id_type>(*it++);
1881 
1882  tmp = *it++;
1883 #ifdef LIBMESH_ENABLE_AMR
1884  const unsigned int p_level = cast_int<unsigned int>(tmp);
1885 #endif
1886 
1887  Elem * parent = (parent_id == DofObject::invalid_id) ?
1888  nullptr : mesh.elem_ptr(parent_id);
1889 
1890  auto elem = Elem::build(elem_type, parent);
1891 
1892  elem->set_id() = e;
1893 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1894  elem->set_unique_id(unique_id);
1895 #endif
1896  elem->processor_id() = proc_id;
1897  elem->subdomain_id() = subdomain_id;
1898 #ifdef LIBMESH_ENABLE_AMR
1899  elem->hack_p_level(p_level);
1900 
1901  if (parent)
1902  {
1903  parent->add_child(elem.get());
1904  parent->set_refinement_flag (Elem::INACTIVE);
1905  elem->set_refinement_flag (Elem::JUST_REFINED);
1906  }
1907 #endif
1908 
1909  // Node ids for this Elem
1910  for (unsigned int n=0, n_n = elem->n_nodes(); n != n_n;
1911  n++, ++it)
1912  {
1913  const dof_id_type global_node_number =
1914  cast_int<dof_id_type>(*it);
1915 
1916  Node *node = mesh.query_node_ptr(global_node_number);
1917 
1918  if (node)
1919  elem->set_node(n) = node;
1920  else
1921  {
1922  std::unique_ptr<Node> new_node = Node::build(Point(), global_node_number);
1923 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1924  // If we have to overwrite this it'll happen later
1925  new_node->set_unique_id(n_elem + global_node_number);
1926 #endif
1927  elem->set_node(n) = mesh.add_node(std::move(new_node));
1928  }
1929  }
1930 
1931  elems_of_dimension[elem->dim()] = true;
1932  Elem * added_elem = mesh.add_elem(std::move(elem));
1933 
1934  // Make sure that the Elem we just added to the Mesh has
1935  // space for the required number of extra integers. Note
1936  // that we have to add the Elem to the Mesh prior to
1937  // accessing any of its extra integers, since otherwise the
1938  // Elem does not know that it should have extra integers...
1939  libmesh_assert_equal_to(n_elem_integers, added_elem->n_extra_integers());
1940 
1941  // Extra integers for this Elem
1942  for (unsigned int ei=0; ei<n_elem_integers; ++ei)
1943  {
1944  auto extra_int = cast_int<dof_id_type>(*it++);
1945  added_elem->set_extra_integer(ei, extra_int);
1946  }
1947  }
1948  }
1949 
1950  // Set the mesh dimension to the largest encountered for an element
1951  for (unsigned char i=0; i!=4; ++i)
1952  if (elems_of_dimension[i])
1954 
1955 #if LIBMESH_DIM < 3
1956  libmesh_error_msg_if(mesh.mesh_dimension() > LIBMESH_DIM,
1957  "Cannot open dimension "
1958  << mesh.mesh_dimension()
1959  << " mesh file when configured without "
1960  << mesh.mesh_dimension()
1961  << "D support.");
1962 #endif
1963 }
ElemType
Defines an enum for geometric element types.
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:850
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:107
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
const Parallel::Communicator & comm() const
static const unsigned int type_to_n_nodes_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of nodes in the element...
Definition: elem.h:610
uint8_t processor_id_type
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:273
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
virtual const Node * query_node_ptr(const dof_id_type i) const =0
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:269
uint64_t new_header_id_type
Definition: xdr_io.h:63
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
static std::unique_ptr< Node > build(const Node &n)
Definition: node.h:315
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:371
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2470
processor_id_type processor_id() const
uint8_t unique_id_type
Definition: id_types.h:86
void set_extra_integer(const unsigned int index, const dof_id_type value)
Sets the value on this object of the extra integer associated with index, which should have been obta...
Definition: dof_object.h:1079
uint8_t dof_id_type
Definition: id_types.h:67
bool version_at_least_1_8_0() const
Definition: xdr_io.C:2504

◆ read_serialized_edge_bcs()

template<typename T >
void libMesh::XdrIO::read_serialized_edge_bcs ( Xdr io,
type_size 
)
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 2291 of file xdr_io.C.

References read_serialized_bcs_helper().

Referenced by read().

2292 {
2293  read_serialized_bcs_helper(io, type_size, "edge");
2294 }
void read_serialized_bcs_helper(Xdr &io, T type_size, 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:2192

◆ read_serialized_nodes()

void libMesh::XdrIO::read_serialized_nodes ( Xdr io,
const dof_id_type  n_nodes,
const std::vector< new_header_id_type > &  meta_data 
)
private

Read the nodal locations for a parallel, distributed mesh.

Definition at line 1968 of file xdr_io.C.

References _field_width, TIMPI::Communicator::broadcast(), 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(), libMesh::MeshBase::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::MeshBase::node_ref(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::DofObject::set_extra_integer(), libMesh::MeshBase::set_next_unique_id(), libMesh::DofObject::set_unique_id(), version_at_least_0_9_6(), and version_at_least_1_8_0().

Referenced by read().

1971 {
1972  libmesh_assert (io.reading());
1973 
1974  // convenient reference to our mesh
1975  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1976 
1977  if (!mesh.n_nodes()) return;
1978 
1979  // At this point the elements have been read from file and placeholder nodes
1980  // have been assigned. These nodes, however, do not have the proper (x,y,z)
1981  // locations or unique_id values. This method will read all the
1982  // nodes from disk, and each processor can then grab the individual
1983  // values it needs.
1984 
1985  // If the file includes unique ids for nodes (as indicated by a
1986  // flag in 0.9.6+ files), those will be read next.
1987 
1988  // build up a list of the nodes contained in our local mesh. These are the nodes
1989  // stored on the local processor whose (x,y,z) and unique_id values
1990  // need to be corrected.
1991  std::vector<dof_id_type> needed_nodes;
1992  needed_nodes.reserve (mesh.n_nodes());
1993  {
1994  for (auto & node : mesh.node_ptr_range())
1995  needed_nodes.push_back(node->id());
1996 
1997  std::sort (needed_nodes.begin(), needed_nodes.end());
1998 
1999  // We should not have any duplicate node->id()s
2000  libmesh_assert (std::unique(needed_nodes.begin(), needed_nodes.end()) == needed_nodes.end());
2001  }
2002 
2003  // Version 1.8.0+ introduces node integers
2004  const std::size_t n_node_integers_index = 11;
2005  new_header_id_type n_node_integers = 0;
2006  if (version_at_least_1_8_0())
2007  {
2008  libmesh_assert_greater_equal(meta_data.size(), 13);
2009  n_node_integers = meta_data[n_node_integers_index];
2010  }
2011 
2012  // Get the nodes in blocks.
2013  std::vector<Real> coords;
2014  std::pair<std::vector<dof_id_type>::iterator,
2015  std::vector<dof_id_type>::iterator> pos;
2016  pos.first = needed_nodes.begin();
2017 
2018  // Broadcast node coordinates
2019  for (std::size_t blk=0, first_node=0, last_node=0; last_node<n_nodes; blk++)
2020  {
2021  first_node = blk*io_blksize;
2022  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
2023 
2024  coords.resize(3*(last_node - first_node));
2025 
2026  if (this->processor_id() == 0)
2027  io.data_stream (coords.empty() ? nullptr : coords.data(),
2028  cast_int<unsigned int>(coords.size()));
2029 
2030  // For large numbers of processors the majority of processors at any given
2031  // block may not actually need these data. It may be worth profiling this,
2032  // although it is expected that disk IO will be the bottleneck
2033  this->comm().broadcast (coords);
2034 
2035  for (std::size_t n=first_node, idx=0; n<last_node; n++, idx+=3)
2036  {
2037  // first see if we need this node. use pos.first as a smart lower
2038  // bound, this will ensure that the size of the searched range
2039  // decreases as we match nodes.
2040  pos = std::equal_range (pos.first, needed_nodes.end(), n);
2041 
2042  if (pos.first != pos.second) // we need this node.
2043  {
2044  libmesh_assert_equal_to (*pos.first, n);
2045  libmesh_assert(!libmesh_isnan(coords[idx+0]));
2046  libmesh_assert(!libmesh_isnan(coords[idx+1]));
2047  libmesh_assert(!libmesh_isnan(coords[idx+2]));
2048  mesh.node_ref(cast_int<dof_id_type>(n)) =
2049  Point (coords[idx+0],
2050  coords[idx+1],
2051  coords[idx+2]);
2052 
2053  }
2054  }
2055  }
2056 
2057  // Check for node unique ids
2058  unsigned short read_unique_ids = false;
2059 
2060  if (version_at_least_0_9_6())
2061  {
2062  if (this->processor_id() == 0)
2063  io.data (read_unique_ids);
2064 
2065  this->comm().broadcast (read_unique_ids);
2066  }
2067 
2068  // If no node unique ids are in the file, well, we already
2069  // assigned our own ... *but*, our ids might conflict with the
2070  // file-assigned element unique ids. Let's check on that.
2071  // Should be easy since we're serialized.
2072  if (!read_unique_ids)
2073  {
2074 #ifdef LIBMESH_ENABLE_UNIQUE_ID
2075  unique_id_type max_elem_unique_id = 0;
2076  for (auto & elem : mesh.element_ptr_range())
2077  max_elem_unique_id = std::max(max_elem_unique_id,
2078  elem->unique_id()+1);
2079  if (max_elem_unique_id > mesh.n_elem())
2080  {
2081  for (auto & node : mesh.node_ptr_range())
2082  node->set_unique_id(max_elem_unique_id + node->id());
2083  }
2084  mesh.set_next_unique_id(max_elem_unique_id + mesh.n_nodes());
2085 #endif
2086  }
2087  else
2088  {
2089  std::vector<uint32_t> unique_32;
2090  std::vector<uint64_t> unique_64;
2091 
2092  // We're starting over from node 0 again
2093  pos.first = needed_nodes.begin();
2094 
2095  for (std::size_t blk=0, first_node=0, last_node=0; last_node<n_nodes; blk++)
2096  {
2097  first_node = blk*io_blksize;
2098  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
2099 
2100  libmesh_assert((_field_width == 8) || (_field_width == 4));
2101 
2102  if (_field_width == 8)
2103  unique_64.resize(last_node - first_node);
2104  else
2105  unique_32.resize(last_node - first_node);
2106 
2107  if (this->processor_id() == 0)
2108  {
2109  if (_field_width == 8)
2110  io.data_stream (unique_64.empty() ? nullptr : unique_64.data(),
2111  cast_int<unsigned int>(unique_64.size()));
2112  else
2113  io.data_stream (unique_32.empty() ? nullptr : unique_32.data(),
2114  cast_int<unsigned int>(unique_32.size()));
2115  }
2116 
2117 #ifdef LIBMESH_ENABLE_UNIQUE_ID
2118  if (_field_width == 8)
2119  this->comm().broadcast (unique_64);
2120  else
2121  this->comm().broadcast (unique_32);
2122 
2123  for (std::size_t n=first_node, idx=0; n<last_node; n++, idx++)
2124  {
2125  // first see if we need this node. use pos.first as a smart lower
2126  // bound, this will ensure that the size of the searched range
2127  // decreases as we match nodes.
2128  pos = std::equal_range (pos.first, needed_nodes.end(), n);
2129 
2130  if (pos.first != pos.second) // we need this node.
2131  {
2132  libmesh_assert_equal_to (*pos.first, n);
2133  if (_field_width == 8)
2134  mesh.node_ref(cast_int<dof_id_type>(n)).set_unique_id(unique_64[idx]);
2135  else
2136  mesh.node_ref(cast_int<dof_id_type>(n)).set_unique_id(unique_32[idx]);
2137  }
2138  }
2139 #endif // LIBMESH_ENABLE_UNIQUE_ID
2140  }
2141  }
2142 
2143  // Read extra node integers (if present) in chunks on processor 0 and broadcast to
2144  // all other procs. For a ReplicatedMesh, all procs need to know about all Nodes'
2145  // extra integers. For a DistributedMesh, this broadcasting will transmit some
2146  // redundant information.
2147  if (n_node_integers)
2148  {
2149  std::vector<dof_id_type> extra_integers;
2150 
2151  // We're starting over from node 0 again
2152  pos.first = needed_nodes.begin();
2153 
2154  for (std::size_t blk=0, first_node=0, last_node=0; last_node<n_nodes; blk++)
2155  {
2156  first_node = blk*io_blksize;
2157  last_node = std::min((blk+1)*io_blksize, std::size_t(n_nodes));
2158 
2159  extra_integers.resize((last_node - first_node) * n_node_integers);
2160 
2161  // Read in block of node integers on proc 0 only...
2162  if (this->processor_id() == 0)
2163  io.data_stream (extra_integers.empty() ? nullptr : extra_integers.data(),
2164  cast_int<unsigned int>(extra_integers.size()));
2165 
2166  // ... and broadcast it to all other procs.
2167  this->comm().broadcast (extra_integers);
2168 
2169  for (std::size_t n=first_node, idx=0; n<last_node; n++, idx++)
2170  {
2171  // first see if we need this node. use pos.first as a smart lower
2172  // bound, this will ensure that the size of the searched range
2173  // decreases as we match nodes.
2174  pos = std::equal_range (pos.first, needed_nodes.end(), n);
2175 
2176  if (pos.first != pos.second) // we need this node.
2177  {
2178  libmesh_assert_equal_to (*pos.first, n);
2179 
2180  Node & node_ref = mesh.node_ref(cast_int<dof_id_type>(n));
2181  for (unsigned int i=0; i != n_node_integers; ++i)
2182  node_ref.set_extra_integer(i, extra_integers[n_node_integers*idx + i]);
2183  }
2184  }
2185  } // end for (block-based extra integer reads)
2186  } // end if (n_node_integers)
2187 }
unique_id_type & set_unique_id()
Definition: dof_object.h:852
bool version_at_least_0_9_6() const
Definition: xdr_io.C:2480
const Parallel::Communicator & comm() const
virtual void set_next_unique_id(unique_id_type id)=0
Sets the next available unique id to be used.
bool libmesh_isnan(T x)
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
unsigned int _field_width
Definition: xdr_io.h:361
uint64_t new_header_id_type
Definition: xdr_io.h:63
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:371
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:575
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
uint8_t unique_id_type
Definition: id_types.h:86
void set_extra_integer(const unsigned int index, const dof_id_type value)
Sets the value on this object of the extra integer associated with index, which should have been obta...
Definition: dof_object.h:1079
virtual dof_id_type n_nodes() const =0
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.
bool version_at_least_1_8_0() const
Definition: xdr_io.C:2504

◆ read_serialized_nodesets()

template<typename T >
void libMesh::XdrIO::read_serialized_nodesets ( Xdr io,
type_size 
)
private

Read the nodeset conditions for a parallel, distributed mesh.

Returns
The number of nodesets read

Definition at line 2307 of file xdr_io.C.

References libMesh::BoundaryInfo::add_node(), boundary_condition_file_name(), TIMPI::Communicator::broadcast(), 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().

2308 {
2309  if (this->boundary_condition_file_name() == "n/a") return;
2310 
2311  libmesh_assert (io.reading());
2312 
2313  // convenient reference to our mesh
2314  MeshBase & mesh = MeshInput<MeshBase>::mesh();
2315 
2316  // and our boundary info object
2317  BoundaryInfo & boundary_info = mesh.get_boundary_info();
2318 
2319  // Version 0.9.2+ introduces unique ids
2320  read_serialized_bc_names(io, boundary_info, false); // nodeset names
2321 
2322  std::vector<T> input_buffer;
2323 
2324  new_header_id_type n_nodesets=0;
2325  if (this->processor_id() == 0)
2326  {
2327  if (this->version_at_least_1_3_0())
2328  io.data (n_nodesets);
2329  else
2330  {
2331  old_header_id_type temp;
2332  io.data (temp);
2333  n_nodesets = temp;
2334  }
2335  }
2336  this->comm().broadcast (n_nodesets);
2337 
2338  for (std::size_t blk=0, first_bc=0, last_bc=0; last_bc<n_nodesets; blk++)
2339  {
2340  first_bc = blk*io_blksize;
2341  last_bc = std::min((blk+1)*io_blksize, std::size_t(n_nodesets));
2342 
2343  input_buffer.resize (2*(last_bc - first_bc));
2344 
2345  if (this->processor_id() == 0)
2346  io.data_stream (input_buffer.empty() ? nullptr : input_buffer.data(),
2347  cast_int<unsigned int>(input_buffer.size()));
2348 
2349  this->comm().broadcast (input_buffer);
2350 
2351  // Look for BCs in this block for all nodes we have (not just
2352  // local ones). Do this by checking all entries for
2353  // IDs matching a node we can query.
2354  for (std::size_t idx=0, ibs=input_buffer.size(); idx<ibs; idx+=2)
2355  {
2356  const dof_id_type dof_id =
2357  cast_int<dof_id_type>(input_buffer[idx+0]);
2358  const boundary_id_type bc_id =
2359  cast_int<boundary_id_type>(input_buffer[idx+1]);
2360 
2361  const Node * node = mesh.query_node_ptr(dof_id);
2362  if (node)
2363  boundary_info.add_node (node, bc_id);
2364  }
2365  input_buffer.clear();
2366  }
2367 }
uint32_t old_header_id_type
Definition: xdr_io.h:60
const Parallel::Communicator & comm() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
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:2371
int8_t boundary_id_type
Definition: id_types.h:51
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2497
virtual const Node * query_node_ptr(const dof_id_type i) const =0
libmesh_assert(ctx)
uint64_t new_header_id_type
Definition: xdr_io.h:63
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:371
processor_id_type processor_id() const
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_serialized_shellface_bcs()

template<typename T >
void libMesh::XdrIO::read_serialized_shellface_bcs ( Xdr io,
type_size 
)
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 2299 of file xdr_io.C.

References read_serialized_bcs_helper().

Referenced by read().

2300 {
2301  read_serialized_bcs_helper(io, type_size, "shellface");
2302 }
void read_serialized_bcs_helper(Xdr &io, T type_size, 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:2192

◆ read_serialized_side_bcs()

template<typename T >
void libMesh::XdrIO::read_serialized_side_bcs ( Xdr io,
type_size 
)
private

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

Returns
The number of bcs read

Definition at line 2283 of file xdr_io.C.

References read_serialized_bcs_helper().

Referenced by read().

2284 {
2285  read_serialized_bcs_helper(io, type_size, "side");
2286 }
void read_serialized_bcs_helper(Xdr &io, T type_size, 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:2192

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

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

Referenced by read().

1665 {
1666  const bool read_entity_info = version_at_least_0_9_2();
1667  const bool use_new_header_type (this->version_at_least_1_3_0());
1668  if (read_entity_info)
1669  {
1670  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1671 
1672  new_header_id_type n_subdomain_names = 0;
1673  std::vector<new_header_id_type> subdomain_ids;
1674  std::vector<std::string> subdomain_names;
1675 
1676  // Read the sideset names
1677  if (this->processor_id() == 0)
1678  {
1679  if (use_new_header_type)
1680  io.data(n_subdomain_names);
1681  else
1682  {
1683  old_header_id_type temp;
1684  io.data(temp);
1685  n_subdomain_names = temp;
1686  }
1687 
1688  subdomain_ids.resize(n_subdomain_names);
1689  subdomain_names.resize(n_subdomain_names);
1690 
1691  if (n_subdomain_names)
1692  {
1693  if (use_new_header_type)
1694  io.data(subdomain_ids);
1695  else
1696  {
1697  std::vector<old_header_id_type> temp;
1698  io.data(temp);
1699  subdomain_ids.assign(temp.begin(), temp.end());
1700  }
1701 
1702  io.data(subdomain_names);
1703  }
1704  }
1705 
1706  // Broadcast the subdomain names to all processors
1707  this->comm().broadcast(n_subdomain_names);
1708  if (n_subdomain_names == 0)
1709  return;
1710 
1711  subdomain_ids.resize(n_subdomain_names);
1712  subdomain_names.resize(n_subdomain_names);
1713  this->comm().broadcast(subdomain_ids);
1714  this->comm().broadcast(subdomain_names);
1715 
1716  // Reassemble the named subdomain information
1717  std::map<subdomain_id_type, std::string> & subdomain_map = mesh.set_subdomain_name_map();
1718 
1719  for (unsigned int i=0; i<n_subdomain_names; ++i)
1720  subdomain_map.emplace(subdomain_ids[i], subdomain_names[i]);
1721  }
1722 }
uint32_t old_header_id_type
Definition: xdr_io.h:60
const Parallel::Communicator & comm() const
bool version_at_least_1_3_0() const
Definition: xdr_io.C:2497
uint64_t new_header_id_type
Definition: xdr_io.h:63
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
bool version_at_least_0_9_2() const
Definition: xdr_io.C:2470
processor_id_type processor_id() const
const DofMap &dof_map LIBMESH_COMMA unsigned int std::string & set_subdomain_name_map()
Definition: mesh_base.h:1669

◆ 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 410 of file xdr_io.h.

References _write_parallel, and _write_serial.

411 {
412  this->_write_serial = false;
413  this->_write_parallel = false;
414 }
bool _write_parallel
Definition: xdr_io.h:359
bool _write_serial
Definition: xdr_io.h:358

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

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

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

101 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1789

◆ 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 400 of file xdr_io.h.

References _write_parallel, and _write_serial.

401 {
402  this->_write_parallel = do_parallel;
403 
404  this->_write_serial = !do_parallel;
405 }
bool _write_parallel
Definition: xdr_io.h:359
bool _write_serial
Definition: xdr_io.h:358

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

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

189 {
190  char c, line[256];
191 
192  while (in.get(c), c==comment_start)
193  in.getline (line, 255);
194 
195  // put back first character of
196  // first non-comment line
197  in.putback (c);
198 }

◆ subdomain_map_file_name() [1/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.

References _subdomain_map_file.

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

158 { return _subdomain_map_file; }
std::string _subdomain_map_file
Definition: xdr_io.h:365

◆ subdomain_map_file_name() [2/2]

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

Definition at line 159 of file xdr_io.h.

References _subdomain_map_file.

159 { return _subdomain_map_file; }
std::string _subdomain_map_file
Definition: xdr_io.h:365

◆ version() [1/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.

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

140 { return _version; }
std::string _version
Definition: xdr_io.h:362

◆ version() [2/2]

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

Definition at line 141 of file xdr_io.h.

References _version.

141 { return _version; }
std::string _version
Definition: xdr_io.h:362

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

References version().

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

2471 {
2472  return
2473  (this->version().find("0.9.2") != std::string::npos) ||
2474  (this->version().find("0.9.6") != std::string::npos) ||
2475  (this->version().find("1.1.0") != std::string::npos) ||
2476  (this->version().find("1.3.0") != std::string::npos) ||
2477  (this->version().find("1.8.0") != std::string::npos);
2478 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140

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

References version().

Referenced by read_serialized_nodes().

2481 {
2482  return
2483  (this->version().find("0.9.6") != std::string::npos) ||
2484  (this->version().find("1.1.0") != std::string::npos) ||
2485  (this->version().find("1.3.0") != std::string::npos) ||
2486  (this->version().find("1.8.0") != std::string::npos);
2487 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140

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

References version().

Referenced by read().

2490 {
2491  return
2492  (this->version().find("1.1.0") != std::string::npos) ||
2493  (this->version().find("1.3.0") != std::string::npos) ||
2494  (this->version().find("1.8.0") != std::string::npos);
2495 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140

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

References version().

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

2498 {
2499  return
2500  (this->version().find("1.3.0") != std::string::npos) ||
2501  (this->version().find("1.8.0") != std::string::npos);
2502 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140

◆ version_at_least_1_8_0()

bool libMesh::XdrIO::version_at_least_1_8_0 ( ) const
Returns
true if the current file has an XDR/XDA version that matches or exceeds 1.8.0.

In this version we added support for writing the Mesh's "extra" integer fields to the file.

Definition at line 2504 of file xdr_io.C.

References version().

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

2505 {
2506  return
2507  (this->version().find("1.8.0") != std::string::npos);
2508 }
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140

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

References _write_unique_id, TIMPI::Communicator::barrier(), binary(), boundary_condition_file_name(), libMesh::Xdr::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::ENCODE, libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::get_elem_integer_name(), libMesh::MeshBase::get_elemset_codes(), libMesh::MeshBase::get_elemsets(), libMesh::MeshBase::get_node_integer_name(), 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::MeshTools::n_elem(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_elem_integers(), libMesh::MeshBase::n_node_integers(), 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().

112 {
113  libmesh_error_msg_if(this->legacy(), "We don't support writing parallel files in the legacy format.");
114 
115  Xdr io ((this->processor_id() == 0) ? name : "", this->binary() ? ENCODE : WRITE);
116 
117  LOG_SCOPE("write()","XdrIO");
118 
119  // convenient reference to our mesh
120  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
121 
123  new_header_id_type max_node_id = mesh.max_node_id();
124 
129  unsigned int n_p_levels = MeshTools::n_p_levels (mesh);
130  new_header_id_type n_elem_integers = mesh.n_elem_integers();
131  new_header_id_type n_node_integers = mesh.n_node_integers();
132  std::vector<dof_id_type> elemset_codes = mesh.get_elemset_codes();
133 
134  bool write_parallel_files = this->write_parallel();
135 
136  //-------------------------------------------------------------
137  // For all the optional files -- the default file name is "n/a".
138  // However, the user may specify an optional external file.
139 
140  // If there are BCs and the user has not already provided a
141  // file name then write to "."
142  if ((n_side_bcs || n_edge_bcs || n_shellface_bcs || n_nodesets) &&
143  this->boundary_condition_file_name() == "n/a")
144  this->boundary_condition_file_name() = ".";
145 
146  // If there are more than one subdomains and the user has not specified an
147  // external file then write the subdomain mapping to the default file "."
148  if ((mesh.n_subdomains() > 0) &&
149  (this->subdomain_map_file_name() == "n/a"))
150  this->subdomain_map_file_name() = ".";
151 
152  // In general we don't write the partition information.
153 
154  // If we have p levels and the user has not already provided
155  // a file name then write to "."
156  if ((n_p_levels > 1) &&
157  (this->polynomial_level_file_name() == "n/a"))
158  this->polynomial_level_file_name() = ".";
159 
160  // write the header
161  if (this->processor_id() == 0)
162  {
163  std::string full_ver = this->version() + (write_parallel_files ? " parallel" : "");
164  io.data (full_ver);
165 
166  io.data (n_elem, "# number of elements");
167  io.data (max_node_id, "# number of nodes"); // We'll write invalid coords into gaps
168 
169  io.data (this->boundary_condition_file_name(), "# boundary condition specification file");
170  io.data (this->subdomain_map_file_name(), "# subdomain id specification file");
171  io.data (this->partition_map_file_name(), "# processor id specification file");
172  io.data (this->polynomial_level_file_name(), "# p-level specification file");
173 
174  // Version 0.9.2+ introduces sizes for each type
175  new_header_id_type write_size = sizeof(xdr_id_type), zero_size = 0;
176 
177  const bool
178  write_p_level = ("." == this->polynomial_level_file_name()),
179  write_partitioning = ("." == this->partition_map_file_name()),
180  write_subdomain_id = ("." == this->subdomain_map_file_name()),
181  write_bcs = ("." == this->boundary_condition_file_name());
182 
183  io.data (write_size, "# type size");
184  io.data (_write_unique_id ? write_size : zero_size, "# uid size");
185  io.data (write_partitioning ? write_size : zero_size, "# pid size");
186  io.data (write_subdomain_id ? write_size : zero_size, "# sid size");
187  io.data (write_p_level ? write_size : zero_size, "# p-level size");
188  // Boundary Condition sizes
189  io.data (write_bcs ? write_size : zero_size, "# eid size"); // elem id
190  io.data (write_bcs ? write_size : zero_size, "# side size"); // side number
191  io.data (write_bcs ? write_size : zero_size, "# bid size"); // boundary id
192 
193  // Write the data size for extra integers stored on the mesh. Like
194  // everything else in the header, they will be of size write_size.
195  io.data((n_elem_integers || n_node_integers) ? write_size : zero_size, "# extra integer size");
196 
197  // Write the names of the extra node integers (see also: CheckpointIO).
198  std::vector<std::string> node_integer_names;
199  for (unsigned int i=0; i != n_node_integers; ++i)
200  node_integer_names.push_back(mesh.get_node_integer_name(i));
201  io.data(node_integer_names, "# node integer names");
202 
203  // Write the names of the extra elem integers (see also: CheckpointIO).
204  std::vector<std::string> elem_integer_names;
205  for (unsigned int i=0; i != n_elem_integers; ++i)
206  elem_integer_names.push_back(mesh.get_elem_integer_name(i));
207  io.data(elem_integer_names, "# elem integer names");
208 
209  // Write the vector of elemset codes to the header (this will
210  // also write the size of the vector, which is the number of
211  // elemset codes).
212  io.data(elemset_codes, "# elemset codes");
213 
214  // For each elemset code, write out the associated elemset ids
215  MeshBase::elemset_type id_set_to_fill;
216  for (const auto & elemset_code : elemset_codes)
217  {
218  mesh.get_elemsets(elemset_code, id_set_to_fill);
219 
220  // Transfer elemset ids to vector for writing
221  std::vector<dof_id_type> elemset_id_vec(id_set_to_fill.begin(), id_set_to_fill.end());
222 
223  // Write vector of elemset ids to file with comment
224  std::string comment_string = "# elemset ids for elemset code " + std::to_string(elemset_code);
225  io.data(elemset_id_vec, comment_string);
226  }
227  }
228 
229  if (write_parallel_files)
230  {
231  // Parallel xdr mesh files aren't implemented yet; until they
232  // are we'll just warn the user and write a serial file.
233  libMesh::out << "Warning! Parallel xda/xdr is not yet implemented.\n";
234  libMesh::out << "Writing a serialized file instead." << std::endl;
235 
236  // write subdomain names
238 
239  // write connectivity
240  this->write_serialized_connectivity (io, cast_int<dof_id_type>(n_elem), n_elem_integers);
241 
242  // write the nodal locations
243  this->write_serialized_nodes (io, cast_int<dof_id_type>(max_node_id), n_node_integers);
244 
245  // write the side boundary condition information
246  this->write_serialized_side_bcs (io, n_side_bcs);
247 
248  // write the nodeset information
249  this->write_serialized_nodesets (io, n_nodesets);
250 
251  // write the edge boundary condition information
252  this->write_serialized_edge_bcs (io, n_edge_bcs);
253 
254  // write the "shell face" boundary condition information
255  this->write_serialized_shellface_bcs (io, n_shellface_bcs);
256  }
257  else
258  {
259  // write subdomain names
261 
262  // write connectivity
263  this->write_serialized_connectivity (io, cast_int<dof_id_type>(n_elem), n_elem_integers);
264 
265  // write the nodal locations
266  this->write_serialized_nodes (io, cast_int<dof_id_type>(max_node_id), n_node_integers);
267 
268  // write the side boundary condition information
269  this->write_serialized_side_bcs (io, n_side_bcs);
270 
271  // write the nodeset information
272  this->write_serialized_nodesets (io, n_nodesets);
273 
274  // write the edge boundary condition information
275  this->write_serialized_edge_bcs (io, n_edge_bcs);
276 
277  // write the "shell face" boundary condition information
278  this->write_serialized_shellface_bcs (io, n_shellface_bcs);
279  }
280 
281  // pause all processes until the writing ends -- this will
282  // protect for the pathological case where a write is
283  // followed immediately by a read. The write must be
284  // guaranteed to complete first.
285  io.close();
286  this->comm().barrier();
287 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
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:1306
const MT & mesh() const
Definition: mesh_output.h:259
std::size_t n_boundary_conds() const
unsigned int n_node_integers() const
Definition: mesh_base.h:1056
bool write_parallel() const
Report whether we should write parallel files.
Definition: xdr_io.h:379
std::vector< dof_id_type > get_elemset_codes() const
Return a vector of all elemset codes defined on the mesh.
Definition: mesh_base.C:397
std::size_t n_edge_conds() const
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:850
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:1285
bool legacy() const
Get/Set the flag indicating if we should read/write legacy.
Definition: xdr_io.h:109
std::size_t n_shellface_conds() const
void barrier() const
unsigned int n_elem_integers() const
Definition: mesh_base.h:934
const Parallel::Communicator & comm() const
void write_serialized_subdomain_names(Xdr &io) const
Write subdomain name information - NEW in 0.9.2 format.
Definition: xdr_io.C:291
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
void write_serialized_nodes(Xdr &io, const dof_id_type n_nodes, const new_header_id_type n_node_integers) const
Write the nodal locations for a parallel, distributed mesh.
Definition: xdr_io.C:692
const std::string & get_elem_integer_name(unsigned int i) const
Definition: mesh_base.h:923
void get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type &id_set_to_fill) const
Look up the element sets for a given elemset code and vice-versa.
Definition: mesh_base.C:381
largest_id_type xdr_id_type
Definition: xdr_io.h:57
const std::string & boundary_condition_file_name() const
Get/Set the boundary condition file name.
Definition: xdr_io.h:146
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
uint64_t new_header_id_type
Definition: xdr_io.h:63
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
void write_serialized_connectivity(Xdr &io, const dof_id_type n_elem, const new_header_id_type n_elem_integers) const
Write the connectivity for a parallel, distributed mesh.
Definition: xdr_io.C:330
bool _write_unique_id
Definition: xdr_io.h:360
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition: mesh_base.h:297
const std::string & version() const
Get/Set the version string.
Definition: xdr_io.h:140
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
OStreamProxy out
std::size_t n_nodeset_conds() const
const std::string & get_node_integer_name(unsigned int i) const
Definition: mesh_base.h:1045
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:1299
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: xdr_io.h:103
virtual dof_id_type max_node_id() const =0
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
unsigned int n_p_levels(const MeshBase &mesh)
Definition: mesh_tools.C:866
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:1292

◆ 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 89 of file mesh_output.C.

References libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.

Referenced by libMesh::ExodusII_IO::write_timestep_discontinuous().

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

◆ 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.

References libMesh::EquationSystems::build_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.

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

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-parallel format, non-renumbered mesh may not have a contiguous
46  // numbering, and that needs to be fixed before we can build a solution vector.
47  if (!_is_parallel_format &&
48  (my_mesh.max_elem_id() != my_mesh.n_elem() ||
49  my_mesh.max_node_id() != my_mesh.n_nodes()))
50  {
51  // If we were allowed to renumber then we should have already
52  // been properly renumbered...
53  libmesh_assert(!my_mesh.allow_renumbering());
54 
55  libmesh_do_once(libMesh::out <<
56  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
57  << std::endl;);
58 
59  my_mesh.allow_renumbering(true);
60 
61  my_mesh.renumber_nodes_and_elements();
62 
63  // Not sure what good going back to false will do here, the
64  // renumbering horses have already left the barn...
65  my_mesh.allow_renumbering(false);
66  }
67 
69  {
70  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
71 
72  // Build the list of variable names that will be written.
73  std::vector<std::string> names;
74  es.build_variable_names (names, nullptr, system_names);
75 
76  // Build the nodal solution values & get the variable
77  // names from the EquationSystems object
78  std::vector<Number> soln;
79  es.build_solution_vector (soln, system_names,
80  this->get_add_sides());
81 
82  this->write_nodal_data (fname, soln, names);
83  }
84  else // _is_parallel_format
85  this->write_nodal_data (fname, es, system_names);
86 }
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:109
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:202
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:184
libmesh_assert(ctx)
OStreamProxy out
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:193

◆ write_nodal_data() [1/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::ExodusII_IO, libMesh::Nemesis_IO, libMesh::GmshIO, libMesh::NameBasedIO, libMesh::VTKIO, libMesh::UCDIO, libMesh::GMVIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 109 of file mesh_output.h.

112  { libmesh_not_implemented(); }

◆ 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 149 of file mesh_output.C.

References libMesh::NumericVector< T >::localize().

152 {
153  // This is the fallback implementation for parallel I/O formats that
154  // do not yet implement proper writing in parallel, and instead rely
155  // on the full solution vector being available on all processors.
156  std::vector<Number> soln;
157  parallel_soln.localize(soln);
158  this->write_nodal_data(fname, soln, names);
159 }
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:109
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ write_nodal_data() [3/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 162 of file mesh_output.C.

References libMesh::EquationSystems::build_parallel_solution_vector(), and libMesh::EquationSystems::build_variable_names().

165 {
166  std::vector<std::string> names;
167  es.build_variable_names (names, nullptr, system_names);
168 
169  std::unique_ptr<NumericVector<Number>> parallel_soln =
170  es.build_parallel_solution_vector(system_names);
171 
172  this->write_nodal_data (fname, *parallel_soln, names);
173 }
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:109

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

121  { libmesh_not_implemented(); }

◆ write_parallel()

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

Report whether we should write parallel files.

Definition at line 379 of file xdr_io.h.

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

Referenced by write().

380 {
381  // We can't insist on both serial and parallel
382  libmesh_assert (!this->_write_serial || !this->_write_parallel);
383 
384  // If we insisted on serial, do that
385  if (this->_write_serial)
386  return false;
387 
388  // If we insisted on parallel, do that
389  if (this->_write_parallel)
390  return true;
391 
392  // If we're doing things automatically, check the mesh
393  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
394  return !mesh.is_serial();
395 }
const MT & mesh() const
Definition: mesh_output.h:259
bool _write_parallel
Definition: xdr_io.h:359
virtual bool is_serial() const
Definition: mesh_base.h:205
libmesh_assert(ctx)
bool _write_serial
Definition: xdr_io.h:358

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

References libMesh::Xdr::data(), libMesh::Quality::name(), and libMesh::ParallelObject::processor_id().

Referenced by write_serialized_bcs_helper(), and write_serialized_nodesets().

1381 {
1382  if (this->processor_id() == 0)
1383  {
1384  const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1385  info.get_sideset_name_map() : info.get_nodeset_name_map();
1386 
1387  std::vector<new_header_id_type> boundary_ids;
1388  boundary_ids.reserve(boundary_map.size());
1389 
1390  std::vector<std::string> boundary_names;
1391  boundary_names.reserve(boundary_map.size());
1392 
1393  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
1394  // return writable references in boundary_info, it's possible for the user to leave some entity names
1395  // blank. We can't write those to the XDA file.
1396  new_header_id_type n_boundary_names = 0;
1397  for (const auto & [bndry_id, name] : boundary_map)
1398  if (!name.empty())
1399  {
1400  n_boundary_names++;
1401  boundary_ids.push_back(bndry_id);
1402  boundary_names.push_back(name);
1403  }
1404 
1405  if (is_sideset)
1406  io.data(n_boundary_names, "# sideset id to name map");
1407  else
1408  io.data(n_boundary_names, "# nodeset id to name map");
1409  // Write out the ids and names in two vectors
1410  if (n_boundary_names)
1411  {
1412  io.data(boundary_ids);
1413  io.data(boundary_names);
1414  }
1415  }
1416 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
MPI_Info info
uint64_t new_header_id_type
Definition: xdr_io.h:63
processor_id_type processor_id() const

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

References libMesh::as_range(), libMesh::BoundaryInfo::boundary_ids(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::BoundaryInfo::edge_boundary_ids(), TIMPI::Communicator::gather(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshTools::Generation::Private::idx(), libMesh::BoundaryInfo::invalid_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), 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().

1164 {
1165  libmesh_assert (io.writing());
1166 
1167  // convenient reference to our mesh
1168  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
1169 
1170  // and our boundary info object
1171  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1172 
1173  // Version 0.9.2+ introduces entity names
1174  write_serialized_bc_names(io, boundary_info, true); // sideset names
1175 
1176  new_header_id_type n_bcs_out = n_bcs;
1177  if (this->processor_id() == 0)
1178  {
1179  std::stringstream comment_string;
1180  comment_string << "# number of " << bc_type << " boundary conditions";
1181  io.data (n_bcs_out, comment_string.str());
1182  }
1183  n_bcs_out = 0;
1184 
1185  if (!n_bcs) return;
1186 
1187  std::vector<xdr_id_type> xfer_bcs, recv_bcs;
1188  std::vector<std::size_t> bc_sizes(this->n_processors());
1189 
1190  // Container to catch boundary IDs handed back by BoundaryInfo
1191  std::vector<boundary_id_type> bc_ids;
1192 
1193  // Boundary conditions are only specified for level-0 elements
1194  dof_id_type n_local_level_0_elem=0;
1195  for (const auto & elem : as_range(mesh.local_level_elements_begin(0),
1196  mesh.local_level_elements_end(0)))
1197  {
1198  if (bc_type == "side")
1199  {
1200  for (auto s : elem->side_index_range())
1201  {
1202  boundary_info.boundary_ids (elem, s, bc_ids);
1203  for (const auto & bc_id : bc_ids)
1204  if (bc_id != BoundaryInfo::invalid_id)
1205  {
1206  xfer_bcs.push_back (n_local_level_0_elem);
1207  xfer_bcs.push_back (s) ;
1208  xfer_bcs.push_back (bc_id);
1209  }
1210  }
1211  }
1212  else if (bc_type == "edge")
1213  {
1214  for (auto e : elem->edge_index_range())
1215  {
1216  boundary_info.edge_boundary_ids (elem, e, bc_ids);
1217  for (const auto & bc_id : bc_ids)
1218  if (bc_id != BoundaryInfo::invalid_id)
1219  {
1220  xfer_bcs.push_back (n_local_level_0_elem);
1221  xfer_bcs.push_back (e) ;
1222  xfer_bcs.push_back (bc_id);
1223  }
1224  }
1225  }
1226  else if (bc_type == "shellface")
1227  {
1228  for (unsigned short sf=0; sf<2; sf++)
1229  {
1230  boundary_info.shellface_boundary_ids (elem, sf, bc_ids);
1231  for (const auto & bc_id : bc_ids)
1232  if (bc_id != BoundaryInfo::invalid_id)
1233  {
1234  xfer_bcs.push_back (n_local_level_0_elem);
1235  xfer_bcs.push_back (sf) ;
1236  xfer_bcs.push_back (bc_id);
1237  }
1238  }
1239  }
1240  else
1241  {
1242  libmesh_error_msg("bc_type not recognized: " + bc_type);
1243  }
1244 
1245  // Increment the level-0 element counter.
1246  n_local_level_0_elem++;
1247  }
1248 
1249  xfer_bcs.push_back(n_local_level_0_elem);
1250  std::size_t my_size = xfer_bcs.size();
1251  this->comm().gather (0, my_size, bc_sizes);
1252 
1253  // All processors send their xfer buffers to processor 0
1254  // Processor 0 will receive all buffers and write out the bcs
1255  if (this->processor_id() == 0)
1256  {
1257  dof_id_type elem_offset = 0;
1258  for (auto pid : make_range(this->n_processors()))
1259  {
1260  recv_bcs.resize(bc_sizes[pid]);
1261  if (pid == 0)
1262  recv_bcs = xfer_bcs;
1263  else
1264  this->comm().receive (pid, recv_bcs);
1265 
1266  const dof_id_type my_n_local_level_0_elem
1267  = cast_int<dof_id_type>(recv_bcs.back());
1268  recv_bcs.pop_back();
1269 
1270  for (std::size_t idx=0, rbs=recv_bcs.size(); idx<rbs; idx += 3, n_bcs_out++)
1271  recv_bcs[idx+0] += elem_offset;
1272 
1273  io.data_stream (recv_bcs.empty() ? nullptr : recv_bcs.data(),
1274  cast_int<unsigned int>(recv_bcs.size()), 3);
1275  elem_offset += my_n_local_level_0_elem;
1276  }
1277  libmesh_assert_equal_to (n_bcs, n_bcs_out);
1278  }
1279  else
1280  this->comm().send (0, xfer_bcs);
1281 }
const MT & mesh() const
Definition: mesh_output.h:259
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
static const boundary_id_type invalid_id
Number used for internal use.
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
libmesh_assert(ctx)
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:1380
uint64_t new_header_id_type
Definition: xdr_io.h:63
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
processor_id_type processor_id() const
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:67

◆ write_serialized_connectivity()

void libMesh::XdrIO::write_serialized_connectivity ( Xdr io,
const dof_id_type  n_elem,
const new_header_id_type  n_elem_integers 
) const
private

Write the connectivity for a parallel, distributed mesh.

Definition at line 330 of file xdr_io.C.

References _write_unique_id, libMesh::as_range(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), TIMPI::Communicator::gather(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshTools::n_active_levels(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_elem(), n_nodes, libMesh::ParallelObject::n_processors(), pack_element(), partition_map_file_name(), polynomial_level_file_name(), libMesh::ParallelObject::processor_id(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), subdomain_map_file_name(), TIMPI::Communicator::sum(), and libMesh::Xdr::writing().

Referenced by write().

333 {
334  libmesh_assert (io.writing());
335 
336  const bool
337  write_p_level = ("." == this->polynomial_level_file_name()),
338  write_partitioning = ("." == this->partition_map_file_name()),
339  write_subdomain_id = ("." == this->subdomain_map_file_name());
340 
341  // convenient reference to our mesh
342  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
343  libmesh_assert_equal_to (n_elem, mesh.n_elem());
344 
345  // We will only write active elements and their parents.
346  const unsigned int n_active_levels = MeshTools::n_active_levels (mesh);
347  std::vector<xdr_id_type> n_global_elem_at_level(n_active_levels);
348 
349  // Find the number of local and global elements at each level
350 #ifndef NDEBUG
351  xdr_id_type tot_n_elem = 0;
352 #endif
353  for (unsigned int level=0; level<n_active_levels; level++)
354  {
355  n_global_elem_at_level[level] =
356  MeshTools::n_elem(mesh.local_level_elements_begin(level),
357  mesh.local_level_elements_end(level));
358 
359  this->comm().sum(n_global_elem_at_level[level]);
360 #ifndef NDEBUG
361  tot_n_elem += n_global_elem_at_level[level];
362 #endif
363  libmesh_assert_less_equal (n_global_elem_at_level[level], n_elem);
364  libmesh_assert_less_equal (tot_n_elem, n_elem);
365  }
366 
367  std::vector<xdr_id_type>
368  xfer_conn, recv_conn;
369  std::vector<dof_id_type>
370  n_elem_on_proc(this->n_processors()), processor_offsets(this->n_processors());
371  std::vector<xdr_id_type> output_buffer;
372  std::vector<std::size_t>
373  xfer_buf_sizes(this->n_processors());
374 
375 #ifdef LIBMESH_ENABLE_AMR
376  typedef std::map<dof_id_type, std::pair<processor_id_type, dof_id_type>> id_map_type;
377  id_map_type parent_id_map, child_id_map;
378 #endif
379 
380  dof_id_type my_next_elem=0, next_global_elem=0;
381 
382  //-------------------------------------------
383  // First write the level-0 elements directly.
384  for (const auto & elem : as_range(mesh.local_level_elements_begin(0),
385  mesh.local_level_elements_end(0)))
386  {
387  pack_element (xfer_conn, elem,
388  /*parent_id=*/DofObject::invalid_id,
389  /*parent_pid=*/DofObject::invalid_id,
390  n_elem_integers);
391 #ifdef LIBMESH_ENABLE_AMR
392  parent_id_map[elem->id()] = std::make_pair(this->processor_id(),
393  my_next_elem);
394 #endif
395  ++my_next_elem;
396  }
397  xfer_conn.push_back(my_next_elem); // toss in the number of elements transferred.
398 
399  std::size_t my_size = xfer_conn.size();
400  this->comm().gather (0, my_next_elem, n_elem_on_proc);
401  this->comm().gather (0, my_size, xfer_buf_sizes);
402 
403  processor_offsets[0] = 0;
404  for (auto pid : IntRange<processor_id_type>(1, this->n_processors()))
405  processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
406 
407  // All processors send their xfer buffers to processor 0.
408  // Processor 0 will receive the data and write out the elements.
409  if (this->processor_id() == 0)
410  {
411  // Write the number of elements at this level.
412  {
413  std::string comment = "# n_elem at level 0", legend = ", [ type ";
414  if (_write_unique_id)
415  legend += "uid ";
416  if (write_partitioning)
417  legend += "pid ";
418  if (write_subdomain_id)
419  legend += "sid ";
420  if (write_p_level)
421  legend += "p_level ";
422  legend += "(n0 ... nN-1) ]";
423  comment += legend;
424  io.data (n_global_elem_at_level[0], comment);
425  }
426 
427  for (auto pid : make_range(this->n_processors()))
428  {
429  recv_conn.resize(xfer_buf_sizes[pid]);
430  if (pid == 0)
431  recv_conn = xfer_conn;
432  else
433  this->comm().receive (pid, recv_conn);
434 
435  // at a minimum, the buffer should contain the number of elements,
436  // which could be 0.
437  libmesh_assert (!recv_conn.empty());
438 
439  for (auto [elem, recv_conn_iter, n_elem_received] =
440  std::tuple{xdr_id_type(0), recv_conn.begin(), recv_conn.back()};
441  elem<n_elem_received; elem++, next_global_elem++)
442  {
443  output_buffer.clear();
444 
445  // n. nodes
446  const xdr_id_type n_nodes = *recv_conn_iter++;
447 
448  // type
449  output_buffer.push_back(*recv_conn_iter++);
450 
451  // unique_id
452  xdr_id_type tmp = *recv_conn_iter++;
453  if (_write_unique_id)
454  output_buffer.push_back(tmp);
455 
456  // processor id
457  tmp = *recv_conn_iter++;
458  if (write_partitioning)
459  output_buffer.push_back(tmp);
460 
461  // subdomain id
462  tmp = *recv_conn_iter++;
463  if (write_subdomain_id)
464  output_buffer.push_back(tmp);
465 
466 #ifdef LIBMESH_ENABLE_AMR
467  // p level
468  tmp = *recv_conn_iter++;
469  if (write_p_level)
470  output_buffer.push_back(tmp);
471 #endif
472 
473  for (dof_id_type node=0; node<n_nodes; node++)
474  output_buffer.push_back(*recv_conn_iter++);
475 
476  // Write out the elem extra integers after the connectivity
477  for (dof_id_type n=0; n<n_elem_integers; n++)
478  output_buffer.push_back(*recv_conn_iter++);
479 
480  io.data_stream
481  (output_buffer.data(),
482  cast_int<unsigned int>(output_buffer.size()),
483  cast_int<unsigned int>(output_buffer.size()));
484  }
485  }
486  }
487  else
488  this->comm().send (0, xfer_conn);
489 
490 #ifdef LIBMESH_ENABLE_AMR
491  //--------------------------------------------------------------------
492  // Next write the remaining elements indirectly through their parents.
493  // This will insure that the children are written in the proper order
494  // so they can be reconstructed properly.
495  for (unsigned int level=1; level<n_active_levels; level++)
496  {
497  xfer_conn.clear();
498 
499  dof_id_type my_n_elem_written_at_level = 0;
500  for (const auto & parent : as_range(mesh.local_level_elements_begin(level-1),
501  mesh.local_level_elements_end(level-1)))
502  if (!parent->active()) // we only want the parents elements at this level, and
503  { // there is no direct iterator for this obscure use
504  id_map_type::iterator pos = parent_id_map.find(parent->id());
505  libmesh_assert (pos != parent_id_map.end());
506  const processor_id_type parent_pid = pos->second.first;
507  const dof_id_type parent_id = pos->second.second;
508  parent_id_map.erase(pos);
509 
510  for (auto & child : parent->child_ref_range())
511  {
512  pack_element (xfer_conn, &child, parent_id, parent_pid, n_elem_integers);
513 
514  // this approach introduces the possibility that we write
515  // non-local elements. These elements may well be parents
516  // at the next step
517  child_id_map[child.id()] = std::make_pair (child.processor_id(),
518  my_n_elem_written_at_level++);
519  my_next_elem++;
520  }
521  }
522  xfer_conn.push_back(my_n_elem_written_at_level);
523  my_size = xfer_conn.size();
524  this->comm().gather (0, my_size, xfer_buf_sizes);
525 
526  // Processor 0 will receive the data and write the elements.
527  if (this->processor_id() == 0)
528  {
529  // Write the number of elements at this level.
530  {
531  std::ostringstream buf;
532  buf << "# n_elem at level " << level << ", [ type ";
533 
534  if (_write_unique_id)
535  buf << "uid ";
536  buf << "parent ";
537  if (write_partitioning)
538  buf << "pid ";
539  if (write_subdomain_id)
540  buf << "sid ";
541  if (write_p_level)
542  buf << "p_level ";
543  buf << "(n0 ... nN-1) ]";
544 
545  io.data (n_global_elem_at_level[level], buf.str());
546  }
547 
548  for (auto pid : make_range(this->n_processors()))
549  {
550  recv_conn.resize(xfer_buf_sizes[pid]);
551  if (pid == 0)
552  recv_conn = xfer_conn;
553  else
554  this->comm().receive (pid, recv_conn);
555 
556  // at a minimum, the buffer should contain the number of elements,
557  // which could be 0.
558  libmesh_assert (!recv_conn.empty());
559 
560  for (auto [elem, recv_conn_iter, n_elem_received] =
561  std::tuple{xdr_id_type(0), recv_conn.begin(), recv_conn.back()};
562  elem<n_elem_received;
563  elem++, next_global_elem++)
564  {
565  output_buffer.clear();
566 
567  // n. nodes
568  const xdr_id_type n_nodes = *recv_conn_iter++;
569 
570  // type
571  output_buffer.push_back(*recv_conn_iter++);
572 
573  // unique_id
574  xdr_id_type tmp = *recv_conn_iter++;
575  if (_write_unique_id)
576  output_buffer.push_back(tmp);
577 
578  // parent local id
579  const xdr_id_type parent_local_id = *recv_conn_iter++;
580 
581  // parent processor id
582  const xdr_id_type parent_pid = *recv_conn_iter++;
583 
584  output_buffer.push_back (parent_local_id+processor_offsets[parent_pid]);
585 
586  // processor id
587  tmp = *recv_conn_iter++;
588  if (write_partitioning)
589  output_buffer.push_back(tmp);
590 
591  // subdomain id
592  tmp = *recv_conn_iter++;
593  if (write_subdomain_id)
594  output_buffer.push_back(tmp);
595 
596  // p level
597  tmp = *recv_conn_iter++;
598  if (write_p_level)
599  output_buffer.push_back(tmp);
600 
601  // connectivity
602  for (xdr_id_type node=0; node<n_nodes; node++)
603  output_buffer.push_back(*recv_conn_iter++);
604 
605  // Write out the elem extra integers after the connectivity
606  for (dof_id_type n=0; n<n_elem_integers; n++)
607  output_buffer.push_back(*recv_conn_iter++);
608 
609  io.data_stream
610  (output_buffer.data(),
611  cast_int<unsigned int>(output_buffer.size()),
612  cast_int<unsigned int>(output_buffer.size()));
613  }
614  }
615  }
616  else
617  this->comm().send (0, xfer_conn);
618 
619  // update the processor_offsets
620  processor_offsets[0] = processor_offsets.back() + n_elem_on_proc.back();
621  this->comm().gather (0, my_n_elem_written_at_level, n_elem_on_proc);
622  for (auto pid : IntRange<processor_id_type>(1, this->n_processors()))
623  processor_offsets[pid] = processor_offsets[pid-1] + n_elem_on_proc[pid-1];
624 
625  // Now, at the next level we will again iterate over local parents. However,
626  // those parents may have been written by other processors (at this step),
627  // so we need to gather them into our *_id_maps.
628  {
629  std::map<processor_id_type, std::vector<dof_id_type>> requested_ids;
630 
631  for (const auto & elem : as_range(mesh.local_level_elements_begin(level),
632  mesh.local_level_elements_end(level)))
633  if (!child_id_map.count(elem->id()))
634  {
635  libmesh_assert_not_equal_to (elem->parent()->processor_id(), this->processor_id());
636  const processor_id_type pid = elem->parent()->processor_id();
637  if (pid != this->processor_id())
638  requested_ids[pid].push_back(elem->id());
639  }
640 
641  auto gather_functor =
642  [& child_id_map]
643  (processor_id_type libmesh_dbg_var(pid),
644  const std::vector<dof_id_type> & ids,
645  std::vector<dof_id_type> & data)
646  {
647  const std::size_t ids_size = ids.size();
648  data.resize(ids_size);
649 
650  // Fill those requests by overwriting the requested ids
651  for (std::size_t i=0; i != ids_size; i++)
652  {
653  libmesh_assert (child_id_map.count(ids[i]));
654  libmesh_assert_equal_to (child_id_map[ids[i]].first, pid);
655 
656  data[i] = child_id_map[ids[i]].second;
657  }
658  };
659 
660  auto action_functor =
661  [& child_id_map]
662  (processor_id_type pid,
663  const std::vector<dof_id_type> & ids,
664  const std::vector<dof_id_type> & data)
665  {
666  std::size_t data_size = data.size();
667 
668  for (std::size_t i=0; i != data_size; i++)
669  child_id_map[ids[i]] =
670  std::make_pair (pid, data[i]);
671  };
672 
673  // Trade ids back and forth
674  const dof_id_type * ex = nullptr;
675  Parallel::pull_parallel_vector_data
676  (this->comm(), requested_ids, gather_functor, action_functor, ex);
677 
678  // overwrite the parent_id_map with the child_id_map, but
679  // use std::map::swap() for efficiency.
680  parent_id_map.swap(child_id_map);
681  child_id_map.clear();
682  }
683  }
684 #endif // LIBMESH_ENABLE_AMR
685  if (this->processor_id() == 0)
686  libmesh_assert_equal_to (next_global_elem, n_elem);
687 
688 }
const MT & mesh() const
Definition: mesh_output.h:259
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:850
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
void sum(T &r) const
const Parallel::Communicator & comm() const
largest_id_type xdr_id_type
Definition: xdr_io.h:57
uint8_t processor_id_type
processor_id_type n_processors() const
const dof_id_type n_nodes
Definition: tecplot_io.C:67
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
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
const std::string & subdomain_map_file_name() const
Get/Set the subdomain file name.
Definition: xdr_io.h:158
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
const std::string & partition_map_file_name() const
Get/Set the partitioning file name.
Definition: xdr_io.h:152
bool _write_unique_id
Definition: xdr_io.h:360
const std::string & polynomial_level_file_name() const
Get/Set the polynomial degree file name.
Definition: xdr_io.h:164
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
void pack_element(std::vector< xdr_id_type > &conn, const Elem *elem, const dof_id_type parent_id, const dof_id_type parent_pid, const new_header_id_type n_elem_integers) const
Pack an element into a transfer buffer for parallel communication.
Definition: xdr_io.C:2430
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:67
unsigned int n_active_levels(const MeshBase &mesh)
Definition: mesh_tools.C:771

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

References write_serialized_bcs_helper().

Referenced by write().

1293 {
1294  write_serialized_bcs_helper(io, n_edge_bcs, "edge");
1295 }
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:1163

◆ write_serialized_nodes()

void libMesh::XdrIO::write_serialized_nodes ( Xdr io,
const dof_id_type  n_nodes,
const new_header_id_type  n_node_integers 
) const
private

Write the nodal locations for a parallel, distributed mesh.

Definition at line 692 of file xdr_io.C.

References libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), TIMPI::Communicator::gather(), libMesh::DofObject::get_extra_integer(), TIMPI::Communicator::get_unique_tag(), libMesh::DofObject::id(), libMesh::MeshTools::Generation::Private::idx(), libMesh::index_range(), io_blksize, libMesh::make_range(), libMesh::MeshBase::max_node_id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), and libMesh::DofObject::unique_id().

Referenced by write().

694 {
695  // convenient reference to our mesh
696  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
697  libmesh_assert_equal_to (max_node_id, mesh.max_node_id());
698 
699  std::vector<dof_id_type> xfer_ids;
700  std::vector<Real> xfer_coords;
701  std::vector<Real> & coords=xfer_coords;
702 
703  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
704  std::vector<std::vector<Real>> recv_coords(this->n_processors());
705 
706 #ifndef NDEBUG
707  std::size_t n_written=0;
708 #endif
709 
710  // Note: do not be tempted to replace the node loops below with
711  // range-based iterators, these iterators must be defined outside
712  // the blk loop since node_iter is updated at each iteration.
713  MeshBase::const_node_iterator node_iter = mesh.local_nodes_begin();
714  const MeshBase::const_node_iterator nodes_end = mesh.local_nodes_end();
715 
716  for (std::size_t blk=0, last_node=0; last_node<max_node_id; blk++)
717  {
718  const std::size_t first_node = blk*io_blksize;
719  last_node = std::min((blk+1)*io_blksize, std::size_t(max_node_id));
720 
721  const std::size_t tot_id_size = last_node - first_node;
722 
723  // Build up the xfer buffers on each processor
724  xfer_ids.clear();
725  xfer_coords.clear();
726 
727  for (; node_iter != nodes_end; ++node_iter)
728  {
729  const Node & node = **node_iter;
730  libmesh_assert_greater_equal(node.id(), first_node);
731  if (node.id() >= last_node)
732  break;
733 
734  xfer_ids.push_back(node.id());
735  xfer_coords.push_back(node(0));
736 #if LIBMESH_DIM > 1
737  xfer_coords.push_back(node(1));
738 #endif
739 #if LIBMESH_DIM > 2
740  xfer_coords.push_back(node(2));
741 #endif
742  }
743 
744  //-------------------------------------
745  // Send the xfer buffers to processor 0
746  std::vector<std::size_t> ids_size;
747 
748  const std::size_t my_ids_size = xfer_ids.size();
749 
750  // explicitly gather ids_size
751  this->comm().gather (0, my_ids_size, ids_size);
752 
753  // We will have lots of simultaneous receives if we are
754  // processor 0, so let's use nonblocking receives.
755  std::vector<Parallel::Request>
756  id_request_handles(this->n_processors()-1),
757  coord_request_handles(this->n_processors()-1);
758 
759  Parallel::MessageTag
760  id_tag = mesh.comm().get_unique_tag(),
761  coord_tag = mesh.comm().get_unique_tag();
762 
763  // Post the receives -- do this on processor 0 only.
764  if (this->processor_id() == 0)
765  {
766  for (auto pid : make_range(this->n_processors()))
767  {
768  recv_ids[pid].resize(ids_size[pid]);
769  recv_coords[pid].resize(ids_size[pid]*LIBMESH_DIM);
770 
771  if (pid == 0)
772  {
773  recv_ids[0] = xfer_ids;
774  recv_coords[0] = xfer_coords;
775  }
776  else
777  {
778  this->comm().receive (pid, recv_ids[pid],
779  id_request_handles[pid-1],
780  id_tag);
781  this->comm().receive (pid, recv_coords[pid],
782  coord_request_handles[pid-1],
783  coord_tag);
784  }
785  }
786  }
787  else
788  {
789  // Send -- do this on all other processors.
790  this->comm().send(0, xfer_ids, id_tag);
791  this->comm().send(0, xfer_coords, coord_tag);
792  }
793 
794  // -------------------------------------------------------
795  // Receive the messages and write the output on processor 0.
796  if (this->processor_id() == 0)
797  {
798  // Wait for all the receives to complete. We have no
799  // need for the statuses since we already know the
800  // buffer sizes.
801  Parallel::wait (id_request_handles);
802  Parallel::wait (coord_request_handles);
803 
804 #ifndef NDEBUG
805  for (auto pid : make_range(this->n_processors()))
806  libmesh_assert_equal_to(recv_coords[pid].size(),
807  recv_ids[pid].size()*LIBMESH_DIM);
808 #endif
809 
810  // Write the coordinates in this block.
811  // Some of these coordinates may correspond to ids for which
812  // no node exists, if we have a discontiguous node
813  // numbering!
814  //
815  // The purpose of communicating the xfer_ids/recv_ids buffer
816  // is so that we can handle discontiguous node numberings:
817  // we do not actually write the node ids themselves anywhere
818  // in the xdr file. We do write the unique ids to file, if
819  // enabled (see next section).
820 
821  // Write invalid values for unused node ids
822  coords.clear();
823  coords.resize (3*tot_id_size, std::numeric_limits<Real>::quiet_NaN());
824 
825  for (auto pid : make_range(this->n_processors()))
826  for (auto idx : index_range(recv_ids[pid]))
827  {
828  libmesh_assert_less_equal(first_node, recv_ids[pid][idx]);
829  const std::size_t local_idx = recv_ids[pid][idx] - first_node;
830  libmesh_assert_less(local_idx, tot_id_size);
831 
832  libmesh_assert_less ((3*local_idx+2), coords.size());
833  libmesh_assert_less ((LIBMESH_DIM*idx+LIBMESH_DIM-1), recv_coords[pid].size());
834 
835  coords[3*local_idx+0] = recv_coords[pid][LIBMESH_DIM*idx+0];
836 #if LIBMESH_DIM > 1
837  coords[3*local_idx+1] = recv_coords[pid][LIBMESH_DIM*idx+1];
838 #else
839  coords[3*local_idx+1] = 0.;
840 #endif
841 #if LIBMESH_DIM > 2
842  coords[3*local_idx+2] = recv_coords[pid][LIBMESH_DIM*idx+2];
843 #else
844  coords[3*local_idx+2] = 0.;
845 #endif
846 
847 #ifndef NDEBUG
848  n_written++;
849 #endif
850  }
851 
852  io.data_stream (coords.empty() ? nullptr : coords.data(),
853  cast_int<unsigned int>(coords.size()), /*line_break=*/3);
854  }
855  } // end for (block-based coord writes)
856 
857  if (this->processor_id() == 0)
858  libmesh_assert_less_equal (n_written, max_node_id);
859 
860 #ifdef LIBMESH_ENABLE_UNIQUE_ID
861  // XDR unsigned char doesn't work as anticipated
862  unsigned short write_unique_ids = 1;
863 #else
864  unsigned short write_unique_ids = 0;
865 #endif
866 
867  if (this->processor_id() == 0)
868  io.data (write_unique_ids, "# presence of unique ids");
869 
870 #ifdef LIBMESH_ENABLE_UNIQUE_ID
871 {
872  std::vector<xdr_id_type> xfer_unique_ids;
873  std::vector<xdr_id_type> & unique_ids=xfer_unique_ids;
874  std::vector<std::vector<xdr_id_type>> recv_unique_ids (this->n_processors());
875 
876 #ifndef NDEBUG
877  // Reset write counter
878  n_written = 0;
879 #endif
880 
881  // Return node iterator to the beginning
882  node_iter = mesh.local_nodes_begin();
883 
884  for (std::size_t blk=0, last_node=0; last_node<max_node_id; blk++)
885  {
886  const std::size_t first_node = blk*io_blksize;
887  last_node = std::min((blk+1)*io_blksize, std::size_t(max_node_id));
888 
889  const std::size_t tot_id_size = last_node - first_node;
890 
891  // Build up the xfer buffers on each processor
892  xfer_ids.clear();
893  xfer_ids.reserve(tot_id_size);
894  xfer_unique_ids.clear();
895  xfer_unique_ids.reserve(tot_id_size);
896 
897  for (; node_iter != nodes_end; ++node_iter)
898  {
899  const Node & node = **node_iter;
900  libmesh_assert_greater_equal(node.id(), first_node);
901  if (node.id() >= last_node)
902  break;
903 
904  xfer_ids.push_back(node.id());
905  xfer_unique_ids.push_back(node.unique_id());
906  }
907 
908  //-------------------------------------
909  // Send the xfer buffers to processor 0
910  std::vector<std::size_t> ids_size;
911 
912  const std::size_t my_ids_size = xfer_ids.size();
913 
914  // explicitly gather ids_size
915  this->comm().gather (0, my_ids_size, ids_size);
916 
917  // We will have lots of simultaneous receives if we are
918  // processor 0, so let's use nonblocking receives.
919  std::vector<Parallel::Request>
920  unique_id_request_handles(this->n_processors()-1),
921  id_request_handles(this->n_processors()-1);
922 
923  Parallel::MessageTag
924  unique_id_tag = mesh.comm().get_unique_tag(),
925  id_tag = mesh.comm().get_unique_tag();
926 
927  // Post the receives -- do this on processor 0 only.
928  if (this->processor_id() == 0)
929  {
930  for (auto pid : make_range(this->n_processors()))
931  {
932  recv_ids[pid].resize(ids_size[pid]);
933  recv_unique_ids[pid].resize(ids_size[pid]);
934 
935  if (pid == 0)
936  {
937  recv_ids[0] = xfer_ids;
938  recv_unique_ids[0] = xfer_unique_ids;
939  }
940  else
941  {
942  this->comm().receive (pid, recv_ids[pid],
943  id_request_handles[pid-1],
944  id_tag);
945  this->comm().receive (pid, recv_unique_ids[pid],
946  unique_id_request_handles[pid-1],
947  unique_id_tag);
948  }
949  }
950  }
951  else
952  {
953  // Send -- do this on all other processors.
954  this->comm().send(0, xfer_ids, id_tag);
955  this->comm().send(0, xfer_unique_ids, unique_id_tag);
956  }
957 
958  // -------------------------------------------------------
959  // Receive the messages and write the output on processor 0.
960  if (this->processor_id() == 0)
961  {
962  // Wait for all the receives to complete. We have no
963  // need for the statuses since we already know the
964  // buffer sizes.
965  Parallel::wait (id_request_handles);
966  Parallel::wait (unique_id_request_handles);
967 
968 #ifndef NDEBUG
969  for (auto pid : make_range(this->n_processors()))
970  libmesh_assert_equal_to
971  (recv_ids[pid].size(), recv_unique_ids[pid].size());
972 #endif
973 
974  libmesh_assert_less_equal
975  (tot_id_size, std::min(io_blksize, std::size_t(max_node_id)));
976 
977  // Write the unique ids in this block.
978  unique_ids.clear();
979  unique_ids.resize(tot_id_size, unique_id_type(-1));
980 
981  for (auto pid : make_range(this->n_processors()))
982  for (auto idx : index_range(recv_ids[pid]))
983  {
984  libmesh_assert_less_equal(first_node, recv_ids[pid][idx]);
985  const std::size_t local_idx = recv_ids[pid][idx] - first_node;
986  libmesh_assert_less (local_idx, unique_ids.size());
987 
988  unique_ids[local_idx] = recv_unique_ids[pid][idx];
989 
990 #ifndef NDEBUG
991  n_written++;
992 #endif
993  }
994 
995  io.data_stream (unique_ids.empty() ? nullptr : unique_ids.data(),
996  cast_int<unsigned int>(unique_ids.size()), /*line_break=*/1);
997  }
998  } // end for (block-based unique_id writes)
999 
1000  if (this->processor_id() == 0)
1001  libmesh_assert_less_equal (n_written, max_node_id);
1002 }
1003 #endif // LIBMESH_ENABLE_UNIQUE_ID
1004 
1005  // Next: do "block"-based I/O for the extra node integers (if necessary)
1006  if (n_node_integers)
1007  {
1008 #ifndef NDEBUG
1009  // Reset write counter
1010  n_written = 0;
1011 #endif
1012 
1013  // Return node iterator to the beginning
1014  node_iter = mesh.local_nodes_begin();
1015 
1016  // Data structures for writing "extra" node integers
1017  std::vector<dof_id_type> xfer_node_integers;
1018  std::vector<dof_id_type> & node_integers = xfer_node_integers;
1019  std::vector<std::vector<dof_id_type>> recv_node_integers(this->n_processors());
1020 
1021  for (std::size_t blk=0, last_node=0; last_node<max_node_id; blk++)
1022  {
1023  const std::size_t first_node = blk*io_blksize;
1024  last_node = std::min((blk+1)*io_blksize, std::size_t(max_node_id));
1025 
1026  const std::size_t tot_id_size = last_node - first_node;
1027 
1028  // Build up the xfer buffers on each processor
1029  xfer_ids.clear();
1030  xfer_ids.reserve(tot_id_size);
1031  xfer_node_integers.clear();
1032  xfer_node_integers.reserve(tot_id_size * n_node_integers);
1033 
1034  for (; node_iter != nodes_end; ++node_iter)
1035  {
1036  const Node & node = **node_iter;
1037  libmesh_assert_greater_equal(node.id(), first_node);
1038  if (node.id() >= last_node)
1039  break;
1040 
1041  xfer_ids.push_back(node.id());
1042 
1043  // Append current node's node integers to xfer buffer
1044  for (unsigned int i=0; i != n_node_integers; ++i)
1045  xfer_node_integers.push_back(node.get_extra_integer(i));
1046  }
1047 
1048  //-------------------------------------
1049  // Send the xfer buffers to processor 0
1050  std::vector<std::size_t> ids_size;
1051 
1052  const std::size_t my_ids_size = xfer_ids.size();
1053 
1054  // explicitly gather ids_size
1055  this->comm().gather (0, my_ids_size, ids_size);
1056 
1057  // We will have lots of simultaneous receives if we are
1058  // processor 0, so let's use nonblocking receives.
1059  std::vector<Parallel::Request>
1060  node_integers_request_handles(this->n_processors()-1),
1061  id_request_handles(this->n_processors()-1);
1062 
1063  Parallel::MessageTag
1064  node_integers_tag = mesh.comm().get_unique_tag(),
1065  id_tag = mesh.comm().get_unique_tag();
1066 
1067  // Post the receives -- do this on processor 0 only.
1068  if (this->processor_id() == 0)
1069  {
1070  for (auto pid : make_range(this->n_processors()))
1071  {
1072  recv_ids[pid].resize(ids_size[pid]);
1073  recv_node_integers[pid].resize(n_node_integers * ids_size[pid]);
1074 
1075  if (pid == 0)
1076  {
1077  recv_ids[0] = xfer_ids;
1078  recv_node_integers[0] = xfer_node_integers;
1079  }
1080  else
1081  {
1082  this->comm().receive (pid, recv_ids[pid],
1083  id_request_handles[pid-1],
1084  id_tag);
1085  this->comm().receive (pid, recv_node_integers[pid],
1086  node_integers_request_handles[pid-1],
1087  node_integers_tag);
1088  }
1089  }
1090  }
1091  else
1092  {
1093  // Send -- do this on all other processors.
1094  this->comm().send(0, xfer_ids, id_tag);
1095  this->comm().send(0, xfer_node_integers, node_integers_tag);
1096  }
1097 
1098  // -------------------------------------------------------
1099  // Receive the messages and write the output on processor 0.
1100  if (this->processor_id() == 0)
1101  {
1102  // Wait for all the receives to complete. We have no
1103  // need for the statuses since we already know the
1104  // buffer sizes.
1105  Parallel::wait (id_request_handles);
1106  Parallel::wait (node_integers_request_handles);
1107 
1108 #ifndef NDEBUG
1109  for (auto pid : make_range(this->n_processors()))
1110  libmesh_assert_equal_to
1111  (recv_ids[pid].size(), recv_node_integers[pid].size() / n_node_integers);
1112 #endif
1113 
1114  libmesh_assert_less_equal
1115  (tot_id_size, std::min(io_blksize, std::size_t(max_node_id)));
1116 
1117  // Write the node integers in this block. We will write
1118  // invalid node integers if no node exists, i.e. if we
1119  // have a discontiguous node numbering!
1120  //
1121  // The purpose of communicating the xfer_ids/recv_ids buffer
1122  // is so that we can handle discontiguous node numberings:
1123  // we do not actually write the node ids themselves anywhere
1124  // in the xdr file. We do write the unique ids to file, if
1125  // enabled (see previous section).
1126 
1127  // Note: we initialize the node_integers array with invalid values,
1128  // so any indices which don't get written to in the loop below will
1129  // just contain invalid values.
1130  node_integers.clear();
1131  node_integers.resize (n_node_integers*tot_id_size, static_cast<dof_id_type>(-1));
1132 
1133  for (auto pid : make_range(this->n_processors()))
1134  for (auto idx : index_range(recv_ids[pid]))
1135  {
1136  libmesh_assert_less_equal(first_node, recv_ids[pid][idx]);
1137  const std::size_t local_idx = recv_ids[pid][idx] - first_node;
1138 
1139  // Assert that we won't index past the end of the node_integers array
1140  libmesh_assert_less (local_idx, tot_id_size);
1141 
1142  for (unsigned int i=0; i != n_node_integers; ++i)
1143  node_integers[n_node_integers*local_idx + i] = recv_node_integers[pid][n_node_integers*idx + i];
1144 
1145 #ifndef NDEBUG
1146  n_written++;
1147 #endif
1148  }
1149 
1150  io.data_stream (node_integers.empty() ? nullptr : node_integers.data(),
1151  cast_int<unsigned int>(node_integers.size()), /*line_break=*/n_node_integers);
1152  }
1153  } // end for (block-based unique_id writes)
1154 
1155  if (this->processor_id() == 0)
1156  libmesh_assert_less_equal (n_written, max_node_id);
1157 
1158  } // end if (n_node_integers)
1159 }
const MT & mesh() const
Definition: mesh_output.h:259
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
static const std::size_t io_blksize
Define the block size to use for chunked IO.
Definition: xdr_io.h:371
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
virtual dof_id_type max_node_id() const =0
processor_id_type processor_id() const
uint8_t unique_id_type
Definition: id_types.h:86
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
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.

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

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

Referenced by write().

1307 {
1308  libmesh_assert (io.writing());
1309 
1310  // convenient reference to our mesh
1311  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
1312 
1313  // and our boundary info object
1314  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
1315 
1316  // Version 0.9.2+ introduces entity names
1317  write_serialized_bc_names(io, boundary_info, false); // nodeset names
1318 
1319  new_header_id_type n_nodesets_out = n_nodesets;
1320  if (this->processor_id() == 0)
1321  io.data (n_nodesets_out, "# number of nodesets");
1322  n_nodesets_out = 0;
1323 
1324  if (!n_nodesets) return;
1325 
1326  std::vector<xdr_id_type> xfer_bcs, recv_bcs;
1327  std::vector<std::size_t> bc_sizes(this->n_processors());
1328 
1329  // Container to catch boundary IDs handed back by BoundaryInfo
1330  std::vector<boundary_id_type> nodeset_ids;
1331 
1332  dof_id_type n_node=0;
1333  for (const auto & node : mesh.local_node_ptr_range())
1334  {
1335  boundary_info.boundary_ids (node, nodeset_ids);
1336  for (const auto & bc_id : nodeset_ids)
1337  if (bc_id != BoundaryInfo::invalid_id)
1338  {
1339  xfer_bcs.push_back (node->id());
1340  xfer_bcs.push_back (bc_id);
1341  }
1342  }
1343 
1344  xfer_bcs.push_back(n_node);
1345  std::size_t my_size = xfer_bcs.size();
1346  this->comm().gather (0, my_size, bc_sizes);
1347 
1348  // All processors send their xfer buffers to processor 0
1349  // Processor 0 will receive all buffers and write out the bcs
1350  if (this->processor_id() == 0)
1351  {
1352  dof_id_type node_offset = 0;
1353  for (auto pid : make_range(this->n_processors()))
1354  {
1355  recv_bcs.resize(bc_sizes[pid]);
1356  if (pid == 0)
1357  recv_bcs = xfer_bcs;
1358  else
1359  this->comm().receive (pid, recv_bcs);
1360 
1361  const dof_id_type my_n_node =
1362  cast_int<dof_id_type>(recv_bcs.back());
1363  recv_bcs.pop_back();
1364 
1365  for (std::size_t idx=0, rbs=recv_bcs.size(); idx<rbs; idx += 2, n_nodesets_out++)
1366  recv_bcs[idx+0] += node_offset;
1367 
1368  io.data_stream (recv_bcs.empty() ? nullptr : recv_bcs.data(),
1369  cast_int<unsigned int>(recv_bcs.size()), 2);
1370  node_offset += my_n_node;
1371  }
1372  libmesh_assert_equal_to (n_nodesets, n_nodesets_out);
1373  }
1374  else
1375  this->comm().send (0, xfer_bcs);
1376 }
const MT & mesh() const
Definition: mesh_output.h:259
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
static const boundary_id_type invalid_id
Number used for internal use.
libmesh_assert(ctx)
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:1380
uint64_t new_header_id_type
Definition: xdr_io.h:63
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
processor_id_type processor_id() const
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:67

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

References write_serialized_bcs_helper().

Referenced by write().

1300 {
1301  write_serialized_bcs_helper(io, n_shellface_bcs, "shellface");
1302 }
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:1163

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

References write_serialized_bcs_helper().

Referenced by write().

1286 {
1287  write_serialized_bcs_helper(io, n_side_bcs, "side");
1288 }
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:1163

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

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

Referenced by write().

292 {
293  if (this->processor_id() == 0)
294  {
295  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
296 
297  const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
298 
299  std::vector<new_header_id_type> subdomain_ids;
300  subdomain_ids.reserve(subdomain_map.size());
301 
302  std::vector<std::string> subdomain_names;
303  subdomain_names.reserve(subdomain_map.size());
304 
305  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
306  // return writable references in mesh_base, it's possible for the user to leave some entity names
307  // blank. We can't write those to the XDA file.
308  new_header_id_type n_subdomain_names = 0;
309  for (const auto & [sbd_id, name] : subdomain_map)
310  if (!name.empty())
311  {
312  n_subdomain_names++;
313  subdomain_ids.push_back(sbd_id);
314  subdomain_names.push_back(name);
315  }
316 
317  io.data(n_subdomain_names, "# subdomain id to name map");
318  // Write out the ids and names in two vectors
319  if (n_subdomain_names)
320  {
321  io.data(subdomain_ids);
322  io.data(subdomain_names);
323  }
324  }
325 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const MT & mesh() const
Definition: mesh_output.h:259
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1671
uint64_t new_header_id_type
Definition: xdr_io.h:63
processor_id_type processor_id() const

Member Data Documentation

◆ _bc_file_name

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

Definition at line 363 of file xdr_io.h.

Referenced by boundary_condition_file_name().

◆ _binary

bool libMesh::XdrIO::_binary
private

Definition at line 356 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 361 of file xdr_io.h.

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

◆ _is_parallel_format

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

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

◆ _legacy

bool libMesh::XdrIO::_legacy
private

Definition at line 357 of file xdr_io.h.

Referenced by legacy().

◆ _p_level_file

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

Definition at line 366 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 364 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 193 of file mesh_output.h.

◆ _subdomain_map_file

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

Definition at line 365 of file xdr_io.h.

Referenced by subdomain_map_file_name().

◆ _version

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

Definition at line 362 of file xdr_io.h.

Referenced by version().

◆ _write_parallel

bool libMesh::XdrIO::_write_parallel
private

Definition at line 359 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 358 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 360 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

◆ io_blksize

const std::size_t libMesh::XdrIO::io_blksize = 128000
staticprivate

Define the block size to use for chunked IO.

Definition at line 371 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: