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:233
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  MeshInput<MeshBase> (), // write-only
178  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
180  _binary (binary_in),
181  _parallel (false),
182  _version ("checkpoint-1.5"),
185 {
186 }
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:233
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::STLIO::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 253 of file checkpoint_io.C.

254 {
255  auto header = header_file(input_name, n_procs);
256  auto ret = std::remove(header.c_str());
257  if (ret != 0)
258  libmesh_warning("Failed to clean up checkpoint header '" << header << "': " << std::strerror(ret));
259 
260  for (processor_id_type i = 0; i < n_procs; i++)
261  {
262  auto split = split_file(input_name, n_procs, i);
263  ret = std::remove(split.c_str());
264  if (ret != 0)
265  libmesh_warning("Failed to clean up checkpoint split file '" << split << "': " << std::strerror(ret));
266  }
267 
268  auto dir = split_dir(input_name, n_procs);
269  ret = rmdir(dir.c_str());
270  if (ret != 0)
271  libmesh_warning("Failed to clean up checkpoint split dir '" << dir << "': " << std::strerror(ret));
272 
273  // We expect that this may fail if there are other split configurations still present in this
274  // directory - so don't bother to check/warn for failure.
275  rmdir(input_name.c_str());
276 }
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::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::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::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), 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::AdvectionSystem::assemble_claw_rhs(), 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::Partitioner::build_graph(), 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::CondensedEigenSystem::copy_super_to_sub(), 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< T >::create_submatrix_nosort(), create_wrapped_function(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::RBEIMEvaluation::distribute_bfs(), 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::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), 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::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::AdvectionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::PetscDMWrapper::init_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_constraint_rows(), 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::MeshTools::n_connected_components(), libMesh::DofMap::n_constrained_dofs(), libMesh::MeshBase::n_constraint_rows(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_dofs_per_processor(), 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::MeshBase::print_constraint_rows(), 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::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), 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::VariationalMeshSmoother::smooth(), libMesh::ClawSystem::solve_conservation_law(), 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(), VolumeTest::testC0PolygonMethods(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), 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(), update_current_local_solution(), 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::MeshTools::volume(), libMesh::STLIO::write(), 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::STLIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO::read(), read(), libMesh::VTKIO::read(), libMesh::STLIO::read_ascii(), read_bcs(), libMesh::STLIO::read_binary(), 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::STLIO::write(), 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 1461 of file checkpoint_io.C.

References libMesh::as_range().

1463 {
1464  unsigned int max_level = 0;
1465 
1466  for (const auto & elem : as_range(begin, end))
1467  max_level = std::max(elem->level(), max_level);
1468 
1469  return max_level + 1;
1470 }
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::Partitioner::build_graph(), 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::UnstructuredMesh::copy_nodes_and_elements(), 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::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_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::DofMap::n_dofs_per_processor(), 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::MeshBase::print_constraint_rows(), 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::MeshFunction::check_found_elem(), 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_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::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::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::MeshBase::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(), 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::MeshTools::n_connected_components(), libMesh::MeshBase::n_constraint_rows(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMapBase::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::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::MeshBase::print_constraint_rows(), 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::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), 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::testBadGmsh(), 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::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), 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 815 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, libMesh::MeshBase::recalculate_n_partitions(), select_split_config(), libMesh::MeshBase::set_distributed(), libMesh::MeshBase::skip_partitioning(), and libMesh::MeshBase::update_post_partitioning().

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

816 {
817  LOG_SCOPE("read()","CheckpointIO");
818 
819  MeshBase & mesh = MeshInput<MeshBase>::mesh();
820 
822 
823  header_id_type data_size;
824  processor_id_type input_n_procs = select_split_config(input_name, data_size);
825  auto header_name = header_file(input_name, input_n_procs);
826  bool input_parallel = input_n_procs > 0;
827 
828  // If this is a serial read then we're going to only read the mesh
829  // on processor 0, then broadcast it
830  if ((input_parallel && !mesh.is_replicated()) || mesh.processor_id() == 0)
831  {
832  // If we're trying to read a parallel checkpoint file on a
833  // replicated mesh, we'll read every file on processor 0 so we
834  // can broadcast it later. If we're on a distributed mesh then
835  // we'll read every id to it's own processor and we'll "wrap
836  // around" with any ids that exceed our processor count.
837  const processor_id_type begin_proc_id =
838  (input_parallel && !mesh.is_replicated()) ?
839  mesh.processor_id() : 0;
840  const processor_id_type stride =
841  (input_parallel && !mesh.is_replicated()) ?
842  mesh.n_processors() : 1;
843 
844  for (processor_id_type proc_id = begin_proc_id; proc_id < input_n_procs;
845  proc_id = cast_int<processor_id_type>(proc_id + stride))
846  {
847  auto file_name = split_file(input_name, input_n_procs, proc_id);
848 
849  {
850  std::ifstream in (file_name.c_str());
851 
852  libmesh_error_msg_if(!in.good(), "ERROR: cannot locate specified file:\n\t" << file_name);
853  }
854 
855  // Do we expect all our files' remote_elem entries to really
856  // be remote? Only if we're not reading multiple input
857  // files on the same processor.
858  const bool expect_all_remote =
859  (input_n_procs <= mesh.n_processors() &&
860  !mesh.is_replicated());
861 
862  Xdr io (file_name, this->binary() ? DECODE : READ);
863 
864  switch (data_size) {
865  case 2:
866  this->read_subfile<uint16_t>(io, expect_all_remote);
867  break;
868  case 4:
869  this->read_subfile<uint32_t>(io, expect_all_remote);
870  break;
871  case 8:
872  this->read_subfile<uint64_t>(io, expect_all_remote);
873  break;
874  default:
875  libmesh_error();
876  }
877 
878  io.close();
879  }
880  }
881 
882  // If the mesh was only read on processor 0 then we need to broadcast it
883  if (mesh.is_replicated())
884  MeshCommunication().broadcast(mesh);
885  // If the mesh is really distributed then we need to make sure it
886  // knows that
887  else if (mesh.n_processors() > 1)
889 
890  // If the mesh isn't getting even critical partitioning then we
891  // should update cached data from the partitioning we just read in
892  if (mesh.skip_partitioning())
893  {
896  }
897 }
void skip_partitioning(bool skip)
If true is passed in then nothing on this mesh will be (re)partitioned.
Definition: mesh_base.h:1254
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:226
uint8_t processor_id_type
processor_id_type n_processors() const
libmesh_assert(ctx)
unsigned int recalculate_n_partitions()
In a few (very rare) cases, the user may have manually tagged the elements with specific processor ID...
Definition: mesh_base.C:1618
virtual bool is_replicated() const
Definition: mesh_base.h:233
bool binary() const
Get/Set the flag indicating if we should read/write binary.
virtual void update_post_partitioning()
Recalculate any cached data after elements and nodes have been repartitioned.
Definition: mesh_base.h:1177
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 1418 of file checkpoint_io.C.

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

1419 {
1420  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1421  info.set_sideset_name_map() : info.set_nodeset_name_map();
1422 
1423  std::vector<file_id_type> boundary_ids;
1424  std::vector<std::string> boundary_names;
1425 
1426  file_id_type n_boundary_names = 0;
1427 
1428  if (is_sideset)
1429  io.data(n_boundary_names, "# sideset id to name map");
1430  else
1431  io.data(n_boundary_names, "# nodeset id to name map");
1432 
1433  if (n_boundary_names)
1434  {
1435  io.data(boundary_ids);
1436  io.data(boundary_names);
1437  }
1438 
1439  // Add them back into the map
1440  for (auto i : index_range(boundary_ids))
1441  boundary_map[cast_int<boundary_id_type>(boundary_ids[i])] =
1442  boundary_names[i];
1443 }
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:117

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

1371 {
1372  // convenient reference to our mesh
1373  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1374 
1375  // and our boundary info object
1376  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1377 
1378  std::vector<file_id_type> element_id_list;
1379  std::vector<uint16_t> side_list;
1380  std::vector<file_id_type> bc_id_list;
1381 
1382  io.data(element_id_list, "# element ids for bcs");
1383  io.data(side_list, "# sides of elements for bcs");
1384  io.data(bc_id_list, "# bc ids");
1385 
1386  for (auto i : index_range(element_id_list))
1387  boundary_info.add_side
1388  (cast_int<dof_id_type>(element_id_list[i]), side_list[i],
1389  cast_int<boundary_id_type>(bc_id_list[i]));
1390 }
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
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:117

◆ 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 1136 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::invalid_uint, libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::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().

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

903 {
904  MeshBase & mesh = MeshInput<MeshBase>::mesh();
905 
906  // Hack for codes which don't look at all elem dimensions
907  uint16_t mesh_dimension;
908 
909  // Will this be a parallel input file? With how many processors? Stay tuned!
910  uint16_t input_parallel;
911  file_id_type input_n_procs;
912 
913  std::vector<std::string> node_integer_names, elem_integer_names;
914 
915  // We'll write a header file from processor 0 and broadcast.
916  if (this->processor_id() == 0)
917  {
918  Xdr io (name, this->binary() ? DECODE : READ);
919 
920  // read the version, but don't care about it
921  std::string input_version;
922  io.data(input_version);
923 
924  // read the data type, don't care about it this time
925  header_id_type data_size;
926  io.data (data_size);
927 
928  // read the dimension
929  io.data (mesh_dimension);
930 
931  // Read whether or not this is a parallel file
932  io.data(input_parallel);
933 
934  // With how many processors?
935  if (input_parallel)
936  io.data(input_n_procs);
937 
938  // read subdomain names
939  this->read_subdomain_names<file_id_type>(io);
940 
941  // read boundary names
942  BoundaryInfo & boundary_info = mesh.get_boundary_info();
943 
944  this->read_bc_names<file_id_type>(io, boundary_info, true); // sideset names
945  this->read_bc_names<file_id_type>(io, boundary_info, false); // nodeset names
946 
947  // read extra integer names?
948  std::swap(input_version, this->version());
949  const bool read_extra_integers = this->version_at_least_1_5();
950  std::swap(input_version, this->version());
951 
952  if (read_extra_integers)
953  this->read_integers_names<file_id_type>
954  (io, node_integer_names, elem_integer_names);
955  }
956 
957  // broadcast data from processor 0, set values everywhere
958  this->comm().broadcast(mesh_dimension);
959  mesh.set_mesh_dimension(cast_int<unsigned char>(mesh_dimension));
960 
961  this->comm().broadcast(input_parallel);
962 
963  if (input_parallel)
964  this->comm().broadcast(input_n_procs);
965  else
966  input_n_procs = 1;
967 
968  std::map<subdomain_id_type, std::string> & subdomain_map =
970  this->comm().broadcast(subdomain_map);
971 
972  BoundaryInfo & boundary_info = mesh.get_boundary_info();
973  this->comm().broadcast(boundary_info.set_sideset_name_map());
974  this->comm().broadcast(boundary_info.set_nodeset_name_map());
975 
976  this->comm().broadcast(node_integer_names);
977  this->comm().broadcast(elem_integer_names);
978 
979  for (auto & int_name : node_integer_names)
980  mesh.add_node_integer(int_name);
981 
982  for (auto & int_name : elem_integer_names)
983  mesh.add_elem_integer(int_name);
984 
985  return input_parallel ? input_n_procs : 0;
986 }
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:560
const Parallel::Communicator & comm() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:275
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:649
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:1692

◆ 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 1448 of file checkpoint_io.C.

References libMesh::Xdr::data().

1451 {
1452  file_id_type n_node_integers, n_elem_integers;
1453 
1454  io.data(n_node_integers, "# n_extra_integers per node");
1455  io.data(node_integer_names);
1456  io.data(n_elem_integers, "# n_extra_integers per elem");
1457  io.data(elem_integer_names);
1458 }

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

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

1396 {
1397  // convenient reference to our mesh
1398  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1399 
1400  // and our boundary info object
1401  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1402 
1403  std::vector<file_id_type> node_id_list;
1404  std::vector<file_id_type> bc_id_list;
1405 
1406  io.data(node_id_list, "# node id list");
1407  io.data(bc_id_list, "# nodeset bc id list");
1408 
1409  for (auto i : index_range(node_id_list))
1410  boundary_info.add_node
1411  (cast_int<dof_id_type>(node_id_list[i]),
1412  cast_int<boundary_id_type>(bc_id_list[i]));
1413 }
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:165
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:117

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

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

◆ read_subdomain_names()

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

Read subdomain name information.

Definition at line 1012 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().

1013 {
1014  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1015 
1016  std::map<subdomain_id_type, std::string> & subdomain_map =
1018 
1019  std::vector<file_id_type> subdomain_ids;
1020  subdomain_ids.reserve(subdomain_map.size());
1021 
1022  std::vector<std::string> subdomain_names;
1023  subdomain_names.reserve(subdomain_map.size());
1024 
1025  file_id_type n_subdomain_names = 0;
1026  io.data(n_subdomain_names, "# subdomain id to name map");
1027 
1028  if (n_subdomain_names)
1029  {
1030  io.data(subdomain_ids);
1031  io.data(subdomain_names);
1032 
1033  for (auto i : index_range(subdomain_ids))
1034  subdomain_map[cast_int<subdomain_id_type>(subdomain_ids[i])] =
1035  subdomain_names[i];
1036  }
1037 }
const DofMap &dof_map LIBMESH_COMMA unsigned int std::string & set_subdomain_name_map()
Definition: mesh_base.h:1692
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:117

◆ 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 991 of file checkpoint_io.C.

992 {
993  // read the nodal locations
994  this->read_nodes<file_id_type> (io);
995 
996  // read connectivity
997  this->read_connectivity<file_id_type> (io);
998 
999  // read remote_elem connectivity
1000  this->read_remote_elem<file_id_type> (io, expect_all_remote);
1001 
1002  // read the boundary conditions
1003  this->read_bcs<file_id_type> (io);
1004 
1005  // read the nodesets
1006  this->read_nodesets<file_id_type> (io);
1007 }

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

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

◆ 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 279 of file checkpoint_io.C.

References version().

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

280 {
281  return (this->version().find("1.5") != std::string::npos);
282 }
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 285 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_element_dependencies(), 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(), 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().

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

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

Referenced by write().

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

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

Referenced by write().

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

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

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

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

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

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

◆ write_subdomain_names()

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

Write subdomain name information.

Definition at line 507 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().

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

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: