libMesh::CheckpointIO Class Reference

#include <checkpoint_io.h>

Inheritance diagram for libMesh::CheckpointIO:

Public Types

typedef largest_id_type xdr_id_type
 
typedef uint64_t header_id_type
 

Public Member Functions

 CheckpointIO (MeshBase &, const bool=false)
 
 CheckpointIO (const MeshBase &, const bool=false)
 
virtual ~CheckpointIO ()
 
virtual void read (const std::string &) libmesh_override
 
virtual void write (const std::string &) libmesh_override
 
bool binary () const
 
bool & binary ()
 
bool parallel () const
 
bool & parallel ()
 
const std::string & version () const
 
std::string & version ()
 
const std::vector< processor_id_type > & current_processor_ids () const
 
std::vector< processor_id_type > & current_processor_ids ()
 
const processor_id_typecurrent_n_processors () const
 
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)
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 
unsigned int & ascii_precision ()
 
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)
 
void skip_comment_lines (std::istream &in, const char comment_start)
 
const MeshBasemesh () const
 

Protected Attributes

std::vector< bool > elems_of_dimension
 
const bool _is_parallel_format
 
const bool _serial_only_needed_on_proc_0
 
const Parallel::Communicator_communicator
 

Private Member Functions

void write_subdomain_names (Xdr &io) const
 
void write_connectivity (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 
void write_remote_elem (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 
void write_nodes (Xdr &io, const std::set< const Node * > &nodeset) const
 
void write_bcs (Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
 
void write_nodesets (Xdr &io, const std::set< const Node * > &nodeset) const
 
void write_bc_names (Xdr &io, const BoundaryInfo &info, bool is_sideset) const
 
template<typename file_id_type >
file_id_type read_header (const std::string &name)
 
template<typename file_id_type >
void read_subfile (Xdr &io, bool expect_all_remote)
 
template<typename file_id_type >
void read_subdomain_names (Xdr &io)
 
template<typename file_id_type >
void read_connectivity (Xdr &io)
 
template<typename file_id_type >
void read_remote_elem (Xdr &io, bool expect_all_remote)
 
template<typename file_id_type >
void read_nodes (Xdr &io)
 
template<typename file_id_type >
void read_bcs (Xdr &io)
 
template<typename file_id_type >
void read_nodesets (Xdr &io)
 
template<typename file_id_type >
void read_bc_names (Xdr &io, BoundaryInfo &info, bool is_sideset)
 
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.

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)
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)
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
inline

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

Definition at line 99 of file checkpoint_io.h.

References _binary.

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

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

Definition at line 100 of file checkpoint_io.h.

References _binary.

100 { return _binary; }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
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_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(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), 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::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), 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::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), 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::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TopologyMap::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< 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::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(), 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::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), 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(), 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(), libMesh::Nemesis_IO::read(), read(), libMesh::XdrIO::read(), read_header(), 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::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), 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(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _communicator
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 137 of file checkpoint_io.h.

References _my_n_processors.

137 { return _my_n_processors; }
processor_id_type _my_n_processors
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 124 of file checkpoint_io.h.

References _my_processor_ids.

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

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

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

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

Referenced by current_n_processors().

1131 {
1132  unsigned int max_level = 0;
1133 
1134  for (MeshBase::const_element_iterator it = begin;
1135  it != end; ++it)
1136  max_level = std::max((*it)->level(), max_level);
1137 
1138  return max_level + 1;
1139 }
IterBase * end
long double max(long double a, double b)
unsigned int max_level(const MeshBase &mesh)
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
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::DistributedVector< T >::init(), 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(), libMesh::XdrIO::read(), read_connectivity(), 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(), 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:722
const Parallel::Communicator & _communicator
bool libMesh::CheckpointIO::parallel ( ) const
inline

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

Definition at line 105 of file checkpoint_io.h.

References _parallel.

Referenced by write().

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

Definition at line 106 of file checkpoint_io.h.

References _parallel.

106 { return _parallel; }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
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::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::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::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), 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::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(), libMesh::MeshRefinement::make_coarsening_compatible(), 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::ExodusII_IO_Helper::read_node_num_map(), 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(), 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::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::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:720
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 546 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().

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

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

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

Read the connectivity for a parallel, distributed mesh

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

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

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

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

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

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

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

Referenced by current_n_processors().

740 {
741  // read the nodal locations
742  this->read_nodes<file_id_type> (io);
743 
744  // read connectivity
745  this->read_connectivity<file_id_type> (io);
746 
747  // read remote_elem connectivity
748  this->read_remote_elem<file_id_type> (io, expect_all_remote);
749 
750  // read the boundary conditions
751  this->read_bcs<file_id_type> (io);
752 
753  // read the nodesets
754  this->read_nodesets<file_id_type> (io);
755 }
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 91 of file mesh_input.h.

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

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

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

Get/Set the version string.

Definition at line 111 of file checkpoint_io.h.

References _version.

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

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

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)
Definition: elem_quality.C:39
void write_nodes(Xdr &io, const std::set< const Node * > &nodeset) const
void write_nodesets(Xdr &io, const std::set< const Node * > &nodeset) const
void write_connectivity(Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
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
std::vector< processor_id_type > _my_processor_ids
void write_remote_elem(Xdr &io, const std::set< const Elem *, CompareElemIdsByLevel > &elements) const
void write_bc_names(Xdr &io, const BoundaryInfo &info, bool is_sideset) const
void write_subdomain_names(Xdr &io) const
static const processor_id_type invalid_processor_id
Definition: dof_object.h:345
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
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
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 510 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().

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

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

474 {
475  libmesh_assert (io.writing());
476 
477  // convenient reference to our mesh
478  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
479 
480  // and our boundary info object
481  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
482 
483  std::vector<dof_id_type> full_node_id_list;
484  std::vector<boundary_id_type> full_bc_id_list;
485 
486  boundary_info.build_node_list(full_node_id_list, full_bc_id_list);
487 
488  std::size_t nodeset_size = full_node_id_list.size();
489  libmesh_assert_equal_to(nodeset_size, full_bc_id_list.size());
490 
491  std::vector<largest_id_type> node_id_list;
492  std::vector<largest_id_type> bc_id_list;
493 
494  node_id_list.reserve(nodeset_size);
495  bc_id_list.reserve(nodeset_size);
496 
497  for (std::size_t i = 0; i != nodeset_size; ++i)
498  if (nodeset.count(mesh.node_ptr(full_node_id_list[i])))
499  {
500  node_id_list.push_back(full_node_id_list[i]);
501  bc_id_list.push_back(full_bc_id_list[i]);
502  }
503 
504  io.data(node_id_list, "# node id list");
505  io.data(bc_id_list, "# nodeset bc id list");
506 }
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::n_neighbors(), libMesh::Elem::neighbor_ptr(), libMesh::remote_elem, 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 (unsigned int n=0; n != elem.n_neighbors(); ++n)
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  for (unsigned int c = 0; c != elem.n_children(); ++c)
407  {
408  const Elem * child = elem.child_ptr(c);
409  if (child == remote_elem ||
410  (child && !elements.count(child)))
411  {
412  parent_ids.push_back(elem.id());
413  child_numbers.push_back(c);
414  }
415  }
416 #endif
417  }
418 
419  io.data(elem_ids, "# remote neighbor elem_ids");
420  io.data(elem_sides, "# remote neighbor elem_sides");
421  io.data(parent_ids, "# remote child parent_ids");
422  io.data(child_numbers, "# remote child_numbers");
423 }
IterBase * 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 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().


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