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

The CheckpointIO class can be used to write simplified restart files that can be used to restart simulations that have crashed. More...

#include <checkpoint_io.h>

Inheritance diagram for libMesh::CheckpointIO:
[legend]

Public Types

typedef largest_id_type xdr_id_type
 
typedef uint64_t header_id_type
 

Public Member Functions

 CheckpointIO (MeshBase &, const bool=false)
 Constructor. More...
 
 CheckpointIO (const MeshBase &, const bool=false)
 Constructor. More...
 
virtual ~CheckpointIO ()
 Destructor. More...
 
virtual void read (const std::string &input_name) override
 This method implements reading a mesh from a specified file. More...
 
virtual void write (const std::string &name) 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 parallel () const
 Get/Set the flag indicating if we should read/write binary. More...
 
bool & parallel ()
 
const std::string & version () const
 Get/Set the version string. More...
 
std::string & version ()
 
bool version_at_least_1_5 () const
 
const std::vector< processor_id_type > & current_processor_ids () const
 Get/Set the processor id or processor ids to use. More...
 
std::vector< processor_id_type > & current_processor_ids ()
 
const processor_id_typecurrent_n_processors () const
 Get/Set the n_processors to use. More...
 
processor_id_typecurrent_n_processors ()
 
template<typename file_id_type >
void read_remote_elem (Xdr &io, bool libmesh_dbg_var(expect_all_remote))
 
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
 

Static Public Member Functions

static void cleanup (const std::string &input_name, processor_id_type n_procs)
 Used to remove a checkpoint directory and its corresponding files. More...
 

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_subdomain_names (Xdr &io) const
 Write subdomain name information. More...
 
void write_connectivity (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 Write the connectivity for part of a mesh. More...
 
void write_remote_elem (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 Write the remote_elem neighbor and child links for part of a mesh. More...
 
void write_nodes (Xdr &io, const connected_node_set_type &nodeset) const
 Write the nodal locations for part of a mesh. More...
 
void write_bcs (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements, const std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type >> &bc_triples) const
 Write the side boundary conditions for part of a mesh. More...
 
void write_nodesets (Xdr &io, const connected_node_set_type &nodeset, const std::vector< std::tuple< dof_id_type, boundary_id_type >> &bc_tuples) const
 Write the nodal boundary conditions for part of a mesh. More...
 
void write_bc_names (Xdr &io, const BoundaryInfo &info, bool is_sideset) const
 Write boundary names information (sideset and nodeset) More...
 
template<typename file_id_type >
file_id_type read_header (const std::string &name)
 Read header data on processor 0, then broadcast. More...
 
template<typename file_id_type >
void read_subfile (Xdr &io, bool expect_all_remote)
 Read a non-header file. More...
 
template<typename file_id_type >
void read_subdomain_names (Xdr &io)
 Read subdomain name information. More...
 
template<typename file_id_type >
void read_connectivity (Xdr &io)
 Read the connectivity for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_remote_elem (Xdr &io, bool expect_all_remote)
 Read the remote_elem neighbor and child links for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_nodes (Xdr &io)
 Read the nodal locations for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_bcs (Xdr &io)
 Read the boundary conditions for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_nodesets (Xdr &io)
 Read the nodeset conditions for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_bc_names (Xdr &io, BoundaryInfo &info, bool is_sideset)
 Read boundary names information (sideset and nodeset) More...
 
template<typename file_id_type >
void read_integers_names (Xdr &io, std::vector< std::string > &node_integer_names, std::vector< std::string > &elem_integer_names)
 Read extra integers names information. More...
 
unsigned int n_active_levels_in (MeshBase::const_element_iterator begin, MeshBase::const_element_iterator end) const
 
processor_id_type select_split_config (const std::string &input_name, header_id_type &data_size)
 

Private Attributes

bool _binary
 
bool _parallel
 
std::string _version
 
std::vector< processor_id_type_my_processor_ids
 
processor_id_type _my_n_processors
 

Detailed Description

The CheckpointIO class can be used to write simplified restart files that can be used to restart simulations that have crashed.

Author
Benjamin Kirk
John Peterson
Derek Gaston
Roy Stogner
Date
2017

Definition at line 61 of file checkpoint_io.h.

Member Typedef Documentation

◆ header_id_type

Definition at line 70 of file checkpoint_io.h.

◆ xdr_id_type

Definition at line 67 of file checkpoint_io.h.

Constructor & Destructor Documentation

◆ CheckpointIO() [1/2]

libMesh::CheckpointIO::CheckpointIO ( 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 164 of file checkpoint_io.C.

164  :
165  MeshInput<MeshBase> (mesh,/* is_parallel_format = */ true),
166  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
168  _binary (binary_in),
169  _parallel (false),
170  _version ("checkpoint-1.5"),
173 {
174 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
template class LIBMESH_EXPORT MeshOutput< MeshBase >
Definition: mesh_output.C:180
std::vector< processor_id_type > _my_processor_ids
processor_id_type n_processors() const
processor_id_type _my_n_processors
virtual bool is_replicated() const
Definition: mesh_base.h:227
processor_id_type processor_id() const

◆ CheckpointIO() [2/2]

libMesh::CheckpointIO::CheckpointIO ( 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 176 of file checkpoint_io.C.

176  :
177  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
179  _binary (binary_in),
180  _parallel (false),
183 {
184 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
template class LIBMESH_EXPORT MeshOutput< MeshBase >
Definition: mesh_output.C:180
std::vector< processor_id_type > _my_processor_ids
processor_id_type n_processors() const
processor_id_type _my_n_processors
virtual bool is_replicated() const
Definition: mesh_base.h:227
processor_id_type processor_id() const

◆ ~CheckpointIO()

libMesh::CheckpointIO::~CheckpointIO ( )
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::CheckpointIO::binary ( ) const
inline

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

Definition at line 146 of file checkpoint_io.h.

References _binary.

Referenced by read(), read_header(), select_split_config(), CheckpointIOTest::testSplitter(), and write().

146 { return _binary; }

◆ binary() [2/2]

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

Definition at line 147 of file checkpoint_io.h.

References _binary.

147 { return _binary; }

◆ cleanup()

void libMesh::CheckpointIO::cleanup ( const std::string &  input_name,
processor_id_type  n_procs 
)
static

Used to remove a checkpoint directory and its corresponding files.

This effectively undoes all the work done be calls to write(...). For example, if a checkpoint configuration was written via:

unsigned int n_splits = 42;
std::unique_ptr<CheckpointIO> cp = split_mesh(my_mesh, n_splits);
// ...
cp->write("foo.cpr");

then you could remove all the corresponding created files/dirs by:

CheckpointIO::cleanup(my_mesh, n_splits);

Or for cases where the split configuration was determined automatically (e.g. via number of running procs with distributed/parallel mesh), then you could:

CheckpointIO::cleanup(your_mesh, your_mesh.comm().size());

Other remaining checkpoint split configurations for the mesh are left unmodified.

Definition at line 251 of file checkpoint_io.C.

252 {
253  auto header = header_file(input_name, n_procs);
254  auto ret = std::remove(header.c_str());
255  if (ret != 0)
256  libmesh_warning("Failed to clean up checkpoint header '" << header << "': " << std::strerror(ret));
257 
258  for (processor_id_type i = 0; i < n_procs; i++)
259  {
260  auto split = split_file(input_name, n_procs, i);
261  ret = std::remove(split.c_str());
262  if (ret != 0)
263  libmesh_warning("Failed to clean up checkpoint split file '" << split << "': " << std::strerror(ret));
264  }
265 
266  auto dir = split_dir(input_name, n_procs);
267  ret = rmdir(dir.c_str());
268  if (ret != 0)
269  libmesh_warning("Failed to clean up checkpoint split dir '" << dir << "': " << std::strerror(ret));
270 
271  // We expect that this may fail if there are other split configurations still present in this
272  // directory - so don't bother to check/warn for failure.
273  rmdir(input_name.c_str());
274 }
uint8_t processor_id_type
tbb::split split
Dummy "splitting object" used to distinguish splitting constructors from copy constructors.
Definition: threads_tbb.h:77

◆ 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(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), read_header(), libMesh::XdrIO::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(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::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(), 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(), libMesh::XdrIO::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(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::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

◆ current_n_processors() [1/2]

const processor_id_type& libMesh::CheckpointIO::current_n_processors ( ) const
inline

Get/Set the n_processors to use.

The default n_processors to use is the n_processors() of the mesh.

This is used for m->n parallel checkpoint file writing: You can force CheckpointIO to view the world as if it contains this number of processors by setting it here

Definition at line 193 of file checkpoint_io.h.

References _my_n_processors.

Referenced by CheckpointIOTest::testSplitter().

193 { return _my_n_processors; }
processor_id_type _my_n_processors

◆ current_n_processors() [2/2]

processor_id_type& libMesh::CheckpointIO::current_n_processors ( )
inline

Definition at line 194 of file checkpoint_io.h.

References _my_n_processors.

194 { return _my_n_processors; }
processor_id_type _my_n_processors

◆ current_processor_ids() [1/2]

const std::vector<processor_id_type>& libMesh::CheckpointIO::current_processor_ids ( ) const
inline

Get/Set the processor id or processor ids to use.

The default processor_id to use is the processor_id() of the mesh.

This is used for m->n parallel checkpoint file writing: You can force CheckpointIO to write out different partitions of a mesh by setting which partitions to write from each processor here.

Definition at line 180 of file checkpoint_io.h.

References _my_processor_ids.

Referenced by CheckpointIOTest::testSplitter().

180 { return _my_processor_ids; }
std::vector< processor_id_type > _my_processor_ids

◆ current_processor_ids() [2/2]

std::vector<processor_id_type>& libMesh::CheckpointIO::current_processor_ids ( )
inline

Definition at line 181 of file checkpoint_io.h.

References _my_processor_ids.

181 { return _my_processor_ids; }
std::vector< processor_id_type > _my_processor_ids

◆ 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

◆ 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(), libMesh::XdrIO::read(), read(), libMesh::VTKIO::read(), read_bcs(), read_connectivity(), libMesh::ExodusII_IO::read_header(), read_header(), libMesh::XdrIO::read_header(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), read_nodes(), read_nodesets(), read_remote_elem(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::ExodusII_IO::read_sideset_data(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), read_subdomain_names(), libMesh::TetGenIO::write(), libMesh::Nemesis_IO::write(), libMesh::XdrIO::write(), 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(), write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::ExodusII_IO::write_sideset_data(), libMesh::UCDIO::write_soln(), and 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_active_levels_in()

unsigned int libMesh::CheckpointIO::n_active_levels_in ( MeshBase::const_element_iterator  begin,
MeshBase::const_element_iterator  end 
) const
private
Returns
The number of levels of refinement in the active mesh on this processor.
Note
This includes all elements on this processor even those not owned by this processor! Implemented by looping over all the active elements and finding the maximum level.

Definition at line 1450 of file checkpoint_io.C.

References libMesh::as_range(), and libMesh::MeshTools::max_level().

1452 {
1453  unsigned int max_level = 0;
1454 
1455  for (const auto & elem : as_range(begin, end))
1456  max_level = std::max(elem->level(), max_level);
1457 
1458  return max_level + 1;
1459 }
unsigned int max_level(const MeshBase &mesh)
Find the maximum h-refinement level in a mesh.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57

◆ n_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(), read(), read_connectivity(), libMesh::XdrIO::read_header(), 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(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::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)

◆ parallel() [1/2]

bool libMesh::CheckpointIO::parallel ( ) const
inline

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

Definition at line 152 of file checkpoint_io.h.

References _parallel.

Referenced by CheckpointIOTest::testSplitter(), and write().

152 { return _parallel; }

◆ parallel() [2/2]

bool& libMesh::CheckpointIO::parallel ( )
inline

Definition at line 153 of file checkpoint_io.h.

References _parallel.

153 { return _parallel; }

◆ 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(), libMesh::XdrIO::read(), read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), read_header(), libMesh::XdrIO::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(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::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(), 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(), libMesh::XdrIO::write(), write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_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(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::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::CheckpointIO::read ( const std::string &  input_name)
overridevirtual

This method implements reading a mesh from a specified file.

If the mesh has been split for running on several processors, input_name should simply be the name of the mesh split directory without the "-split[n]" suffix. The number of splits will be determined automatically by the number of processes being used for the mesh at the time of reading.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 814 of file checkpoint_io.C.

References binary(), libMesh::MeshCommunication::broadcast(), libMesh::Xdr::close(), libMesh::DECODE, libMesh::MeshBase::is_replicated(), libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::n_elem(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::READ, select_split_config(), and libMesh::MeshBase::set_distributed().

Referenced by libMesh::NameBasedIO::read(), and CheckpointIOTest::testSplitter().

815 {
816  LOG_SCOPE("read()","CheckpointIO");
817 
818  MeshBase & mesh = MeshInput<MeshBase>::mesh();
819 
821 
822  header_id_type data_size;
823  processor_id_type input_n_procs = select_split_config(input_name, data_size);
824  auto header_name = header_file(input_name, input_n_procs);
825  bool input_parallel = input_n_procs > 0;
826 
827  // If this is a serial read then we're going to only read the mesh
828  // on processor 0, then broadcast it
829  if ((input_parallel && !mesh.is_replicated()) || mesh.processor_id() == 0)
830  {
831  // If we're trying to read a parallel checkpoint file on a
832  // replicated mesh, we'll read every file on processor 0 so we
833  // can broadcast it later. If we're on a distributed mesh then
834  // we'll read every id to it's own processor and we'll "wrap
835  // around" with any ids that exceed our processor count.
836  const processor_id_type begin_proc_id =
837  (input_parallel && !mesh.is_replicated()) ?
838  mesh.processor_id() : 0;
839  const processor_id_type stride =
840  (input_parallel && !mesh.is_replicated()) ?
841  mesh.n_processors() : 1;
842 
843  for (processor_id_type proc_id = begin_proc_id; proc_id < input_n_procs;
844  proc_id = cast_int<processor_id_type>(proc_id + stride))
845  {
846  auto file_name = split_file(input_name, input_n_procs, proc_id);
847 
848  {
849  std::ifstream in (file_name.c_str());
850 
851  libmesh_error_msg_if(!in.good(), "ERROR: cannot locate specified file:\n\t" << file_name);
852  }
853 
854  // Do we expect all our files' remote_elem entries to really
855  // be remote? Only if we're not reading multiple input
856  // files on the same processor.
857  const bool expect_all_remote =
858  (input_n_procs <= mesh.n_processors() &&
859  !mesh.is_replicated());
860 
861  Xdr io (file_name, this->binary() ? DECODE : READ);
862 
863  switch (data_size) {
864  case 2:
865  this->read_subfile<uint16_t>(io, expect_all_remote);
866  break;
867  case 4:
868  this->read_subfile<uint32_t>(io, expect_all_remote);
869  break;
870  case 8:
871  this->read_subfile<uint64_t>(io, expect_all_remote);
872  break;
873  default:
874  libmesh_error();
875  }
876 
877  io.close();
878  }
879  }
880 
881  // If the mesh was only read on processor 0 then we need to broadcast it
882  if (mesh.is_replicated())
883  MeshCommunication().broadcast(mesh);
884  // If the mesh is really distributed then we need to make sure it
885  // knows that
886  else if (mesh.n_processors() > 1)
888 }
processor_id_type select_split_config(const std::string &input_name, header_id_type &data_size)
virtual void set_distributed()
Asserts that not all elements and nodes of the mesh necessarily exist on the current processor...
Definition: mesh_base.h:220
uint8_t processor_id_type
processor_id_type n_processors() const
libmesh_assert(ctx)
virtual bool is_replicated() const
Definition: mesh_base.h:227
bool binary() const
Get/Set the flag indicating if we should read/write binary.
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const

◆ read_bc_names()

template<typename file_id_type >
void libMesh::CheckpointIO::read_bc_names ( Xdr io,
BoundaryInfo info,
bool  is_sideset 
)
private

Read boundary names information (sideset and nodeset)

Definition at line 1407 of file checkpoint_io.C.

References libMesh::Xdr::data(), and libMesh::index_range().

1408 {
1409  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1410  info.set_sideset_name_map() : info.set_nodeset_name_map();
1411 
1412  std::vector<file_id_type> boundary_ids;
1413  std::vector<std::string> boundary_names;
1414 
1415  file_id_type n_boundary_names = 0;
1416 
1417  if (is_sideset)
1418  io.data(n_boundary_names, "# sideset id to name map");
1419  else
1420  io.data(n_boundary_names, "# nodeset id to name map");
1421 
1422  if (n_boundary_names)
1423  {
1424  io.data(boundary_ids);
1425  io.data(boundary_names);
1426  }
1427 
1428  // Add them back into the map
1429  for (auto i : index_range(boundary_ids))
1430  boundary_map[cast_int<boundary_id_type>(boundary_ids[i])] =
1431  boundary_names[i];
1432 }
MPI_Info info
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

◆ read_bcs()

template<typename file_id_type >
void libMesh::CheckpointIO::read_bcs ( Xdr io)
private

Read the boundary conditions for a parallel, distributed mesh.

Definition at line 1359 of file checkpoint_io.C.

References libMesh::BoundaryInfo::add_side(), libMesh::Xdr::data(), libMesh::MeshBase::get_boundary_info(), libMesh::index_range(), libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshInput< MT >::mesh().

1360 {
1361  // convenient reference to our mesh
1362  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1363 
1364  // and our boundary info object
1365  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1366 
1367  std::vector<file_id_type> element_id_list;
1368  std::vector<uint16_t> side_list;
1369  std::vector<file_id_type> bc_id_list;
1370 
1371  io.data(element_id_list, "# element ids for bcs");
1372  io.data(side_list, "# sides of elements for bcs");
1373  io.data(bc_id_list, "# bc ids");
1374 
1375  for (auto i : index_range(element_id_list))
1376  boundary_info.add_side
1377  (cast_int<dof_id_type>(element_id_list[i]), side_list[i],
1378  cast_int<boundary_id_type>(bc_id_list[i]));
1379 }
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
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

◆ read_connectivity()

template<typename file_id_type >
void libMesh::CheckpointIO::read_connectivity ( Xdr io)
private

Read the connectivity for a parallel, distributed mesh.

Definition at line 1127 of file checkpoint_io.C.

References libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::Elem::build(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshBase::elem_ptr(), libMesh::DofObject::get_extra_integer(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::n_elem_integers(), libMesh::DofObject::n_extra_integers(), n_nodes, libMesh::Elem::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::Elem::node_id(), libMesh::MeshBase::node_ptr(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::MeshBase::query_elem_ptr(), libMesh::DofObject::set_extra_integer(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), libMesh::Elem::type_to_n_nodes_map, and version_at_least_1_5().

1128 {
1129  // convenient reference to our mesh
1130  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1131 
1132  const bool read_extra_integers = this->version_at_least_1_5();
1133 
1134  const unsigned int n_extra_integers =
1135  read_extra_integers ? mesh.n_elem_integers() : 0;
1136 
1137  file_id_type n_elems_here;
1138  io.data(n_elems_here);
1139 
1140  // Keep track of the highest dimensional element we've added to the mesh
1141  unsigned int highest_elem_dim = 1;
1142 
1143  // RHS: Originally we used invalid_processor_id as a "no parent" tag
1144  // number, because I'm an idiot. Let's try to support broken files
1145  // as much as possible.
1146  bool file_is_broken = false;
1147 
1148  for (unsigned int i=0; i<n_elems_here; i++)
1149  {
1150  // id type pid subdomain_id parent_id
1151  std::vector<file_id_type> elem_data(6 + n_extra_integers);
1152  io.data_stream
1153  (elem_data.data(), cast_int<unsigned int>(elem_data.size()),
1154  cast_int<unsigned int>(elem_data.size()));
1155 
1156 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1157  file_id_type unique_id = 0;
1158  io.data(unique_id, "# unique id");
1159 #endif
1160 
1161 #ifdef LIBMESH_ENABLE_AMR
1162  uint16_t p_level = 0;
1163  io.data(p_level, "# p_level");
1164 
1165  uint16_t rflag, pflag;
1166  io.data(rflag, "# rflag");
1167  io.data(pflag, "# pflag");
1168 #endif
1169 
1170  unsigned int n_nodes = Elem::type_to_n_nodes_map[elem_data[1]];
1171 
1172  // Snag the node ids this element was connected to
1173  std::vector<file_id_type> conn_data(n_nodes);
1174  io.data_stream
1175  (conn_data.data(), cast_int<unsigned int>(conn_data.size()),
1176  cast_int<unsigned int>(conn_data.size()));
1177 
1178  const dof_id_type id =
1179  cast_int<dof_id_type> (elem_data[0]);
1180  const ElemType elem_type =
1181  static_cast<ElemType> (elem_data[1]);
1182  const processor_id_type proc_id =
1183  cast_int<processor_id_type>
1184  (elem_data[2] % mesh.n_processors());
1185  const subdomain_id_type subdomain_id =
1186  cast_int<subdomain_id_type>(elem_data[3]);
1187 
1188  // Old broken files used processsor_id_type(-1)...
1189  // But we *know* our first element will be level 0
1190  if (i == 0 && elem_data[4] == 65535)
1191  file_is_broken = true;
1192 
1193  // On a broken file we can't tell whether a parent of 65535 is a
1194  // null parent or an actual parent of 65535. Assuming the
1195  // former will cause less breakage.
1196  Elem * parent =
1197  (elem_data[4] == static_cast<largest_id_type>(-1) ||
1198  (file_is_broken && elem_data[4] == 65535)) ?
1199  nullptr : mesh.elem_ptr(cast_int<dof_id_type>(elem_data[4]));
1200 
1201  const unsigned short int child_num =
1202  (elem_data[5] == static_cast<largest_id_type>(-1) ||
1203  (file_is_broken && elem_data[5] == 65535)) ?
1204  static_cast<unsigned short>(-1) :
1205  cast_int<unsigned short>(elem_data[5]);
1206 
1207  if (!parent)
1208  libmesh_assert_equal_to
1209  (child_num, static_cast<unsigned short>(-1));
1210 
1211  Elem * old_elem = mesh.query_elem_ptr(id);
1212 
1213  // If we already have this element (e.g. from another file,
1214  // when reading multiple distributed CheckpointIO files into
1215  // a ReplicatedMesh) then we don't want to add it again
1216  // (because ReplicatedMesh can't handle that) but we do want
1217  // to assert consistency between what we're reading and what
1218  // we have.
1219  if (old_elem)
1220  {
1221  libmesh_assert_equal_to(elem_type, old_elem->type());
1222  libmesh_assert_equal_to(proc_id, old_elem->processor_id());
1223  libmesh_assert_equal_to(subdomain_id, old_elem->subdomain_id());
1224  if (parent)
1225  libmesh_assert_equal_to(parent, old_elem->parent());
1226  else
1227  libmesh_assert(!old_elem->parent());
1228 
1229  libmesh_assert_equal_to(n_extra_integers, old_elem->n_extra_integers());
1230 #ifndef NDEBUG
1231  for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1232  {
1233  const dof_id_type extra_int = cast_int<dof_id_type>(elem_data[6+ei]);
1234  libmesh_assert_equal_to(extra_int, old_elem->get_extra_integer(ei));
1235  }
1236 #endif
1237 
1238  libmesh_assert_equal_to(old_elem->n_nodes(), conn_data.size());
1239 
1240  for (unsigned int n=0,
1241  n_conn = cast_int<unsigned int>(conn_data.size());
1242  n != n_conn; n++)
1243  libmesh_assert_equal_to
1244  (old_elem->node_id(n),
1245  cast_int<dof_id_type>(conn_data[n]));
1246  }
1247  else
1248  {
1249  // Create the element
1250  auto elem = Elem::build(elem_type, parent);
1251 
1252 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1253  elem->set_unique_id(unique_id);
1254 #endif
1255 
1256  if (elem->dim() > highest_elem_dim)
1257  highest_elem_dim = elem->dim();
1258 
1259  elem->set_id() = id;
1260  elem->processor_id() = proc_id;
1261  elem->subdomain_id() = subdomain_id;
1262 
1263 #ifdef LIBMESH_ENABLE_AMR
1264  elem->hack_p_level(p_level);
1265 
1266  elem->set_refinement_flag (cast_int<Elem::RefinementState>(rflag));
1267  elem->set_p_refinement_flag(cast_int<Elem::RefinementState>(pflag));
1268 
1269  // Set parent connections
1270  if (parent)
1271  {
1272  // We must specify a child_num, because we will have
1273  // skipped adding any preceding remote_elem children
1274  parent->add_child(elem.get(), child_num);
1275  }
1276 #else
1277  libmesh_ignore(child_num);
1278 #endif
1279 
1280  libmesh_assert(elem->n_nodes() == conn_data.size());
1281 
1282  // Connect all the nodes to this element
1283  for (unsigned int n=0,
1284  n_conn = cast_int<unsigned int>(conn_data.size());
1285  n != n_conn; n++)
1286  elem->set_node(n) =
1287  mesh.node_ptr(cast_int<dof_id_type>(conn_data[n]));
1288 
1289  Elem * added_elem = mesh.add_elem(std::move(elem));
1290 
1291  libmesh_assert_equal_to(n_extra_integers, added_elem->n_extra_integers());
1292  for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1293  {
1294  const dof_id_type extra_int = cast_int<dof_id_type>(elem_data[6+ei]);
1295  added_elem->set_extra_integer(ei, extra_int);
1296  }
1297  }
1298  }
1299 
1300  mesh.set_mesh_dimension(cast_int<unsigned char>(highest_elem_dim));
1301 }
ElemType
Defines an enum for geometric element types.
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
unsigned int n_elem_integers() const
Definition: mesh_base.h:934
uint64_t largest_id_type
Definition: id_types.h:148
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
processor_id_type n_processors() const
void libmesh_ignore(const Args &...)
const dof_id_type n_nodes
Definition: tecplot_io.C:67
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
libmesh_assert(ctx)
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:269
virtual const Elem * elem_ptr(const dof_id_type i) const =0
bool version_at_least_1_5() const
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_header()

template<typename file_id_type >
file_id_type libMesh::CheckpointIO::read_header ( const std::string &  name)
private

Read header data on processor 0, then broadcast.

Returns the number of processors for which parallel non-header files have been written, or 0 if files were written in serial.

Definition at line 893 of file checkpoint_io.C.

References libMesh::MeshBase::add_elem_integer(), libMesh::MeshBase::add_node_integer(), binary(), TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, libMesh::MeshBase::get_boundary_info(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::Quality::name(), libMesh::ParallelObject::processor_id(), libMesh::READ, libMesh::MeshBase::set_mesh_dimension(), libMesh::BoundaryInfo::set_nodeset_name_map(), libMesh::BoundaryInfo::set_sideset_name_map(), libMesh::MeshBase::set_subdomain_name_map(), version(), and version_at_least_1_5().

894 {
895  MeshBase & mesh = MeshInput<MeshBase>::mesh();
896 
897  // Hack for codes which don't look at all elem dimensions
898  uint16_t mesh_dimension;
899 
900  // Will this be a parallel input file? With how many processors? Stay tuned!
901  uint16_t input_parallel;
902  file_id_type input_n_procs;
903 
904  std::vector<std::string> node_integer_names, elem_integer_names;
905 
906  // We'll write a header file from processor 0 and broadcast.
907  if (this->processor_id() == 0)
908  {
909  Xdr io (name, this->binary() ? DECODE : READ);
910 
911  // read the version, but don't care about it
912  std::string input_version;
913  io.data(input_version);
914 
915  // read the data type, don't care about it this time
916  header_id_type data_size;
917  io.data (data_size);
918 
919  // read the dimension
920  io.data (mesh_dimension);
921 
922  // Read whether or not this is a parallel file
923  io.data(input_parallel);
924 
925  // With how many processors?
926  if (input_parallel)
927  io.data(input_n_procs);
928 
929  // read subdomain names
930  this->read_subdomain_names<file_id_type>(io);
931 
932  // read boundary names
933  BoundaryInfo & boundary_info = mesh.get_boundary_info();
934 
935  this->read_bc_names<file_id_type>(io, boundary_info, true); // sideset names
936  this->read_bc_names<file_id_type>(io, boundary_info, false); // nodeset names
937 
938  // read extra integer names?
939  std::swap(input_version, this->version());
940  const bool read_extra_integers = this->version_at_least_1_5();
941  std::swap(input_version, this->version());
942 
943  if (read_extra_integers)
944  this->read_integers_names<file_id_type>
945  (io, node_integer_names, elem_integer_names);
946  }
947 
948  // broadcast data from processor 0, set values everywhere
949  this->comm().broadcast(mesh_dimension);
950  mesh.set_mesh_dimension(cast_int<unsigned char>(mesh_dimension));
951 
952  this->comm().broadcast(input_parallel);
953 
954  if (input_parallel)
955  this->comm().broadcast(input_n_procs);
956  else
957  input_n_procs = 1;
958 
959  std::map<subdomain_id_type, std::string> & subdomain_map =
961  this->comm().broadcast(subdomain_map);
962 
963  BoundaryInfo & boundary_info = mesh.get_boundary_info();
964  this->comm().broadcast(boundary_info.set_sideset_name_map());
965  this->comm().broadcast(boundary_info.set_nodeset_name_map());
966 
967  this->comm().broadcast(node_integer_names);
968  this->comm().broadcast(elem_integer_names);
969 
970  for (auto & int_name : node_integer_names)
971  mesh.add_node_integer(int_name);
972 
973  for (auto & int_name : elem_integer_names)
974  mesh.add_elem_integer(int_name);
975 
976  return input_parallel ? input_n_procs : 0;
977 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const std::string & version() const
Get/Set the version string.
unsigned int add_elem_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each element in the mesh...
Definition: mesh_base.C:512
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 set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:269
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
bool version_at_least_1_5() const
unsigned int add_node_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each node in the mesh.
Definition: mesh_base.C:601
bool binary() const
Get/Set the flag indicating if we should read/write binary.
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

◆ read_integers_names()

template<typename file_id_type >
void libMesh::CheckpointIO::read_integers_names ( Xdr io,
std::vector< std::string > &  node_integer_names,
std::vector< std::string > &  elem_integer_names 
)
private

Read extra integers names information.

Definition at line 1437 of file checkpoint_io.C.

References libMesh::Xdr::data().

1440 {
1441  file_id_type n_node_integers, n_elem_integers;
1442 
1443  io.data(n_node_integers, "# n_extra_integers per node");
1444  io.data(node_integer_names);
1445  io.data(n_elem_integers, "# n_extra_integers per elem");
1446  io.data(elem_integer_names);
1447 }

◆ read_nodes()

template<typename file_id_type >
void libMesh::CheckpointIO::read_nodes ( Xdr io)
private

Read the nodal locations for a parallel, distributed mesh.

Definition at line 1033 of file checkpoint_io.C.

References libMesh::MeshBase::add_point(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::DofObject::n_extra_integers(), libMesh::MeshBase::n_node_integers(), libMesh::ParallelObject::n_processors(), libMesh::MeshBase::query_node_ptr(), libMesh::DofObject::set_extra_integer(), libMesh::DofObject::set_unique_id(), and version_at_least_1_5().

1034 {
1035  // convenient reference to our mesh
1036  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1037 
1038  file_id_type n_nodes_here;
1039  io.data(n_nodes_here, "# n_nodes on proc");
1040 
1041  const bool read_extra_integers = this->version_at_least_1_5();
1042 
1043  const unsigned int n_extra_integers =
1044  read_extra_integers ? mesh.n_node_integers() : 0;
1045 
1046  // Will hold the node id and pid and extra integers
1047  std::vector<file_id_type> id_pid(2 + n_extra_integers);
1048 
1049  // For the coordinates
1050  std::vector<Real> coords(LIBMESH_DIM);
1051 
1052  for (unsigned int i=0; i<n_nodes_here; i++)
1053  {
1054  io.data_stream(id_pid.data(), 2 + n_extra_integers, 2 + n_extra_integers);
1055 
1056 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1057  file_id_type unique_id = 0;
1058  io.data(unique_id, "# unique id");
1059 #endif
1060 
1061  io.data_stream(coords.data(), LIBMESH_DIM, LIBMESH_DIM);
1062 
1063  Point p;
1064  p(0) = coords[0];
1065 
1066 #if LIBMESH_DIM > 1
1067  p(1) = coords[1];
1068 #endif
1069 
1070 #if LIBMESH_DIM > 2
1071  p(2) = coords[2];
1072 #endif
1073 
1074  const dof_id_type id = cast_int<dof_id_type>(id_pid[0]);
1075 
1076  // "Wrap around" if we see more processors than we're using.
1077  processor_id_type pid =
1078  cast_int<processor_id_type>(id_pid[1] % mesh.n_processors());
1079 
1080  // If we already have this node (e.g. from another file, when
1081  // reading multiple distributed CheckpointIO files into a
1082  // ReplicatedMesh) then we don't want to add it again (because
1083  // ReplicatedMesh can't handle that) but we do want to assert
1084  // consistency between what we're reading and what we have.
1085  const Node * old_node = mesh.query_node_ptr(id);
1086 
1087  if (old_node)
1088  {
1089  libmesh_assert_equal_to(pid, old_node->processor_id());
1090 
1091  libmesh_assert_equal_to(n_extra_integers, old_node->n_extra_integers());
1092 #ifndef NDEBUG
1093  for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1094  {
1095  const dof_id_type extra_int = cast_int<dof_id_type>(id_pid[2+ei]);
1096  libmesh_assert_equal_to(extra_int, old_node->get_extra_integer(ei));
1097  }
1098 #endif
1099 
1100 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1101  libmesh_assert_equal_to(unique_id, old_node->unique_id());
1102 #endif
1103  }
1104  else
1105  {
1106  Node * node =
1107  mesh.add_point(p, id, pid);
1108 
1109 #ifdef LIBMESH_ENABLE_UNIQUE_ID
1110  node->set_unique_id(unique_id);
1111 #endif
1112 
1113  libmesh_assert_equal_to(n_extra_integers, node->n_extra_integers());
1114 
1115  for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1116  {
1117  const dof_id_type extra_int = cast_int<dof_id_type>(id_pid[2+ei]);
1118  node->set_extra_integer(ei, extra_int);
1119  }
1120  }
1121  }
1122 }
unique_id_type & set_unique_id()
Definition: dof_object.h:852
unsigned int n_node_integers() const
Definition: mesh_base.h:1056
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
uint8_t processor_id_type
processor_id_type n_processors() const
virtual const Node * query_node_ptr(const dof_id_type i) const =0
bool version_at_least_1_5() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_nodesets()

template<typename file_id_type >
void libMesh::CheckpointIO::read_nodesets ( Xdr io)
private

Read the nodeset conditions for a parallel, distributed mesh.

Definition at line 1384 of file checkpoint_io.C.

References libMesh::BoundaryInfo::add_node(), libMesh::Xdr::data(), libMesh::MeshBase::get_boundary_info(), libMesh::index_range(), libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshInput< MT >::mesh().

1385 {
1386  // convenient reference to our mesh
1387  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1388 
1389  // and our boundary info object
1390  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1391 
1392  std::vector<file_id_type> node_id_list;
1393  std::vector<file_id_type> bc_id_list;
1394 
1395  io.data(node_id_list, "# node id list");
1396  io.data(bc_id_list, "# nodeset bc id list");
1397 
1398  for (auto i : index_range(node_id_list))
1399  boundary_info.add_node
1400  (cast_int<dof_id_type>(node_id_list[i]),
1401  cast_int<boundary_id_type>(bc_id_list[i]));
1402 }
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
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

◆ read_remote_elem() [1/2]

template<typename file_id_type >
void libMesh::CheckpointIO::read_remote_elem ( Xdr io,
bool  expect_all_remote 
)
private

Read the remote_elem neighbor and child links for a parallel, distributed mesh.

If we expect all these remote_elem links to truly be remote, because we aren't doing an N -> M restart with M < N, then we set expect_all_remote to true and test more assertions.

◆ read_remote_elem() [2/2]

template<typename file_id_type >
void libMesh::CheckpointIO::read_remote_elem ( Xdr io,
bool   libmesh_dbg_varexpect_all_remote 
)

Definition at line 1305 of file checkpoint_io.C.

References libMesh::Elem::add_child(), libMesh::Xdr::data(), libMesh::MeshBase::elem_ref(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::raw_child_ptr(), libMesh::remote_elem, and libMesh::Elem::set_neighbor().

1306 {
1307  // convenient reference to our mesh
1308  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1309 
1310  // Find the remote_elem neighbor links
1311  std::vector<file_id_type> elem_ids;
1312  std::vector<uint16_t> elem_sides;
1313 
1314  io.data(elem_ids, "# remote neighbor elem_ids");
1315  io.data(elem_sides, "# remote neighbor elem_sides");
1316 
1317  libmesh_assert_equal_to(elem_ids.size(), elem_sides.size());
1318 
1319  for (auto i : index_range(elem_ids))
1320  {
1321  Elem & elem = mesh.elem_ref(cast_int<dof_id_type>(elem_ids[i]));
1322  if (!elem.neighbor_ptr(elem_sides[i]))
1323  elem.set_neighbor(elem_sides[i],
1324  const_cast<RemoteElem *>(remote_elem));
1325  else
1326  libmesh_assert(!expect_all_remote);
1327  }
1328 
1329  // Find the remote_elem children links
1330  std::vector<file_id_type> parent_ids;
1331  std::vector<uint16_t> child_numbers;
1332 
1333  io.data(parent_ids, "# remote child parent_ids");
1334  io.data(child_numbers, "# remote child_numbers");
1335 
1336 #ifdef LIBMESH_ENABLE_AMR
1337  for (auto i : index_range(parent_ids))
1338  {
1339  Elem & elem = mesh.elem_ref(cast_int<dof_id_type>(parent_ids[i]));
1340 
1341  // We'd like to assert that no child pointer already exists to
1342  // be overwritten by remote_elem, but Elem doesn't actually have
1343  // an API that will return a child pointer without asserting
1344  // that it isn't nullptr.
1345  const Elem * child = elem.raw_child_ptr(child_numbers[i]);
1346 
1347  if (!child)
1348  elem.add_child(const_cast<RemoteElem *>(remote_elem),
1349  child_numbers[i]);
1350  else
1351  libmesh_assert(!expect_all_remote);
1352  }
1353 #endif
1354 }
void add_child(Elem *elem)
Adds a child pointer to the array of children of this element.
Definition: elem.C:1668
libmesh_assert(ctx)
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
Definition: elem.h:2427
const Elem * raw_child_ptr(unsigned int i) const
Definition: elem.h:2991
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:618
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
const RemoteElem * remote_elem
Definition: remote_elem.C:54

◆ read_subdomain_names()

template<typename file_id_type >
void libMesh::CheckpointIO::read_subdomain_names ( Xdr io)
private

Read subdomain name information.

Definition at line 1003 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::index_range(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshBase::set_subdomain_name_map().

1004 {
1005  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1006 
1007  std::map<subdomain_id_type, std::string> & subdomain_map =
1009 
1010  std::vector<file_id_type> subdomain_ids;
1011  subdomain_ids.reserve(subdomain_map.size());
1012 
1013  std::vector<std::string> subdomain_names;
1014  subdomain_names.reserve(subdomain_map.size());
1015 
1016  file_id_type n_subdomain_names = 0;
1017  io.data(n_subdomain_names, "# subdomain id to name map");
1018 
1019  if (n_subdomain_names)
1020  {
1021  io.data(subdomain_ids);
1022  io.data(subdomain_names);
1023 
1024  for (auto i : index_range(subdomain_ids))
1025  subdomain_map[cast_int<subdomain_id_type>(subdomain_ids[i])] =
1026  subdomain_names[i];
1027  }
1028 }
const DofMap &dof_map LIBMESH_COMMA unsigned int std::string & set_subdomain_name_map()
Definition: mesh_base.h:1669
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

◆ read_subfile()

template<typename file_id_type >
void libMesh::CheckpointIO::read_subfile ( Xdr io,
bool  expect_all_remote 
)
private

Read a non-header file.

Definition at line 982 of file checkpoint_io.C.

983 {
984  // read the nodal locations
985  this->read_nodes<file_id_type> (io);
986 
987  // read connectivity
988  this->read_connectivity<file_id_type> (io);
989 
990  // read remote_elem connectivity
991  this->read_remote_elem<file_id_type> (io, expect_all_remote);
992 
993  // read the boundary conditions
994  this->read_bcs<file_id_type> (io);
995 
996  // read the nodesets
997  this->read_nodesets<file_id_type> (io);
998 }

◆ select_split_config()

processor_id_type libMesh::CheckpointIO::select_split_config ( const std::string &  input_name,
header_id_type data_size 
)
private

Definition at line 188 of file checkpoint_io.C.

References _my_n_processors, binary(), TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, libMesh::ParallelObject::processor_id(), and libMesh::READ.

Referenced by read().

189 {
190  std::string header_name;
191 
192  // We'll read a header file from processor 0 and broadcast.
193  if (this->processor_id() == 0)
194  {
195  header_name = header_file(input_name, _my_n_processors);
196 
197  {
198  // look for header+splits with nprocs equal to _my_n_processors
199  std::ifstream in (header_name.c_str());
200  if (!in.good())
201  {
202  // otherwise fall back to a serial/single-split mesh
203  auto orig_header_name = header_name;
204  header_name = header_file(input_name, 1);
205  std::ifstream in2 (header_name.c_str());
206  libmesh_error_msg_if(!in2.good(),
207  "ERROR: Neither one of the following files can be located:\n\t'"
208  << orig_header_name << "' nor\n\t'" << input_name << "'\n"
209  << "If you are running a parallel job, double check that you've "
210  << "created a split for " << _my_n_processors << " ranks.\n"
211  << "Note: One of paths above may refer to a valid directory on your "
212  << "system, however we are attempting to read a valid header file.");
213  }
214  }
215 
216  Xdr io (header_name, this->binary() ? DECODE : READ);
217 
218  // read the version, but don't care about it
219  std::string input_version;
220  io.data(input_version);
221 
222  // read the data type
223  io.data (data_size);
224  }
225 
226  this->comm().broadcast(data_size);
227  this->comm().broadcast(header_name);
228 
229  // How many per-processor files are here?
230  largest_id_type input_n_procs;
231 
232  switch (data_size) {
233  case 2:
234  input_n_procs = this->read_header<uint16_t>(header_name);
235  break;
236  case 4:
237  input_n_procs = this->read_header<uint32_t>(header_name);
238  break;
239  case 8:
240  input_n_procs = this->read_header<uint64_t>(header_name);
241  break;
242  default:
243  libmesh_error();
244  }
245 
246  if (!input_n_procs)
247  input_n_procs = 1;
248  return cast_int<processor_id_type>(input_n_procs);
249 }
uint64_t largest_id_type
Definition: id_types.h:148
const Parallel::Communicator & comm() const
processor_id_type _my_n_processors
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
bool binary() const
Get/Set the flag indicating if we should read/write binary.
processor_id_type processor_id() const

◆ 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 libMesh::XdrIO::read_header().

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

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

◆ version() [1/2]

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

Get/Set the version string.

Definition at line 158 of file checkpoint_io.h.

References _version.

Referenced by read_header(), and version_at_least_1_5().

158 { return _version; }

◆ version() [2/2]

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

Definition at line 159 of file checkpoint_io.h.

References _version.

159 { return _version; }

◆ version_at_least_1_5()

bool libMesh::CheckpointIO::version_at_least_1_5 ( ) const
Returns
true if the current file has an XDR/XDA version that matches or exceeds 1.5

As of this version we encode any extra integer data that has been attached to a mesh.

Definition at line 277 of file checkpoint_io.C.

References version().

Referenced by read_connectivity(), read_header(), read_nodes(), write(), write_connectivity(), and write_nodes().

278 {
279  return (this->version().find("1.5") != std::string::npos);
280 }
const std::string & version() const
Get/Set the version string.

◆ write()

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

This method implements writing a mesh to a specified file.

If the mesh has been split for running on several processors, this will create a subdirectory named "[name]-split[n]" where name is the given name argument and n is the number of processors the mesh is split for running on. For example:

unsigned int n_splits = 42;
std::unique_ptr<CheckpointIO> cp = split_mesh(my_mesh, n_splits);
// ...
cp->write("foo.cpr");

would create a directory named "foo.cpr-split42".

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 283 of file checkpoint_io.C.

References _my_n_processors, _my_processor_ids, _parallel, _version, binary(), libMesh::BoundaryInfo::build_node_list(), libMesh::BoundaryInfo::build_side_list(), libMesh::Xdr::close(), libMesh::connect_children(), libMesh::connect_families(), libMesh::Xdr::data(), libMesh::ENCODE, libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::get_elem_integer_name(), libMesh::MeshBase::get_node_integer_name(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::is_serial(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem_integers(), libMesh::MeshBase::n_node_integers(), libMesh::Quality::name(), parallel(), libMesh::ParallelObject::processor_id(), libMesh::query_ghosting_functors(), libMesh::reconnect_nodes(), version_at_least_1_5(), libMesh::WRITE, write_bc_names(), write_bcs(), write_connectivity(), write_nodes(), write_nodesets(), write_remote_elem(), and write_subdomain_names().

Referenced by CheckpointIOTest::testSplitter(), and libMesh::NameBasedIO::write().

284 {
285  LOG_SCOPE("write()", "CheckpointIO");
286 
287  // convenient reference to our mesh
288  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
289 
290  // FIXME: For backwards compatibility, we'll assume for now that we
291  // only want to write distributed meshes in parallel. Later we can
292  // do a gather_to_zero() and support that case too.
294 
295  processor_id_type use_n_procs = 1;
296  if (_parallel)
297  use_n_procs = _my_n_processors;
298 
299  std::string header_file_name = header_file(name, use_n_procs);
300  make_dir(name, use_n_procs);
301 
302  // We'll write a header file from processor 0 to make it easier to do unambiguous
303  // restarts later:
304  if (this->processor_id() == 0)
305  {
306  Xdr io (header_file_name, this->binary() ? ENCODE : WRITE);
307 
308  // write the version
309  io.data(_version, "# version");
310 
311  // write what kind of data type we're using
312  header_id_type data_size = sizeof(largest_id_type);
313  io.data(data_size, "# integer size");
314 
315  // Write out the max mesh dimension for backwards compatibility
316  // with code that sets it independently of element dimensions
317  {
318  uint16_t mesh_dimension = cast_int<uint16_t>(mesh.mesh_dimension());
319  io.data(mesh_dimension, "# dimensions");
320  }
321 
322  // Write out whether or not this is serial output
323  {
324  uint16_t parallel = _parallel;
325  io.data(parallel, "# parallel");
326  }
327 
328  // If we're writing out a parallel mesh then we need to write the number of processors
329  // so we can check it upon reading the file
330  if (_parallel)
331  {
333  io.data(n_procs, "# n_procs");
334  }
335 
336  // write subdomain names
337  this->write_subdomain_names(io);
338 
339  // write boundary id names
340  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
341  write_bc_names(io, boundary_info, true); // sideset names
342  write_bc_names(io, boundary_info, false); // nodeset names
343 
344  // write extra integer names
345  const bool write_extra_integers = this->version_at_least_1_5();
346 
347  if (write_extra_integers)
348  {
349  largest_id_type n_node_integers = mesh.n_node_integers();
350  io.data(n_node_integers, "# n_extra_integers per node");
351 
352  std::vector<std::string> node_integer_names;
353  for (unsigned int i=0; i != n_node_integers; ++i)
354  node_integer_names.push_back(mesh.get_node_integer_name(i));
355 
356  io.data(node_integer_names);
357 
358  largest_id_type n_elem_integers = mesh.n_elem_integers();
359  io.data(n_elem_integers, "# n_extra_integers per elem");
360 
361  std::vector<std::string> elem_integer_names;
362  for (unsigned int i=0; i != n_elem_integers; ++i)
363  elem_integer_names.push_back(mesh.get_elem_integer_name(i));
364 
365  io.data(elem_integer_names);
366  }
367 
368 
369  }
370 
371  // If this is a serial mesh written to a serial file then we're only
372  // going to write local data from processor 0. If this is a mesh being
373  // written in parallel then we're going to write from every
374  // processor.
375  std::vector<processor_id_type> ids_to_write;
376 
377  // We're going to sort elements by pid in one pass, to avoid sending
378  // predicated iterators through the whole mesh N_p times.
379  //
380  // The data type here needs to be a non-const-pointer to whatever
381  // our element_iterator is a const-pointer to, for compatibility
382  // later.
383  typedef std::remove_const<MeshBase::const_element_iterator::value_type>::type nc_v_t;
384  std::unordered_map<processor_id_type, std::vector<nc_v_t>> elements_on_pid;
385 
386  if (_parallel)
387  {
388  ids_to_write = _my_processor_ids;
389  for (processor_id_type p : ids_to_write)
390  elements_on_pid[p].clear();
391  auto eop_end = elements_on_pid.end();
392  for (auto & elem : mesh.element_ptr_range())
393  {
394  const processor_id_type p = elem->processor_id();
395  auto eop_it = elements_on_pid.find(p);
396  if (eop_it != eop_end)
397  eop_it->second.push_back(elem);
398  }
399  }
400  else if (mesh.is_serial())
401  {
402  if (mesh.processor_id() == 0)
403  {
404  // placeholder
405  ids_to_write.push_back(0);
406  }
407  }
408  else
409  {
410  libmesh_error_msg("Cannot write serial checkpoint from distributed mesh");
411  }
412 
413  // Call build_side_list() and build_node_list() just *once* to avoid
414  // redundant expensive sorts during mesh splitting.
415  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
416  std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>>
417  bc_triples = boundary_info.build_side_list();
418  std::vector<std::tuple<dof_id_type, boundary_id_type>>
419  bc_tuples = boundary_info.build_node_list();
420 
421  for (const auto & my_pid : ids_to_write)
422  {
423  auto file_name = split_file(name, use_n_procs, my_pid);
424  Xdr io (file_name, this->binary() ? ENCODE : WRITE);
425 
426  std::set<const Elem *, CompareElemIdsByLevel> elements;
427 
428  // For serial files or for already-distributed meshs, we write
429  // everything we can see.
430  if (!_parallel || !mesh.is_serial())
431  elements.insert(mesh.elements_begin(), mesh.elements_end());
432  // For parallel files written from serial meshes we write what
433  // we'd be required to keep if we were to be deleting remote
434  // elements. This allows us to write proper parallel files even
435  // from a ReplicateMesh.
436  //
437  // WARNING: If we have a DistributedMesh which used
438  // "add_extra_ghost_elem" rather than ghosting functors to
439  // preserve elements and which is *also* currently serialized
440  // then we're not preserving those elements here. As a quick
441  // workaround user code should delete_remote_elements() before
442  // writing the checkpoint; as a long term workaround user code
443  // should use ghosting functors instead of extra_ghost_elem
444  // lists.
445  else
446  {
448  {
449  const auto elements_vec_it = elements_on_pid.find(p);
450  if (elements_vec_it != elements_on_pid.end())
451  {
452  auto & p_elements = elements_vec_it->second;
453 
454  // Be compatible with both deprecated and
455  // corrected MeshBase iterator types
457 
458  v_t * elempp = p_elements.data();
459  v_t * elemend = elempp + p_elements.size();
460 
461  const MeshBase::const_element_iterator
462  pid_elements_begin = MeshBase::const_element_iterator
463  (elempp, elemend, Predicates::NotNull<v_t *>()),
464  pid_elements_end = MeshBase::const_element_iterator
465  (elemend, elemend, Predicates::NotNull<v_t *>()),
466  active_pid_elements_begin = MeshBase::const_element_iterator
467  (elempp, elemend, Predicates::Active<v_t *>()),
468  active_pid_elements_end = MeshBase::const_element_iterator
469  (elemend, elemend, Predicates::Active<v_t *>());
470 
472  (mesh, p, active_pid_elements_begin,
473  active_pid_elements_end, elements);
474  connect_children(mesh, pid_elements_begin,
475  pid_elements_end, elements);
476  }
477  connect_families(elements);
478  }
479  }
480 
481  connected_node_set_type connected_nodes;
482  reconnect_nodes(elements, connected_nodes);
483 
484  // write the nodal locations
485  this->write_nodes (io, connected_nodes);
486 
487  // write connectivity
488  this->write_connectivity (io, elements);
489 
490  // write remote_elem connectivity
491  this->write_remote_elem (io, elements);
492 
493  // write the boundary condition information
494  this->write_bcs (io, elements, bc_triples);
495 
496  // write the nodeset information
497  this->write_nodesets (io, connected_nodes, bc_tuples);
498 
499  // close it up
500  io.close();
501  }
502 
503  // this->comm().barrier();
504 }
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
void write_remote_elem(Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
Write the remote_elem neighbor and child links for part of a mesh.
unsigned int n_node_integers() const
Definition: mesh_base.h:1056
void write_connectivity(Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
Write the connectivity for part of a mesh.
void write_nodes(Xdr &io, const connected_node_set_type &nodeset) const
Write the nodal locations for part of a mesh.
unsigned int n_elem_integers() const
Definition: mesh_base.h:934
uint64_t largest_id_type
Definition: id_types.h:148
void write_bcs(Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements, const std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type >> &bc_triples) const
Write the side boundary conditions for part of a mesh.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
bool parallel() const
Get/Set the flag indicating if we should read/write binary.
const std::string & get_elem_integer_name(unsigned int i) const
Definition: mesh_base.h:923
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, sides, and ids for those sides.
std::vector< processor_id_type > _my_processor_ids
uint8_t processor_id_type
virtual bool is_serial() const
Definition: mesh_base.h:205
void write_subdomain_names(Xdr &io) const
Write subdomain name information.
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:488
processor_id_type _my_n_processors
void write_nodesets(Xdr &io, const connected_node_set_type &nodeset, const std::vector< std::tuple< dof_id_type, boundary_id_type >> &bc_tuples) const
Write the nodal boundary conditions for part of a mesh.
void write_bc_names(Xdr &io, const BoundaryInfo &info, bool is_sideset) const
Write boundary names information (sideset and nodeset)
void reconnect_nodes(const std::set< const Elem *, CompareElemIdsByLevel > &connected_elements, connected_node_set_type &connected_nodes)
std::set< const Node * > connected_node_set_type
void query_ghosting_functors(const MeshBase &mesh, processor_id_type pid, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
bool version_at_least_1_5() const
void connect_families(std::set< const Elem *, CompareElemIdsByLevel > &connected_elements, const MeshBase *mesh=nullptr)
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
const std::string & get_node_integer_name(unsigned int i) const
Definition: mesh_base.h:1045
bool binary() const
Get/Set the flag indicating if we should read/write binary.
void connect_children(const MeshBase &mesh, MeshBase::const_element_iterator elem_it, MeshBase::const_element_iterator elem_end, std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
processor_id_type processor_id() const

◆ write_bc_names()

void libMesh::CheckpointIO::write_bc_names ( Xdr io,
const BoundaryInfo info,
bool  is_sideset 
) const
private

Write boundary names information (sideset and nodeset)

Definition at line 782 of file checkpoint_io.C.

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

Referenced by write().

783 {
784  const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
785  info.get_sideset_name_map() : info.get_nodeset_name_map();
786 
787  std::vector<largest_id_type> boundary_ids; boundary_ids.reserve(boundary_map.size());
788  std::vector<std::string> boundary_names; boundary_names.reserve(boundary_map.size());
789 
790  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
791  // return writable references in boundary_info, it's possible for the user to leave some entity names
792  // blank. We can't write those to the XDA file.
793  largest_id_type n_boundary_names = 0;
794  for (const auto & [id, name] : boundary_map)
795  if (!name.empty())
796  {
797  n_boundary_names++;
798  boundary_ids.push_back(id);
799  boundary_names.push_back(name);
800  }
801 
802  if (is_sideset)
803  io.data(n_boundary_names, "# sideset id to name map");
804  else
805  io.data(n_boundary_names, "# nodeset id to name map");
806  // Write out the ids and names in two vectors
807  if (n_boundary_names)
808  {
809  io.data(boundary_ids);
810  io.data(boundary_names);
811  }
812 }
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 largest_id_type
Definition: id_types.h:148

◆ write_bcs()

void libMesh::CheckpointIO::write_bcs ( Xdr io,
const std::set< const Elem *, CompareElemIdsByLevel > &  elements,
const std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type >> &  bc_triples 
) const
private

Write the side boundary conditions for part of a mesh.

Definition at line 714 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::libmesh_assert(), and libMesh::Xdr::writing().

Referenced by write().

717 {
718  libmesh_assert (io.writing());
719 
720  // Build a list of (elem, side, bc) tuples.
721  std::size_t bc_size = bc_triples.size();
722 
723  std::vector<largest_id_type> element_id_list;
724  std::vector<uint16_t> side_list;
725  std::vector<largest_id_type> bc_id_list;
726 
727  element_id_list.reserve(bc_size);
728  side_list.reserve(bc_size);
729  bc_id_list.reserve(bc_size);
730 
731  std::unordered_set<dof_id_type> elems;
732  for (auto & e : elements)
733  elems.insert(e->id());
734 
735  for (const auto & t : bc_triples)
736  if (elems.count(std::get<0>(t)))
737  {
738  element_id_list.push_back(std::get<0>(t));
739  side_list.push_back(std::get<1>(t));
740  bc_id_list.push_back(std::get<2>(t));
741  }
742 
743 
744  io.data(element_id_list, "# element ids for bcs");
745  io.data(side_list, "# sides of elements for bcs");
746  io.data(bc_id_list, "# bc ids");
747 }
libmesh_assert(ctx)

◆ write_connectivity()

void libMesh::CheckpointIO::write_connectivity ( Xdr io,
const std::set< const Elem *, CompareElemIdsByLevel > &  elements 
) const
private

Write the connectivity for part of a mesh.

Definition at line 590 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::libmesh_assert(), libMesh::MeshOutput< MT >::mesh(), n_nodes, version_at_least_1_5(), and libMesh::Xdr::writing().

Referenced by write().

592 {
593  libmesh_assert (io.writing());
594 
595  const bool write_extra_integers = this->version_at_least_1_5();
596  const unsigned int n_extra_integers =
597  write_extra_integers ? MeshOutput<MeshBase>::mesh().n_elem_integers() : 0;
598 
599  // Put these out here to reduce memory churn
600  // id type pid subdomain_id parent_id extra_integer_0 ...
601  std::vector<largest_id_type> elem_data(6 + n_extra_integers);
602  std::vector<largest_id_type> conn_data;
603 
604  largest_id_type n_elems_here = elements.size();
605 
606  io.data(n_elems_here, "# number of elements");
607 
608  for (const auto & elem : elements)
609  {
610  unsigned int n_nodes = elem->n_nodes();
611 
612  elem_data[0] = elem->id();
613  elem_data[1] = elem->type();
614  elem_data[2] = elem->processor_id();
615  elem_data[3] = elem->subdomain_id();
616 
617 #ifdef LIBMESH_ENABLE_AMR
618  if (elem->parent() != nullptr)
619  {
620  elem_data[4] = elem->parent()->id();
621  elem_data[5] = elem->parent()->which_child_am_i(elem);
622  }
623  else
624 #endif
625  {
626  elem_data[4] = static_cast<largest_id_type>(-1);
627  elem_data[5] = static_cast<largest_id_type>(-1);
628  }
629 
630  for (unsigned int i=0; i != n_extra_integers; ++i)
631  elem_data[6+i] = elem->get_extra_integer(i);
632 
633  conn_data.resize(n_nodes);
634 
635  for (unsigned int i=0; i<n_nodes; i++)
636  conn_data[i] = elem->node_id(i);
637 
638  io.data_stream(elem_data.data(),
639  cast_int<unsigned int>(elem_data.size()),
640  cast_int<unsigned int>(elem_data.size()));
641 
642 #ifdef LIBMESH_ENABLE_UNIQUE_ID
643  largest_id_type unique_id = elem->unique_id();
644 
645  io.data(unique_id, "# unique id");
646 #endif
647 
648 #ifdef LIBMESH_ENABLE_AMR
649  uint16_t p_level = cast_int<uint16_t>(elem->p_level());
650  io.data(p_level, "# p_level");
651 
652  uint16_t rflag = elem->refinement_flag();
653  io.data(rflag, "# rflag");
654 
655  uint16_t pflag = elem->p_refinement_flag();
656  io.data(pflag, "# pflag");
657 #endif
658  io.data_stream(conn_data.data(),
659  cast_int<unsigned int>(conn_data.size()),
660  cast_int<unsigned int>(conn_data.size()));
661  }
662 }
const MT & mesh() const
Definition: mesh_output.h:259
uint64_t largest_id_type
Definition: id_types.h:148
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
bool version_at_least_1_5() const

◆ 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_nodes()

void libMesh::CheckpointIO::write_nodes ( Xdr io,
const connected_node_set_type nodeset 
) const
private

Write the nodal locations for part of a mesh.

Definition at line 540 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshOutput< MT >::mesh(), and version_at_least_1_5().

Referenced by write().

542 {
543  largest_id_type n_nodes_here = nodeset.size();
544 
545  io.data(n_nodes_here, "# n_nodes on proc");
546 
547  const bool write_extra_integers = this->version_at_least_1_5();
548  const unsigned int n_extra_integers =
549  write_extra_integers ? MeshOutput<MeshBase>::mesh().n_node_integers() : 0;
550 
551  // Will hold the node id and pid and extra integers
552  std::vector<largest_id_type> id_pid(2 + n_extra_integers);
553 
554  // For the coordinates
555  std::vector<Real> coords(LIBMESH_DIM);
556 
557  for (const auto & node : nodeset)
558  {
559  id_pid[0] = node->id();
560  id_pid[1] = node->processor_id();
561 
562  libmesh_assert_equal_to(n_extra_integers, node->n_extra_integers());
563  for (unsigned int i=0; i != n_extra_integers; ++i)
564  id_pid[2+i] = node->get_extra_integer(i);
565 
566  io.data_stream(id_pid.data(), 2 + n_extra_integers, 2 + n_extra_integers);
567 
568 #ifdef LIBMESH_ENABLE_UNIQUE_ID
569  largest_id_type unique_id = node->unique_id();
570 
571  io.data(unique_id, "# unique id");
572 #endif
573 
574  coords[0] = (*node)(0);
575 
576 #if LIBMESH_DIM > 1
577  coords[1] = (*node)(1);
578 #endif
579 
580 #if LIBMESH_DIM > 2
581  coords[2] = (*node)(2);
582 #endif
583 
584  io.data_stream(coords.data(), LIBMESH_DIM, 3);
585  }
586 }
const MT & mesh() const
Definition: mesh_output.h:259
uint64_t largest_id_type
Definition: id_types.h:148
bool version_at_least_1_5() const

◆ write_nodesets()

void libMesh::CheckpointIO::write_nodesets ( Xdr io,
const connected_node_set_type nodeset,
const std::vector< std::tuple< dof_id_type, boundary_id_type >> &  bc_tuples 
) const
private

Write the nodal boundary conditions for part of a mesh.

Definition at line 751 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::node_ptr(), and libMesh::Xdr::writing().

Referenced by write().

754 {
755  libmesh_assert (io.writing());
756 
757  // convenient reference to our mesh
758  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
759 
760  // Build a list of (node, bc) tuples
761  std::size_t nodeset_size = bc_tuples.size();
762 
763  std::vector<largest_id_type> node_id_list;
764  std::vector<largest_id_type> bc_id_list;
765 
766  node_id_list.reserve(nodeset_size);
767  bc_id_list.reserve(nodeset_size);
768 
769  for (const auto & t : bc_tuples)
770  if (nodeset.count(mesh.node_ptr(std::get<0>(t))))
771  {
772  node_id_list.push_back(std::get<0>(t));
773  bc_id_list.push_back(std::get<1>(t));
774  }
775 
776  io.data(node_id_list, "# node id list");
777  io.data(bc_id_list, "# nodeset bc id list");
778 }
const MT & mesh() const
Definition: mesh_output.h:259
libmesh_assert(ctx)
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ write_remote_elem()

void libMesh::CheckpointIO::write_remote_elem ( Xdr io,
const std::set< const Elem *, CompareElemIdsByLevel > &  elements 
) const
private

Write the remote_elem neighbor and child links for part of a mesh.

Definition at line 665 of file checkpoint_io.C.

References libMesh::Elem::child_ptr(), libMesh::Xdr::data(), libMesh::libmesh_assert(), libMesh::Elem::neighbor_ptr(), libMesh::remote_elem, and libMesh::Xdr::writing().

Referenced by write().

667 {
668  libmesh_assert (io.writing());
669 
670  // Find the remote_elem neighbor and child links
671  std::vector<largest_id_type> elem_ids, parent_ids;
672  std::vector<uint16_t> elem_sides, child_numbers;
673 
674  for (const auto & elem : elements)
675  {
676  for (auto n : elem->side_index_range())
677  {
678  const Elem * neigh = elem->neighbor_ptr(n);
679  if (neigh == remote_elem ||
680  (neigh && !elements.count(neigh)))
681  {
682  elem_ids.push_back(elem->id());
683  elem_sides.push_back(n);
684  }
685  }
686 
687 #ifdef LIBMESH_ENABLE_AMR
688  if (elem->has_children())
689  {
690  for (unsigned short c = 0,
691  nc = cast_int<unsigned short>(elem->n_children());
692  c != nc; ++c)
693  {
694  const Elem * child = elem->child_ptr(c);
695  if (child == remote_elem ||
696  (child && !elements.count(child)))
697  {
698  parent_ids.push_back(elem->id());
699  child_numbers.push_back(c);
700  }
701  }
702  }
703 #endif
704  }
705 
706  io.data(elem_ids, "# remote neighbor elem_ids");
707  io.data(elem_sides, "# remote neighbor elem_sides");
708  io.data(parent_ids, "# remote child parent_ids");
709  io.data(child_numbers, "# remote child_numbers");
710 }
libmesh_assert(ctx)
const RemoteElem * remote_elem
Definition: remote_elem.C:54

◆ write_subdomain_names()

void libMesh::CheckpointIO::write_subdomain_names ( Xdr io) const
private

Write subdomain name information.

Definition at line 506 of file checkpoint_io.C.

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

Referenced by write().

507 {
508  {
509  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
510 
511  const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
512 
513  std::vector<largest_id_type> subdomain_ids; subdomain_ids.reserve(subdomain_map.size());
514  std::vector<std::string> subdomain_names; subdomain_names.reserve(subdomain_map.size());
515 
516  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
517  // return writable references in mesh_base, it's possible for the user to leave some entity names
518  // blank. We can't write those to the XDA file.
519  largest_id_type n_subdomain_names = 0;
520  for (const auto & [id, name] : subdomain_map)
521  if (!name.empty())
522  {
523  n_subdomain_names++;
524  subdomain_ids.push_back(id);
525  subdomain_names.push_back(name);
526  }
527 
528  io.data(n_subdomain_names, "# subdomain id to name map");
529  // Write out the ids and names in two vectors
530  if (n_subdomain_names)
531  {
532  io.data(subdomain_ids);
533  io.data(subdomain_names);
534  }
535  }
536 }
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
uint64_t largest_id_type
Definition: id_types.h:148
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition: mesh_base.h:1671

Member Data Documentation

◆ _binary

bool libMesh::CheckpointIO::_binary
private

Definition at line 328 of file checkpoint_io.h.

Referenced by binary().

◆ _communicator

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

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

◆ _my_n_processors

processor_id_type libMesh::CheckpointIO::_my_n_processors
private

Definition at line 336 of file checkpoint_io.h.

Referenced by current_n_processors(), select_split_config(), and write().

◆ _my_processor_ids

std::vector<processor_id_type> libMesh::CheckpointIO::_my_processor_ids
private

Definition at line 333 of file checkpoint_io.h.

Referenced by current_processor_ids(), and write().

◆ _parallel

bool libMesh::CheckpointIO::_parallel
private

Definition at line 329 of file checkpoint_io.h.

Referenced by parallel(), and write().

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

◆ _version

std::string libMesh::CheckpointIO::_version
private

Definition at line 330 of file checkpoint_io.h.

Referenced by version(), and write().

◆ elems_of_dimension

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

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