libMesh::CheckpointIO Class Reference

#include <checkpoint_io.h>

Inheritance diagram for libMesh::CheckpointIO:

Public Types

typedef largest_id_type xdr_id_type
 
typedef uint32_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 processor_id_typecurrent_processor_id () const
 
processor_id_typecurrent_processor_id ()
 
const processor_id_typecurrent_n_processors () const
 
processor_id_typecurrent_n_processors ()
 
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 build_elem_list ()
 
void build_node_list ()
 
void write_subdomain_names (Xdr &io) const
 
void write_connectivity (Xdr &io) const
 
void write_nodes (Xdr &io) const
 
void write_bcs (Xdr &io) const
 
void write_nodesets (Xdr &io) const
 
void write_bc_names (Xdr &io, const BoundaryInfo &info, bool is_sideset) const
 
void read_subdomain_names (Xdr &io)
 
void read_connectivity (Xdr &io)
 
void read_nodes (Xdr &io)
 
void read_bcs (Xdr &io)
 
void read_nodesets (Xdr &io)
 
void read_bc_names (Xdr &io, BoundaryInfo &info, bool is_sideset)
 
unsigned int n_active_levels_on_processor (const MeshBase &mesh) const
 

Private Attributes

bool _binary
 
bool _parallel
 
std::string _version
 
unsigned int _mesh_dimension
 
std::set< largest_id_type_local_elements
 These are sets of IDs to make the lookup for boundary conditions simpler. More...
 
std::set< largest_id_type_nodes_connected_to_local_elements
 
processor_id_type _my_processor_id
 The processor_id to use. More...
 
processor_id_type _my_n_processors
 The number of processors to use. More...
 

Detailed Description

The CheckpointIO class can be used to write simplified restart files that can be used to restart simulations that have crashed. Only N-to-N (procs) restart is supported with CheckpointIO files.

Author
Benjamin Kirk
John Peterson
Derek Gaston
Date
2013

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

49  :
50  MeshInput<MeshBase> (mesh,/* is_parallel_format = */ true),
51  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
53  _binary (binary_in),
54  _parallel (false),
55  _version ("checkpoint-1.1"),
58 {
59 }
ParallelObject(const Parallel::Communicator &comm_in)
processor_id_type n_processors() const
processor_id_type _my_processor_id
The processor_id to use.
processor_id_type _my_n_processors
The number of processors to use.
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 63 of file checkpoint_io.C.

63  :
64  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
66  _binary (binary_in),
67  _parallel (false),
70 {
71 }
ParallelObject(const Parallel::Communicator &comm_in)
processor_id_type n_processors() const
processor_id_type _my_processor_id
The processor_id to use.
processor_id_type _my_n_processors
The number of processors to use.
processor_id_type processor_id() const
libMesh::CheckpointIO::~CheckpointIO ( )
virtual

Destructor.

Definition at line 75 of file checkpoint_io.C.

76 {
77 }

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(), and write().

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

Definition at line 100 of file checkpoint_io.h.

References _binary.

100 { return _binary; }
void libMesh::CheckpointIO::build_elem_list ( )
private

Build up the elem list

Definition at line 157 of file checkpoint_io.C.

References _local_elements, _my_processor_id, _parallel, libMesh::Elem::active(), libMesh::MeshBase::elements_begin(), libMesh::MeshBase::elements_end(), end, libMesh::Elem::find_point_neighbors(), libMesh::DofObject::id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::pid_elements_begin(), and libMesh::MeshBase::pid_elements_end().

Referenced by current_n_processors(), and write().

158 {
159  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
160 
161  MeshBase::const_element_iterator it = mesh.elements_begin();
162  MeshBase::const_element_iterator end = mesh.elements_end();
163 
164  if (_parallel)
165  {
166  it = mesh.pid_elements_begin(_my_processor_id);
167  end = mesh.pid_elements_end(_my_processor_id);
168  }
169 
170  std::set<const Elem *> neighbors;
171 
172  for (; it != end; ++it)
173  {
174  Elem * elem = *it;
175 
176  _local_elements.insert(elem->id());
177 
178  // Make sure the neighbors vector is cleared out in case this Elem
179  // isn't active and we skip calling find_point_neighbors().
180  neighbors.clear();
181 
182  // Also need to add in all the point neighbors of this element.
183  // Point neighbors can only be found for active elements...
184  if (elem->active())
185  elem->find_point_neighbors(neighbors);
186 
187  std::set<const Elem *>::iterator
188  set_it = neighbors.begin(),
189  set_end = neighbors.end();
190 
191  for (; set_it != set_end; ++set_it)
192  _local_elements.insert((*set_it)->id());
193  }
194 }
std::set< largest_id_type > _local_elements
These are sets of IDs to make the lookup for boundary conditions simpler.
IterBase * end
const MT & mesh() const
Definition: mesh_output.h:216
processor_id_type _my_processor_id
The processor_id to use.
void libMesh::CheckpointIO::build_node_list ( )
private

Build up the node list

Definition at line 196 of file checkpoint_io.C.

References _local_elements, _nodes_connected_to_local_elements, libMesh::MeshBase::elem_ptr(), end, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::Elem::n_nodes(), and libMesh::Elem::node_id().

Referenced by current_n_processors(), and write().

197 {
198  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
199 
200  std::set<largest_id_type>::iterator it = _local_elements.begin();
201  const std::set<largest_id_type>::iterator end = _local_elements.end();
202 
203  for (; it != end; ++it)
204  {
205  const Elem * elem = mesh.elem_ptr(*it);
206 
207  for (unsigned int n = 0; n < elem->n_nodes(); n++)
208  _nodes_connected_to_local_elements.insert(elem->node_id(n));
209  }
210 }
std::set< largest_id_type > _nodes_connected_to_local_elements
std::set< largest_id_type > _local_elements
These are sets of IDs to make the lookup for boundary conditions simpler.
IterBase * end
const MT & mesh() const
Definition: mesh_output.h:216
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::MeshTools::bounding_box(), 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::MeshRefinement::create_parent_error_vector(), 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::MeshTools::processor_bounding_box(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), 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::MeshTools::subdomain_bounding_box(), 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::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

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

References _my_n_processors.

131 { return _my_n_processors; }
processor_id_type _my_n_processors
The number of processors to use.
const processor_id_type& libMesh::CheckpointIO::current_processor_id ( ) const
inline

Get/Set the processor_id to use

This is used for m->n parallel checkpoint file writing: You can force CheckpointIO to view the world as if it is on a particular processor_id by setting it here

Definition at line 121 of file checkpoint_io.h.

References _my_processor_id.

121 { return _my_processor_id; }
processor_id_type _my_processor_id
The processor_id to use.
processor_id_type& libMesh::CheckpointIO::current_processor_id ( )
inline

Definition at line 122 of file checkpoint_io.h.

References _my_processor_id.

122 { return _my_processor_id; }
processor_id_type _my_processor_id
The processor_id to use.
MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited

Returns the object as a writeable reference.

Referenced by libMesh::GMVIO::_read_one_cell(), build_elem_list(), build_node_list(), current_n_processors(), 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(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), read_nodes(), read_nodesets(), 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(), write_connectivity(), 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_nodes(), write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), and write_subdomain_names().

unsigned int libMesh::CheckpointIO::n_active_levels_on_processor ( const MeshBase mesh) const
private

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

References _local_elements, libMesh::MeshBase::elem_ptr(), end, libMesh::Elem::level(), std::max(), and libMesh::MeshTools::max_level().

Referenced by current_n_processors(), and write_connectivity().

859 {
860  unsigned int max_level = 0;
861 
862  std::set<largest_id_type>::iterator it = _local_elements.begin();
863  const std::set<largest_id_type>::iterator end = _local_elements.end();
864 
865  for (; it != end; ++it)
866  max_level = std::max(mesh.elem_ptr((*it))->level(), max_level);
867 
868  return max_level + 1;
869 }
std::set< largest_id_type > _local_elements
These are sets of IDs to make the lookup for boundary conditions simpler.
IterBase * end
long double max(long double a, double b)
unsigned int max_level(const MeshBase &mesh)
unsigned int level() const
Definition: elem.h:2115
virtual const Elem * elem_ptr(const dof_id_type i) const =0
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::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::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::MeshTools::processor_bounding_box(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), 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::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:679
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 read(), and 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(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), 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::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::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:677
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 520 of file checkpoint_io.C.

References _mesh_dimension, _my_n_processors, _my_processor_id, _parallel, _version, binary(), libMesh::MeshCommunication::broadcast(), libMesh::Xdr::data(), libMesh::DECODE, libMesh::MeshBase::is_replicated(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::Quality::name(), parallel(), libMesh::READ, read_bcs(), read_connectivity(), read_nodes(), read_nodesets(), read_subdomain_names(), and libMesh::MeshBase::set_mesh_dimension().

Referenced by libMesh::NameBasedIO::read().

521 {
522  LOG_SCOPE("read()","CheckpointIO");
523 
524  MeshBase & mesh = MeshInput<MeshBase>::mesh();
525 
526  // Try to dynamic cast the mesh to see if it's a DistributedMesh object
527  // Note: Just using is_serial() is not good enough because the Mesh won't
528  // have been prepared yet when is when that flag gets set to false... sigh.
529  _parallel = _parallel || !mesh.is_replicated();
530 
531  // If this is a serial mesh then we're going to only read it on processor 0 and broadcast it
532  if (_parallel || _my_processor_id == 0)
533  {
534  std::ostringstream file_name_stream;
535 
536  file_name_stream << name;
537 
538  if (_parallel)
539  file_name_stream << "-" << _my_n_processors << "-" << _my_processor_id;
540 
541  {
542  std::ifstream in (file_name_stream.str().c_str());
543 
544  if (!in.good())
545  libmesh_error_msg("ERROR: cannot locate specified file:\n\t" << file_name_stream.str());
546  }
547 
548  Xdr io (file_name_stream.str(), this->binary() ? DECODE : READ);
549 
550  // read the version
551  io.data (_version);
552 
553  // read the dimension
554  io.data (_mesh_dimension);
555  mesh.set_mesh_dimension(_mesh_dimension);
556 
557  // Check if the mesh we're reading is the same as the one that was written
558  {
559  unsigned int parallel;
560  io.data(parallel, "# parallel");
561 
562  if (_parallel != parallel)
563  libmesh_error_msg("Attempted to read a " <<
564  (parallel ? "parallel" : "non-parallel")
565  << " (" << parallel << ')'
566  << " checkpoint file with a " <<
567  (_parallel ? "parallel" : "non-parallel")
568  << " checkpoint object!");
569  }
570 
571  // If this is a parallel mesh then we need to check to ensure we're reading this on the same number of procs
572  if (_parallel)
573  {
574  largest_id_type n_procs;
575  io.data(n_procs, "# n_procs");
576 
577  if (n_procs != _my_n_processors)
578  libmesh_error_msg("Attempted to utilize a checkpoint file on " << _my_n_processors << " processors but it was written using " << n_procs << "!!");
579  }
580 
581  // read subdomain names
582  this->read_subdomain_names(io);
583 
584  // read the nodal locations
585  this->read_nodes (io);
586 
587  // read connectivity
588  this->read_connectivity (io);
589 
590  // read the boundary conditions
591  this->read_bcs (io);
592 
593  // read the nodesets
594  this->read_nodesets (io);
595 
596  io.close();
597  }
598 
599  // If the mesh is serial then we only read it on processor 0 so we need to broadcast it
600  if (!_parallel)
601  MeshCommunication().broadcast(mesh);
602 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
void read_bcs(Xdr &io)
void read_nodes(Xdr &io)
uint64_t largest_id_type
Definition: id_types.h:138
processor_id_type _my_processor_id
The processor_id to use.
void read_nodesets(Xdr &io)
bool parallel() const
processor_id_type _my_n_processors
The number of processors to use.
void read_connectivity(Xdr &io)
unsigned int _mesh_dimension
void read_subdomain_names(Xdr &io)
bool binary() const
Definition: checkpoint_io.h:99
void libMesh::CheckpointIO::read_bc_names ( Xdr io,
BoundaryInfo info,
bool  is_sideset 
)
private

Read boundary names information (sideset and nodeset) - NEW in 0.9.2 format

Definition at line 831 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(), and read_bcs().

832 {
833  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
834  info.set_sideset_name_map() : info.set_nodeset_name_map();
835 
836  std::vector<boundary_id_type> boundary_ids;
837  std::vector<std::string> boundary_names;
838 
839  header_id_type n_boundary_names = 0;
840 
841  if (is_sideset)
842  io.data(n_boundary_names, "# sideset id to name map");
843  else
844  io.data(n_boundary_names, "# nodeset id to name map");
845 
846  if (n_boundary_names)
847  {
848  io.data(boundary_ids);
849  io.data(boundary_names);
850  }
851 
852  // Add them back into the map
853  for (std::size_t i=0; i<boundary_ids.size(); i++)
854  boundary_map[boundary_ids[i]] = boundary_names[i];
855 }
void libMesh::CheckpointIO::read_bcs ( Xdr io)
private

Read the boundary conditions for a parallel, distributed mesh

Definition at line 785 of file checkpoint_io.C.

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

Referenced by current_n_processors(), and read().

786 {
787  // convenient reference to our mesh
788  MeshBase & mesh = MeshInput<MeshBase>::mesh();
789 
790  // and our boundary info object
791  BoundaryInfo & boundary_info = mesh.get_boundary_info();
792 
793  // Version 0.9.2+ introduces entity names
794  read_bc_names(io, boundary_info, true); // sideset names
795  read_bc_names(io, boundary_info, false); // nodeset names
796 
797  std::vector<dof_id_type> element_id_list;
798  std::vector<unsigned short int> side_list;
799  std::vector<boundary_id_type> bc_id_list;
800 
801  io.data(element_id_list, "# element ids for bcs");
802  io.data(side_list, "# sides of elements for bcs");
803  io.data(bc_id_list, "# bc ids");
804 
805  for (std::size_t i=0; i<element_id_list.size(); i++)
806  boundary_info.add_side(element_id_list[i], side_list[i], bc_id_list[i]);
807 }
void read_bc_names(Xdr &io, BoundaryInfo &info, bool is_sideset)
void libMesh::CheckpointIO::read_connectivity ( Xdr io)
private

Read the connectivity for a parallel, distributed mesh

Definition at line 685 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::Elem::INACTIVE, libMesh::DofObject::invalid_processor_id, libMesh::Elem::JUST_REFINED, libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshTools::n_active_levels(), n_nodes, libMesh::Elem::n_nodes(), libMesh::MeshBase::node_ptr(), libMesh::DofObject::processor_id(), libMesh::DofObject::set_id(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::Elem::set_refinement_flag(), libMesh::DofObject::set_unique_id(), libMesh::Elem::subdomain_id(), and libMesh::Elem::type_to_n_nodes_map.

Referenced by current_n_processors(), and read().

686 {
687  // convenient reference to our mesh
688  MeshBase & mesh = MeshInput<MeshBase>::mesh();
689 
690  unsigned int n_active_levels;
691  io.data(n_active_levels, "# n_active_levels");
692 
693  // Keep track of the highest dimensional element we've added to the mesh
694  unsigned int highest_elem_dim = 1;
695 
696  for (unsigned int level=0; level < n_active_levels; level++)
697  {
698  xdr_id_type n_elem_at_level = 0;
699  io.data (n_elem_at_level, "");
700 
701  for (unsigned int i=0; i<n_elem_at_level; i++)
702  {
703  // id type pid subdomain_id parent_id
704  std::vector<largest_id_type> elem_data(5);
705  io.data_stream
706  (&elem_data[0], cast_int<unsigned int>(elem_data.size()),
707  cast_int<unsigned int>(elem_data.size()));
708 
709 #ifdef LIBMESH_ENABLE_UNIQUE_ID
710  largest_id_type unique_id = 0;
711  io.data(unique_id, "# unique id");
712 #endif
713 
714 #ifdef LIBMESH_ENABLE_AMR
715  unsigned int p_level = 0;
716 
717  io.data(p_level, "# p_level");
718 #endif
719 
720  unsigned int n_nodes = Elem::type_to_n_nodes_map[elem_data[1]];
721 
722  // Snag the node ids this element was connected to
723  std::vector<largest_id_type> conn_data(n_nodes);
724  io.data_stream
725  (&conn_data[0], cast_int<unsigned int>(conn_data.size()),
726  cast_int<unsigned int>(conn_data.size()));
727 
728  const dof_id_type id =
729  cast_int<dof_id_type> (elem_data[0]);
730  const ElemType elem_type =
731  static_cast<ElemType> (elem_data[1]);
732  const processor_id_type proc_id =
733  cast_int<processor_id_type>(elem_data[2]);
734  const subdomain_id_type subdomain_id =
735  cast_int<subdomain_id_type>(elem_data[3]);
736  const dof_id_type parent_id =
737  cast_int<dof_id_type> (elem_data[4]);
738 
739  Elem * parent =
740  (parent_id == DofObject::invalid_processor_id) ?
741  libmesh_nullptr : mesh.elem_ptr(parent_id);
742 
743  // Create the element
744  Elem * elem = Elem::build(elem_type, parent).release();
745 
746 #ifdef LIBMESH_ENABLE_UNIQUE_ID
747  elem->set_unique_id() = unique_id;
748 #endif
749 
750  if (elem->dim() > highest_elem_dim)
751  highest_elem_dim = elem->dim();
752 
753  elem->set_id() = id;
754  elem->processor_id() = proc_id;
755  elem->subdomain_id() = subdomain_id;
756 
757 #ifdef LIBMESH_ENABLE_AMR
758  elem->hack_p_level(p_level);
759 
760  // Set parent connections
761  if (parent)
762  {
763  parent->add_child(elem);
764  parent->set_refinement_flag (Elem::INACTIVE);
765  elem->set_refinement_flag (Elem::JUST_REFINED);
766  }
767 #endif
768 
769  libmesh_assert(elem->n_nodes() == conn_data.size());
770 
771  // Connect all the nodes to this element
772  for (std::size_t n=0; n<conn_data.size(); n++)
773  elem->set_node(n) =
774  mesh.node_ptr(cast_int<dof_id_type>(conn_data[n]));
775 
776  mesh.add_elem(elem);
777  }
778  }
779 
780  mesh.set_mesh_dimension(cast_int<unsigned char>(highest_elem_dim));
781 }
static UniquePtr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:234
TestClass subdomain_id_type
Definition: id_types.h:43
uint64_t largest_id_type
Definition: id_types.h:138
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:496
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:346
largest_id_type xdr_id_type
Definition: checkpoint_io.h:56
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int n_active_levels(const MeshBase &mesh)
Definition: mesh_tools.C:532
void libMesh::CheckpointIO::read_nodes ( Xdr io)
private

Read the nodal locations for a parallel, distributed mesh

Definition at line 635 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(), and libMesh::DofObject::set_unique_id().

Referenced by current_n_processors(), and read().

636 {
637  // convenient reference to our mesh
638  MeshBase & mesh = MeshInput<MeshBase>::mesh();
639 
640  unsigned int n_nodes_here;
641  io.data(n_nodes_here, "# n_nodes on proc");
642 
643  // Will hold the node id and pid
644  std::vector<largest_id_type> id_pid(2);
645 
646  // For the coordinates
647  std::vector<Real> coords(LIBMESH_DIM);
648 
649  for (unsigned int i=0; i<n_nodes_here; i++)
650  {
651  io.data_stream(&id_pid[0], 2, 2);
652 
653 #ifdef LIBMESH_ENABLE_UNIQUE_ID
654  largest_id_type unique_id = 0;
655  io.data(unique_id, "# unique id");
656 #endif
657 
658  io.data_stream(&coords[0], LIBMESH_DIM, LIBMESH_DIM);
659 
660  Point p;
661  p(0) = coords[0];
662 
663 #if LIBMESH_DIM > 1
664  p(1) = coords[1];
665 #endif
666 
667 #if LIBMESH_DIM > 2
668  p(2) = coords[2];
669 #endif
670 
671 #ifdef LIBMESH_ENABLE_UNIQUE_ID
672  Node * node =
673 #endif
674  mesh.add_point(p, cast_int<dof_id_type>(id_pid[0]),
675  cast_int<processor_id_type>(id_pid[1]));
676 
677 #ifdef LIBMESH_ENABLE_UNIQUE_ID
678  node->set_unique_id() = unique_id;
679 #endif
680  }
681 }
uint64_t largest_id_type
Definition: id_types.h:138
void libMesh::CheckpointIO::read_nodesets ( Xdr io)
private

Read the nodeset conditions for a parallel, distributed mesh

Definition at line 811 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(), and read().

812 {
813  // convenient reference to our mesh
814  MeshBase & mesh = MeshInput<MeshBase>::mesh();
815 
816  // and our boundary info object
817  BoundaryInfo & boundary_info = mesh.get_boundary_info();
818 
819  std::vector<dof_id_type> node_id_list;
820  std::vector<boundary_id_type> bc_id_list;
821 
822  io.data(node_id_list, "# node id list");
823  io.data(bc_id_list, "# nodeset bc id list");
824 
825  for (std::size_t i=0; i<node_id_list.size(); i++)
826  boundary_info.add_node(node_id_list[i], bc_id_list[i]);
827 }
void libMesh::CheckpointIO::read_subdomain_names ( Xdr io)
private

Read subdomain name information - NEW in 0.9.2 format

Definition at line 606 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(), and read().

607 {
608  MeshBase & mesh = MeshInput<MeshBase>::mesh();
609 
610  std::map<subdomain_id_type, std::string> & subdomain_map =
611  mesh.set_subdomain_name_map();
612 
613  std::vector<header_id_type> subdomain_ids;
614  subdomain_ids.reserve(subdomain_map.size());
615 
616  std::vector<std::string> subdomain_names;
617  subdomain_names.reserve(subdomain_map.size());
618 
619  header_id_type n_subdomain_names = 0;
620  io.data(n_subdomain_names, "# subdomain id to name map");
621 
622  if (n_subdomain_names)
623  {
624  io.data(subdomain_ids);
625  io.data(subdomain_names);
626 
627  for (std::size_t i=0; i<subdomain_ids.size(); i++)
628  subdomain_map[cast_int<subdomain_id_type>(subdomain_ids[i])] =
629  subdomain_names[i];
630  }
631 }
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:1264
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 82 of file checkpoint_io.C.

References _my_n_processors, _my_processor_id, _parallel, _version, binary(), build_elem_list(), build_node_list(), libMesh::Xdr::data(), libMesh::ENCODE, libMesh::MeshBase::is_replicated(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::Quality::name(), parallel(), libMesh::WRITE, write_bcs(), write_connectivity(), write_nodes(), write_nodesets(), and write_subdomain_names().

83 {
84  LOG_SCOPE("write()", "CheckpointIO");
85 
86  // convenient reference to our mesh
87  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
88 
89  // Try to dynamic cast the mesh to see if it's a DistributedMesh object
90  // Note: Just using is_serial() is not good enough because the Mesh won't
91  // have been prepared yet when is when that flag gets set to false... sigh.
92  _parallel = _parallel || !mesh.is_replicated();
93 
94  // If this is a serial mesh then we're only going to write it on processor 0
95  if (_parallel || _my_processor_id == 0)
96  {
97  std::ostringstream file_name_stream;
98 
99  file_name_stream << name;
100 
101  if (_parallel)
102  file_name_stream << "-" << _my_n_processors << "-" << _my_processor_id;
103 
104  Xdr io (file_name_stream.str(), this->binary() ? ENCODE : WRITE);
105 
106  // write the version
107  io.data(_version, "# version");
108 
109  // Write out whether or not this is a serial mesh (helps with error checking on read)
110  {
111  unsigned int mesh_dimension = mesh.mesh_dimension();
112  io.data(mesh_dimension, "# dimensions");
113  }
114 
115  // Write out whether or not this is a serial mesh (helps with error checking on read)
116  {
117  unsigned int 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  // Build the list of local elements
130  this->build_elem_list();
131 
132  // Build the list of nodes connected to local elements
133  this->build_node_list();
134 
135  // write subdomain names
136  this->write_subdomain_names(io);
137 
138  // write the nodal locations
139  this->write_nodes (io);
140 
141  // write connectivity
142  this->write_connectivity (io);
143 
144  // write the boundary condition information
145  this->write_bcs (io);
146 
147  // write the nodeset information
148  this->write_nodesets (io);
149 
150  // close it up
151  io.close();
152  }
153 
154  // this->comm().barrier();
155 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
uint64_t largest_id_type
Definition: id_types.h:138
const MT & mesh() const
Definition: mesh_output.h:216
void write_nodes(Xdr &io) const
processor_id_type _my_processor_id
The processor_id to use.
bool parallel() const
void write_subdomain_names(Xdr &io) const
processor_id_type _my_n_processors
The number of processors to use.
void write_bcs(Xdr &io) const
void write_nodesets(Xdr &io) const
bool binary() const
Definition: checkpoint_io.h:99
void write_connectivity(Xdr &io) const
void libMesh::CheckpointIO::write_bc_names ( Xdr io,
const BoundaryInfo info,
bool  is_sideset 
) const
private

Write boundary names information (sideset and nodeset) - NEW in 0.9.2 format

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

484 {
485  const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
486  info.get_sideset_name_map() : info.get_nodeset_name_map();
487 
488  std::vector<boundary_id_type> boundary_ids; boundary_ids.reserve(boundary_map.size());
489  std::vector<std::string> boundary_names; boundary_names.reserve(boundary_map.size());
490 
491  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
492  // return writable references in boundary_info, it's possible for the user to leave some entity names
493  // blank. We can't write those to the XDA file.
494  header_id_type n_boundary_names = 0;
495  std::map<boundary_id_type, std::string>::const_iterator it_end = boundary_map.end();
496  for (std::map<boundary_id_type, std::string>::const_iterator it = boundary_map.begin(); it != it_end; ++it)
497  {
498  if (!it->second.empty())
499  {
500  n_boundary_names++;
501  boundary_ids.push_back(it->first);
502  boundary_names.push_back(it->second);
503  }
504  }
505 
506  if (is_sideset)
507  io.data(n_boundary_names, "# sideset id to name map");
508  else
509  io.data(n_boundary_names, "# nodeset id to name map");
510  // Write out the ids and names in two vectors
511  if (n_boundary_names)
512  {
513  io.data(boundary_ids);
514  io.data(boundary_names);
515  }
516 }
void libMesh::CheckpointIO::write_bcs ( Xdr io) const
private

Write the boundary conditions for a parallel, distributed mesh

Definition at line 386 of file checkpoint_io.C.

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

Referenced by current_n_processors(), and write().

387 {
388  libmesh_assert (io.writing());
389 
390  // convenient reference to our mesh
391  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
392 
393  // and our boundary info object
394  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
395 
396  // Version 0.9.2+ introduces entity names
397  write_bc_names(io, boundary_info, true); // sideset names
398  write_bc_names(io, boundary_info, false); // nodeset names
399 
400  std::vector<dof_id_type> orig_element_id_list;
401  std::vector<unsigned short int> orig_side_list;
402  std::vector<boundary_id_type> orig_bc_id_list;
403 
404  boundary_info.build_side_list(orig_element_id_list, orig_side_list, orig_bc_id_list);
405 
406  size_t num_orig_elements = orig_element_id_list.size();
407 
408  std::vector<dof_id_type> element_id_list;
409  std::vector<unsigned short int> side_list;
410  std::vector<boundary_id_type> bc_id_list;
411 
412  element_id_list.reserve(num_orig_elements);
413  side_list.reserve(num_orig_elements);
414  bc_id_list.reserve(num_orig_elements);
415 
416  // Filter these lists to only include local elements
417  for (unsigned int i = 0; i < num_orig_elements; i++)
418  {
419  if (_local_elements.find(orig_element_id_list[i]) != _local_elements.end())
420  {
421  // Only write out BCs for truly local elements
422  if (_parallel &&
423  mesh.elem_ptr(orig_element_id_list[i])->processor_id() != _my_processor_id)
424  continue;
425 
426  element_id_list.push_back(orig_element_id_list[i]);
427  side_list.push_back(orig_side_list[i]);
428  bc_id_list.push_back(orig_bc_id_list[i]);
429  }
430  }
431 
432  io.data(element_id_list, "# element ids for bcs");
433  io.data(side_list, "# sides of elements for bcs");
434  io.data(bc_id_list, "# bc ids");
435 }
std::set< largest_id_type > _local_elements
These are sets of IDs to make the lookup for boundary conditions simpler.
const MT & mesh() const
Definition: mesh_output.h:216
processor_id_type _my_processor_id
The processor_id to use.
libmesh_assert(j)
void write_bc_names(Xdr &io, const BoundaryInfo &info, bool is_sideset) const
void libMesh::CheckpointIO::write_connectivity ( Xdr io) const
private

Write the connectivity for a parallel, distributed mesh

Definition at line 299 of file checkpoint_io.C.

References _local_elements, libMesh::Xdr::data(), libMesh::Xdr::data_stream(), end, libMesh::DofObject::id(), libMesh::DofObject::invalid_processor_id, libMesh::Elem::level(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshTools::n_active_levels(), n_active_levels_on_processor(), n_nodes, libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), libMesh::Elem::p_level(), libMesh::Elem::parent(), libMesh::DofObject::processor_id(), libMesh::Elem::subdomain_id(), libMesh::Elem::type(), libMesh::DofObject::unique_id(), and libMesh::Xdr::writing().

Referenced by current_n_processors(), and write().

300 {
301  libmesh_assert (io.writing());
302 
303  // convenient reference to our mesh
304  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
305 
306  // We will only write active elements and their parents.
307  unsigned int n_active_levels = n_active_levels_on_processor(mesh);
308 
309  std::vector<xdr_id_type> n_elem_at_level(n_active_levels, 0);
310 
311  // Find the number of elements at each level
312  {
313  std::set<largest_id_type>::iterator it = _local_elements.begin();
314  const std::set<largest_id_type>::iterator end = _local_elements.end();
315 
316  for (; it != end; ++it)
317  n_elem_at_level[mesh.elem_ptr(*it)->level()]++;
318  }
319 
320  io.data(n_active_levels, "# n_active_levels");
321 
322  // Put these out here to reduce memory churn
323  // id type pid subdomain_id parent_id
324  std::vector<largest_id_type> elem_data(5);
325  std::vector<largest_id_type> conn_data;
326 
327  for (unsigned int level=0; level < n_active_levels; level++)
328  {
329  std::ostringstream comment;
330  comment << "# n_elem at level ";
331  comment << level ;
332  io.data (n_elem_at_level[level], comment.str().c_str());
333 
334  std::set<largest_id_type>::iterator it = _local_elements.begin();
335  const std::set<largest_id_type>::iterator end = _local_elements.end();
336 
337  for (; it != end; ++it)
338  {
339  const Elem & elem = mesh.elem_ref(*it);
340 
341  // Only write elements of the current level.
342  if (elem.level() != level)
343  continue;
344 
345  unsigned int n_nodes = elem.n_nodes();
346 
347  elem_data[0] = elem.id();
348  elem_data[1] = elem.type();
349  elem_data[2] = elem.processor_id();
350  elem_data[3] = elem.subdomain_id();
351 
352  if (elem.parent() != libmesh_nullptr)
353  elem_data[4] = elem.parent()->id();
354  else
355  elem_data[4] = DofObject::invalid_processor_id;
356 
357  conn_data.resize(n_nodes);
358 
359  for (unsigned int i=0; i<n_nodes; i++)
360  conn_data[i] = elem.node_id(i);
361 
362  io.data_stream(&elem_data[0],
363  cast_int<unsigned int>(elem_data.size()),
364  cast_int<unsigned int>(elem_data.size()));
365 
366 #ifdef LIBMESH_ENABLE_UNIQUE_ID
367  largest_id_type unique_id = elem.unique_id();
368 
369  io.data(unique_id, "# unique id");
370 #endif
371 
372 #ifdef LIBMESH_ENABLE_AMR
373  unsigned int p_level = elem.p_level();
374 
375  io.data(p_level, "# p_level");
376 #endif
377  io.data_stream(&conn_data[0],
378  cast_int<unsigned int>(conn_data.size()),
379  cast_int<unsigned int>(conn_data.size()));
380  }
381  }
382 }
uint64_t largest_id_type
Definition: id_types.h:138
const class libmesh_nullptr_t libmesh_nullptr
std::set< largest_id_type > _local_elements
These are sets of IDs to make the lookup for boundary conditions simpler.
IterBase * end
const MT & mesh() const
Definition: mesh_output.h:216
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:346
unsigned int n_active_levels_on_processor(const MeshBase &mesh) const
unsigned int n_active_levels(const MeshBase &mesh)
Definition: mesh_tools.C:532
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::UCDIO, libMesh::VTKIO, 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
private

Write the nodal locations for a parallel, distributed mesh

Definition at line 249 of file checkpoint_io.C.

References _nodes_connected_to_local_elements, libMesh::Xdr::data(), libMesh::Xdr::data_stream(), end, libMesh::DofObject::id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::node_ref(), libMesh::DofObject::processor_id(), and libMesh::DofObject::unique_id().

Referenced by current_n_processors(), and write().

250 {
251  // convenient reference to our mesh
252  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
253 
254  unsigned int n_nodes_here = _nodes_connected_to_local_elements.size();
255 
256  io.data(n_nodes_here, "# n_nodes on proc");
257 
258  // Will hold the node id and pid
259  std::vector<largest_id_type> id_pid(2);
260 
261  // For the coordinates
262  std::vector<Real> coords(LIBMESH_DIM);
263 
264  std::set<largest_id_type>::iterator
267 
268  for (; it != end; ++it)
269  {
270  const Node & node = mesh.node_ref(*it);
271 
272  id_pid[0] = node.id();
273  id_pid[1] = node.processor_id();
274 
275  io.data_stream(&id_pid[0], 2, 2);
276 
277 #ifdef LIBMESH_ENABLE_UNIQUE_ID
278  largest_id_type unique_id = node.unique_id();
279 
280  io.data(unique_id, "# unique id");
281 #endif
282 
283  coords[0] = node(0);
284 
285 #if LIBMESH_DIM > 1
286  coords[1] = node(1);
287 #endif
288 
289 #if LIBMESH_DIM > 2
290  coords[2] = node(2);
291 #endif
292 
293  io.data_stream(&coords[0], LIBMESH_DIM, 3);
294  }
295 }
std::set< largest_id_type > _nodes_connected_to_local_elements
uint64_t largest_id_type
Definition: id_types.h:138
IterBase * end
const MT & mesh() const
Definition: mesh_output.h:216
void libMesh::CheckpointIO::write_nodesets ( Xdr io) const
private

Write the boundary conditions for a parallel, distributed mesh

Definition at line 439 of file checkpoint_io.C.

References _my_processor_id, _nodes_connected_to_local_elements, _parallel, 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().

440 {
441  libmesh_assert (io.writing());
442 
443  // convenient reference to our mesh
444  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
445 
446  // and our boundary info object
447  const BoundaryInfo & boundary_info = mesh.get_boundary_info();
448 
449  std::vector<dof_id_type> orig_node_id_list;
450  std::vector<boundary_id_type> orig_bc_id_list;
451 
452  boundary_info.build_node_list(orig_node_id_list, orig_bc_id_list);
453 
454  size_t num_orig_nodes = orig_node_id_list.size();
455 
456  std::vector<dof_id_type> node_id_list;
457  std::vector<boundary_id_type> bc_id_list;
458 
459  node_id_list.reserve(num_orig_nodes);
460  bc_id_list.reserve(num_orig_nodes);
461 
462  // Filter these lists to only include nodes connected to local elements
463  for (unsigned int i = 0; i < num_orig_nodes; i++)
464  {
465  if (_nodes_connected_to_local_elements.find(orig_node_id_list[i]) != _nodes_connected_to_local_elements.end())
466  {
467  // Only write out BCs for truly local nodes
468  if (_parallel &&
469  mesh.node_ptr(orig_node_id_list[i])->processor_id() != _my_processor_id)
470  continue;
471 
472  node_id_list.push_back(orig_node_id_list[i]);
473  bc_id_list.push_back(orig_bc_id_list[i]);
474  }
475  }
476 
477  io.data(node_id_list, "# node id list");
478  io.data(bc_id_list, "# nodeset bc id list");
479 }
std::set< largest_id_type > _nodes_connected_to_local_elements
const MT & mesh() const
Definition: mesh_output.h:216
processor_id_type _my_processor_id
The processor_id to use.
libmesh_assert(j)
void libMesh::CheckpointIO::write_subdomain_names ( Xdr io) const
private

Write subdomain name information - NEW in 0.9.2 format

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

213 {
214  {
215  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
216 
217  const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
218 
219  std::vector<header_id_type> subdomain_ids; subdomain_ids.reserve(subdomain_map.size());
220  std::vector<std::string> subdomain_names; subdomain_names.reserve(subdomain_map.size());
221 
222  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
223  // return writable references in mesh_base, it's possible for the user to leave some entity names
224  // blank. We can't write those to the XDA file.
225  header_id_type n_subdomain_names = 0;
226  std::map<subdomain_id_type, std::string>::const_iterator it_end = subdomain_map.end();
227  for (std::map<subdomain_id_type, std::string>::const_iterator it = subdomain_map.begin(); it != it_end; ++it)
228  {
229  if (!it->second.empty())
230  {
231  n_subdomain_names++;
232  subdomain_ids.push_back(it->first);
233  subdomain_names.push_back(it->second);
234  }
235  }
236 
237  io.data(n_subdomain_names, "# subdomain id to name map");
238  // Write out the ids and names in two vectors
239  if (n_subdomain_names)
240  {
241  io.data(subdomain_ids);
242  io.data(subdomain_names);
243  }
244  }
245 }
const MT & mesh() const
Definition: mesh_output.h:216

Member Data Documentation

bool libMesh::CheckpointIO::_binary
private

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

std::set<largest_id_type> libMesh::CheckpointIO::_local_elements
private

These are sets of IDs to make the lookup for boundary conditions simpler.

Definition at line 225 of file checkpoint_io.h.

Referenced by build_elem_list(), build_node_list(), n_active_levels_on_processor(), write_bcs(), and write_connectivity().

unsigned int libMesh::CheckpointIO::_mesh_dimension
private

Definition at line 222 of file checkpoint_io.h.

Referenced by read().

processor_id_type libMesh::CheckpointIO::_my_n_processors
private

The number of processors to use.

Definition at line 232 of file checkpoint_io.h.

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

processor_id_type libMesh::CheckpointIO::_my_processor_id
private

The processor_id to use.

Definition at line 229 of file checkpoint_io.h.

Referenced by build_elem_list(), current_processor_id(), read(), write(), write_bcs(), and write_nodesets().

std::set<largest_id_type> libMesh::CheckpointIO::_nodes_connected_to_local_elements
private

Definition at line 226 of file checkpoint_io.h.

Referenced by build_node_list(), write_nodes(), and write_nodesets().

bool libMesh::CheckpointIO::_parallel
private

Definition at line 220 of file checkpoint_io.h.

Referenced by build_elem_list(), parallel(), read(), write(), write_bcs(), and write_nodesets().

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

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


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