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

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

#include <checkpoint_io.h>

Inheritance diagram for libMesh::CheckpointIO:
[legend]

Public Types

typedef largest_id_type xdr_id_type
 
typedef uint64_t header_id_type
 

Public Member Functions

 CheckpointIO (MeshBase &, const bool=false)
 Constructor. More...
 
 CheckpointIO (const MeshBase &, const bool=false)
 Constructor. More...
 
virtual ~CheckpointIO ()
 Destructor. More...
 
virtual void read (const std::string &) libmesh_override
 This method implements reading a mesh from a specified file. More...
 
virtual void write (const std::string &) libmesh_override
 This method implements writing a mesh to a specified file. More...
 
bool binary () const
 Get/Set the flag indicating if we should read/write binary. More...
 
bool & binary ()
 
bool parallel () const
 Get/Set the flag indicating if we should read/write binary. More...
 
bool & parallel ()
 
const std::string & version () const
 Get/Set the version string. More...
 
std::string & version ()
 
const std::vector< processor_id_type > & current_processor_ids () const
 Get/Set the processor id or processor ids to use. More...
 
std::vector< processor_id_type > & current_processor_ids ()
 
const processor_id_typecurrent_n_processors () const
 Get/Set the n_processors to use. More...
 
processor_id_typecurrent_n_processors ()
 
template<typename file_id_type >
void read_remote_elem (Xdr &io, bool libmesh_dbg_var(expect_all_remote))
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
 This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided. More...
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

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

Protected Attributes

std::vector< bool > elems_of_dimension
 A vector of bools describing what dimension elements have been encountered when reading a mesh. More...
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable. More...
 
const bool _serial_only_needed_on_proc_0
 Flag specifying whether this format can be written by only serializing the mesh to processor zero. More...
 
const Parallel::Communicator_communicator
 

Private Member Functions

void write_subdomain_names (Xdr &io) const
 Write subdomain name information. More...
 
void write_connectivity (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 Write the connectivity for part of a mesh. More...
 
void write_remote_elem (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 Write the remote_elem neighbor and child links for part of a mesh. More...
 
void write_nodes (Xdr &io, const std::set< const Node * > &nodeset) const
 Write the nodal locations for part of a mesh. More...
 
void write_bcs (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 Write the side boundary conditions for part of a mesh. More...
 
void write_nodesets (Xdr &io, const std::set< const Node * > &nodeset) const
 Write the nodal boundary conditions for part of a mesh. More...
 
void write_bc_names (Xdr &io, const BoundaryInfo &info, bool is_sideset) const
 Write boundary names information (sideset and nodeset) More...
 
template<typename file_id_type >
file_id_type read_header (const std::string &name)
 Read header data on processor 0, then broadcast. More...
 
template<typename file_id_type >
void read_subfile (Xdr &io, bool expect_all_remote)
 Read a non-header file. More...
 
template<typename file_id_type >
void read_subdomain_names (Xdr &io)
 Read subdomain name information. More...
 
template<typename file_id_type >
void read_connectivity (Xdr &io)
 Read the connectivity for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_remote_elem (Xdr &io, bool expect_all_remote)
 Read the remote_elem neighbor and child links for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_nodes (Xdr &io)
 Read the nodal locations for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_bcs (Xdr &io)
 Read the boundary conditions for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_nodesets (Xdr &io)
 Read the nodeset conditions for a parallel, distributed mesh. More...
 
template<typename file_id_type >
void read_bc_names (Xdr &io, BoundaryInfo &info, bool is_sideset)
 Read boundary names information (sideset and nodeset) More...
 
unsigned int n_active_levels_in (MeshBase::const_element_iterator begin, MeshBase::const_element_iterator end) const
 

Private Attributes

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

Detailed Description

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

Author
Benjamin Kirk
John Peterson
Derek Gaston
Roy Stogner
Date
2017

Definition at line 50 of file checkpoint_io.h.

Member Typedef Documentation

Definition at line 59 of file checkpoint_io.h.

Definition at line 56 of file checkpoint_io.h.

Constructor & Destructor Documentation

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

50  :
51  MeshInput<MeshBase> (mesh,/* is_parallel_format = */ true),
52  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
54  _binary (binary_in),
55  _parallel (false),
56  _version ("checkpoint-1.2"),
59 {
60 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
processor_id_type n_processors() const
std::vector< processor_id_type > _my_processor_ids
processor_id_type _my_n_processors
processor_id_type processor_id() const
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 64 of file checkpoint_io.C.

64  :
65  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
67  _binary (binary_in),
68  _parallel (false),
71 {
72 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
processor_id_type n_processors() const
std::vector< processor_id_type > _my_processor_ids
processor_id_type _my_n_processors
processor_id_type processor_id() const
libMesh::CheckpointIO::~CheckpointIO ( )
virtual

Destructor.

Definition at line 76 of file checkpoint_io.C.

77 {
78 }

Member Function Documentation

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

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

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

Referenced by libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

bool libMesh::CheckpointIO::binary ( ) const

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

Definition at line 99 of file checkpoint_io.h.

References _binary.

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

99 { return _binary; }
bool& libMesh::CheckpointIO::binary ( )

Definition at line 100 of file checkpoint_io.h.

References _binary.

100 { return _binary; }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_preconditioner_apply(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), 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::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), add_cube_convex_hull_to_mesh(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), new_function_base(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), FEMParameters::read(), libMesh::Nemesis_IO::read(), read(), libMesh::XdrIO::read(), read_header(), libMesh::XdrIO::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), libMesh::MeshRefinement::test_unflagged(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::XdrIO::write_serialized_bcs_helper(), 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().

88  { return _communicator; }
const Parallel::Communicator & _communicator
const processor_id_type& libMesh::CheckpointIO::current_n_processors ( ) const

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 137 of file checkpoint_io.h.

References _my_n_processors.

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

137 { return _my_n_processors; }
processor_id_type _my_n_processors
processor_id_type& libMesh::CheckpointIO::current_n_processors ( )
const std::vector<processor_id_type>& libMesh::CheckpointIO::current_processor_ids ( ) const

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 124 of file checkpoint_io.h.

References _my_processor_ids.

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

124 { return _my_processor_ids; }
std::vector< processor_id_type > _my_processor_ids
std::vector<processor_id_type>& libMesh::CheckpointIO::current_processor_ids ( )

Definition at line 125 of file checkpoint_io.h.

References _my_processor_ids.

125 { return _my_processor_ids; }
std::vector< processor_id_type > _my_processor_ids
MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited
Returns
The object as a writable reference.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::UNVIO::elements_out(), libMesh::UNVIO::groups_in(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::UNVIO::nodes_out(), libMesh::GMVIO::read(), libMesh::ExodusII_IO::read(), read(), libMesh::XdrIO::read(), read_bcs(), read_connectivity(), read_header(), libMesh::XdrIO::read_header(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), read_nodes(), read_nodesets(), read_remote_elem(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), read_subdomain_names(), libMesh::UCDIO::UCDIO(), libMesh::VTKIO::VTKIO(), libMesh::TetGenIO::write(), libMesh::ExodusII_IO::write(), write(), libMesh::XdrIO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), write_bcs(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::UCDIO::write_implementation(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), and write_subdomain_names().

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
protectedinherited
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 1132 of file checkpoint_io.C.

References end, std::max(), and libMesh::MeshTools::max_level().

Referenced by current_n_processors().

1134 {
1135  unsigned int max_level = 0;
1136 
1137  for (MeshBase::const_element_iterator it = begin;
1138  it != end; ++it)
1139  max_level = std::max((*it)->level(), max_level);
1140 
1141  return max_level + 1;
1142 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
long double max(long double a, double b)
unsigned int max_level(const MeshBase &mesh)
Find the maximum h-refinement level in a mesh.
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), read(), read_connectivity(), libMesh::XdrIO::read_header(), read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:726
const Parallel::Communicator & _communicator
bool libMesh::CheckpointIO::parallel ( ) const

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

Definition at line 105 of file checkpoint_io.h.

References _parallel.

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

105 { return _parallel; }
bool& libMesh::CheckpointIO::parallel ( )

Definition at line 106 of file checkpoint_io.h.

References _parallel.

106 { return _parallel; }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited
Returns
The rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::EquationSystems::get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), read_header(), libMesh::XdrIO::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), BoundaryInfoTest::testShellFaceConstraints(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), write(), libMesh::XdrIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), write_output_solvedata(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:724
void libMesh::CheckpointIO::read ( const std::string &  name)
virtual

This method implements reading a mesh from a specified file.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 549 of file checkpoint_io.C.

References binary(), libMesh::MeshCommunication::broadcast(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), 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::Quality::name(), libMesh::ParallelObject::processor_id(), libMesh::READ, and libMesh::MeshBase::set_distributed().

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

550 {
551  LOG_SCOPE("read()","CheckpointIO");
552 
553  MeshBase & mesh = MeshInput<MeshBase>::mesh();
554 
555  libmesh_assert(!mesh.n_elem());
556 
557  // What size data is being used in this file?
558  header_id_type data_size;
559 
560  // How many per-processor files are here?
561  largest_id_type input_n_procs;
562 
563  // We'll read a header file from processor 0 and broadcast.
564  if (this->processor_id() == 0)
565  {
566  {
567  std::ifstream in (name.c_str());
568 
569  if (!in.good())
570  libmesh_error_msg("ERROR: cannot locate header file:\n\t" << name);
571  }
572 
573  Xdr io (name, this->binary() ? DECODE : READ);
574 
575  // read the version, but don't care about it
576  std::string input_version;
577  io.data(input_version);
578 
579  // read the data type
580  io.data (data_size);
581  }
582 
583  this->comm().broadcast(data_size);
584 
585  switch (data_size) {
586  case 2:
587  input_n_procs = this->read_header<uint16_t>(name);
588  break;
589  case 4:
590  input_n_procs = this->read_header<uint32_t>(name);
591  break;
592  case 8:
593  input_n_procs = this->read_header<uint64_t>(name);
594  break;
595  default:
596  libmesh_error();
597  }
598 
599  bool input_parallel = input_n_procs;
600  if (!input_n_procs)
601  input_n_procs = 1;
602 
603  // If this is a serial read then we're going to only read the mesh
604  // on processor 0, then broadcast it
605  if ((input_parallel && !mesh.is_replicated()) || mesh.processor_id() == 0)
606  {
607  // If we're trying to read a parallel checkpoint file on a
608  // replicated mesh, we'll read every file on processor 0 so we
609  // can broadcast it later. If we're on a distributed mesh then
610  // we'll read every id to it's own processor and we'll "wrap
611  // around" with any ids that exceed our processor count.
612  const processor_id_type begin_proc_id =
613  (input_parallel && !mesh.is_replicated()) ?
614  mesh.processor_id() : 0;
615  const processor_id_type stride =
616  (input_parallel && !mesh.is_replicated()) ?
617  mesh.n_processors() : 1;
618 
619  for (processor_id_type proc_id = begin_proc_id; proc_id < input_n_procs; proc_id += stride)
620  {
621  std::ostringstream file_name_stream;
622 
623  file_name_stream << name;
624 
625  file_name_stream << "-" << (input_parallel ? input_n_procs : 1) << "-" << proc_id;
626 
627  {
628  std::ifstream in (file_name_stream.str().c_str());
629 
630  if (!in.good())
631  libmesh_error_msg("ERROR: cannot locate specified file:\n\t" << file_name_stream.str());
632  }
633 
634  // Do we expect all our files' remote_elem entries to really
635  // be remote? Only if we're not reading multiple input
636  // files on the same processor.
637  const bool expect_all_remote =
638  (input_n_procs <= mesh.n_processors() &&
639  !mesh.is_replicated());
640 
641  Xdr io (file_name_stream.str(), this->binary() ? DECODE : READ);
642 
643  switch (data_size) {
644  case 2:
645  this->read_subfile<uint16_t>(io, expect_all_remote);
646  break;
647  case 4:
648  this->read_subfile<uint32_t>(io, expect_all_remote);
649  break;
650  case 8:
651  this->read_subfile<uint64_t>(io, expect_all_remote);
652  break;
653  default:
654  libmesh_error();
655  }
656 
657  io.close();
658  }
659  }
660 
661  // If the mesh was only read on processor 0 then we need to broadcast it
662  if (mesh.is_replicated())
663  MeshCommunication().broadcast(mesh);
664  // If the mesh is really distributed then we need to make sure it
665  // knows that
666  else if (mesh.n_processors() > 1)
667  mesh.set_distributed();
668 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
uint64_t largest_id_type
Definition: id_types.h:139
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
const Parallel::Communicator & comm() const
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: checkpoint_io.h:99
processor_id_type processor_id() const
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 1104 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::BoundaryInfo::set_nodeset_name_map(), and libMesh::BoundaryInfo::set_sideset_name_map().

Referenced by current_n_processors().

1105 {
1106  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
1107  info.set_sideset_name_map() : info.set_nodeset_name_map();
1108 
1109  std::vector<file_id_type> boundary_ids;
1110  std::vector<std::string> boundary_names;
1111 
1112  file_id_type n_boundary_names = 0;
1113 
1114  if (is_sideset)
1115  io.data(n_boundary_names, "# sideset id to name map");
1116  else
1117  io.data(n_boundary_names, "# nodeset id to name map");
1118 
1119  if (n_boundary_names)
1120  {
1121  io.data(boundary_ids);
1122  io.data(boundary_names);
1123  }
1124 
1125  // Add them back into the map
1126  for (std::size_t i=0; i<boundary_ids.size(); i++)
1127  boundary_map[cast_int<boundary_id_type>(boundary_ids[i])] =
1128  boundary_names[i];
1129 }
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 1056 of file checkpoint_io.C.

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

Referenced by current_n_processors().

1057 {
1058  // convenient reference to our mesh
1059  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1060 
1061  // and our boundary info object
1062  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1063 
1064  std::vector<file_id_type> element_id_list;
1065  std::vector<uint16_t> side_list;
1066  std::vector<file_id_type> bc_id_list;
1067 
1068  io.data(element_id_list, "# element ids for bcs");
1069  io.data(side_list, "# sides of elements for bcs");
1070  io.data(bc_id_list, "# bc ids");
1071 
1072  for (std::size_t i=0; i<element_id_list.size(); i++)
1073  boundary_info.add_side
1074  (cast_int<dof_id_type>(element_id_list[i]), side_list[i],
1075  cast_int<dof_id_type>(bc_id_list[i]));
1076 }
template<typename file_id_type >
void libMesh::CheckpointIO::read_connectivity ( Xdr io)
private

Read the connectivity for a parallel, distributed mesh.

Definition at line 866 of file checkpoint_io.C.

References libMesh::MeshBase::add_elem(), libMesh::Elem::build(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::Elem::dim(), libMesh::MeshBase::elem_ptr(), libMesh::Elem::hack_p_level(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), n_nodes, libMesh::Elem::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::Elem::node_id(), libMesh::MeshBase::node_ptr(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::MeshBase::query_elem_ptr(), libMesh::DofObject::set_id(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::Elem::set_p_refinement_flag(), libMesh::Elem::set_refinement_flag(), libMesh::DofObject::set_unique_id(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), and libMesh::Elem::type_to_n_nodes_map.

Referenced by current_n_processors().

867 {
868  // convenient reference to our mesh
869  MeshBase & mesh = MeshInput<MeshBase>::mesh();
870 
871  file_id_type n_elems_here;
872  io.data(n_elems_here);
873 
874  // Keep track of the highest dimensional element we've added to the mesh
875  unsigned int highest_elem_dim = 1;
876 
877  for (unsigned int i=0; i<n_elems_here; i++)
878  {
879  // id type pid subdomain_id parent_id
880  std::vector<file_id_type> elem_data(6);
881  io.data_stream
882  (&elem_data[0], cast_int<unsigned int>(elem_data.size()),
883  cast_int<unsigned int>(elem_data.size()));
884 
885 #ifdef LIBMESH_ENABLE_UNIQUE_ID
886  file_id_type unique_id = 0;
887  io.data(unique_id, "# unique id");
888 #endif
889 
890 #ifdef LIBMESH_ENABLE_AMR
891  uint16_t p_level = 0;
892  io.data(p_level, "# p_level");
893 
894  uint16_t rflag, pflag;
895  io.data(rflag, "# rflag");
896  io.data(pflag, "# pflag");
897 #endif
898 
899  unsigned int n_nodes = Elem::type_to_n_nodes_map[elem_data[1]];
900 
901  // Snag the node ids this element was connected to
902  std::vector<file_id_type> conn_data(n_nodes);
903  io.data_stream
904  (&conn_data[0], cast_int<unsigned int>(conn_data.size()),
905  cast_int<unsigned int>(conn_data.size()));
906 
907  const dof_id_type id =
908  cast_int<dof_id_type> (elem_data[0]);
909  const ElemType elem_type =
910  static_cast<ElemType> (elem_data[1]);
911  const processor_id_type proc_id =
912  cast_int<processor_id_type>
913  (elem_data[2] % mesh.n_processors());
914  const subdomain_id_type subdomain_id =
915  cast_int<subdomain_id_type>(elem_data[3]);
916  const dof_id_type parent_id =
917  cast_int<dof_id_type> (elem_data[4]);
918  const unsigned short int child_num =
919  cast_int<dof_id_type> (elem_data[5]);
920 
921  Elem * parent =
922  (parent_id == DofObject::invalid_processor_id) ?
923  libmesh_nullptr : mesh.elem_ptr(parent_id);
924 
925  if (!parent)
926  libmesh_assert_equal_to
927  (child_num, DofObject::invalid_processor_id);
928 
929  Elem * old_elem = mesh.query_elem_ptr(id);
930 
931  // If we already have this element (e.g. from another file,
932  // when reading multiple distributed CheckpointIO files into
933  // a ReplicatedMesh) then we don't want to add it again
934  // (because ReplicatedMesh can't handle that) but we do want
935  // to assert consistency between what we're reading and what
936  // we have.
937  if (old_elem)
938  {
939  libmesh_assert_equal_to(elem_type, old_elem->type());
940  libmesh_assert_equal_to(proc_id, old_elem->processor_id());
941  libmesh_assert_equal_to(subdomain_id, old_elem->subdomain_id());
942  if (parent)
943  libmesh_assert_equal_to(parent, old_elem->parent());
944  else
945  libmesh_assert(!old_elem->parent());
946 
947  libmesh_assert_equal_to(old_elem->n_nodes(), conn_data.size());
948 
949  for (std::size_t n=0; n != conn_data.size(); ++n)
950  libmesh_assert_equal_to
951  (old_elem->node_id(n),
952  cast_int<dof_id_type>(conn_data[n]));
953  }
954  else
955  {
956  // Create the element
957  Elem * elem = Elem::build(elem_type, parent).release();
958 
959 #ifdef LIBMESH_ENABLE_UNIQUE_ID
960  elem->set_unique_id() = unique_id;
961 #endif
962 
963  if (elem->dim() > highest_elem_dim)
964  highest_elem_dim = elem->dim();
965 
966  elem->set_id() = id;
967  elem->processor_id() = proc_id;
968  elem->subdomain_id() = subdomain_id;
969 
970 #ifdef LIBMESH_ENABLE_AMR
971  elem->hack_p_level(p_level);
972 
973  elem->set_refinement_flag (cast_int<Elem::RefinementState>(rflag));
974  elem->set_p_refinement_flag(cast_int<Elem::RefinementState>(pflag));
975 
976  // Set parent connections
977  if (parent)
978  {
979  // We must specify a child_num, because we will have
980  // skipped adding any preceding remote_elem children
981  parent->add_child(elem, child_num);
982  }
983 #endif
984 
985  libmesh_assert(elem->n_nodes() == conn_data.size());
986 
987  // Connect all the nodes to this element
988  for (std::size_t n=0; n<conn_data.size(); n++)
989  elem->set_node(n) =
990  mesh.node_ptr(cast_int<dof_id_type>(conn_data[n]));
991 
992  mesh.add_elem(elem);
993  }
994  }
995 
996  mesh.set_mesh_dimension(cast_int<unsigned char>(highest_elem_dim));
997 }
static UniquePtr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:238
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
ElemType
Defines an enum for geometric element types.
uint8_t processor_id_type
Definition: id_types.h:99
const class libmesh_nullptr_t libmesh_nullptr
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:564
libmesh_assert(j)
const dof_id_type n_nodes
Definition: tecplot_io.C:67
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
uint8_t dof_id_type
Definition: id_types.h:64
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 673 of file checkpoint_io.C.

References binary(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::DECODE, libMesh::MeshBase::get_boundary_info(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::ParallelObject::processor_id(), libMesh::READ, libMesh::MeshBase::set_mesh_dimension(), libMesh::BoundaryInfo::set_nodeset_name_map(), libMesh::BoundaryInfo::set_sideset_name_map(), and libMesh::MeshBase::set_subdomain_name_map().

Referenced by current_n_processors().

674 {
675  MeshBase & mesh = MeshInput<MeshBase>::mesh();
676 
677  // Hack for codes which don't look at all elem dimensions
678  uint16_t mesh_dimension;
679 
680  // Will this be a parallel input file? With how many processors? Stay tuned!
681  uint16_t input_parallel;
682  file_id_type input_n_procs;
683 
684  // We'll write a header file from processor 0 and broadcast.
685  if (this->processor_id() == 0)
686  {
687  Xdr io (name, this->binary() ? DECODE : READ);
688 
689  // read the version, but don't care about it
690  std::string input_version;
691  io.data(input_version);
692 
693  // read the data type, don't care about it this time
694  header_id_type data_size;
695  io.data (data_size);
696 
697  // read the dimension
698  io.data (mesh_dimension);
699 
700  // Read whether or not this is a parallel file
701  io.data(input_parallel);
702 
703  // With how many processors?
704  if (input_parallel)
705  io.data(input_n_procs);
706 
707  // read subdomain names
708  this->read_subdomain_names<file_id_type>(io);
709 
710  // read boundary names
711  BoundaryInfo & boundary_info = mesh.get_boundary_info();
712 
713  this->read_bc_names<file_id_type>(io, boundary_info, true); // sideset names
714  this->read_bc_names<file_id_type>(io, boundary_info, false); // nodeset names
715  }
716 
717  // broadcast data from processor 0, set values everywhere
718  this->comm().broadcast(mesh_dimension);
719  mesh.set_mesh_dimension(mesh_dimension);
720 
721  this->comm().broadcast(input_parallel);
722 
723  if (input_parallel)
724  this->comm().broadcast(input_n_procs);
725  else
726  input_n_procs = 1;
727 
728  std::map<subdomain_id_type, std::string> & subdomain_map =
729  mesh.set_subdomain_name_map();
730  this->comm().broadcast(subdomain_map);
731 
732  BoundaryInfo & boundary_info = mesh.get_boundary_info();
733  this->comm().broadcast(boundary_info.set_sideset_name_map());
734  this->comm().broadcast(boundary_info.set_nodeset_name_map());
735 
736  return input_parallel ? input_n_procs : 0;
737 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
void broadcast(T &data, const unsigned int root_id=0) const
Take a local value and broadcast it to all processors.
const Parallel::Communicator & comm() const
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: checkpoint_io.h:99
processor_id_type processor_id() const
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 793 of file checkpoint_io.C.

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

Referenced by current_n_processors().

794 {
795  // convenient reference to our mesh
796  MeshBase & mesh = MeshInput<MeshBase>::mesh();
797 
798  file_id_type n_nodes_here;
799  io.data(n_nodes_here, "# n_nodes on proc");
800 
801  // Will hold the node id and pid
802  std::vector<file_id_type> id_pid(2);
803 
804  // For the coordinates
805  std::vector<Real> coords(LIBMESH_DIM);
806 
807  for (unsigned int i=0; i<n_nodes_here; i++)
808  {
809  io.data_stream(&id_pid[0], 2, 2);
810 
811 #ifdef LIBMESH_ENABLE_UNIQUE_ID
812  file_id_type unique_id = 0;
813  io.data(unique_id, "# unique id");
814 #endif
815 
816  io.data_stream(&coords[0], LIBMESH_DIM, LIBMESH_DIM);
817 
818  Point p;
819  p(0) = coords[0];
820 
821 #if LIBMESH_DIM > 1
822  p(1) = coords[1];
823 #endif
824 
825 #if LIBMESH_DIM > 2
826  p(2) = coords[2];
827 #endif
828 
829  const dof_id_type id = cast_int<dof_id_type>(id_pid[0]);
830 
831  // "Wrap around" if we see more processors than we're using.
832  processor_id_type pid =
833  cast_int<processor_id_type>(id_pid[1] % mesh.n_processors());
834 
835  // If we already have this node (e.g. from another file, when
836  // reading multiple distributed CheckpointIO files into a
837  // ReplicatedMesh) then we don't want to add it again (because
838  // ReplicatedMesh can't handle that) but we do want to assert
839  // consistency between what we're reading and what we have.
840  const Node * old_node = mesh.query_node_ptr(id);
841 
842  if (old_node)
843  {
844  libmesh_assert_equal_to(pid, old_node->processor_id());
845 #ifdef LIBMESH_ENABLE_UNIQUE_ID
846  libmesh_assert_equal_to(unique_id, old_node->unique_id());
847 #endif
848  }
849  else
850  {
851 #ifdef LIBMESH_ENABLE_UNIQUE_ID
852  Node * node =
853 #endif
854  mesh.add_point(p, id, pid);
855 
856 #ifdef LIBMESH_ENABLE_UNIQUE_ID
857  node->set_unique_id() = unique_id;
858 #endif
859  }
860  }
861 }
uint8_t processor_id_type
Definition: id_types.h:99
uint8_t dof_id_type
Definition: id_types.h:64
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 1081 of file checkpoint_io.C.

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

Referenced by current_n_processors().

1082 {
1083  // convenient reference to our mesh
1084  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1085 
1086  // and our boundary info object
1087  BoundaryInfo & boundary_info = mesh.get_boundary_info();
1088 
1089  std::vector<file_id_type> node_id_list;
1090  std::vector<file_id_type> bc_id_list;
1091 
1092  io.data(node_id_list, "# node id list");
1093  io.data(bc_id_list, "# nodeset bc id list");
1094 
1095  for (std::size_t i=0; i<node_id_list.size(); i++)
1096  boundary_info.add_node
1097  (cast_int<dof_id_type>(node_id_list[i]),
1098  cast_int<boundary_id_type>(bc_id_list[i]));
1099 }
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.

Referenced by current_n_processors().

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

Definition at line 1001 of file checkpoint_io.C.

References libMesh::Elem::add_child(), libMesh::Xdr::data(), libMesh::MeshBase::elem_ref(), 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().

1002 {
1003  // convenient reference to our mesh
1004  MeshBase & mesh = MeshInput<MeshBase>::mesh();
1005 
1006  // Find the remote_elem neighbor links
1007  std::vector<file_id_type> elem_ids;
1008  std::vector<uint16_t> elem_sides;
1009 
1010  io.data(elem_ids, "# remote neighbor elem_ids");
1011  io.data(elem_sides, "# remote neighbor elem_sides");
1012 
1013  libmesh_assert_equal_to(elem_ids.size(), elem_sides.size());
1014 
1015  for (std::size_t i=0; i != elem_ids.size(); ++i)
1016  {
1017  Elem & elem = mesh.elem_ref(cast_int<dof_id_type>(elem_ids[i]));
1018  if (!elem.neighbor_ptr(elem_sides[i]))
1019  elem.set_neighbor(elem_sides[i],
1020  const_cast<RemoteElem *>(remote_elem));
1021  else
1022  libmesh_assert(!expect_all_remote);
1023  }
1024 
1025  // Find the remote_elem children links
1026  std::vector<file_id_type> parent_ids;
1027  std::vector<uint16_t> child_numbers;
1028 
1029  io.data(parent_ids, "# remote child parent_ids");
1030  io.data(child_numbers, "# remote child_numbers");
1031 
1032 #ifdef LIBMESH_ENABLE_AMR
1033  for (std::size_t i=0; i != parent_ids.size(); ++i)
1034  {
1035  Elem & elem = mesh.elem_ref(cast_int<dof_id_type>(parent_ids[i]));
1036 
1037  // We'd like to assert that no child pointer already exists to
1038  // be overwritten by remote_elem, but Elem doesn't actually have
1039  // an API that will return a child pointer without asserting
1040  // that it isn't NULL
1041  //
1042  const Elem * child = elem.raw_child_ptr(child_numbers[i]);
1043 
1044  if (!child)
1045  elem.add_child(const_cast<RemoteElem *>(remote_elem),
1046  child_numbers[i]);
1047  else
1048  libmesh_assert(!expect_all_remote);
1049  }
1050 #endif
1051 }
libmesh_assert(j)
const RemoteElem * remote_elem
Definition: remote_elem.C:57
template<typename file_id_type >
void libMesh::CheckpointIO::read_subdomain_names ( Xdr io)
private

Read subdomain name information.

Definition at line 763 of file checkpoint_io.C.

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

Referenced by current_n_processors().

764 {
765  MeshBase & mesh = MeshInput<MeshBase>::mesh();
766 
767  std::map<subdomain_id_type, std::string> & subdomain_map =
768  mesh.set_subdomain_name_map();
769 
770  std::vector<file_id_type> subdomain_ids;
771  subdomain_ids.reserve(subdomain_map.size());
772 
773  std::vector<std::string> subdomain_names;
774  subdomain_names.reserve(subdomain_map.size());
775 
776  file_id_type n_subdomain_names = 0;
777  io.data(n_subdomain_names, "# subdomain id to name map");
778 
779  if (n_subdomain_names)
780  {
781  io.data(subdomain_ids);
782  io.data(subdomain_names);
783 
784  for (std::size_t i=0; i<subdomain_ids.size(); i++)
785  subdomain_map[cast_int<subdomain_id_type>(subdomain_ids[i])] =
786  subdomain_names[i];
787  }
788 }
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 742 of file checkpoint_io.C.

Referenced by current_n_processors().

743 {
744  // read the nodal locations
745  this->read_nodes<file_id_type> (io);
746 
747  // read connectivity
748  this->read_connectivity<file_id_type> (io);
749 
750  // read remote_elem connectivity
751  this->read_remote_elem<file_id_type> (io, expect_all_remote);
752 
753  // read the boundary conditions
754  this->read_bcs<file_id_type> (io);
755 
756  // read the nodesets
757  this->read_nodesets<file_id_type> (io);
758 }
void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
protectedinherited

Sets the number of partitions in the mesh.

Typically this gets done by the partitioner, but some parallel file formats begin "pre-partitioned".

Definition at line 91 of file mesh_input.h.

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

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

91 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1329
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.

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

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

Get/Set the version string.

Definition at line 111 of file checkpoint_io.h.

References _version.

111 { return _version; }
std::string& libMesh::CheckpointIO::version ( )

Definition at line 112 of file checkpoint_io.h.

References _version.

112 { return _version; }
void libMesh::CheckpointIO::write ( const std::string &  name)
virtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 83 of file checkpoint_io.C.

References _my_n_processors, _my_processor_ids, _parallel, _version, binary(), libMesh::connect_children(), libMesh::connect_families(), libMesh::Xdr::data(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), libMesh::ENCODE, libMesh::MeshBase::get_boundary_info(), libMesh::DofObject::invalid_processor_id, libMesh::MeshBase::is_serial(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), parallel(), libMesh::ParallelObject::processor_id(), libMesh::query_ghosting_functors(), libMesh::reconnect_nodes(), libMesh::WRITE, write_bc_names(), write_bcs(), write_connectivity(), write_nodes(), write_nodesets(), write_remote_elem(), and write_subdomain_names().

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

84 {
85  LOG_SCOPE("write()", "CheckpointIO");
86 
87  // convenient reference to our mesh
88  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
89 
90  // FIXME: For backwards compatibility, we'll assume for now that we
91  // only want to write distributed meshes in parallel. Later we can
92  // do a gather_to_zero() and support that case too.
93  _parallel = _parallel || !mesh.is_serial();
94 
95  // We'll write a header file from processor 0 to make it easier to do unambiguous
96  // restarts later:
97  if (this->processor_id() == 0)
98  {
99  Xdr io (name, this->binary() ? ENCODE : WRITE);
100 
101  // write the version
102  io.data(_version, "# version");
103 
104  // write what kind of data type we're using
105  header_id_type data_size = sizeof(largest_id_type);
106  io.data(data_size, "# integer size");
107 
108  // Write out the max mesh dimension for backwards compatibility
109  // with code that sets it independently of element dimensions
110  {
111  uint16_t mesh_dimension = mesh.mesh_dimension();
112  io.data(mesh_dimension, "# dimensions");
113  }
114 
115  // Write out whether or not this is serial output
116  {
117  uint16_t parallel = _parallel;
118  io.data(parallel, "# parallel");
119  }
120 
121  // If we're writing out a parallel mesh then we need to write the number of processors
122  // so we can check it upon reading the file
123  if (_parallel)
124  {
126  io.data(n_procs, "# n_procs");
127  }
128 
129  // write subdomain names
130  this->write_subdomain_names(io);
131 
132  // write boundary id names
133  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
134  write_bc_names(io, boundary_info, true); // sideset names
135  write_bc_names(io, boundary_info, false); // nodeset names
136  }
137 
138  // If this is a serial mesh written to a serial file then we're only
139  // going to write local data from processor 0. If this is a mesh being
140  // written in parallel then we're going to write from every
141  // processor.
142  std::vector<processor_id_type> ids_to_write;
143 
144  if (_parallel)
145  {
146  ids_to_write = _my_processor_ids;
147  }
148  else if (mesh.is_serial())
149  {
150  if (mesh.processor_id() == 0)
151  {
152  // placeholder
153  ids_to_write.push_back(0);
154  }
155  }
156  else
157  {
158  libmesh_error_msg("Cannot write serial checkpoint from distributed mesh");
159  }
160 
161  for (std::vector<processor_id_type>::const_iterator
162  id_it = ids_to_write.begin(), id_end = ids_to_write.end();
163  id_it != id_end; ++id_it)
164  {
165  const processor_id_type my_pid = *id_it;
166 
167  std::ostringstream file_name_stream;
168 
169  file_name_stream << name << "-" << (_parallel ? _my_n_processors : 1) << "-" << my_pid;
170 
171  Xdr io (file_name_stream.str(), this->binary() ? ENCODE : WRITE);
172 
173  std::set<const Elem *, CompareElemIdsByLevel> elements;
174 
175  // For serial files or for already-distributed meshs, we write
176  // everything we can see.
177  if (!_parallel || !mesh.is_serial())
178  elements.insert(mesh.elements_begin(), mesh.elements_end());
179  // For parallel files written from serial meshes we write what
180  // we'd be required to keep if we were to be deleting remote
181  // elements. This allows us to write proper parallel files even
182  // from a ReplicateMesh.
183  //
184  // WARNING: If we have a DistributedMesh which used
185  // "add_extra_ghost_elem" rather than ghosting functors to
186  // preserve elements and which is *also* currently serialized
187  // then we're not preserving those elements here. As a quick
188  // workaround user code should delete_remote_elements() before
189  // writing the checkpoint; as a long term workaround user code
190  // should use ghosting functors instead of extra_ghost_elem
191  // lists.
192  else
193  {
194  query_ghosting_functors(mesh, my_pid, false, elements);
196  connect_children(mesh, my_pid, elements);
198  connect_families(elements);
199  }
200 
201  std::set<const Node *> connected_nodes;
202  reconnect_nodes(elements, connected_nodes);
203 
204  // write the nodal locations
205  this->write_nodes (io, connected_nodes);
206 
207  // write connectivity
208  this->write_connectivity (io, elements);
209 
210  // write remote_elem connectivity
211  this->write_remote_elem (io, elements);
212 
213  // write the boundary condition information
214  this->write_bcs (io, elements);
215 
216  // write the nodeset information
217  this->write_nodesets (io, connected_nodes);
218 
219  // close it up
220  io.close();
221  }
222 
223  // this->comm().barrier();
224 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
void write_nodes(Xdr &io, const std::set< const Node * > &nodeset) const
Write the nodal locations for part of a mesh.
void write_nodesets(Xdr &io, const std::set< const Node * > &nodeset) 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 connect_children(const MeshBase &mesh, processor_id_type pid, std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
void reconnect_nodes(const std::set< const Elem *, CompareElemIdsByLevel > &connected_elements, std::set< const Node * > &connected_nodes)
uint64_t largest_id_type
Definition: id_types.h:139
uint8_t processor_id_type
Definition: id_types.h:99
const MT & mesh() const
Definition: mesh_output.h:216
bool parallel() const
Get/Set the flag indicating if we should read/write binary.
std::vector< processor_id_type > _my_processor_ids
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_bc_names(Xdr &io, const BoundaryInfo &info, bool is_sideset) const
Write boundary names information (sideset and nodeset)
void write_subdomain_names(Xdr &io) const
Write subdomain name information.
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
processor_id_type _my_n_processors
void connect_families(std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
void write_bcs(Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
Write the side boundary conditions for part of a mesh.
void query_ghosting_functors(const MeshBase &mesh, processor_id_type pid, bool newly_coarsened_only, std::set< const Elem *, CompareElemIdsByLevel > &connected_elements)
bool binary() const
Get/Set the flag indicating if we should read/write binary.
Definition: checkpoint_io.h:99
processor_id_type processor_id() const
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 513 of file checkpoint_io.C.

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

Referenced by current_n_processors(), and write().

514 {
515  const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
516  info.get_sideset_name_map() : info.get_nodeset_name_map();
517 
518  std::vector<largest_id_type> boundary_ids; boundary_ids.reserve(boundary_map.size());
519  std::vector<std::string> boundary_names; boundary_names.reserve(boundary_map.size());
520 
521  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
522  // return writable references in boundary_info, it's possible for the user to leave some entity names
523  // blank. We can't write those to the XDA file.
524  largest_id_type n_boundary_names = 0;
525  std::map<boundary_id_type, std::string>::const_iterator it_end = boundary_map.end();
526  for (std::map<boundary_id_type, std::string>::const_iterator it = boundary_map.begin(); it != it_end; ++it)
527  {
528  if (!it->second.empty())
529  {
530  n_boundary_names++;
531  boundary_ids.push_back(it->first);
532  boundary_names.push_back(it->second);
533  }
534  }
535 
536  if (is_sideset)
537  io.data(n_boundary_names, "# sideset id to name map");
538  else
539  io.data(n_boundary_names, "# nodeset id to name map");
540  // Write out the ids and names in two vectors
541  if (n_boundary_names)
542  {
543  io.data(boundary_ids);
544  io.data(boundary_names);
545  }
546 }
uint64_t largest_id_type
Definition: id_types.h:139
void libMesh::CheckpointIO::write_bcs ( Xdr io,
const std::set< const Elem *, CompareElemIdsByLevel > &  elements 
) const
private

Write the side boundary conditions for part of a mesh.

Definition at line 430 of file checkpoint_io.C.

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

Referenced by current_n_processors(), and write().

432 {
433  libmesh_assert (io.writing());
434 
435  // convenient reference to our mesh
436  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
437 
438  // and our boundary info object
439  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
440 
441  std::vector<dof_id_type> full_element_id_list;
442  std::vector<uint16_t> full_side_list;
443  std::vector<boundary_id_type> full_bc_id_list;
444 
445  boundary_info.build_side_list(full_element_id_list, full_side_list, full_bc_id_list);
446 
447  std::size_t bc_size = full_element_id_list.size();
448  libmesh_assert_equal_to(bc_size, full_side_list.size());
449  libmesh_assert_equal_to(bc_size, full_bc_id_list.size());
450 
451  std::vector<largest_id_type> element_id_list;
452  std::vector<uint16_t> side_list;
453  std::vector<largest_id_type> bc_id_list;
454 
455  element_id_list.reserve(bc_size);
456  side_list.reserve(bc_size);
457  bc_id_list.reserve(bc_size);
458 
459  for (std::size_t i = 0; i != bc_size; ++i)
460  if (elements.count(mesh.elem_ptr(full_element_id_list[i])))
461  {
462  element_id_list.push_back(full_element_id_list[i]);
463  side_list.push_back(full_side_list[i]);
464  bc_id_list.push_back(full_bc_id_list[i]);
465  }
466 
467 
468  io.data(element_id_list, "# element ids for bcs");
469  io.data(side_list, "# sides of elements for bcs");
470  io.data(bc_id_list, "# bc ids");
471 }
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
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 308 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::Xdr::data_stream(), end, libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libmesh_nullptr, n_nodes, libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), libMesh::Elem::p_level(), libMesh::Elem::p_refinement_flag(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::Elem::refinement_flag(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), libMesh::DofObject::unique_id(), libMesh::Elem::which_child_am_i(), and libMesh::Xdr::writing().

Referenced by current_n_processors(), and write().

310 {
311  libmesh_assert (io.writing());
312 
313  // Put these out here to reduce memory churn
314  // id type pid subdomain_id parent_id
315  std::vector<largest_id_type> elem_data(6);
316  std::vector<largest_id_type> conn_data;
317 
318  largest_id_type n_elems_here = elements.size();
319 
320  io.data(n_elems_here, "# number of elements");
321 
322  for (std::set<const Elem *, CompareElemIdsByLevel>::const_iterator it = elements.begin(),
323  end = elements.end(); it != end; ++it)
324  {
325  const Elem & elem = **it;
326 
327  unsigned int n_nodes = elem.n_nodes();
328 
329  elem_data[0] = elem.id();
330  elem_data[1] = elem.type();
331  elem_data[2] = elem.processor_id();
332  elem_data[3] = elem.subdomain_id();
333 
334 #ifdef LIBMESH_ENABLE_AMR
335  if (elem.parent() != libmesh_nullptr)
336  {
337  elem_data[4] = elem.parent()->id();
338  elem_data[5] = elem.parent()->which_child_am_i(&elem);
339  }
340  else
341 #endif
342  {
343  elem_data[4] = DofObject::invalid_processor_id;
344  elem_data[5] = DofObject::invalid_processor_id;
345  }
346 
347  conn_data.resize(n_nodes);
348 
349  for (unsigned int i=0; i<n_nodes; i++)
350  conn_data[i] = elem.node_id(i);
351 
352  io.data_stream(&elem_data[0],
353  cast_int<unsigned int>(elem_data.size()),
354  cast_int<unsigned int>(elem_data.size()));
355 
356 #ifdef LIBMESH_ENABLE_UNIQUE_ID
357  largest_id_type unique_id = elem.unique_id();
358 
359  io.data(unique_id, "# unique id");
360 #endif
361 
362 #ifdef LIBMESH_ENABLE_AMR
363  uint16_t p_level = elem.p_level();
364  io.data(p_level, "# p_level");
365 
366  uint16_t rflag = elem.refinement_flag();
367  io.data(rflag, "# rflag");
368 
369  uint16_t pflag = elem.p_refinement_flag();
370  io.data(pflag, "# pflag");
371 #endif
372  io.data_stream(&conn_data[0],
373  cast_int<unsigned int>(conn_data.size()),
374  cast_int<unsigned int>(conn_data.size()));
375  }
376 }
uint64_t largest_id_type
Definition: id_types.h:139
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
libmesh_assert(j)
const dof_id_type n_nodes
Definition: tecplot_io.C:67
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:335
virtual void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = libmesh_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.

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

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

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

Definition at line 96 of file mesh_output.h.

References libMesh::MeshOutput< MT >::ascii_precision(), libMesh::MeshOutput< MT >::mesh(), and libMesh::MeshOutput< MT >::write_nodal_data().

99  { libmesh_not_implemented(); }
virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const NumericVector< Number > &  ,
const std::vector< std::string > &   
)
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 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.

void libMesh::CheckpointIO::write_nodes ( Xdr io,
const std::set< const Node * > &  nodeset 
) const
private

Write the nodal locations for part of a mesh.

Definition at line 263 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::Xdr::data_stream(), end, libMesh::DofObject::id(), libMesh::DofObject::processor_id(), and libMesh::DofObject::unique_id().

Referenced by current_n_processors(), and write().

265 {
266  largest_id_type n_nodes_here = nodeset.size();
267 
268  io.data(n_nodes_here, "# n_nodes on proc");
269 
270  // Will hold the node id and pid
271  std::vector<largest_id_type> id_pid(2);
272 
273  // For the coordinates
274  std::vector<Real> coords(LIBMESH_DIM);
275 
276  for (std::set<const Node *>::iterator it = nodeset.begin(),
277  end = nodeset.end(); it != end; ++it)
278  {
279  const Node & node = **it;
280 
281  id_pid[0] = node.id();
282  id_pid[1] = node.processor_id();
283 
284  io.data_stream(&id_pid[0], 2, 2);
285 
286 #ifdef LIBMESH_ENABLE_UNIQUE_ID
287  largest_id_type unique_id = node.unique_id();
288 
289  io.data(unique_id, "# unique id");
290 #endif
291 
292  coords[0] = node(0);
293 
294 #if LIBMESH_DIM > 1
295  coords[1] = node(1);
296 #endif
297 
298 #if LIBMESH_DIM > 2
299  coords[2] = node(2);
300 #endif
301 
302  io.data_stream(&coords[0], LIBMESH_DIM, 3);
303  }
304 }
uint64_t largest_id_type
Definition: id_types.h:139
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
void libMesh::CheckpointIO::write_nodesets ( Xdr io,
const std::set< const Node * > &  nodeset 
) const
private

Write the nodal boundary conditions for part of a mesh.

Definition at line 475 of file checkpoint_io.C.

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

Referenced by current_n_processors(), and write().

477 {
478  libmesh_assert (io.writing());
479 
480  // convenient reference to our mesh
481  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
482 
483  // and our boundary info object
484  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
485 
486  std::vector<dof_id_type> full_node_id_list;
487  std::vector<boundary_id_type> full_bc_id_list;
488 
489  boundary_info.build_node_list(full_node_id_list, full_bc_id_list);
490 
491  std::size_t nodeset_size = full_node_id_list.size();
492  libmesh_assert_equal_to(nodeset_size, full_bc_id_list.size());
493 
494  std::vector<largest_id_type> node_id_list;
495  std::vector<largest_id_type> bc_id_list;
496 
497  node_id_list.reserve(nodeset_size);
498  bc_id_list.reserve(nodeset_size);
499 
500  for (std::size_t i = 0; i != nodeset_size; ++i)
501  if (nodeset.count(mesh.node_ptr(full_node_id_list[i])))
502  {
503  node_id_list.push_back(full_node_id_list[i]);
504  bc_id_list.push_back(full_bc_id_list[i]);
505  }
506 
507  io.data(node_id_list, "# node id list");
508  io.data(bc_id_list, "# nodeset bc id list");
509 }
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
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 379 of file checkpoint_io.C.

References libMesh::Elem::child_ptr(), libMesh::Xdr::data(), end, libMesh::Elem::has_children(), libMesh::DofObject::id(), libMesh::libmesh_assert(), libMesh::Elem::n_children(), libMesh::Elem::neighbor_ptr(), libMesh::remote_elem, libMesh::Elem::side_index_range(), and libMesh::Xdr::writing().

Referenced by current_n_processors(), and write().

381 {
382  libmesh_assert (io.writing());
383 
384  // Find the remote_elem neighbor and child links
385  std::vector<largest_id_type> elem_ids, parent_ids;
386  std::vector<uint16_t> elem_sides, child_numbers;
387 
388  for (std::set<const Elem *, CompareElemIdsByLevel>::const_iterator it = elements.begin(),
389  end = elements.end(); it != end; ++it)
390  {
391  const Elem & elem = **it;
392 
393  for (auto n : elem.side_index_range())
394  {
395  const Elem * neigh = elem.neighbor_ptr(n);
396  if (neigh == remote_elem ||
397  (neigh && !elements.count(neigh)))
398  {
399  elem_ids.push_back(elem.id());
400  elem_sides.push_back(n);
401  }
402  }
403 
404 #ifdef LIBMESH_ENABLE_AMR
405  if (elem.has_children())
406  {
407  const unsigned int nc = elem.n_children();
408  for (unsigned int c = 0; c != nc; ++c)
409  {
410  const Elem * child = elem.child_ptr(c);
411  if (child == remote_elem ||
412  (child && !elements.count(child)))
413  {
414  parent_ids.push_back(elem.id());
415  child_numbers.push_back(c);
416  }
417  }
418  }
419 #endif
420  }
421 
422  io.data(elem_ids, "# remote neighbor elem_ids");
423  io.data(elem_sides, "# remote neighbor elem_sides");
424  io.data(parent_ids, "# remote child parent_ids");
425  io.data(child_numbers, "# remote child_numbers");
426 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
libmesh_assert(j)
const RemoteElem * remote_elem
Definition: remote_elem.C:57
void libMesh::CheckpointIO::write_subdomain_names ( Xdr io) const
private

Write subdomain name information.

Definition at line 226 of file checkpoint_io.C.

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

Referenced by current_n_processors(), and write().

227 {
228  {
229  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
230 
231  const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
232 
233  std::vector<largest_id_type> subdomain_ids; subdomain_ids.reserve(subdomain_map.size());
234  std::vector<std::string> subdomain_names; subdomain_names.reserve(subdomain_map.size());
235 
236  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
237  // return writable references in mesh_base, it's possible for the user to leave some entity names
238  // blank. We can't write those to the XDA file.
239  largest_id_type n_subdomain_names = 0;
240  std::map<subdomain_id_type, std::string>::const_iterator it_end = subdomain_map.end();
241  for (std::map<subdomain_id_type, std::string>::const_iterator it = subdomain_map.begin(); it != it_end; ++it)
242  {
243  if (!it->second.empty())
244  {
245  n_subdomain_names++;
246  subdomain_ids.push_back(it->first);
247  subdomain_names.push_back(it->second);
248  }
249  }
250 
251  io.data(n_subdomain_names, "# subdomain id to name map");
252  // Write out the ids and names in two vectors
253  if (n_subdomain_names)
254  {
255  io.data(subdomain_ids);
256  io.data(subdomain_names);
257  }
258  }
259 }
uint64_t largest_id_type
Definition: id_types.h:139
const MT & mesh() const
Definition: mesh_output.h:216

Member Data Documentation

bool libMesh::CheckpointIO::_binary
private

Definition at line 259 of file checkpoint_io.h.

Referenced by binary().

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited
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 141 of file mesh_output.h.

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

processor_id_type libMesh::CheckpointIO::_my_n_processors
private

Definition at line 267 of file checkpoint_io.h.

Referenced by current_n_processors(), and write().

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

Definition at line 264 of file checkpoint_io.h.

Referenced by current_processor_ids(), and write().

bool libMesh::CheckpointIO::_parallel
private

Definition at line 260 of file checkpoint_io.h.

Referenced by parallel(), and write().

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

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

Definition at line 261 of file checkpoint_io.h.

Referenced by version(), and write().

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

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