libMesh::ExodusII_IO Class Reference

#include <exodusII_io.h>

Inheritance diagram for libMesh::ExodusII_IO:

Public Member Functions

 ExodusII_IO (MeshBase &mesh)
 
virtual ~ExodusII_IO ()
 
virtual void read (const std::string &name)
 
virtual void write (const std::string &fname)
 
void verbose (bool set_verbosity)
 
const std::vector< Real > & get_time_steps ()
 
int get_num_time_steps ()
 
void copy_nodal_solution (System &system, std::string var_name, unsigned int timestep=1)
 
void copy_nodal_solution (System &es, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
 
void copy_elemental_solution (System &es, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
 
void write_discontinuous_exodusII (const std::string &name, const EquationSystems &es)
 
void write_element_data (const EquationSystems &es)
 
void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 
void write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 
void write_global_data (const std::vector< Number > &, const std::vector< std::string > &)
 
void write_information_records (const std::vector< std::string > &)
 
void write_timestep (const std::string &fname, const EquationSystems &es, const int timestep, const Real time)
 
void set_output_variables (const std::vector< std::string > &output_variables, bool allow_empty=true)
 
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
 
void set_coordinate_offset (Point p)
 
void append (bool val)
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=NULL)
 
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_nodal_data_common (std::string fname, const std::vector< std::string > &names, bool continuous=true)
 

Private Attributes

ExodusII_IO_Helperexio_helper
 
int _timestep
 
bool _verbose
 
std::vector< std::string > _output_variables
 
bool _append
 
bool _allow_empty_variables
 

Detailed Description

The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs. By default, LibMesh expects ExodusII files to have a ".exd" or ".e" file extension.

Author
Benjamin Kirk, John Peterson, 2004.

Definition at line 52 of file exodusII_io.h.

Constructor & Destructor Documentation

libMesh::ExodusII_IO::ExodusII_IO ( MeshBase mesh)
explicit

Constructor. Takes a writeable reference to a mesh object. This is the constructor required to read a mesh.

Definition at line 40 of file exodusII_io.C.

40  :
41  MeshInput<MeshBase> (mesh),
42  MeshOutput<MeshBase> (mesh),
44 #ifdef LIBMESH_HAVE_EXODUS_API
45  exio_helper(new ExodusII_IO_Helper(*this)),
46 #endif
47  _timestep(1),
48  _verbose(false),
49  _append(false),
51 {
52 }
libMesh::ExodusII_IO::~ExodusII_IO ( )
virtual

Destructor.

Definition at line 89 of file exodusII_io.C.

References libMesh::ExodusII_IO_Helper::close(), and exio_helper.

90 {
91  exio_helper->close();
92  delete exio_helper;
93 }

Member Function Documentation

void libMesh::ExodusII_IO::append ( bool  val)

If true, this flag will cause the ExodusII_IO object to attempt to open an existing file for writing, rather than creating a new file. Obviously this will only work if the file already exists.

Definition at line 373 of file exodusII_io.C.

References _append.

374 {
375  _append = val;
376 }
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().

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(), libMesh::CheckpointIO::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; }
void libMesh::ExodusII_IO::copy_elemental_solution ( System es,
std::string  system_var_name,
std::string  exodus_var_name,
unsigned int  timestep = 1 
)

If we read in a elemental solution while reading in a mesh, we can attempt to copy that elemental solution into an EquationSystems object.

Definition at line 443 of file exodusII_io.C.

References libMeshEnums::CONSTANT, libMesh::DofObject::dof_number(), libMesh::ExodusII_IO_Helper::elem_var_values, libMesh::err, exio_helper, libMesh::MeshInput< MT >::mesh(), libMeshEnums::MONOMIAL, libMesh::System::number(), libMesh::ExodusII_IO_Helper::opened_for_reading, libMesh::ExodusII_IO_Helper::read_elemental_var_values(), libMesh::System::solution, libMesh::System::update(), libMesh::System::variable_number(), and libMesh::System::variable_type().

444 {
446  {
447  libMesh::err << "ERROR, ExodusII file must be opened for reading before copying an elemental solution!" << std::endl;
448  libmesh_error();
449  }
450 
451  exio_helper->read_elemental_var_values(exodus_var_name, timestep);
452 
453  const unsigned int var_num = system.variable_number(system_var_name);
454  if (system.variable_type(var_num) != FEType(CONSTANT, MONOMIAL))
455  {
456  libMesh::err << "Error! Trying to copy elemental solution into a variable that is not of CONSTANT MONOMIAL type. " << std::endl;
457  libmesh_error();
458  }
459 
460  for (unsigned int i=0; i<exio_helper->elem_var_values.size(); ++i)
461  {
462  const Elem * elem = MeshInput<MeshBase>::mesh().query_elem(i);
463 
464  if (!elem)
465  {
466  libMesh::err << "Error! Mesh returned NULL pointer for elem " << i << std::endl;
467  libmesh_error();
468  }
469 
470  dof_id_type dof_index = elem->dof_number(system.number(), var_num, 0);
471 
472  // If the dof_index is local to this processor, set the value
473  if ((dof_index >= system.solution->first_local_index()) && (dof_index < system.solution->last_local_index()))
474  system.solution->set (dof_index, exio_helper->elem_var_values[i]);
475  }
476 
477  system.solution->close();
478  system.update();
479 }
void libMesh::ExodusII_IO::copy_nodal_solution ( System system,
std::string  var_name,
unsigned int  timestep = 1 
)

Backward compatibility version of function that takes a single variable name

Definition at line 63 of file exodusII_io.C.

64 {
65  libmesh_deprecated();
66  copy_nodal_solution(system, var_name, var_name, timestep);
67 }
void libMesh::ExodusII_IO::copy_nodal_solution ( System es,
std::string  system_var_name,
std::string  exodus_var_name,
unsigned int  timestep = 1 
)

If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution into an EquationSystems object.

Definition at line 408 of file exodusII_io.C.

References libMesh::DofObject::dof_number(), libMesh::err, exio_helper, libMesh::MeshInput< MT >::mesh(), libMesh::ExodusII_IO_Helper::nodal_var_values, libMesh::System::number(), libMesh::ExodusII_IO_Helper::opened_for_reading, libMesh::ExodusII_IO_Helper::read_nodal_var_values(), libMesh::System::solution, libMesh::System::update(), and libMesh::System::variable_number().

409 {
411  {
412  libMesh::err << "ERROR, ExodusII file must be opened for reading before copying a nodal solution!" << std::endl;
413  libmesh_error();
414  }
415 
416  exio_helper->read_nodal_var_values(exodus_var_name, timestep);
417 
418  const unsigned int var_num = system.variable_number(system_var_name);
419 
420  for (unsigned int i=0; i<exio_helper->nodal_var_values.size(); ++i)
421  {
422  const Node* node = MeshInput<MeshBase>::mesh().query_node_ptr(i);
423 
424  if (!node)
425  {
426  libMesh::err << "Error! Mesh returned NULL pointer for node " << i << std::endl;
427  libmesh_error();
428  }
429 
430  dof_id_type dof_index = node->dof_number(system.number(), var_num, 0);
431 
432  // If the dof_index is local to this processor, set the value
433  if ((dof_index >= system.solution->first_local_index()) && (dof_index < system.solution->last_local_index()))
434  system.solution->set (dof_index, exio_helper->nodal_var_values[i]);
435  }
436 
437  system.solution->close();
438  system.update();
439 }
int libMesh::ExodusII_IO::get_num_time_steps ( )

Returns the number of timesteps currently stored in the Exodus file. Knowing the number of time steps currently stored in the file is sometimes necessary when appending, so we can know where to start writing new data. Throws an error if the file is not currently open for reading or writing.

Definition at line 394 of file exodusII_io.C.

References libMesh::err, exio_helper, libMesh::ExodusII_IO_Helper::num_time_steps, libMesh::ExodusII_IO_Helper::opened_for_reading, libMesh::ExodusII_IO_Helper::opened_for_writing, and libMesh::ExodusII_IO_Helper::read_num_time_steps().

395 {
397  {
398  libMesh::err << "ERROR, ExodusII file must be opened for reading or writing before calling ExodusII_IO::get_num_time_steps()!" << std::endl;
399  libmesh_error();
400  }
401 
403  return exio_helper->num_time_steps;
404 }
const std::vector< Real > & libMesh::ExodusII_IO::get_time_steps ( )

Returns an array containing the timesteps in the file

Definition at line 380 of file exodusII_io.C.

References libMesh::err, exio_helper, libMesh::ExodusII_IO_Helper::opened_for_reading, libMesh::ExodusII_IO_Helper::read_time_steps(), and libMesh::ExodusII_IO_Helper::time_steps.

381 {
383  {
384  libMesh::err << "ERROR, ExodusII file must be opened for reading before calling ExodusII_IO::get_time_steps()!" << std::endl;
385  libmesh_error();
386  }
387 
389  return exio_helper->time_steps;
390 }
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(), read(), libMesh::Nemesis_IO::read(), libMesh::GMVIO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::VTKIO::read(), libMesh::LegacyXdrIO::read_ascii(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::UCDIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::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(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::TetGenIO::write(), write(), libMesh::Nemesis_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::CheckpointIO::write_bcs(), libMesh::GMVIO::write_binary(), libMesh::CheckpointIO::write_connectivity(), libMesh::GMVIO::write_discontinuous_gmv(), 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(), write_nodal_data(), write_nodal_data_common(), write_nodal_data_discontinuous(), libMesh::CheckpointIO::write_nodes(), libMesh::CheckpointIO::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 libMesh::CheckpointIO::write_subdomain_names().

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(), libMesh::CheckpointIO::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(), libMesh::CheckpointIO::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(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), libMesh::CheckpointIO::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(), write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements_discontinuous(), write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), 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(), write_nodal_data(), 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(), write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
void libMesh::ExodusII_IO::read ( const std::string &  name)
virtual

This method implements reading a mesh from a specified file. Open the file named name and read the mesh in Sandia National Lab's ExodusII format. This is the method to use for reading in meshes generated by cubit. Works in 2D for TRIs, TRI6s, QUAD s, and QUAD9s. Works in 3D for TET4s, TET10s, HEX8s, and HEX27s.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 97 of file exodusII_io.C.

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), libMesh::MeshBase::boundary_info, libMesh::Elem::build(), libMesh::MeshBase::clear(), libMesh::ExodusII_IO_Helper::connect, libMesh::Elem::dim(), libMesh::MeshBase::elem(), libMesh::ExodusII_IO_Helper::elem_list, libMesh::ExodusII_IO_Helper::elem_num_map, libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::err, exio_helper, libMesh::ExodusII_IO_Helper::get_block_id(), libMesh::ExodusII_IO_Helper::get_block_name(), libMesh::ExodusII_IO_Helper::get_elem_type(), libMesh::ExodusII_IO_Helper::get_node_set_name(), libMesh::ExodusII_IO_Helper::Conversion::get_side_map(), libMesh::ExodusII_IO_Helper::get_side_set_id(), libMesh::ExodusII_IO_Helper::get_side_set_name(), libMesh::DofObject::id(), libMesh::ExodusII_IO_Helper::id_list, libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::ExodusII_IO_Helper::node_list, libMesh::ExodusII_IO_Helper::node_num_map, libMesh::MeshBase::node_ptr(), libMesh::ExodusII_IO_Helper::nodeset_ids, libMesh::ExodusII_IO_Helper::num_elem, libMesh::ExodusII_IO_Helper::num_elem_blk, libMesh::ExodusII_IO_Helper::num_elem_this_blk, libMesh::ExodusII_IO_Helper::num_node_sets, libMesh::ExodusII_IO_Helper::num_nodes, libMesh::ExodusII_IO_Helper::num_nodes_per_elem, libMesh::ExodusII_IO_Helper::num_side_sets, libMesh::ExodusII_IO_Helper::num_sides_per_set, libMesh::ExodusII_IO_Helper::open(), libMesh::ExodusII_IO_Helper::print_header(), libMesh::ExodusII_IO_Helper::read_block_info(), libMesh::ExodusII_IO_Helper::read_elem_in_block(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_header(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::ExodusII_IO_Helper::read_nodes(), libMesh::ExodusII_IO_Helper::read_nodeset(), libMesh::ExodusII_IO_Helper::read_nodeset_info(), libMesh::ExodusII_IO_Helper::read_sideset(), libMesh::ExodusII_IO_Helper::read_sideset_info(), libMesh::MeshBase::reserve_elem(), libMesh::MeshBase::reserve_nodes(), libMesh::DofObject::set_id(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::ExodusII_IO_Helper::side_list, libMesh::Elem::subdomain_id(), libMesh::MeshBase::subdomain_name(), libMesh::Elem::type(), verbose(), libMesh::ExodusII_IO_Helper::x, libMesh::ExodusII_IO_Helper::y, and libMesh::ExodusII_IO_Helper::z.

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

98 {
99  // Get a reference to the mesh we are reading
100  MeshBase& mesh = MeshInput<MeshBase>::mesh();
101 
102  // Clear any existing mesh data
103  mesh.clear();
104 
105  // Keep track of what kinds of elements this file contains
106  elems_of_dimension.clear();
107  elems_of_dimension.resize(4, false);
108 
109 #ifdef DEBUG
110  this->verbose(true);
111 #endif
112 
113  // Instantiate the ElementMaps interface
114  ExodusII_IO_Helper::ElementMaps em;
115 
116  // Open the exodus file in EX_READ mode
117  exio_helper->open(fname.c_str(), /*read_only=*/true);
118 
119  // Get header information from exodus file
121 
122  // Print header information
124 
125  // Read nodes from the exodus file
127 
128  // Reserve space for the nodes.
129  mesh.reserve_nodes(exio_helper->num_nodes);
130 
131  // Read the node number map from the Exodus file. This is
132  // required if we want to preserve the numbering of nodes as it
133  // exists in the Exodus file. If the Exodus file does not contain
134  // a node_num_map, the identity map is returned by this call.
136 
137  // Loop over the nodes, create Nodes with local processor_id 0.
138  for (int i=0; i<exio_helper->num_nodes; i++)
139  {
140  // Use the node_num_map to get the correct ID for Exodus
141  int exodus_id = exio_helper->node_num_map[i];
142 
143  // Catch the node that was added to the mesh
144  Node* added_node = mesh.add_point (Point(exio_helper->x[i], exio_helper->y[i], exio_helper->z[i]), exodus_id-1);
145 
146  // If the Mesh assigned an ID different from what is in the
147  // Exodus file, we should probably error.
148  if (added_node->id() != static_cast<unsigned>(exodus_id-1))
149  {
150  libMesh::err << "Error! Mesh assigned node ID "
151  << added_node->id()
152  << " which is different from the (zero-based) Exodus ID "
153  << exodus_id-1
154  << "!"
155  << std::endl;
156  libmesh_error();
157  }
158  }
159 
160  // This assert is no longer valid if the nodes are not numbered
161  // sequentially starting from 1 in the Exodus file.
162  // libmesh_assert_equal_to (static_cast<unsigned int>(exio_helper->num_nodes), mesh.n_nodes());
163 
164  // Get information about all the blocks
166 
167  // Reserve space for the elements
168  mesh.reserve_elem(exio_helper->num_elem);
169 
170  // Read the element number map from the Exodus file. This is
171  // required if we want to preserve the numbering of elements as it
172  // exists in the Exodus file. If the Exodus file does not contain
173  // an elem_num_map, the identity map is returned by this call.
175 
176  // Read in the element connectivity for each block.
177  int nelem_last_block = 0;
178 
179  // Loop over all the blocks
180  for (int i=0; i<exio_helper->num_elem_blk; i++)
181  {
182  // Read the information for block i
184  int subdomain_id = exio_helper->get_block_id(i);
185 
186  // populate the map of names
187  std::string subdomain_name = exio_helper->get_block_name(i);
188  if (!subdomain_name.empty())
189  mesh.subdomain_name(static_cast<subdomain_id_type>(subdomain_id)) = subdomain_name;
190 
191  // Set any relevant node/edge maps for this element
192  const std::string type_str (exio_helper->get_elem_type());
193  const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(type_str);
194 
195  // Loop over all the faces in this block
196  int jmax = nelem_last_block+exio_helper->num_elem_this_blk;
197  for (int j=nelem_last_block; j<jmax; j++)
198  {
199  Elem* elem = Elem::build (conv.get_canonical_type()).release();
200  libmesh_assert (elem);
201  elem->subdomain_id() = static_cast<subdomain_id_type>(subdomain_id) ;
202 
203  // Use the elem_num_map to obtain the ID of this element in the Exodus file
204  int exodus_id = exio_helper->elem_num_map[j];
205 
206  // Assign this element the same ID it had in the Exodus
207  // file, but make it zero-based by subtracting 1. Note:
208  // some day we could use 1-based numbering in libmesh and
209  // thus match the Exodus numbering exactly, but at the
210  // moment libmesh is zero-based.
211  elem->set_id(exodus_id-1);
212 
213  // Record that we have seen an element of dimension elem->dim()
214  elems_of_dimension[elem->dim()] = true;
215 
216  // Catch the Elem pointer that the Mesh throws back
217  elem = mesh.add_elem (elem);
218 
219  // If the Mesh assigned an ID different from what is in the
220  // Exodus file, we should probably error.
221  if (elem->id() != static_cast<unsigned>(exodus_id-1))
222  {
223  libMesh::err << "Error! Mesh assigned ID "
224  << elem->id()
225  << " which is different from the (zero-based) Exodus ID "
226  << exodus_id-1
227  << "!"
228  << std::endl;
229  libmesh_error();
230  }
231 
232  // Set all the nodes for this element
233  for (int k=0; k<exio_helper->num_nodes_per_elem; k++)
234  {
235  // global index
236  int gi = (j-nelem_last_block)*exio_helper->num_nodes_per_elem + conv.get_node_map(k);
237 
238  // The entries in 'connect' are actually (1-based)
239  // indices into the node_num_map, so to get the right
240  // node ID we:
241  // 1.) Subtract 1 from connect[gi]
242  // 2.) Pass it through node_num_map to get the corresponding Exodus ID
243  // 3.) Subtract 1 from that, since libmesh node numbering is "zero"-based,
244  // even when the Exodus node numbering doesn't start with 1.
245  int libmesh_node_id = exio_helper->node_num_map[exio_helper->connect[gi] - 1] - 1;
246 
247  // Set the node pointer in the Elem
248  elem->set_node(k) = mesh.node_ptr(libmesh_node_id);
249  }
250  }
251 
252  // running sum of # of elements per block,
253  // (should equal total number of elements in the end)
254  nelem_last_block += exio_helper->num_elem_this_blk;
255  }
256 
257  // This assert isn't valid if the Exodus file's numbering doesn't
258  // start with 1! For example, if Exodus's elem_num_map is 21, 22,
259  // 23, 24, 25, 26, 27, 28, 29, 30, ... 84, then by the time you are
260  // done with the loop above, mesh.n_elem() will report 84 and
261  // nelem_last_block will be 64.
262  // libmesh_assert_equal_to (static_cast<unsigned>(nelem_last_block), mesh.n_elem());
263 
264  // Set the mesh dimension to the largest encountered for an element
265  for (unsigned int i=0; i!=4; ++i)
266  if (elems_of_dimension[i])
267  mesh.set_mesh_dimension(i);
268 
269  // Read in sideset information -- this is useful for applying boundary conditions
270  {
271  // Get basic information about all sidesets
273  int offset=0;
274  for (int i=0; i<exio_helper->num_side_sets; i++)
275  {
276  // Compute new offset
277  offset += (i > 0 ? exio_helper->num_sides_per_set[i-1] : 0);
278  exio_helper->read_sideset (i, offset);
279 
280  std::string sideset_name = exio_helper->get_side_set_name(i);
281  if (!sideset_name.empty())
282  mesh.boundary_info->sideset_name(exio_helper->get_side_set_id(i)) = sideset_name;
283  }
284 
285  for (unsigned int e=0; e<exio_helper->elem_list.size(); e++)
286  {
287  // The numbers in the Exodus file sidesets should be thought
288  // of as (1-based) indices into the elem_num_map array. So,
289  // to get the right element ID we have to:
290  // 1.) Subtract 1 from elem_list[e] (to get a zero-based index)
291  // 2.) Pass it through elem_num_map (to get the corresponding Exodus ID)
292  // 3.) Subtract 1 from that, since libmesh is "zero"-based,
293  // even when the Exodus numbering doesn't start with 1.
294  int libmesh_elem_id = exio_helper->elem_num_map[exio_helper->elem_list[e] - 1] - 1;
295 
296  // Set any relevant node/edge maps for this element
297  Elem * elem = mesh.elem(libmesh_elem_id);
298 
299  const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(elem->type());
300 
301  // Add this (elem,side,id) triplet to the BoundaryInfo object.
302  mesh.boundary_info->add_side (libmesh_elem_id,
303  conv.get_side_map(exio_helper->side_list[e]-1),
304  exio_helper->id_list[e]);
305  }
306  }
307 
308  // Read nodeset info
309  {
311 
312  for (int nodeset=0; nodeset<exio_helper->num_node_sets; nodeset++)
313  {
314  int nodeset_id = exio_helper->nodeset_ids[nodeset];
315 
316  std::string nodeset_name = exio_helper->get_node_set_name(nodeset);
317  if (!nodeset_name.empty())
318  mesh.boundary_info->nodeset_name(nodeset_id) = nodeset_name;
319 
320  exio_helper->read_nodeset(nodeset);
321 
322  for (unsigned int node=0; node<exio_helper->node_list.size(); node++)
323  {
324  // As before, the entries in 'node_list' are 1-based
325  // indcies into the node_num_map array, so we have to map
326  // them. See comment above.
327  int libmesh_node_id = exio_helper->node_num_map[exio_helper->node_list[node] - 1] - 1;
328  mesh.boundary_info->add_node(libmesh_node_id, nodeset_id);
329  }
330  }
331  }
332 
333 #if LIBMESH_DIM < 3
334  if (mesh.mesh_dimension() > LIBMESH_DIM)
335  {
336  libMesh::err << "Cannot open dimension " <<
337  mesh.mesh_dimension() <<
338  " mesh file when configured without " <<
339  mesh.mesh_dimension() << "D support." <<
340  std::endl;
341  libmesh_error();
342  }
343 #endif
344 }
void libMesh::ExodusII_IO::set_coordinate_offset ( Point  p)

Allows you to set a vector that is added to the coordinates of all of the nodes. Effectively, this "moves" the mesh to a particular position

Definition at line 365 of file exodusII_io.C.

References exio_helper, and libMesh::ExodusII_IO_Helper::set_coordinate_offset().

366 {
367  libmesh_deprecated();
369 }
void libMesh::ExodusII_IO::set_output_variables ( const std::vector< std::string > &  output_variables,
bool  allow_empty = true 
)

Sets the list of variable names to be included in the output. This is optional. If this is never called then all variables will be present. If this is called and an empty vector is supplied no variables will be output. Setting the allow_empty = false will result in empty vectors supplied here to also be populated with all variables.

Definition at line 55 of file exodusII_io.C.

References _allow_empty_variables, and _output_variables.

56 {
57  _output_variables = output_variables;
58  _allow_empty_variables = allow_empty;
59 }
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().

void libMesh::ExodusII_IO::use_mesh_dimension_instead_of_spatial_dimension ( bool  val)

In the general case, meshes containing 2D elements can be manifolds living in 3D space, thus by default we write all meshes with the Exodus dimension set to LIBMESH_DIM = mesh.spatial_dimension().

In certain cases, however, the user may know his 2D mesh actually lives in the z=0 plane, and therefore wants to write a truly 2D Exodus mesh. In such a case, he should call this function with val=true.

Definition at line 358 of file exodusII_io.C.

References exio_helper, and libMesh::ExodusII_IO_Helper::use_mesh_dimension_instead_of_spatial_dimension().

void libMesh::ExodusII_IO::verbose ( bool  set_verbosity)

Set the flag indicating if we should be verbose.

Definition at line 348 of file exodusII_io.C.

References _verbose, exio_helper, and libMesh::ExodusII_IO_Helper::verbose.

Referenced by read().

349 {
350  _verbose = set_verbosity;
351 
352  // Set the verbose flag in the helper object as well.
354 }
void libMesh::ExodusII_IO::write ( const std::string &  fname)
virtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 653 of file exodusII_io.C.

References _append, _verbose, libMesh::MeshBase::boundary_info, libMesh::ExodusII_IO_Helper::create(), exio_helper, libMesh::ExodusII_IO_Helper::initialize(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ExodusII_IO_Helper::opened_for_writing, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodesets(), and libMesh::ExodusII_IO_Helper::write_sidesets().

Referenced by libMesh::ErrorVector::plot_error(), and libMesh::UnstructuredMesh::write().

654 {
655  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
656 
657  // We may need to gather a ParallelMesh to output it, making that
658  // const qualifier in our constructor a dirty lie
659  MeshSerializer serialize(const_cast<MeshBase&>(mesh), !MeshOutput<MeshBase>::_is_parallel_format);
660 
662 
663  // If the user has set the append flag here, it doesn't really make
664  // sense: the intent of this function is to write a Mesh with no
665  // data, while "appending" is really intended to add data to an
666  // existing file. If we're verbose, print a message to this effect.
667  if (_append && _verbose)
668  libMesh::out << "Warning: Appending in ExodusII_IO::write() does not make sense.\n"
669  << "Creating a new file instead!"
670  << std::endl;
671 
672  exio_helper->create(fname);
673  exio_helper->initialize(fname,mesh);
678 
680  return;
681 
682  if( (mesh.boundary_info->n_edge_conds() > 0) &&
683  _verbose )
684  {
685  libMesh::out << "Warning: Mesh contains edge boundary IDs, but these "
686  << "are not supported by the ExodusII format."
687  << std::endl;
688  }
689 }
void libMesh::ExodusII_IO::write_discontinuous_exodusII ( const std::string &  name,
const EquationSystems es 
)

Writes a exodusII file with discontinuous data

Definition at line 71 of file exodusII_io.C.

References libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_variable_names(), and write_nodal_data_discontinuous().

72 {
73  std::vector<std::string> solution_names;
74  std::vector<Number> v;
75 
76  es.build_variable_names (solution_names);
77  es.build_discontinuous_solution_vector (v);
78 
79  this->write_nodal_data_discontinuous(name, v, solution_names);
80 }
void libMesh::ExodusII_IO::write_element_data ( const EquationSystems es)

Write out element solution.

Definition at line 483 of file exodusII_io.C.

References _output_variables, _timestep, libMesh::EquationSystems::build_variable_names(), libMeshEnums::CONSTANT, libMesh::err, exio_helper, libMesh::EquationSystems::get_solution(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMeshEnums::MONOMIAL, libMesh::ExodusII_IO_Helper::opened_for_writing, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::write_element_values().

Referenced by libMesh::ErrorVector::plot_error().

484 {
485  // Be sure the file has been opened for writing!
487  {
488  libMesh::err << "ERROR, ExodusII file must be initialized "
489  << "before outputting element variables.\n"
490  << std::endl;
491  libmesh_error();
492  }
493 
494  // This function currently only works on SerialMeshes. We rely on
495  // having a reference to a non-const MeshBase object from our
496  // MeshInput parent class to construct a MeshSerializer object,
497  // similar to what is done in ExodusII_IO::write(). Note that
498  // calling ExodusII_IO::write_timestep() followed by
499  // ExodusII_IO::write_element_data() when the underlying Mesh is a
500  // ParallelMesh will result in an unnecessary additional
501  // serialization/re-parallelization step.
503 
504  // To be (possibly) filled with a filtered list of variable names to output.
505  std::vector<std::string> names;
506 
507  // If _output_variables is populated, only output the monomials which are
508  // also in the _output_variables vector.
509  if (_output_variables.size() > 0)
510  {
511  std::vector<std::string> monomials;
512  const FEType type(CONSTANT, MONOMIAL);
513 
514  // Create a list of monomial variable names
515  es.build_variable_names(monomials, &type);
516 
517  // Filter that list against the _output_variables list. Note: if names is still empty after
518  // all this filtering, all the monomial variables will be gathered
519  std::vector<std::string>::iterator it = monomials.begin();
520  for (; it!=monomials.end(); ++it)
521  if (std::find(_output_variables.begin(), _output_variables.end(), *it) != _output_variables.end())
522  names.push_back(*it);
523  }
524 
525  // If we pass in a list of names to "get_solution" it'll filter the variables coming back
526  std::vector<Number> soln;
527  es.get_solution(soln, names);
528 
529  if(soln.empty()) // If there is nothing to write just return
530  return;
531 
532  // The data must ultimately be written block by block. This means that this data
533  // must be sorted appropriately.
535  return;
536 
537  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
538 
541 }
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 write_timestep().

void libMesh::ExodusII_IO::write_global_data ( const std::vector< Number > &  soln,
const std::vector< std::string > &  names 
)

Write out global variables.

Definition at line 617 of file exodusII_io.C.

References _timestep, libMesh::err, exio_helper, libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::opened_for_writing, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::write_global_values().

619 {
621  return;
622 
624  {
625  libMesh::err << "ERROR, ExodusII file must be initialized "
626  << "before outputting global variables.\n"
627  << std::endl;
628  libmesh_error();
629  }
630 
633 }
void libMesh::ExodusII_IO::write_information_records ( const std::vector< std::string > &  records)

Write out information records.

Definition at line 599 of file exodusII_io.C.

References libMesh::err, exio_helper, libMesh::ExodusII_IO_Helper::opened_for_writing, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::write_information_records().

600 {
602  return;
603 
605  {
606  libMesh::err << "ERROR, ExodusII file must be initialized "
607  << "before outputting information records.\n"
608  << std::endl;
609  libmesh_error();
610  }
611 
613 }
void libMesh::ExodusII_IO::write_nodal_data ( const std::string &  fname,
const std::vector< Number > &  soln,
const std::vector< std::string > &  names 
)
virtual

Write out a nodal solution.

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 545 of file exodusII_io.C.

References _allow_empty_variables, _output_variables, _timestep, exio_helper, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::n_nodes(), libMesh::ParallelObject::processor_id(), libMesh::START_LOG(), libMesh::STOP_LOG(), write_nodal_data_common(), and libMesh::ExodusII_IO_Helper::write_nodal_values().

548 {
549  START_LOG("write_nodal_data()", "ExodusII_IO");
550 
551  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
552 
553  int num_vars = libmesh_cast_int<int>(names.size());
554  dof_id_type num_nodes = mesh.n_nodes();
555 
556  // The names of the variables to be output
557  std::vector<std::string> output_names;
558 
560  output_names = _output_variables;
561  else
562  output_names = names;
563 
564  // Call helper function for opening/initializing data
565  this->write_nodal_data_common(fname, output_names, /*continuous=*/true);
566 
567  if(mesh.processor_id())
568  {
569  STOP_LOG("write_nodal_data()", "ExodusII_IO");
570  return;
571  }
572 
573  // This will count the number of variables actually output
574  for (int c=0; c<num_vars; c++)
575  {
576  std::vector<std::string>::iterator pos =
577  std::find(output_names.begin(), output_names.end(), names[c]);
578  if (pos == output_names.end())
579  continue;
580 
581  unsigned int variable_name_position =
582  libmesh_cast_int<unsigned int>(pos - output_names.begin());
583 
584  std::vector<Number> cur_soln(num_nodes);
585 
586  // Copy out this variable's solution
587  for(dof_id_type i=0; i<num_nodes; i++)
588  cur_soln[i] = soln[i*num_vars + c];
589 
590  exio_helper->write_nodal_values(variable_name_position+1,cur_soln,_timestep);
591  }
592 
593  STOP_LOG("write_nodal_data()", "ExodusII_IO");
594 }
void libMesh::ExodusII_IO::write_nodal_data_common ( std::string  fname,
const std::vector< std::string > &  names,
bool  continuous = true 
)
private

This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_data_discontinuous() functions

Definition at line 733 of file exodusII_io.C.

References _append, _verbose, libMesh::MeshBase::boundary_info, libMesh::ExodusII_IO_Helper::create(), libMesh::ExodusII_IO_Helper::current_filename, libMesh::err, exio_helper, libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ExodusII_IO_Helper::open(), libMesh::ExodusII_IO_Helper::opened_for_writing, libMesh::out, libMesh::ExodusII_IO_Helper::read_block_info(), libMesh::ExodusII_IO_Helper::read_header(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodesets(), and libMesh::ExodusII_IO_Helper::write_sidesets().

Referenced by write_nodal_data(), and write_nodal_data_discontinuous().

736 {
737  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
738 
739  // This function can be called multiple times, we only want to open
740  // the ExodusII file the first time it's called.
742  {
743  // If we're appending, open() the file with read_only=false,
744  // otherwise create() it and write the contents of the mesh to
745  // it.
746  if (_append)
747  {
748  exio_helper->open(fname.c_str(), /*read_only=*/false);
749  // If we're appending, it's not valid to call exio_helper->initialize()
750  // or exio_helper->initialize_nodal_variables(), but we do need to set up
751  // certain aspects of the Helper object itself, such as the number of nodes
752  // and elements. We do that by reading the header...
754 
755  // ...and reading the block info
757  }
758  else
759  {
760  exio_helper->create(fname);
761 
762  if (continuous)
763  {
764  exio_helper->initialize(fname,mesh);
767  }
768  else
769  {
773  }
776 
777  if( (mesh.boundary_info->n_edge_conds() > 0) &&
778  _verbose )
779  {
780  libMesh::out << "Warning: Mesh contains edge boundary IDs, but these "
781  << "are not supported by the ExodusII format."
782  << std::endl;
783  }
784 
786  }
787  }
788  else
789  {
790  // We are already open for writing, so check that the filename
791  // passed to this function matches the filename currently in use
792  // by the helper.
793  if (fname != exio_helper->current_filename)
794  {
795  libMesh::err << "Error! This ExodusII_IO object is already associated with file: "
797  << ", cannot use it with requested file: "
798  << fname
799  << std::endl;
800  libmesh_error();
801  }
802  }
803 }
void libMesh::ExodusII_IO::write_nodal_data_discontinuous ( const std::string &  fname,
const std::vector< Number > &  soln,
const std::vector< std::string > &  names 
)

Write out a discontinuous nodal solution.

Definition at line 693 of file exodusII_io.C.

References _timestep, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), end, exio_helper, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::processor_id(), libMesh::START_LOG(), libMesh::STOP_LOG(), write_nodal_data_common(), and libMesh::ExodusII_IO_Helper::write_nodal_values().

Referenced by write_discontinuous_exodusII().

696 {
697  START_LOG("write_nodal_data_discontinuous()", "ExodusII_IO");
698 
699  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
700 
701  int num_vars = libmesh_cast_int<int>(names.size());
702  int num_nodes = 0;
703  MeshBase::const_element_iterator it = mesh.active_elements_begin();
704  const MeshBase::const_element_iterator end = mesh.active_elements_end();
705  for ( ; it != end; ++it)
706  num_nodes += (*it)->n_nodes();
707 
708  // Call helper function for opening/initializing data
709  this->write_nodal_data_common(fname, names, /*continuous=*/false);
710 
711  if (mesh.processor_id())
712  {
713  STOP_LOG("write_nodal_data_discontinuous()", "ExodusII_IO");
714  return;
715  }
716 
717  for (int c=0; c<num_vars; c++)
718  {
719  // Copy out this variable's solution
720  std::vector<Number> cur_soln(num_nodes);
721 
722  for(int i=0; i<num_nodes; i++)
723  cur_soln[i] = soln[i*num_vars + c];
724 
726  }
727 
728  STOP_LOG("write_nodal_data_discontinuous()", "ExodusII_IO");
729 }
void libMesh::ExodusII_IO::write_timestep ( const std::string &  fname,
const EquationSystems es,
const int  timestep,
const Real  time 
)

Writes out the solution at a specific timestep.

Parameters
timestepThe timestep to write out, should be 1 indexed.

Definition at line 637 of file exodusII_io.C.

References _timestep, exio_helper, libMesh::ParallelObject::processor_id(), libMesh::MeshOutput< MeshBase >::write_equation_systems(), and libMesh::ExodusII_IO_Helper::write_timestep().

641 {
642  _timestep = timestep;
643  write_equation_systems(fname,es);
644 
646  return;
647 
648  exio_helper->write_timestep(timestep, time);
649 }

Member Data Documentation

bool libMesh::ExodusII_IO::_allow_empty_variables
private

If true, _output_variables is allowed to remain empty. If false, if _output_variables is empty it will be populated with a complete list of all variables By default, calling set_output_variables() sets this flag to true, but it provides an override.

Definition at line 246 of file exodusII_io.h.

Referenced by set_output_variables(), and write_nodal_data().

bool libMesh::ExodusII_IO::_append
private

Default false. If true, files will be opened with EX_WRITE rather than created from scratch when writing.

Definition at line 231 of file exodusII_io.h.

Referenced by append(), write(), and write_nodal_data_common().

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::vector<std::string> libMesh::ExodusII_IO::_output_variables
private

The names of the variables to be output. If this is empty then all variables are output.

Definition at line 225 of file exodusII_io.h.

Referenced by set_output_variables(), write_element_data(), and write_nodal_data().

int libMesh::ExodusII_IO::_timestep
private

Stores the current value of the timestep when calling ExodusII_IO::write_timestep().

Definition at line 214 of file exodusII_io.h.

Referenced by write_element_data(), write_global_data(), write_nodal_data(), write_nodal_data_discontinuous(), and write_timestep().

bool libMesh::ExodusII_IO::_verbose
private

should we be verbose?

Definition at line 219 of file exodusII_io.h.

Referenced by verbose(), write(), and write_nodal_data_common().

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited
ExodusII_IO_Helper* libMesh::ExodusII_IO::exio_helper
private

Only attempt to instantiate an ExodusII helper class if the Exodus API is defined. This class will have no functionality when LIBMESH_HAVE_EXODUS_API is not defined.

Definition at line 207 of file exodusII_io.h.

Referenced by copy_elemental_solution(), copy_nodal_solution(), get_num_time_steps(), get_time_steps(), read(), set_coordinate_offset(), use_mesh_dimension_instead_of_spatial_dimension(), verbose(), write(), write_element_data(), write_global_data(), write_information_records(), write_nodal_data(), write_nodal_data_common(), write_nodal_data_discontinuous(), write_timestep(), and ~ExodusII_IO().


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:00 UTC

Hosted By:
SourceForge.net Logo