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 &)
 
virtual void write (const std::string &)
 
bool binary () const
 
bool & binary ()
 
const std::string & version () const
 
std::string & version ()
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=NULL)
 
virtual void write_nodal_data (const std::string &, const std::vector< 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 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 Parallel::Communicator_communicator
 

Private Member Functions

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
 
std::string _version
 

Detailed Description

Author
Benjamin Kirk, John Peterson, Derek Gaston

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 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  _version ("checkpoint-1.0")
56 {
57 }
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 61 of file checkpoint_io.C.

61  :
62  MeshOutput<MeshBase>(mesh,/* is_parallel_format = */ true),
64  _binary (binary_in)
65 {
66 }
libMesh::CheckpointIO::~CheckpointIO ( )
virtual

Destructor.

Definition at line 70 of file checkpoint_io.C.

71 {
72 }

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; }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
a reference to the Parallel::Communicator object used by this mesh.

Definition at line 86 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ParallelMesh::add_elem(), libMesh::ImplicitSystem::add_matrix(), libMesh::ParallelMesh::add_node(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), 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::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::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::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().

87  { return _communicator; }
MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited

Returns the object as a writeable reference.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::VTKIO::cells_to_vtk(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::element_in(), libMesh::UNVIO::element_out(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::node_in(), libMesh::UNVIO::node_out(), libMesh::VTKIO::nodes_to_vtk(), libMesh::ExodusII_IO::read(), libMesh::Nemesis_IO::read(), libMesh::GMVIO::read(), read(), libMesh::XdrIO::read(), libMesh::VTKIO::read(), libMesh::LegacyXdrIO::read_ascii(), read_bcs(), read_connectivity(), libMesh::UCDIO::read_implementation(), libMesh::GmshIO::read_mesh(), read_nodes(), read_nodesets(), libMesh::XdrIO::read_serialized_bcs(), 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::TetGenIO::write(), libMesh::ExodusII_IO::write(), libMesh::Nemesis_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::UNVIO::write_implementation(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::Nemesis_IO::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(), 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 725 of file checkpoint_io.C.

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), std::max(), and libMesh::MeshTools::max_level().

Referenced by write_connectivity().

726 {
727  unsigned int max_level = 0;
728 
729  MeshBase::const_element_iterator el = mesh.active_elements_begin();
730  const MeshBase::const_element_iterator end_el = mesh.active_elements_end();
731 
732  for( ; el != end_el; ++el)
733  max_level = std::max((*el)->level(), max_level);
734 
735  return max_level + 1;
736 }
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
the number of processors in the group.

Definition at line 92 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), 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::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), read(), libMesh::UnstructuredMesh::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

93  { return libmesh_cast_int<processor_id_type>(_communicator.size()); }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
the rank of this processor in the group.

Definition at line 98 of file parallel_object.h.

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

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::ParmetisPartitioner::assign_partitioning(), 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::DofMap::build_sparsity(), libMesh::ParallelMesh::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::ExodusII_IO_Helper::create(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::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::Nemesis_IO_Helper::get_ss_param_global(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), 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::Nemesis_IO::read(), read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), read_connectivity(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::ExodusII_IO::write(), write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::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_Helper::write_elements_discontinuous(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), 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::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
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 401 of file checkpoint_io.C.

References _version, binary(), libMesh::MeshCommunication::broadcast(), libMesh::Xdr::data(), libMeshEnums::DECODE, libMesh::err, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::Quality::name(), libMesh::ParallelObject::processor_id(), libMeshEnums::READ, read_bcs(), read_connectivity(), read_nodes(), read_nodesets(), read_subdomain_names(), libMesh::START_LOG(), and libMesh::STOP_LOG().

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

402 {
403  START_LOG("read()","CheckpointIO");
404 
405  MeshBase &mesh = MeshInput<MeshBase>::mesh();
406 
407  // Try to dynamic cast the mesh to see if it's a ParallelMesh object
408  // Note: Just using is_serial() is not good enough because the Mesh won't
409  // have been prepared yet when is when that flag gets set to false... sigh.
410  bool parallel_mesh = dynamic_cast<ParallelMesh*>(&mesh);
411 
412  // If this is a serial mesh then we're going to only read it on processor 0 and broadcast it
413  if(parallel_mesh || this->processor_id() == 0)
414  {
415  std::ostringstream file_name_stream;
416 
417  file_name_stream << name;
418 
419  if(parallel_mesh)
420  file_name_stream << "-" << this->processor_id();
421 
422  {
423  std::ifstream in (file_name_stream.str().c_str());
424 
425  if (!in.good())
426  {
427  libMesh::err << "ERROR: cannot locate specified file:\n\t"
428  << file_name_stream.str()
429  << std::endl;
430  libmesh_error();
431  }
432  }
433 
434  Xdr io (file_name_stream.str(), this->binary() ? DECODE : READ);
435 
436  // read the version
437  io.data (_version);
438 
439  // Check if the mesh we're reading is the same as the one that was written
440  {
441  unsigned int parallel;
442  io.data(parallel, "# parallel");
443 
444  if(parallel_mesh != parallel)
445  {
446  libMesh::err << "Attempted to utilize a checkpoint file with an incompatible mesh distribution!" << std::endl;
447  libmesh_error();
448  }
449  }
450 
451  // If this is a parallel mesh then we need to check to ensure we're reading this on the same number of procs
452  if(parallel_mesh)
453  {
454  largest_id_type n_procs;
455  io.data(n_procs, "# n_procs");
456 
457  if(n_procs != this->n_processors())
458  {
459  libMesh::err << "Attempted to utilize a checkpoint file on " << this->n_processors() << " processors but it was written using " << n_procs << "!!";
460  libmesh_error();
461  }
462  }
463 
464  // read subdomain names
465  this->read_subdomain_names(io);
466 
467  // read the nodal locations
468  this->read_nodes (io);
469 
470  // read connectivity
471  this->read_connectivity (io);
472 
473  // read the boundary conditions
474  this->read_bcs (io);
475 
476  // read the nodesets
477  this->read_nodesets (io);
478 
479  io.close();
480  }
481 
482  // If the mesh is serial then we only read it on processor 0 so we need to broadcast it
483  if(!parallel_mesh)
484  MeshCommunication().broadcast(mesh);
485 
486  STOP_LOG("read()","CheckpointIO");
487 }
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 698 of file checkpoint_io.C.

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

Referenced by read_bcs().

699 {
700  std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
701  info.set_sideset_name_map() : info.set_nodeset_name_map();
702 
703  std::vector<boundary_id_type> boundary_ids;
704  std::vector<std::string> boundary_names;
705 
706  header_id_type n_boundary_names = 0;
707 
708  if (is_sideset)
709  io.data(n_boundary_names, "# sideset id to name map");
710  else
711  io.data(n_boundary_names, "# nodeset id to name map");
712 
713  if (n_boundary_names)
714  {
715  io.data(boundary_ids);
716  io.data(boundary_names);
717  }
718 
719  // Add them back into the map
720  for(unsigned int i=0; i<boundary_ids.size(); i++)
721  boundary_map[boundary_ids[i]] = boundary_names[i];
722 }
void libMesh::CheckpointIO::read_bcs ( Xdr io)
private

Read the boundary conditions for a parallel, distributed mesh

Definition at line 652 of file checkpoint_io.C.

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

Referenced by read().

653 {
654  // convenient reference to our mesh
655  MeshBase &mesh = MeshInput<MeshBase>::mesh();
656 
657  // and our boundary info object
658  BoundaryInfo &boundary_info = *mesh.boundary_info;
659 
660  // Version 0.9.2+ introduces entity names
661  read_bc_names(io, boundary_info, true); // sideset names
662  read_bc_names(io, boundary_info, false); // nodeset names
663 
664  std::vector<dof_id_type> element_id_list;
665  std::vector<unsigned short int> side_list;
666  std::vector<boundary_id_type> bc_id_list;
667 
668  io.data(element_id_list, "# element ids for bcs");
669  io.data(side_list, "# sides of elements for bcs");
670  io.data(bc_id_list, "# bc ids");
671 
672  for(unsigned int i=0; i<element_id_list.size(); i++)
673  boundary_info.add_side(element_id_list[i], side_list[i], bc_id_list[i]);
674 }
void libMesh::CheckpointIO::read_connectivity ( Xdr io)
private

Read the connectivity for a parallel, distributed mesh

Definition at line 564 of file checkpoint_io.C.

References libMesh::Elem::add_child(), libMesh::MeshBase::add_elem(), libMesh::Elem::build(), libMesh::Xdr::data(), libMesh::Xdr::data_stream(), libMesh::Elem::dim(), libMesh::MeshBase::elem(), libMesh::Elem::hack_p_level(), libMesh::Elem::INACTIVE, libMesh::DofObject::invalid_processor_id, libMesh::Elem::JUST_REFINED, libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshTools::n_active_levels(), n_nodes, libMesh::Elem::n_nodes(), libMesh::MeshBase::node_ptr(), libMesh::ParallelObject::processor_id(), 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 read().

565 {
566  // convenient reference to our mesh
567  MeshBase &mesh = MeshInput<MeshBase>::mesh();
568 
569  unsigned int n_active_levels;
570  io.data(n_active_levels, "# n_active_levels");
571 
572  // Keep track of the highest dimensional element we've added to the mesh
573  unsigned int highest_elem_dim = 1;
574 
575  for(unsigned int level=0; level < n_active_levels; level++)
576  {
577  xdr_id_type n_elem_at_level = 0;
578  io.data (n_elem_at_level, "");
579 
580  for (unsigned int i=0; i<n_elem_at_level; i++)
581  {
582  // id type pid subdomain_id parent_id
583  std::vector<largest_id_type> elem_data(5);
584  io.data_stream(&elem_data[0], elem_data.size(), elem_data.size());
585 
586 #ifdef LIBMESH_ENABLE_UNIQUE_ID
587  largest_id_type unique_id = 0;
588  io.data(unique_id, "# unique id");
589 #endif
590 
591 #ifdef LIBMESH_ENABLE_AMR
592  unsigned int p_level = 0;
593 
594  io.data(p_level, "# p_level");
595 #endif
596 
597  unsigned int n_nodes = Elem::type_to_n_nodes_map[elem_data[1]];
598 
599  // Snag the node ids this element was connected to
600  std::vector<largest_id_type> conn_data(n_nodes);
601  io.data_stream(&conn_data[0], conn_data.size(), conn_data.size());
602 
603  const dof_id_type id = elem_data[0];
604  const ElemType elem_type = static_cast<ElemType>(elem_data[1]);
605  const processor_id_type processor_id = elem_data[2];
606  const subdomain_id_type subdomain_id = elem_data[3];
607  const dof_id_type parent_id = elem_data[4];
608 
609  Elem * parent = (parent_id == DofObject::invalid_processor_id) ? NULL : mesh.elem(parent_id);
610 
611  // Create the element
612  Elem * elem = Elem::build(elem_type, parent).release();
613 
614 #ifdef LIBMESH_ENABLE_UNIQUE_ID
615  elem->set_unique_id() = unique_id;
616 #endif
617 
618  if(elem->dim() > highest_elem_dim)
619  highest_elem_dim = elem->dim();
620 
621  elem->set_id() = id;
622  elem->processor_id() = processor_id;
623  elem->subdomain_id() = subdomain_id;
624 
625 #ifdef LIBMESH_ENABLE_AMR
626  elem->hack_p_level(p_level);
627 
628  // Set parent connections
629  if(parent)
630  {
631  parent->add_child(elem);
632  parent->set_refinement_flag (Elem::INACTIVE);
633  elem->set_refinement_flag (Elem::JUST_REFINED);
634  }
635 #endif
636 
637  libmesh_assert(elem->n_nodes() == conn_data.size());
638 
639  // Connect all the nodes to this element
640  for (unsigned int n=0; n<conn_data.size(); n++)
641  elem->set_node(n) = mesh.node_ptr(conn_data[n]);
642 
643  mesh.add_elem(elem);
644  }
645  }
646 
647  mesh.set_mesh_dimension(highest_elem_dim);
648 }
void libMesh::CheckpointIO::read_nodes ( Xdr io)
private

Read the nodal locations for a parallel, distributed mesh

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

516 {
517  // convenient reference to our mesh
518  MeshBase &mesh = MeshInput<MeshBase>::mesh();
519 
520  unsigned int n_nodes_here;
521  io.data(n_nodes_here, "# n_nodes on proc");
522 
523  // Will hold the node id and pid
524  std::vector<largest_id_type> id_pid(2);
525 
526  // For the coordinates
527  std::vector<Real> coords(LIBMESH_DIM);
528 
529  for(unsigned int i=0; i<n_nodes_here; i++)
530  {
531  io.data_stream(&id_pid[0], 2, 2);
532 
533 #ifdef LIBMESH_ENABLE_UNIQUE_ID
534  largest_id_type unique_id = 0;
535  io.data(unique_id, "# unique id");
536 #endif
537 
538  io.data_stream(&coords[0], LIBMESH_DIM, LIBMESH_DIM);
539 
540  Point p;
541  p(0) = coords[0];
542 
543 #if LIBMESH_DIM > 1
544  p(1) = coords[1];
545 #endif
546 
547 #if LIBMESH_DIM > 2
548  p(2) = coords[2];
549 #endif
550 
551 #ifdef LIBMESH_ENABLE_UNIQUE_ID
552  Node * node =
553 #endif
554  mesh.add_point(p, id_pid[0], id_pid[1]);
555 
556 #ifdef LIBMESH_ENABLE_UNIQUE_ID
557  node->set_unique_id() = unique_id;
558 #endif
559  }
560 }
void libMesh::CheckpointIO::read_nodesets ( Xdr io)
private

Read the nodeset conditions for a parallel, distributed mesh

Definition at line 678 of file checkpoint_io.C.

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

Referenced by read().

679 {
680  // convenient reference to our mesh
681  MeshBase &mesh = MeshInput<MeshBase>::mesh();
682 
683  // and our boundary info object
684  BoundaryInfo &boundary_info = *mesh.boundary_info;
685 
686  std::vector<dof_id_type> node_id_list;
687  std::vector<boundary_id_type> bc_id_list;
688 
689  io.data(node_id_list, "# node id list");
690  io.data(bc_id_list, "# nodeset bc id list");
691 
692  for(unsigned int i=0; i<node_id_list.size(); i++)
693  boundary_info.add_node(node_id_list[i], bc_id_list[i]);
694 }
void libMesh::CheckpointIO::read_subdomain_names ( Xdr io)
private

Read subdomain name information - NEW in 0.9.2 format

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

492 {
493  MeshBase &mesh = MeshInput<MeshBase>::mesh();
494 
495  std::map<subdomain_id_type, std::string> & subdomain_map = mesh.set_subdomain_name_map();
496 
497  std::vector<header_id_type> subdomain_ids; subdomain_ids.reserve(subdomain_map.size());
498  std::vector<std::string> subdomain_names; subdomain_names.reserve(subdomain_map.size());
499 
500  header_id_type n_subdomain_names = 0;
501  io.data(n_subdomain_names, "# subdomain id to name map");
502 
503  if(n_subdomain_names)
504  {
505  io.data(subdomain_ids);
506  io.data(subdomain_names);
507 
508  for(unsigned int i=0; i<subdomain_ids.size(); i++)
509  subdomain_map[subdomain_ids[i]] = subdomain_names[i];
510  }
511 }
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 106 of file checkpoint_io.h.

References _version.

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

Definition at line 107 of file checkpoint_io.h.

References _version.

107 { 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 77 of file checkpoint_io.C.

References _version, libMesh::Parallel::Communicator::barrier(), binary(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMeshEnums::ENCODE, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::Quality::name(), libMesh::ParallelObject::processor_id(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMeshEnums::WRITE, write_bcs(), write_connectivity(), write_nodes(), write_nodesets(), and write_subdomain_names().

78 {
79  START_LOG("write()","CheckpointIO");
80 
81  // convenient reference to our mesh
82  const MeshBase &mesh = MeshOutput<MeshBase>::mesh();
83 
84  // Try to dynamic cast the mesh to see if it's a ParallelMesh object
85  // Note: Just using is_serial() is not good enough because the Mesh won't
86  // have been prepared yet when is when that flag gets set to false... sigh.
87  bool parallel_mesh = dynamic_cast<const ParallelMesh*>(&mesh);
88 
89  // If this is a serial mesh then we're only going to write it on processor 0
90  if(parallel_mesh || this->processor_id() == 0)
91  {
92  std::ostringstream file_name_stream;
93 
94  file_name_stream << name;
95 
96  if(parallel_mesh)
97  file_name_stream << "-" << this->processor_id();
98 
99  Xdr io (file_name_stream.str(), this->binary() ? ENCODE : WRITE);
100 
101  // write the version
102  io.data(_version, "# version");
103 
104  // Write out whether or not this is a serial mesh (helps with error checking on read)
105  {
106  unsigned int parallel = parallel_mesh;
107  io.data(parallel, "# parallel");
108  }
109 
110  // If we're writing out a parallel mesh then we need to write the number of processors
111  // so we can check it upon reading the file
112  if(parallel_mesh)
113  {
114  largest_id_type n_procs = this->n_processors();
115  io.data(n_procs, "# n_procs");
116  }
117 
118  // write subdomain names
119  this->write_subdomain_names(io);
120 
121  // write the nodal locations
122  this->write_nodes (io);
123 
124  // write connectivity
125  this->write_connectivity (io);
126 
127  // write the boundary condition information
128  this->write_bcs (io);
129 
130  // write the nodeset information
131  this->write_nodesets (io);
132 
133  // pause all processes until the writing ends -- this will
134  // protect for the pathological case where a write is
135  // followed immediately by a read. The write must be
136  // guaranteed to complete first.
137  io.close();
138  }
139 
140  this->comm().barrier();
141 
142  STOP_LOG("write()","CheckpointIO");
143 }
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 364 of file checkpoint_io.C.

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

Referenced by write_bcs().

365 {
366  const std::map<boundary_id_type, std::string> & boundary_map = is_sideset ?
367  info.get_sideset_name_map() : info.get_nodeset_name_map();
368 
369  std::vector<boundary_id_type> boundary_ids; boundary_ids.reserve(boundary_map.size());
370  std::vector<std::string> boundary_names; boundary_names.reserve(boundary_map.size());
371 
372  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
373  // return writable references in boundary_info, it's possible for the user to leave some entity names
374  // blank. We can't write those to the XDA file.
375  header_id_type n_boundary_names = 0;
376  std::map<boundary_id_type, std::string>::const_iterator it_end = boundary_map.end();
377  for (std::map<boundary_id_type, std::string>::const_iterator it = boundary_map.begin(); it != it_end; ++it)
378  {
379  if (!it->second.empty())
380  {
381  n_boundary_names++;
382  boundary_ids.push_back(it->first);
383  boundary_names.push_back(it->second);
384  }
385  }
386 
387  if (is_sideset)
388  io.data(n_boundary_names, "# sideset id to name map");
389  else
390  io.data(n_boundary_names, "# nodeset id to name map");
391  // Write out the ids and names in two vectors
392  if (n_boundary_names)
393  {
394  io.data(boundary_ids);
395  io.data(boundary_names);
396  }
397 }
void libMesh::CheckpointIO::write_bcs ( Xdr io) const
private

Write the boundary conditions for a parallel, distributed mesh

Definition at line 316 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(), write_bc_names(), and libMesh::Xdr::writing().

Referenced by write().

317 {
318  libmesh_assert (io.writing());
319 
320  // convenient reference to our mesh
321  const MeshBase &mesh = MeshOutput<MeshBase>::mesh();
322 
323  // and our boundary info object
324  const BoundaryInfo &boundary_info = *mesh.boundary_info;
325 
326  // Version 0.9.2+ introduces entity names
327  write_bc_names(io, boundary_info, true); // sideset names
328  write_bc_names(io, boundary_info, false); // nodeset names
329 
330  std::vector<dof_id_type> element_id_list;
331  std::vector<unsigned short int> side_list;
332  std::vector<boundary_id_type> bc_id_list;
333 
334  boundary_info.build_side_list(element_id_list, side_list, bc_id_list);
335 
336  io.data(element_id_list, "# element ids for bcs");
337  io.data(side_list, "# sides of elements for bcs");
338  io.data(bc_id_list, "# bc ids");
339 }
void libMesh::CheckpointIO::write_connectivity ( Xdr io) const
private

Write the connectivity for a parallel, distributed mesh

Definition at line 236 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::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshTools::n_active_levels(), n_active_levels_on_processor(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::Elem::n_nodes(), libMesh::Elem::node(), 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 write().

237 {
238  libmesh_assert (io.writing());
239 
240  // convenient reference to our mesh
241  const MeshBase &mesh = MeshOutput<MeshBase>::mesh();
242 
243  // We will only write active elements and their parents.
244  unsigned int n_active_levels = n_active_levels_on_processor(mesh);
245 
246  std::vector<xdr_id_type> n_elem_at_level(n_active_levels);
247 
248  // Find the number of elements at each level
249  for (unsigned int level=0; level<n_active_levels; level++)
250  {
251  MeshBase::const_element_iterator it = mesh.level_elements_begin(level);
252  MeshBase::const_element_iterator end = mesh.level_elements_end(level);
253 
254  n_elem_at_level[level] = MeshTools::n_elem(it, end);
255  }
256 
257  typedef std::map<dof_id_type, std::pair<processor_id_type, dof_id_type> > id_map_type;
258  id_map_type parent_id_map, child_id_map;
259 
260  io.data(n_active_levels, "# n_active_levels");
261 
262  for(unsigned int level=0; level < n_active_levels; level++)
263  {
264  std::ostringstream comment;
265  comment << "# n_elem at level ";
266  comment << level ;
267  io.data (n_elem_at_level[level], comment.str().c_str());
268 
269  MeshBase::const_element_iterator it = mesh.level_elements_begin(level);
270  MeshBase::const_element_iterator end = mesh.level_elements_end(level);
271  for (; it != end; ++it)
272  {
273  Elem & elem = *(*it);
274 
275  unsigned int n_nodes = elem.n_nodes();
276 
277  // id type pid subdomain_id parent_id
278  std::vector<largest_id_type> elem_data(5);
279 
280  elem_data[0] = elem.id();
281  elem_data[1] = elem.type();
282  elem_data[2] = elem.processor_id();
283  elem_data[3] = elem.subdomain_id();
284 
285  if(elem.parent() != NULL)
286  elem_data[4] = elem.parent()->id();
287  else
288  elem_data[4] = DofObject::invalid_processor_id;
289 
290  std::vector<largest_id_type> conn_data(n_nodes);
291 
292  for(unsigned int i=0; i<n_nodes; i++)
293  conn_data[i] = elem.node(i);
294 
295  io.data_stream(&elem_data[0], elem_data.size(), elem_data.size());
296 
297 #ifdef LIBMESH_ENABLE_UNIQUE_ID
298  largest_id_type unique_id = elem.unique_id();
299 
300  io.data(unique_id, "# unique id");
301 #endif
302 
303 #ifdef LIBMESH_ENABLE_AMR
304  unsigned int p_level = elem.p_level();
305 
306  io.data(p_level, "# p_level");
307 #endif
308 
309  io.data_stream(&conn_data[0], conn_data.size(), conn_data.size());
310  }
311  }
312 }
virtual void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = NULL 
)
virtualinherited

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

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

Definition at line 98 of file mesh_output.h.

101  { libmesh_error(); }
void libMesh::CheckpointIO::write_nodes ( Xdr io) const
private

Write the nodal locations for a parallel, distributed mesh

Definition at line 184 of file checkpoint_io.C.

References libMesh::Xdr::data(), libMesh::Xdr::data_stream(), end, libMesh::DofObject::id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshTools::n_nodes(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::DofObject::processor_id(), and libMesh::DofObject::unique_id().

Referenced by write().

185 {
186  // convenient reference to our mesh
187  const MeshBase &mesh = MeshOutput<MeshBase>::mesh();
188 
189  MeshBase::const_node_iterator
190  it = mesh.nodes_begin(),
191  end = mesh.nodes_end();
192 
193  unsigned int n_nodes_here = MeshTools::n_nodes(it, end);
194 
195  io.data(n_nodes_here, "# n_nodes on proc");
196 
197  it = mesh.nodes_begin();
198 
199  // Will hold the node id and pid
200  std::vector<largest_id_type> id_pid(2);
201 
202  // For the coordinates
203  std::vector<Real> coords(LIBMESH_DIM);
204 
205  for(; it != end; ++it)
206  {
207  Node & node = *(*it);
208 
209  id_pid[0] = node.id();
210  id_pid[1] = node.processor_id();
211 
212  io.data_stream(&id_pid[0], 2, 2);
213 
214 #ifdef LIBMESH_ENABLE_UNIQUE_ID
215  largest_id_type unique_id = node.unique_id();
216 
217  io.data(unique_id, "# unique id");
218 #endif
219 
220  coords[0] = node(0);
221 
222 #if LIBMESH_DIM > 1
223  coords[1] = node(1);
224 #endif
225 
226 #if LIBMESH_DIM > 2
227  coords[2] = node(2);
228 #endif
229 
230  io.data_stream(&coords[0], LIBMESH_DIM, 3);
231  }
232 }
void libMesh::CheckpointIO::write_nodesets ( Xdr io) const
private

Write the boundary conditions for a parallel, distributed mesh

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

344 {
345  libmesh_assert (io.writing());
346 
347  // convenient reference to our mesh
348  const MeshBase &mesh = MeshOutput<MeshBase>::mesh();
349 
350  // and our boundary info object
351  const BoundaryInfo &boundary_info = *mesh.boundary_info;
352 
353  std::vector<dof_id_type> node_id_list;
354  std::vector<boundary_id_type> bc_id_list;
355 
356  boundary_info.build_node_list(node_id_list, bc_id_list);
357 
358  io.data(node_id_list, "# node id list");
359  io.data(bc_id_list, "# nodeset bc id list");
360 }
void libMesh::CheckpointIO::write_subdomain_names ( Xdr io) const
private

Write subdomain name information - NEW in 0.9.2 format

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

148 {
149  {
150  const MeshBase &mesh = MeshOutput<MeshBase>::mesh();
151 
152  const std::map<subdomain_id_type, std::string> & subdomain_map = mesh.get_subdomain_name_map();
153 
154  std::vector<header_id_type> subdomain_ids; subdomain_ids.reserve(subdomain_map.size());
155  std::vector<std::string> subdomain_names; subdomain_names.reserve(subdomain_map.size());
156 
157  // We need to loop over the map and make sure that there aren't any invalid entries. Since we
158  // return writable references in mesh_base, it's possible for the user to leave some entity names
159  // blank. We can't write those to the XDA file.
160  header_id_type n_subdomain_names = 0;
161  std::map<subdomain_id_type, std::string>::const_iterator it_end = subdomain_map.end();
162  for (std::map<subdomain_id_type, std::string>::const_iterator it = subdomain_map.begin(); it != it_end; ++it)
163  {
164  if (!it->second.empty())
165  {
166  n_subdomain_names++;
167  subdomain_ids.push_back(it->first);
168  subdomain_names.push_back(it->second);
169  }
170  }
171 
172  io.data(n_subdomain_names, "# subdomain id to name map");
173  // Write out the ids and names in two vectors
174  if (n_subdomain_names)
175  {
176  io.data(subdomain_ids);
177  io.data(subdomain_names);
178  }
179  }
180 }

Member Data Documentation

bool libMesh::CheckpointIO::_binary
private

Definition at line 183 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 126 of file mesh_output.h.

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

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

Definition at line 184 of file checkpoint_io.h.

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


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:59 UTC

Hosted By:
SourceForge.net Logo