libMesh
Loading...
Searching...
No Matches
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.
 
 CheckpointIO (const MeshBase &, const bool=false)
 Constructor.
 
virtual ~CheckpointIO ()
 Destructor.
 
virtual void read (const std::string &input_name) override
 This method implements reading a mesh from a specified file.
 
virtual void write (const std::string &name) override
 This method implements writing a mesh to a specified file.
 
bool binary () const
 Get/Set the flag indicating if we should read/write binary.
 
bool & binary ()
 
bool parallel () const
 Get/Set the flag indicating if we should read/write binary.
 
bool & parallel ()
 
const std::string & version () const
 Get/Set the version string.
 
std::string & version ()
 
bool version_at_least_1_5 () const
 
bool version_at_least_1_6 () const
 
const std::vector< processor_id_type > & current_processor_ids () const
 Get/Set the processor id or processor ids to use.
 
std::vector< processor_id_type > & current_processor_ids ()
 
const processor_id_typecurrent_n_processors () const
 Get/Set the n_processors to use.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files.
 
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.
 

Protected Member Functions

MeshBasemesh ()
 
void set_n_partitions (unsigned int n_parts)
 Sets the number of partitions in the mesh.
 
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.
 
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.
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable.
 
const bool _serial_only_needed_on_proc_0
 Flag specifying whether this format can be written by only serializing the mesh to processor zero.
 
const Parallel::Communicator_communicator
 

Private Member Functions

void write_subdomain_names (Xdr &io) const
 Write subdomain name information.
 
void write_connectivity (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 Write the connectivity for part of a mesh.
 
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.
 
void write_nodes (Xdr &io, const connected_node_set_type &nodeset) const
 Write the nodal locations for part of a mesh.
 
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.
 
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)
 
template<typename file_id_type >
file_id_type read_header (const std::string &name)
 Read header data on processor 0, then broadcast.
 
template<typename file_id_type >
void read_subfile (Xdr &io, bool expect_all_remote)
 Read a non-header file.
 
template<typename file_id_type >
void read_subdomain_names (Xdr &io)
 Read subdomain name information.
 
template<typename file_id_type >
void read_connectivity (Xdr &io)
 Read the connectivity for a parallel, distributed mesh.
 
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.
 
template<typename file_id_type >
void read_nodes (Xdr &io)
 Read the nodal locations for a parallel, distributed mesh.
 
template<typename file_id_type >
void read_bcs (Xdr &io)
 Read the boundary conditions for a parallel, distributed mesh.
 
template<typename file_id_type >
void read_nodesets (Xdr &io)
 Read the nodeset conditions for a parallel, distributed mesh.
 
template<typename file_id_type >
void read_bc_names (Xdr &io, BoundaryInfo &info, bool is_sideset)
 Read boundary names information (sideset and nodeset)
 
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.
 
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
 
MeshBase_obj
 A pointer to a non-const object object.
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable.
 
unsigned int _ascii_precision
 Precision to use when writing ASCII files.
 

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

167 :
168 MeshInput<MeshBase> (mesh,/* is_parallel_format = */ true),
169 MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
171 _binary (binary_in),
172 _parallel (false),
173 _version ("checkpoint-1.6"),
176{
177}
processor_id_type _my_n_processors
std::vector< processor_id_type > _my_processor_ids
virtual bool is_replicated() const
Definition mesh_base.h:379
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
processor_id_type processor_id() const
processor_id_type n_processors() const
template class LIBMESH_EXPORT MeshOutput< MeshBase >

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

179 :
180 MeshInput<MeshBase> (), // write-only
181 MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
183 _binary (binary_in),
184 _parallel (false),
185 _version ("checkpoint-1.6"),
188{
189}

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

270{
271 return _ascii_precision;
272}
unsigned int _ascii_precision
Precision to use when writing ASCII files.

◆ binary() [1/2]

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

Definition at line 147 of file checkpoint_io.h.

147{ return _binary; }

References _binary.

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

146{ return _binary; }

References _binary.

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

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

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

Referenced by CheckpointIOTest::testC0PolygonCheckpoint(), and CheckpointIOTest::testC0PolyhedronCheckpoint().

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

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

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::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::System::add_matrix(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::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::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::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::MeshTetInterface::check_hull_integrity(), libMesh::MeshBase::complete_preparation(), 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::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), PetscSolverConfiguration::configure_solver(), 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::MeshBase::detect_interior_parents(), 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::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), 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::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(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::MeshTetInterface::improve_hull_integrity(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::StaticCondensation::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::LocationMap< T >::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), ElasticitySystem::init_data(), 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::Modification::interpolate_surface(), 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_snes_mffd_interface(), libMesh::libmesh_petsc_snes_postcheck(), 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::MeshCommunication::make_elems_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::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::PetscVector< T >::operator=(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::ReplicatedMesh::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(), LaplaceSystem::postprocess(), PoissonSystem::postprocess(), 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(), libMesh::XdrIO::read(), libMesh::Nemesis_IO::read(), FEMParameters::read(), libMesh::EquationSystems::read(), read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::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::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::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(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::BoundaryInfo::remove_edge_id(), libMesh::BoundaryInfo::remove_node_id(), libMesh::BoundaryInfo::remove_shellface_id(), libMesh::BoundaryInfo::remove_side_id(), 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::NoxNonlinearSolver< Number >::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshBase::sync_subdomain_name_map(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolygonTest::test_write_and_read_pentagon(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), CheckpointIOTest::testC0PolygonCheckpoint(), VolumeTest::testC0PolygonMethods(), CheckpointIOTest::testC0PolyhedronCheckpoint(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriEdge3ToTri7CenterFixup(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectScalarCoarsening(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testSelectiveRenumber(), BoundaryMeshSubdomainTest::testSingleSubdomain(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), update_current_local_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::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::RBConstruction::write_riesz_representors_to_files(), libMesh::TransientRBConstruction::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().

◆ current_n_processors() [1/2]

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

Definition at line 202 of file checkpoint_io.h.

202{ return _my_n_processors; }

References _my_n_processors.

◆ current_n_processors() [2/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 201 of file checkpoint_io.h.

201{ return _my_n_processors; }

References _my_n_processors.

Referenced by CheckpointIOTest::testSplitter().

◆ current_processor_ids() [1/2]

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

Definition at line 189 of file checkpoint_io.h.

189{ return _my_processor_ids; }

References _my_processor_ids.

◆ current_processor_ids() [2/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 188 of file checkpoint_io.h.

188{ return _my_processor_ids; }

References _my_processor_ids.

Referenced by CheckpointIOTest::testSplitter().

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

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

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
Returns
The object as a read-only reference.

Definition at line 168 of file mesh_output.h.

260{
261 libmesh_assert(_obj);
262 return *_obj;
263}
const MeshBase *const _obj
A pointer to a constant object.
libmesh_assert(ctx)

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

1641{
1642 unsigned int max_level = 0;
1643
1644 for (const auto & elem : as_range(begin, end))
1645 max_level = std::max(elem->level(), max_level);
1646
1647 return max_level + 1;
1648}
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.

References libMesh::as_range().

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

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 }
processor_id_type size() const

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and libMesh::Parallel::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::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::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::NumericVector< T >::is_effectively_ghosted(), libMesh::NumericVector< T >::is_effectively_serial(), 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::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::MeshBase::partition(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::Nemesis_IO::read(), read(), libMesh::NameBasedIO::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::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::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().

◆ parallel() [1/2]

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

Definition at line 153 of file checkpoint_io.h.

153{ return _parallel; }

References _parallel.

◆ parallel() [2/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.

152{ return _parallel; }

References _parallel.

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

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

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

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), 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::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), 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::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::MeshTools::Modification::interpolate_surface(), libMesh::SparsityPattern::Build::join(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::TransientRBEvaluation::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(), main(), 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::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::XdrIO::read(), libMesh::Nemesis_IO::read(), read(), libMesh::NameBasedIO::read(), libMesh::EquationSystems::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::read_header(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::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::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(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolygonTest::test_write_and_read_pentagon(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), BoundaryInfoTest::testBoundaryIDs(), 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(), BoundaryInfoTest::testInternalBoundary(), MeshInputTest::testLowOrderEdgeBlocks(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), BoundaryMeshSubdomainTest::testSingleSubdomain(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::write(), write(), libMesh::EquationSystems::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_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::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::UCDIO::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::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_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::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

◆ read()

void libMesh::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 850 of file checkpoint_io.C.

851{
852 LOG_SCOPE("read()","CheckpointIO");
853
854 MeshBase & mesh = MeshInput<MeshBase>::mesh();
855
857
858 header_id_type data_size;
859 processor_id_type input_n_procs = select_split_config(input_name, data_size);
860 auto header_name = header_file(input_name, input_n_procs);
861 bool input_parallel = input_n_procs > 0;
862
863 // If this is a serial read then we're going to only read the mesh
864 // on processor 0, then broadcast it
865 if ((input_parallel && !mesh.is_replicated()) || mesh.processor_id() == 0)
866 {
867 // If we're trying to read a parallel checkpoint file on a
868 // replicated mesh, we'll read every file on processor 0 so we
869 // can broadcast it later. If we're on a distributed mesh then
870 // we'll read every id to it's own processor and we'll "wrap
871 // around" with any ids that exceed our processor count.
872 const processor_id_type begin_proc_id =
873 (input_parallel && !mesh.is_replicated()) ?
874 mesh.processor_id() : 0;
875 const processor_id_type stride =
876 (input_parallel && !mesh.is_replicated()) ?
877 mesh.n_processors() : 1;
878
879 for (processor_id_type proc_id = begin_proc_id; proc_id < input_n_procs;
880 proc_id = cast_int<processor_id_type>(proc_id + stride))
881 {
882 auto file_name = split_file(input_name, input_n_procs, proc_id);
883
884 {
885 std::ifstream in (file_name.c_str());
886
887 libmesh_error_msg_if(!in.good(), "ERROR: cannot locate specified file:\n\t" << file_name);
888 }
889
890 // Do we expect all our files' remote_elem entries to really
891 // be remote? Only if we're not reading multiple input
892 // files on the same processor.
893 const bool expect_all_remote =
894 (input_n_procs <= mesh.n_processors() &&
896
897 Xdr io (file_name, this->binary() ? DECODE : READ);
898
899 switch (data_size) {
900 case 2:
901 this->read_subfile<uint16_t>(io, expect_all_remote);
902 break;
903 case 4:
904 this->read_subfile<uint32_t>(io, expect_all_remote);
905 break;
906 case 8:
907 this->read_subfile<uint64_t>(io, expect_all_remote);
908 break;
909 default:
910 libmesh_error();
911 }
912
913 io.close();
914 }
915 }
916
917 // If the mesh was only read on processor 0 then we need to broadcast it
918 if (mesh.is_replicated())
919 MeshCommunication().broadcast(mesh);
920 // If the mesh is really distributed then we need to make sure it
921 // knows that
922 else if (mesh.n_processors() > 1)
924
925 // If the mesh isn't getting even critical partitioning then we
926 // should update cached data from the partitioning we just read in
928 {
931 }
932}
processor_id_type select_split_config(const std::string &input_name, header_id_type &data_size)
bool binary() const
Get/Set the flag indicating if we should read/write binary.
virtual dof_id_type n_elem() const =0
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:1813
virtual void update_post_partitioning()
Recalculate any cached data (or invalidate any caches that are computed on the fly) after elements an...
Definition mesh_base.C:1180
virtual void set_distributed()
Asserts that not all elements and nodes of the mesh necessarily exist on the current processor.
Definition mesh_base.h:372
void skip_partitioning(bool skip)
If true is passed in then nothing on this mesh will be (re)partitioned.
Definition mesh_base.h:1429

References binary(), libMesh::MeshCommunication::broadcast(), libMesh::Xdr::close(), libMesh::DECODE, libMesh::MeshBase::is_replicated(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::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(), CheckpointIOTest::testC0PolygonCheckpoint(), CheckpointIOTest::testC0PolyhedronCheckpoint(), and CheckpointIOTest::testSplitter().

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

1597{
1598 std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1599 info.set_sideset_name_map() : info.set_nodeset_name_map();
1600
1601 std::vector<file_id_type> boundary_ids;
1602 std::vector<std::string> boundary_names;
1603
1604 file_id_type n_boundary_names = 0;
1605
1606 if (is_sideset)
1607 io.data(n_boundary_names, "# sideset id to name map");
1608 else
1609 io.data(n_boundary_names, "# nodeset id to name map");
1610
1611 if (n_boundary_names)
1612 {
1613 io.data(boundary_ids);
1614 io.data(boundary_names);
1615 }
1616
1617 // Add them back into the map
1618 for (auto i : index_range(boundary_ids))
1619 boundary_map[cast_int<boundary_id_type>(boundary_ids[i])] =
1620 boundary_names[i];
1621}
MPI_Info info
Tnew cast_int(Told oldvar)
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:153
int8_t boundary_id_type
Definition id_types.h:51

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

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

1549{
1550 // convenient reference to our mesh
1551 MeshBase & mesh = MeshInput<MeshBase>::mesh();
1552
1553 // and our boundary info object
1554 BoundaryInfo & boundary_info = mesh.get_boundary_info();
1555
1556 std::vector<file_id_type> element_id_list;
1557 std::vector<uint16_t> side_list;
1558 std::vector<file_id_type> bc_id_list;
1559
1560 io.data(element_id_list, "# element ids for bcs");
1561 io.data(side_list, "# sides of elements for bcs");
1562 io.data(bc_id_list, "# bc ids");
1563
1564 for (auto i : index_range(element_id_list))
1565 boundary_info.add_side
1566 (cast_int<dof_id_type>(element_id_list[i]), side_list[i],
1567 cast_int<boundary_id_type>(bc_id_list[i]));
1568}
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
uint8_t dof_id_type
Definition id_types.h:67

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

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

1175{
1176 // convenient reference to our mesh
1177 MeshBase & mesh = MeshInput<MeshBase>::mesh();
1178
1179 const bool read_extra_integers = this->version_at_least_1_5();
1180 const bool read_runtime_topology = this->version_at_least_1_6();
1181
1182 const unsigned int n_extra_integers =
1183 read_extra_integers ? mesh.n_elem_integers() : 0;
1184
1185 file_id_type n_elems_here;
1186 io.data(n_elems_here);
1187
1188 // Keep track of the highest dimensional element we've added to the mesh
1189 unsigned int highest_elem_dim = mesh.mesh_dimension();
1190
1191 // RHS: Originally we used invalid_processor_id as a "no parent" tag
1192 // number, because I'm an idiot. Let's try to support broken files
1193 // as much as possible.
1194 bool file_is_broken = false;
1195
1196 for (unsigned int i=0; i<n_elems_here; i++)
1197 {
1198 // id type pid subdomain_id parent_id
1199 std::vector<file_id_type> elem_data(6 + n_extra_integers);
1200 io.data_stream
1201 (elem_data.data(), cast_int<unsigned int>(elem_data.size()),
1202 cast_int<unsigned int>(elem_data.size()));
1203
1204#ifdef LIBMESH_ENABLE_UNIQUE_ID
1205 file_id_type unique_id = 0;
1206 io.data(unique_id, "# unique id");
1207#endif
1208
1209#ifdef LIBMESH_ENABLE_AMR
1210 uint16_t p_level = 0;
1211 io.data(p_level, "# p_level");
1212
1213 uint16_t rflag, pflag;
1214 io.data(rflag, "# rflag");
1215 io.data(pflag, "# pflag");
1216#endif
1217
1218 const ElemType elem_type =
1219 static_cast<ElemType>(elem_data[1]);
1220 const bool is_c0polygon = (elem_type == C0POLYGON);
1221 const bool is_c0polyhedron = (elem_type == C0POLYHEDRON);
1222
1223 unsigned int n_nodes = Elem::type_to_n_nodes_map[elem_data[1]];
1224 // Runtime-topology types have no fixed node count in this map.
1225 const bool has_runtime_topology = (n_nodes == invalid_uint);
1226 std::vector<std::vector<unsigned int>> nodes_on_sides;
1227
1228 if (has_runtime_topology)
1229 {
1230 libmesh_error_msg_if
1231 (!read_runtime_topology,
1232 "Checkpoint format 1.6 or newer is required to read " <<
1233 Utility::enum_to_string(elem_type) << " elements.");
1234
1235 std::vector<file_id_type> runtime_topology;
1236 io.data(runtime_topology, "# runtime topology");
1237 libmesh_error_msg_if(runtime_topology.size() < 2,
1238 "Invalid runtime element topology.");
1239
1240 std::size_t topology_index = 0;
1241 n_nodes =
1242 cast_int<unsigned int>(runtime_topology[topology_index++]);
1243 const unsigned int n_sides =
1244 cast_int<unsigned int>(runtime_topology[topology_index++]);
1245 nodes_on_sides.resize(n_sides);
1246
1247 for (auto s : index_range(nodes_on_sides))
1248 {
1249 libmesh_error_msg_if
1250 (topology_index == runtime_topology.size(),
1251 "Incomplete runtime element checkpoint topology.");
1252
1253 const unsigned int n_side_nodes =
1254 cast_int<unsigned int>(runtime_topology[topology_index++]);
1255 libmesh_error_msg_if
1256 (n_side_nodes > runtime_topology.size() - topology_index,
1257 "Invalid runtime element side checkpoint topology.");
1258
1259 auto & side_nodes = nodes_on_sides[s];
1260 side_nodes.resize(n_side_nodes);
1261 for (auto n : index_range(side_nodes))
1262 {
1263 const unsigned int local_node =
1264 cast_int<unsigned int>(runtime_topology[topology_index++]);
1265 libmesh_error_msg_if
1266 (local_node >= n_nodes,
1267 "Runtime element side checkpoint topology references "
1268 "an invalid local node.");
1269 side_nodes[n] = local_node;
1270 }
1271 }
1272
1273 libmesh_error_msg_if
1274 (topology_index != runtime_topology.size(),
1275 "Extra data in runtime element checkpoint topology.");
1276
1277 if (is_c0polygon)
1278 {
1279 libmesh_error_msg_if
1280 (n_nodes < 3 || n_sides != n_nodes,
1281 "Invalid C0POLYGON checkpoint topology.");
1282 for (const auto & side_nodes : nodes_on_sides)
1283 libmesh_error_msg_if
1284 (side_nodes.size() != 2,
1285 "Invalid C0POLYGON side checkpoint topology.");
1286 }
1287 else if (is_c0polyhedron)
1288 {
1289 libmesh_error_msg_if(n_sides < 4,
1290 "Invalid C0POLYHEDRON checkpoint topology.");
1291 for (const auto & side_nodes : nodes_on_sides)
1292 libmesh_error_msg_if
1293 (side_nodes.size() < 3,
1294 "Invalid C0POLYHEDRON side checkpoint topology.");
1295 }
1296 }
1297
1298 // Snag the node ids this element was connected to
1299 std::vector<file_id_type> conn_data(n_nodes);
1300 io.data_stream
1301 (conn_data.data(), cast_int<unsigned int>(conn_data.size()),
1302 cast_int<unsigned int>(conn_data.size()));
1303
1304 const dof_id_type id =
1305 cast_int<dof_id_type> (elem_data[0]);
1306 const processor_id_type proc_id =
1307 cast_int<processor_id_type>
1308 (elem_data[2] % mesh.n_processors());
1309 const subdomain_id_type subdomain_id =
1310 restrict_int<subdomain_id_type>(elem_data[3]);
1311
1312 // Old broken files used processsor_id_type(-1)...
1313 // But we *know* our first element will be level 0
1314 if (i == 0 && elem_data[4] == 65535)
1315 file_is_broken = true;
1316
1317 // On a broken file we can't tell whether a parent of 65535 is a
1318 // null parent or an actual parent of 65535. Assuming the
1319 // former will cause less breakage.
1320 Elem * parent =
1321 (elem_data[4] == static_cast<largest_id_type>(-1) ||
1322 (file_is_broken && elem_data[4] == 65535)) ?
1323 nullptr : mesh.elem_ptr(cast_int<dof_id_type>(elem_data[4]));
1324
1325 const unsigned short int child_num =
1326 (elem_data[5] == static_cast<largest_id_type>(-1) ||
1327 (file_is_broken && elem_data[5] == 65535)) ?
1328 static_cast<unsigned short>(-1) :
1329 cast_int<unsigned short>(elem_data[5]);
1330
1331 if (!parent)
1332 libmesh_assert_equal_to
1333 (child_num, static_cast<unsigned short>(-1));
1334
1335 Elem * old_elem = mesh.query_elem_ptr(id);
1336
1337 // If we already have this element (e.g. from another file,
1338 // when reading multiple distributed CheckpointIO files into
1339 // a ReplicatedMesh) then we don't want to add it again
1340 // (because ReplicatedMesh can't handle that) but we do want
1341 // to assert consistency between what we're reading and what
1342 // we have.
1343 if (old_elem)
1344 {
1345 libmesh_assert_equal_to(elem_type, old_elem->type());
1346 libmesh_assert_equal_to(proc_id, old_elem->processor_id());
1347 libmesh_assert_equal_to(subdomain_id, old_elem->subdomain_id());
1348 if (parent)
1349 libmesh_assert_equal_to(parent, old_elem->parent());
1350 else
1351 libmesh_assert(!old_elem->parent());
1352
1353 libmesh_assert_equal_to(n_extra_integers, old_elem->n_extra_integers());
1354#ifndef NDEBUG
1355 for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1356 {
1357 const dof_id_type extra_int = cast_int<dof_id_type>(elem_data[6+ei]);
1358 libmesh_assert_equal_to(extra_int, old_elem->get_extra_integer(ei));
1359 }
1360#endif
1361
1362 libmesh_assert_equal_to(old_elem->n_nodes(), conn_data.size());
1363
1364 for (unsigned int n=0,
1365 n_conn = cast_int<unsigned int>(conn_data.size());
1366 n != n_conn; n++)
1367 libmesh_assert_equal_to
1368 (old_elem->node_id(n),
1369 cast_int<dof_id_type>(conn_data[n]));
1370
1371 if (has_runtime_topology)
1372 {
1373 libmesh_assert_equal_to(old_elem->n_sides(),
1374 nodes_on_sides.size());
1375#ifndef NDEBUG
1376 for (auto s : index_range(nodes_on_sides))
1377 libmesh_assert(old_elem->nodes_on_side(s) ==
1378 nodes_on_sides[s]);
1379#endif
1380 }
1381 }
1382 else
1383 {
1384 // Create the element
1385 std::unique_ptr<Elem> elem;
1386 std::unique_ptr<Node> generated_mid_elem_node;
1387
1388 if (is_c0polygon)
1389 elem = std::make_unique<C0Polygon>(n_nodes, parent);
1390 else if (is_c0polyhedron)
1391 {
1392 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_sides.size());
1393 for (auto s : index_range(nodes_on_sides))
1394 {
1395 const auto & side_node_indices = nodes_on_sides[s];
1396 auto side =
1397 std::make_shared<C0Polygon>
1398 (cast_int<unsigned int>(side_node_indices.size()));
1399 for (auto n : index_range(side_node_indices))
1400 side->set_node
1401 (n, mesh.node_ptr(cast_int<dof_id_type>
1402 (conn_data[side_node_indices[n]])));
1403 sides[s] = std::move(side);
1404 }
1405
1406 elem = std::make_unique<C0Polyhedron>
1407 (sides, generated_mid_elem_node, parent);
1408
1409 libmesh_error_msg_if
1410 (elem->n_nodes() != conn_data.size(),
1411 "C0POLYHEDRON checkpoint topology is incompatible with "
1412 "this libMesh configuration.");
1413
1414 for (auto n : make_range(elem->n_vertices()))
1415 libmesh_error_msg_if
1416 (elem->node_id(n) !=
1417 cast_int<dof_id_type>(conn_data[n]),
1418 "C0POLYHEDRON checkpoint topology has inconsistent "
1419 "local node ordering.");
1420 }
1421 else
1422 elem = Elem::build(elem_type, parent);
1423
1424 if (has_runtime_topology)
1425 {
1426 libmesh_error_msg_if
1427 (!elem->runtime_topology() ||
1428 elem->n_nodes() != conn_data.size() ||
1429 elem->n_sides() != nodes_on_sides.size(),
1430 Utility::enum_to_string(elem_type) <<
1431 " checkpoint topology is incompatible with this "
1432 "libMesh configuration.");
1433
1434 for (auto s : index_range(nodes_on_sides))
1435 libmesh_error_msg_if
1436 (elem->nodes_on_side(s) != nodes_on_sides[s],
1437 Utility::enum_to_string(elem_type) <<
1438 " checkpoint topology has inconsistent side ordering.");
1439 }
1440
1441#ifdef LIBMESH_ENABLE_UNIQUE_ID
1442 elem->set_unique_id(unique_id);
1443#endif
1444
1445 if (elem->dim() > highest_elem_dim)
1446 highest_elem_dim = elem->dim();
1447
1448 elem->set_id() = id;
1449 elem->processor_id() = proc_id;
1450 elem->subdomain_id() = subdomain_id;
1451
1452#ifdef LIBMESH_ENABLE_AMR
1453 elem->hack_p_level(p_level);
1454
1455 elem->set_refinement_flag (cast_int<Elem::RefinementState>(rflag));
1456 elem->set_p_refinement_flag(cast_int<Elem::RefinementState>(pflag));
1457
1458 // Set parent connections
1459 if (parent)
1460 {
1461 // We must specify a child_num, because we will have
1462 // skipped adding any preceding remote_elem children
1463 parent->add_child(elem.get(), child_num);
1464 }
1465#else
1466 libmesh_ignore(child_num);
1467#endif
1468
1469 libmesh_assert(elem->n_nodes() == conn_data.size());
1470
1471 // Connect all the nodes to this element
1472 for (unsigned int n=0,
1473 n_conn = cast_int<unsigned int>(conn_data.size());
1474 n != n_conn; n++)
1475 elem->set_node(n,
1476 mesh.node_ptr(cast_int<dof_id_type>(conn_data[n])));
1477
1478 Elem * added_elem = mesh.add_elem(std::move(elem));
1479
1480 libmesh_assert_equal_to(n_extra_integers, added_elem->n_extra_integers());
1481 for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1482 {
1483 const dof_id_type extra_int = cast_int<dof_id_type>(elem_data[6+ei]);
1484 added_elem->set_extra_integer(ei, extra_int);
1485 }
1486 }
1487 }
1488
1489 mesh.set_mesh_dimension(cast_int<unsigned char>(highest_elem_dim));
1490}
bool version_at_least_1_6() const
bool version_at_least_1_5() const
static const unsigned int type_to_n_nodes_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of nodes in the element...
Definition elem.h:643
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:442
unsigned int n_elem_integers() const
Definition mesh_base.h:1090
virtual const Node * node_ptr(const dof_id_type i) const =0
unsigned int mesh_dimension() const
Definition mesh_base.C:430
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition mesh_base.h:423
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
std::string enum_to_string(const T e)
ElemType
Defines an enum for geometric element types.
void libmesh_ignore(const Args &...)
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:303
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all....
Definition id_types.h:43
uint64_t largest_id_type
Definition id_types.h:148
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176
const dof_id_type n_nodes
Definition tecplot_io.C:67

References libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::Elem::build(), libMesh::C0POLYGON, libMesh::C0POLYHEDRON, libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::MeshBase::elem_ptr(), libMesh::Utility::enum_to_string(), libMesh::DofObject::get_extra_integer(), libMesh::index_range(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::make_range(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem_integers(), libMesh::DofObject::n_extra_integers(), libMesh::Elem::n_nodes(), n_nodes, libMesh::ParallelObject::n_processors(), libMesh::Elem::n_sides(), libMesh::Elem::node_id(), libMesh::MeshBase::node_ptr(), libMesh::Elem::nodes_on_side(), 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, version_at_least_1_5(), and version_at_least_1_6().

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

938{
939 MeshBase & mesh = MeshInput<MeshBase>::mesh();
940
941 // Hack for codes which don't look at all elem dimensions
942 uint16_t mesh_dimension;
943
944 // Will this be a parallel input file? With how many processors? Stay tuned!
945 uint16_t input_parallel;
946 file_id_type input_n_procs;
947
948 std::string input_version;
949 std::vector<std::string> node_integer_names, elem_integer_names;
950
951 // We'll write a header file from processor 0 and broadcast.
952 if (this->processor_id() == 0)
953 {
954 Xdr io (name, this->binary() ? DECODE : READ);
955
956 // read the version
957 io.data(input_version);
958
959 // read the data type, don't care about it this time
960 header_id_type data_size;
961 io.data (data_size);
962
963 // read the dimension
964 io.data (mesh_dimension);
965
966 // Read whether or not this is a parallel file
967 io.data(input_parallel);
968
969 // With how many processors?
970 if (input_parallel)
971 io.data(input_n_procs);
972
973 // read subdomain names
974 this->read_subdomain_names<file_id_type>(io);
975
976 // read boundary names
977 BoundaryInfo & boundary_info = mesh.get_boundary_info();
978
979 this->read_bc_names<file_id_type>(io, boundary_info, true); // sideset names
980 this->read_bc_names<file_id_type>(io, boundary_info, false); // nodeset names
981
982 // read extra integer names?
983 std::swap(input_version, this->version());
984 const bool read_extra_integers = this->version_at_least_1_5();
985 std::swap(input_version, this->version());
986
987 if (read_extra_integers)
988 this->read_integers_names<file_id_type>
989 (io, node_integer_names, elem_integer_names);
990 }
991
992 // broadcast data from processor 0, set values everywhere
993 this->comm().broadcast(input_version);
994 this->version() = input_version;
995
996 this->comm().broadcast(mesh_dimension);
997 mesh.set_mesh_dimension(cast_int<unsigned char>(mesh_dimension));
998
999 this->comm().broadcast(input_parallel);
1000
1001 if (input_parallel)
1002 this->comm().broadcast(input_n_procs);
1003 else
1004 input_n_procs = 1;
1005
1006 std::map<subdomain_id_type, std::string> & subdomain_map =
1008 this->comm().broadcast(subdomain_map);
1009
1010 BoundaryInfo & boundary_info = mesh.get_boundary_info();
1011 this->comm().broadcast(boundary_info.set_sideset_name_map());
1012 this->comm().broadcast(boundary_info.set_nodeset_name_map());
1013
1014 this->comm().broadcast(node_integer_names);
1015 this->comm().broadcast(elem_integer_names);
1016
1017 for (auto & int_name : node_integer_names)
1018 mesh.add_node_integer(int_name);
1019
1020 for (auto & int_name : elem_integer_names)
1021 mesh.add_elem_integer(int_name);
1022
1023 return input_parallel ? input_n_procs : 0;
1024}
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
const std::string & version() const
Get/Set the version string.
std::map< subdomain_id_type, std::string > & set_subdomain_name_map()
Definition mesh_base.h:1924
const Parallel::Communicator & comm() const

References libMesh::MeshBase::add_elem_integer(), libMesh::MeshBase::add_node_integer(), binary(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, libMesh::MeshBase::get_boundary_info(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), 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().

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

1629{
1630 file_id_type n_node_integers, n_elem_integers;
1631
1632 io.data(n_node_integers, "# n_extra_integers per node");
1633 io.data(node_integer_names);
1634 io.data(n_elem_integers, "# n_extra_integers per elem");
1635 io.data(elem_integer_names);
1636}

References libMesh::Xdr::data().

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

1081{
1082 // convenient reference to our mesh
1083 MeshBase & mesh = MeshInput<MeshBase>::mesh();
1084
1085 file_id_type n_nodes_here;
1086 io.data(n_nodes_here, "# n_nodes on proc");
1087
1088 const bool read_extra_integers = this->version_at_least_1_5();
1089
1090 const unsigned int n_extra_integers =
1091 read_extra_integers ? mesh.n_node_integers() : 0;
1092
1093 // Will hold the node id and pid and extra integers
1094 std::vector<file_id_type> id_pid(2 + n_extra_integers);
1095
1096 // For the coordinates
1097 std::vector<Real> coords(LIBMESH_DIM);
1098
1099 for (unsigned int i=0; i<n_nodes_here; i++)
1100 {
1101 io.data_stream(id_pid.data(), 2 + n_extra_integers, 2 + n_extra_integers);
1102
1103#ifdef LIBMESH_ENABLE_UNIQUE_ID
1104 file_id_type unique_id = 0;
1105 io.data(unique_id, "# unique id");
1106#endif
1107
1108 io.data_stream(coords.data(), LIBMESH_DIM, LIBMESH_DIM);
1109
1110 Point p;
1111 p(0) = coords[0];
1112
1113#if LIBMESH_DIM > 1
1114 p(1) = coords[1];
1115#endif
1116
1117#if LIBMESH_DIM > 2
1118 p(2) = coords[2];
1119#endif
1120
1121 const dof_id_type id = cast_int<dof_id_type>(id_pid[0]);
1122
1123 // "Wrap around" if we see more processors than we're using.
1124 processor_id_type pid =
1125 cast_int<processor_id_type>(id_pid[1] % mesh.n_processors());
1126
1127 // If we already have this node (e.g. from another file, when
1128 // reading multiple distributed CheckpointIO files into a
1129 // ReplicatedMesh) then we don't want to add it again (because
1130 // ReplicatedMesh can't handle that) but we do want to assert
1131 // consistency between what we're reading and what we have.
1132 const Node * old_node = mesh.query_node_ptr(id);
1133
1134 if (old_node)
1135 {
1136 libmesh_assert_equal_to(pid, old_node->processor_id());
1137
1138 libmesh_assert_equal_to(n_extra_integers, old_node->n_extra_integers());
1139#ifndef NDEBUG
1140 for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1141 {
1142 const dof_id_type extra_int = cast_int<dof_id_type>(id_pid[2+ei]);
1143 libmesh_assert_equal_to(extra_int, old_node->get_extra_integer(ei));
1144 }
1145#endif
1146
1147#ifdef LIBMESH_ENABLE_UNIQUE_ID
1148 libmesh_assert_equal_to(unique_id, old_node->unique_id());
1149#endif
1150 }
1151 else
1152 {
1153 Node * node =
1154 mesh.add_point(p, id, pid);
1155
1156#ifdef LIBMESH_ENABLE_UNIQUE_ID
1157 node->set_unique_id(unique_id);
1158#endif
1159
1160 libmesh_assert_equal_to(n_extra_integers, node->n_extra_integers());
1161
1162 for (unsigned int ei=0; ei != n_extra_integers; ++ei)
1163 {
1164 const dof_id_type extra_int = cast_int<dof_id_type>(id_pid[2+ei]);
1165 node->set_extra_integer(ei, extra_int);
1166 }
1167 }
1168 }
1169}
void set_unique_id(unique_id_type new_id)
Sets the unique_id for this DofObject.
Definition dof_object.h:848
virtual const Node * query_node_ptr(const dof_id_type i) const =0
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.
unsigned int n_node_integers() const
Definition mesh_base.h:1212

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

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

1574{
1575 // convenient reference to our mesh
1576 MeshBase & mesh = MeshInput<MeshBase>::mesh();
1577
1578 // and our boundary info object
1579 BoundaryInfo & boundary_info = mesh.get_boundary_info();
1580
1581 std::vector<file_id_type> node_id_list;
1582 std::vector<file_id_type> bc_id_list;
1583
1584 io.data(node_id_list, "# node id list");
1585 io.data(bc_id_list, "# nodeset bc id list");
1586
1587 for (auto i : index_range(node_id_list))
1588 boundary_info.add_node
1589 (cast_int<dof_id_type>(node_id_list[i]),
1590 cast_int<boundary_id_type>(bc_id_list[i]));
1591}

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

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

1495{
1496 // convenient reference to our mesh
1497 MeshBase & mesh = MeshInput<MeshBase>::mesh();
1498
1499 // Find the remote_elem neighbor links
1500 std::vector<file_id_type> elem_ids;
1501 std::vector<uint16_t> elem_sides;
1502
1503 io.data(elem_ids, "# remote neighbor elem_ids");
1504 io.data(elem_sides, "# remote neighbor elem_sides");
1505
1506 libmesh_assert_equal_to(elem_ids.size(), elem_sides.size());
1507
1508 for (auto i : index_range(elem_ids))
1509 {
1510 Elem & elem = mesh.elem_ref(cast_int<dof_id_type>(elem_ids[i]));
1511 if (!elem.neighbor_ptr(elem_sides[i]))
1512 elem.set_neighbor(elem_sides[i],
1513 const_cast<RemoteElem *>(remote_elem));
1514 else
1515 libmesh_assert(!expect_all_remote);
1516 }
1517
1518 // Find the remote_elem children links
1519 std::vector<file_id_type> parent_ids;
1520 std::vector<uint16_t> child_numbers;
1521
1522 io.data(parent_ids, "# remote child parent_ids");
1523 io.data(child_numbers, "# remote child_numbers");
1524
1525#ifdef LIBMESH_ENABLE_AMR
1526 for (auto i : index_range(parent_ids))
1527 {
1528 Elem & elem = mesh.elem_ref(cast_int<dof_id_type>(parent_ids[i]));
1529
1530 // We'd like to assert that no child pointer already exists to
1531 // be overwritten by remote_elem, but Elem doesn't actually have
1532 // an API that will return a child pointer without asserting
1533 // that it isn't nullptr.
1534 const Elem * child = elem.raw_child_ptr(child_numbers[i]);
1535
1536 if (!child)
1537 elem.add_child(const_cast<RemoteElem *>(remote_elem),
1538 child_numbers[i]);
1539 else
1540 libmesh_assert(!expect_all_remote);
1541 }
1542#endif
1543}
const Elem * raw_child_ptr(unsigned int i) const
Definition elem.h:3171
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
Definition elem.h:2635
void add_child(Elem *elem)
Adds a child pointer to the array of children of this element.
Definition elem.C:2053
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:788
const RemoteElem * remote_elem
Definition remote_elem.C:57

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

◆ read_subdomain_names()

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

Read subdomain name information.

Definition at line 1050 of file checkpoint_io.C.

1051{
1052 MeshBase & mesh = MeshInput<MeshBase>::mesh();
1053
1054 std::map<subdomain_id_type, std::string> & subdomain_map =
1056
1057 std::vector<file_id_type> subdomain_ids;
1058 subdomain_ids.reserve(subdomain_map.size());
1059
1060 std::vector<std::string> subdomain_names;
1061 subdomain_names.reserve(subdomain_map.size());
1062
1063 file_id_type n_subdomain_names = 0;
1064 io.data(n_subdomain_names, "# subdomain id to name map");
1065
1066 if (n_subdomain_names)
1067 {
1068 io.data(subdomain_ids);
1069 io.data(subdomain_names);
1070
1071 for (auto i : index_range(subdomain_ids))
1072 subdomain_map[cast_int<subdomain_id_type>(subdomain_ids[i])] =
1073 subdomain_names[i];
1074 }
1075}

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

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

1030{
1031 // read the nodal locations
1032 this->read_nodes<file_id_type> (io);
1033
1034 // read connectivity
1035 this->read_connectivity<file_id_type> (io);
1036
1037 // read remote_elem connectivity
1038 this->read_remote_elem<file_id_type> (io, expect_all_remote);
1039
1040 // read the boundary conditions
1041 this->read_bcs<file_id_type> (io);
1042
1043 // read the nodesets
1044 this->read_nodesets<file_id_type> (io);
1045}

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

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

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

Referenced by read().

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

101{ this->mesh().set_n_partitions() = n_parts; }
MeshBase & mesh

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

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]

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

Definition at line 159 of file checkpoint_io.h.

159{ return _version; }

References _version.

◆ version() [2/2]

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

Get/Set the version string.

Definition at line 158 of file checkpoint_io.h.

158{ return _version; }

References _version.

Referenced by read_header(), version_at_least_1_5(), and version_at_least_1_6().

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

283{
284 return
285 (this->version().find("1.5") != std::string::npos) ||
286 (this->version().find("1.6") != std::string::npos);
287}

References version().

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

◆ version_at_least_1_6()

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

As of this version we encode runtime element topology.

Definition at line 290 of file checkpoint_io.C.

291{
292 return (this->version().find("1.6") != std::string::npos);
293}

References version().

Referenced by read_connectivity(), and write_connectivity().

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

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

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(), 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::testC0PolygonCheckpoint(), CheckpointIOTest::testC0PolyhedronCheckpoint(), CheckpointIOTest::testSplitter(), and libMesh::NameBasedIO::write().

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

819{
820 const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
821 info.get_sideset_name_map() : info.get_nodeset_name_map();
822
823 std::vector<largest_id_type> boundary_ids; boundary_ids.reserve(boundary_map.size());
824 std::vector<std::string> boundary_names; boundary_names.reserve(boundary_map.size());
825
826 // We need to loop over the map and make sure that there aren't any invalid entries. Since we
827 // return writable references in boundary_info, it's possible for the user to leave some entity names
828 // blank. We can't write those to the XDA file.
829 largest_id_type n_boundary_names = 0;
830 for (const auto & [id, name] : boundary_map)
831 if (!name.empty())
832 {
833 n_boundary_names++;
834 boundary_ids.push_back(id);
835 boundary_names.push_back(name);
836 }
837
838 if (is_sideset)
839 io.data(n_boundary_names, "# sideset id to name map");
840 else
841 io.data(n_boundary_names, "# nodeset id to name map");
842 // Write out the ids and names in two vectors
843 if (n_boundary_names)
844 {
845 io.data(boundary_ids);
846 io.data(boundary_names);
847 }
848}
std::string name(const ElemQuality q)
This function returns a string containing some name for q.

References libMesh::Xdr::data().

Referenced by write().

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

753{
754 libmesh_assert (io.writing());
755
756 // Build a list of (elem, side, bc) tuples.
757 std::size_t bc_size = bc_triples.size();
758
759 std::vector<largest_id_type> element_id_list;
760 std::vector<uint16_t> side_list;
761 std::vector<largest_id_type> bc_id_list;
762
763 element_id_list.reserve(bc_size);
764 side_list.reserve(bc_size);
765 bc_id_list.reserve(bc_size);
766
767 std::unordered_set<dof_id_type> elems;
768 for (auto & e : elements)
769 elems.insert(e->id());
770
771 for (const auto & t : bc_triples)
772 if (elems.count(std::get<0>(t)))
773 {
774 element_id_list.push_back(std::get<0>(t));
775 side_list.push_back(std::get<1>(t));
776 bc_id_list.push_back(std::get<2>(t));
777 }
778
779
780 io.data(element_id_list, "# element ids for bcs");
781 io.data(side_list, "# sides of elements for bcs");
782 io.data(bc_id_list, "# bc ids");
783}
const Elem & get(const ElemType type_in)

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

Referenced by write().

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

604{
605 libmesh_assert (io.writing());
606
607 const bool write_extra_integers = this->version_at_least_1_5();
608 const bool write_runtime_topology = this->version_at_least_1_6();
609 const unsigned int n_extra_integers =
610 write_extra_integers ? MeshOutput<MeshBase>::mesh().n_elem_integers() : 0;
611
612 // Put these out here to reduce memory churn
613 // id type pid subdomain_id parent_id extra_integer_0 ...
614 std::vector<largest_id_type> elem_data(6 + n_extra_integers);
615 std::vector<largest_id_type> conn_data;
616 std::vector<largest_id_type> runtime_topology;
617
618 largest_id_type n_elems_here = elements.size();
619
620 io.data(n_elems_here, "# number of elements");
621
622 for (const auto & elem : elements)
623 {
624 unsigned int n_nodes = elem->n_nodes();
625
626 elem_data[0] = elem->id();
627 elem_data[1] = elem->type();
628 elem_data[2] = elem->processor_id();
629 elem_data[3] = elem->subdomain_id();
630
631#ifdef LIBMESH_ENABLE_AMR
632 if (elem->parent() != nullptr)
633 {
634 elem_data[4] = elem->parent()->id();
635 elem_data[5] = elem->parent()->which_child_am_i(elem);
636 }
637 else
638#endif
639 {
640 elem_data[4] = static_cast<largest_id_type>(-1);
641 elem_data[5] = static_cast<largest_id_type>(-1);
642 }
643
644 for (unsigned int i=0; i != n_extra_integers; ++i)
645 elem_data[6+i] = elem->get_extra_integer(i);
646
647 conn_data.resize(n_nodes);
648
649 for (unsigned int i=0; i<n_nodes; i++)
650 conn_data[i] = elem->node_id(i);
651
652 io.data_stream(elem_data.data(),
653 cast_int<unsigned int>(elem_data.size()),
654 cast_int<unsigned int>(elem_data.size()));
655
656#ifdef LIBMESH_ENABLE_UNIQUE_ID
657 largest_id_type unique_id = elem->unique_id();
658
659 io.data(unique_id, "# unique id");
660#endif
661
662#ifdef LIBMESH_ENABLE_AMR
663 uint16_t p_level = cast_int<uint16_t>(elem->p_level());
664 io.data(p_level, "# p_level");
665
666 uint16_t rflag = elem->refinement_flag();
667 io.data(rflag, "# rflag");
668
669 uint16_t pflag = elem->p_refinement_flag();
670 io.data(pflag, "# pflag");
671#endif
672
673 if (elem->runtime_topology())
674 {
675 libmesh_error_msg_if
676 (!write_runtime_topology,
677 "Checkpoint format 1.6 or newer is required to write " <<
678 Utility::enum_to_string(elem->type()) << " elements.");
679
680 runtime_topology.clear();
681 runtime_topology.push_back(n_nodes);
682 runtime_topology.push_back(elem->n_sides());
683 for (auto s : elem->side_index_range())
684 {
685 const auto side_nodes = elem->nodes_on_side(s);
686 runtime_topology.push_back(side_nodes.size());
687 for (const auto n : side_nodes)
688 runtime_topology.push_back(n);
689 }
690
691 io.data(runtime_topology, "# runtime topology");
692 }
693
694 io.data_stream(conn_data.data(),
695 cast_int<unsigned int>(conn_data.size()),
696 cast_int<unsigned int>(conn_data.size()));
697 }
698}

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

Referenced by write().

◆ write_discontinuous_equation_systems()

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

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

Definition at line 101 of file mesh_output.C.

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...
OStreamProxy out

◆ write_equation_systems()

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

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

Reimplemented in libMesh::NameBasedIO, and libMesh::ExodusII_IO.

Definition at line 92 of file mesh_output.C.

34{
35 LOG_SCOPE("write_equation_systems()", "MeshOutput");
36
37 // We may need to gather and/or renumber a DistributedMesh to output
38 // it, making that const qualifier in our constructor a dirty lie
39 MT & my_mesh = const_cast<MT &>(*_obj);
40
41 // If we're asked to write data that's associated with a different
42 // mesh, output files full of garbage are the result.
43 libmesh_assert_equal_to(&es.get_mesh(), _obj);
44
45 // A non-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
68 if (!_is_parallel_format)
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...

◆ write_nodal_data() [1/3]

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

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

Instead of getting a localized copy of the nodal solution vector, it directly uses EquationSystems current_local_solution vectors to look up nodal values.

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

Reimplemented in libMesh::Nemesis_IO.

Definition at line 149 of file mesh_output.C.

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}

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

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 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]

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

Definition at line 109 of file mesh_output.h.

112 { libmesh_not_implemented(); }

◆ write_nodal_data_discontinuous()

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

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

Reimplemented in libMesh::ExodusII_IO.

Definition at line 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 552 of file checkpoint_io.C.

554{
555 largest_id_type n_nodes_here = nodeset.size();
556
557 io.data(n_nodes_here, "# n_nodes on proc");
558
559 const bool write_extra_integers = this->version_at_least_1_5();
560 const unsigned int n_extra_integers =
561 write_extra_integers ? MeshOutput<MeshBase>::mesh().n_node_integers() : 0;
562
563 // Will hold the node id and pid and extra integers
564 std::vector<largest_id_type> id_pid(2 + n_extra_integers);
565
566 // For the coordinates
567 std::vector<Real> coords(LIBMESH_DIM);
568
569 for (const auto & node : nodeset)
570 {
571 id_pid[0] = node->id();
572 id_pid[1] = node->processor_id();
573
574 libmesh_assert_equal_to(n_extra_integers, node->n_extra_integers());
575 for (unsigned int i=0; i != n_extra_integers; ++i)
576 id_pid[2+i] = node->get_extra_integer(i);
577
578 io.data_stream(id_pid.data(), 2 + n_extra_integers, 2 + n_extra_integers);
579
580#ifdef LIBMESH_ENABLE_UNIQUE_ID
581 largest_id_type unique_id = node->unique_id();
582
583 io.data(unique_id, "# unique id");
584#endif
585
586 coords[0] = (*node)(0);
587
588#if LIBMESH_DIM > 1
589 coords[1] = (*node)(1);
590#endif
591
592#if LIBMESH_DIM > 2
593 coords[2] = (*node)(2);
594#endif
595
596 io.data_stream(coords.data(), LIBMESH_DIM, 3);
597 }
598}

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

Referenced by write().

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

790{
791 libmesh_assert (io.writing());
792
793 // convenient reference to our mesh
794 const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
795
796 // Build a list of (node, bc) tuples
797 std::size_t nodeset_size = bc_tuples.size();
798
799 std::vector<largest_id_type> node_id_list;
800 std::vector<largest_id_type> bc_id_list;
801
802 node_id_list.reserve(nodeset_size);
803 bc_id_list.reserve(nodeset_size);
804
805 for (const auto & t : bc_tuples)
806 if (nodeset.count(mesh.node_ptr(std::get<0>(t))))
807 {
808 node_id_list.push_back(std::get<0>(t));
809 bc_id_list.push_back(std::get<1>(t));
810 }
811
812 io.data(node_id_list, "# node id list");
813 io.data(bc_id_list, "# nodeset bc id list");
814}

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

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

703{
704 libmesh_assert (io.writing());
705
706 // Find the remote_elem neighbor and child links
707 std::vector<largest_id_type> elem_ids, parent_ids;
708 std::vector<uint16_t> elem_sides, child_numbers;
709
710 for (const auto & elem : elements)
711 {
712 for (auto n : elem->side_index_range())
713 {
714 const Elem * neigh = elem->neighbor_ptr(n);
715 if (neigh == remote_elem ||
716 (neigh && !elements.count(neigh)))
717 {
718 elem_ids.push_back(elem->id());
719 elem_sides.push_back(n);
720 }
721 }
722
723#ifdef LIBMESH_ENABLE_AMR
724 if (elem->has_children())
725 {
726 for (unsigned short c = 0,
727 nc = cast_int<unsigned short>(elem->n_children());
728 c != nc; ++c)
729 {
730 const Elem * child = elem->child_ptr(c);
731 if (child == remote_elem ||
732 (child && !elements.count(child)))
733 {
734 parent_ids.push_back(elem->id());
735 child_numbers.push_back(c);
736 }
737 }
738 }
739#endif
740 }
741
742 io.data(elem_ids, "# remote neighbor elem_ids");
743 io.data(elem_sides, "# remote neighbor elem_sides");
744 io.data(parent_ids, "# remote child parent_ids");
745 io.data(child_numbers, "# remote child_numbers");
746}

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

◆ write_subdomain_names()

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

Write subdomain name information.

Definition at line 518 of file checkpoint_io.C.

519{
520 {
521 const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
522
523 const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
524
525 std::vector<largest_id_type> subdomain_ids; subdomain_ids.reserve(subdomain_map.size());
526 std::vector<std::string> subdomain_names; subdomain_names.reserve(subdomain_map.size());
527
528 // We need to loop over the map and make sure that there aren't any invalid entries. Since we
529 // return writable references in mesh_base, it's possible for the user to leave some entity names
530 // blank. We can't write those to the XDA file.
531 largest_id_type n_subdomain_names = 0;
532 for (const auto & [id, name] : subdomain_map)
533 if (!name.empty())
534 {
535 n_subdomain_names++;
536 subdomain_ids.push_back(id);
537 subdomain_names.push_back(name);
538 }
539
540 io.data(n_subdomain_names, "# subdomain id to name map");
541 // Write out the ids and names in two vectors
542 if (n_subdomain_names)
543 {
544 io.data(subdomain_ids);
545 io.data(subdomain_names);
546 }
547 }
548}
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition mesh_base.h:1926

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

Referenced by write().

Member Data Documentation

◆ _ascii_precision

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

Precision to use when writing ASCII files.

Definition at line 207 of file mesh_output.h.

◆ _binary

bool libMesh::CheckpointIO::_binary
private

Definition at line 336 of file checkpoint_io.h.

Referenced by binary(), and binary().

◆ _communicator

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

◆ _is_parallel_format [1/2]

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

Flag specifying whether this format is parallel-capable.

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

Definition at line 130 of file mesh_input.h.

◆ _is_parallel_format [2/2]

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

Flag specifying whether this format is parallel-capable.

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

Definition at line 184 of file mesh_output.h.

◆ _my_n_processors

processor_id_type libMesh::CheckpointIO::_my_n_processors
private

◆ _my_processor_ids

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

Definition at line 341 of file checkpoint_io.h.

Referenced by current_processor_ids(), current_processor_ids(), and write().

◆ _obj

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

A pointer to a non-const object object.

This allows us to read the object from file.

Definition at line 123 of file mesh_input.h.

◆ _parallel

bool libMesh::CheckpointIO::_parallel
private

Definition at line 337 of file checkpoint_io.h.

Referenced by parallel(), 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 338 of file checkpoint_io.h.

Referenced by version(), version(), and write().

◆ elems_of_dimension

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

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

Definition at line 107 of file mesh_input.h.


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