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

The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs. More...

#include <exodusII_io.h>

Inheritance diagram for libMesh::ExodusII_IO:
[legend]

Public Member Functions

 ExodusII_IO (MeshBase &mesh, bool single_precision=false)
 Constructor. More...
 
virtual ~ExodusII_IO ()
 Destructor. More...
 
virtual void read (const std::string &name) libmesh_override
 This method implements reading a mesh from a specified file. More...
 
virtual void write (const std::string &fname) libmesh_override
 This method implements writing a mesh to a specified file. More...
 
void verbose (bool set_verbosity)
 Set the flag indicating if we should be verbose. More...
 
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)
 Backward compatibility version of function that takes a single variable name. More...
 
void copy_nodal_solution (System &system, 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. More...
 
void copy_elemental_solution (System &system, 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. More...
 
void write_discontinuous_exodusII (const std::string &name, const EquationSystems &es, const std::set< std::string > *system_names=libmesh_nullptr)
 Writes a exodusII file with discontinuous data. More...
 
void write_element_data (const EquationSystems &es)
 Write out element solution. More...
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) libmesh_override
 Write out a nodal solution. More...
 
void write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 Write out a discontinuous nodal solution. More...
 
void write_global_data (const std::vector< Number > &, const std::vector< std::string > &)
 Write out global variables. More...
 
void write_information_records (const std::vector< std::string > &)
 Write out information records. More...
 
void write_timestep (const std::string &fname, const EquationSystems &es, const int timestep, const Real time)
 Writes out the solution at a specific timestep. More...
 
void 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. More...
 
void 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(). More...
 
void write_as_dimension (unsigned dim)
 Directly control the num_dim which is written to the Exodus file. More...
 
void set_coordinate_offset (Point p)
 Allows you to set a vector that is added to the coordinates of all of the nodes. More...
 
void 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. More...
 
const std::vector< std::string > & get_elem_var_names ()
 Return list of the elemental variable names. More...
 
const std::vector< std::string > & get_nodal_var_names ()
 Return list of the nodal variable names. More...
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
 This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

void write_nodal_data_common (std::string fname, const std::vector< std::string > &names, bool continuous=true)
 This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_data_discontinuous() functions. More...
 

Private Attributes

UniquePtr< ExodusII_IO_Helperexio_helper
 Only attempt to instantiate an ExodusII helper class if the Exodus API is defined. More...
 
int _timestep
 Stores the current value of the timestep when calling ExodusII_IO::write_timestep(). More...
 
bool _verbose
 should we be verbose? More...
 
bool _append
 Default false. More...
 
std::vector< std::string > _output_variables
 The names of the variables to be output. More...
 
bool _allow_empty_variables
 If true, _output_variables is allowed to remain empty. More...
 

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
Date
2004 Handles reading and writing of Exodus binary files.

Definition at line 52 of file exodusII_io.h.

Constructor & Destructor Documentation

libMesh::ExodusII_IO::ExodusII_IO ( MeshBase mesh,
bool  single_precision = false 
)
explicit

Constructor.

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

Definition at line 45 of file exodusII_io.C.

51  :
52  MeshInput<MeshBase> (mesh),
53  MeshOutput<MeshBase> (mesh,
54  /* is_parallel_format = */ false,
55  /* serial_only_needed_on_proc_0 = */ true),
57 #ifdef LIBMESH_HAVE_EXODUS_API
58  exio_helper(new ExodusII_IO_Helper(*this, false, true, single_precision)),
59  _timestep(1),
60  _verbose(false),
61  _append(false),
62 #endif
64 {
65 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:271
bool _verbose
should we be verbose?
Definition: exodusII_io.h:276
bool _append
Default false.
Definition: exodusII_io.h:282
bool _allow_empty_variables
If true, _output_variables is allowed to remain empty.
Definition: exodusII_io.h:304
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
libMesh::ExodusII_IO::~ExodusII_IO ( )
virtual

Destructor.

Definition at line 109 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

110 {
111  exio_helper->close();
112 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265

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 430 of file exodusII_io.C.

References _append.

Referenced by get_elem_var_names(), and main().

431 {
432  _append = val;
433 }
bool _append
Default false.
Definition: exodusII_io.h:282
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
inherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

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

88  { return _communicator; }
const Parallel::Communicator & _communicator
void libMesh::ExodusII_IO::copy_elemental_solution ( System system,
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 491 of file exodusII_io.C.

References libMesh::ParallelObject::comm(), libMesh::CONSTANT, libMesh::DofObject::dof_number(), end, exio_helper, libMesh::MeshInput< MT >::mesh(), libMesh::MONOMIAL, libMesh::DofObject::n_comp(), libMesh::System::number(), libMesh::Parallel::Communicator::rank(), libMesh::System::solution, libMesh::System::update(), libMesh::System::variable_number(), and libMesh::System::variable_type().

Referenced by get_elem_var_names().

495 {
496  if (system.comm().rank() == 0)
497  {
498  if (!exio_helper->opened_for_reading)
499  libmesh_error_msg("ERROR, ExodusII file must be opened for reading before copying an elemental solution!");
500 
501  // Map from element ID to elemental variable value. We need to use
502  // a map here rather than a vector (e.g. elem_var_values) since the
503  // libmesh element numbering can contain "holes". This is the case
504  // if we are reading elemental var values from an adaptively refined
505  // mesh that has not been sequentially renumbered.
506  std::map<dof_id_type, Real> elem_var_value_map;
507  exio_helper->read_elemental_var_values(exodus_var_name, timestep, elem_var_value_map);
508 
509  const unsigned int var_num = system.variable_number(system_var_name);
510  if (system.variable_type(var_num) != FEType(CONSTANT, MONOMIAL))
511  libmesh_error_msg("Error! Trying to copy elemental solution into a variable that is not of CONSTANT MONOMIAL type.");
512 
513  std::map<dof_id_type, Real>::iterator
514  it = elem_var_value_map.begin(),
515  end = elem_var_value_map.end();
516 
517  for (; it!=end; ++it)
518  {
519  const Elem * elem = MeshInput<MeshBase>::mesh().query_elem_ptr(it->first);
520 
521  if (elem && elem->n_comp(system.number(), var_num) > 0)
522  {
523  dof_id_type dof_index = elem->dof_number(system.number(), var_num, 0);
524  system.solution->set (dof_index, it->second);
525  }
526  }
527  }
528 
529  system.solution->close();
530  system.update();
531 }
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
uint8_t dof_id_type
Definition: id_types.h:64
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.

Deprecated:
Use the version of copy_nodal_solution() that takes two names.

Definition at line 78 of file exodusII_io.C.

Referenced by get_elem_var_names(), and WriteVecAndScalar::testWrite().

81 {
82  libmesh_deprecated();
83  copy_nodal_solution(system, var_name, var_name, timestep);
84 }
void 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: exodusII_io.C:78
void libMesh::ExodusII_IO::copy_nodal_solution ( System system,
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 459 of file exodusII_io.C.

References libMesh::DofObject::dof_number(), exio_helper, libMesh::MeshInput< MT >::mesh(), libMesh::DofObject::n_comp(), libMesh::System::number(), libMesh::System::solution, libMesh::System::update(), and libMesh::System::variable_number().

463 {
464  if (!exio_helper->opened_for_reading)
465  libmesh_error_msg("ERROR, ExodusII file must be opened for reading before copying a nodal solution!");
466 
467  exio_helper->read_nodal_var_values(exodus_var_name, timestep);
468 
469  const unsigned int var_num = system.variable_number(system_var_name);
470 
471  for (std::size_t i=0; i<exio_helper->nodal_var_values.size(); ++i)
472  {
473  const Node * node = MeshInput<MeshBase>::mesh().query_node_ptr(i);
474 
475  if (node && node->n_comp(system.number(), var_num) > 0)
476  {
477  dof_id_type dof_index = node->dof_number(system.number(), var_num, 0);
478 
479  // If the dof_index is local to this processor, set the value
480  if ((dof_index >= system.solution->first_local_index()) && (dof_index < system.solution->last_local_index()))
481  system.solution->set (dof_index, exio_helper->nodal_var_values[i]);
482  }
483  }
484 
485  system.solution->close();
486  system.update();
487 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
uint8_t dof_id_type
Definition: id_types.h:64
const std::vector< std::string > & libMesh::ExodusII_IO::get_elem_var_names ( )
const std::vector< std::string > & libMesh::ExodusII_IO::get_nodal_var_names ( )

Return list of the nodal variable names.

Definition at line 943 of file exodusII_io.C.

References exio_helper, and libMesh::ExodusII_IO_Helper::NODAL.

Referenced by get_elem_var_names(), and WriteVecAndScalar::testWrite().

944 {
945  exio_helper->read_var_names(ExodusII_IO_Helper::NODAL);
946  return exio_helper->nodal_var_names;
947 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
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 448 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

449 {
450  if (!exio_helper->opened_for_reading && !exio_helper->opened_for_writing)
451  libmesh_error_msg("ERROR, ExodusII file must be opened for reading or writing before calling ExodusII_IO::get_num_time_steps()!");
452 
453  exio_helper->read_num_time_steps();
454  return exio_helper->num_time_steps;
455 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
const std::vector< Real > & libMesh::ExodusII_IO::get_time_steps ( )
Returns
An array containing the timesteps in the file.

Definition at line 437 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

438 {
439  if (!exio_helper->opened_for_reading)
440  libmesh_error_msg("ERROR, ExodusII file must be opened for reading before calling ExodusII_IO::get_time_steps()!");
441 
442  exio_helper->read_time_steps();
443  return exio_helper->time_steps;
444 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited
Returns
The object as a writable reference.

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

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
protectedinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

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

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:726
const Parallel::Communicator & _communicator
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited
Returns
The rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

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

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

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:724
void libMesh::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 116 of file exodusII_io.C.

References libMesh::MeshBase::add_elem(), libMesh::BoundaryInfo::add_node(), libMesh::MeshBase::add_point(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), libMesh::Elem::build(), libMesh::MeshBase::clear(), libMesh::Elem::dim(), libMesh::MeshBase::elem_ref(), libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::Utility::enum_to_string(), exio_helper, libMesh::MeshBase::get_boundary_info(), libMesh::ExodusII_IO_Helper::Conversion::get_shellface_index_offset(), libMesh::ExodusII_IO_Helper::Conversion::get_side_map(), libMesh::DofObject::id(), libMesh::ExodusII_IO_Helper::Conversion::invalid_id, libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::node_ptr(), libMesh::BoundaryInfo::nodeset_name(), libMesh::MeshBase::reserve_elem(), libMesh::MeshBase::reserve_nodes(), libMesh::DofObject::set_id(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::BoundaryInfo::sideset_name(), libMesh::Elem::subdomain_id(), libMesh::MeshBase::subdomain_name(), and verbose().

Referenced by get_elem_var_names(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), and WriteVecAndScalar::testWrite().

117 {
118  // Get a reference to the mesh we are reading
119  MeshBase & mesh = MeshInput<MeshBase>::mesh();
120 
121  // Clear any existing mesh data
122  mesh.clear();
123 
124  // Keep track of what kinds of elements this file contains
125  elems_of_dimension.clear();
126  elems_of_dimension.resize(4, false);
127 
128 #ifdef DEBUG
129  this->verbose(true);
130 #endif
131 
132  // Instantiate the ElementMaps interface
133  ExodusII_IO_Helper::ElementMaps em;
134 
135  // Open the exodus file in EX_READ mode
136  exio_helper->open(fname.c_str(), /*read_only=*/true);
137 
138  // Get header information from exodus file
139  exio_helper->read_header();
140 
141  // Read the QA records
142  exio_helper->read_qa_records();
143 
144  // Print header information
145  exio_helper->print_header();
146 
147  // Read nodes from the exodus file
148  exio_helper->read_nodes();
149 
150  // Reserve space for the nodes.
151  mesh.reserve_nodes(exio_helper->num_nodes);
152 
153  // Read the node number map from the Exodus file. This is
154  // required if we want to preserve the numbering of nodes as it
155  // exists in the Exodus file. If the Exodus file does not contain
156  // a node_num_map, the identity map is returned by this call.
157  exio_helper->read_node_num_map();
158 
159  // Loop over the nodes, create Nodes with local processor_id 0.
160  for (int i=0; i<exio_helper->num_nodes; i++)
161  {
162  // Use the node_num_map to get the correct ID for Exodus
163  int exodus_id = exio_helper->node_num_map[i];
164 
165  // Catch the node that was added to the mesh
166  Node * added_node = mesh.add_point (Point(exio_helper->x[i], exio_helper->y[i], exio_helper->z[i]), exodus_id-1);
167 
168  // If the Mesh assigned an ID different from what is in the
169  // Exodus file, we should probably error.
170  if (added_node->id() != static_cast<unsigned>(exodus_id-1))
171  libmesh_error_msg("Error! Mesh assigned node ID " \
172  << added_node->id() \
173  << " which is different from the (zero-based) Exodus ID " \
174  << exodus_id-1 \
175  << "!");
176  }
177 
178  // This assert is no longer valid if the nodes are not numbered
179  // sequentially starting from 1 in the Exodus file.
180  // libmesh_assert_equal_to (static_cast<unsigned int>(exio_helper->num_nodes), mesh.n_nodes());
181 
182  // Get information about all the blocks
183  exio_helper->read_block_info();
184 
185  // Reserve space for the elements
186  mesh.reserve_elem(exio_helper->num_elem);
187 
188  // Read the element number map from the Exodus file. This is
189  // required if we want to preserve the numbering of elements as it
190  // exists in the Exodus file. If the Exodus file does not contain
191  // an elem_num_map, the identity map is returned by this call.
192  exio_helper->read_elem_num_map();
193 
194  // Read in the element connectivity for each block.
195  int nelem_last_block = 0;
196 
197  // Loop over all the blocks
198  for (int i=0; i<exio_helper->num_elem_blk; i++)
199  {
200  // Read the information for block i
201  exio_helper->read_elem_in_block (i);
202  int subdomain_id = exio_helper->get_block_id(i);
203 
204  // populate the map of names
205  std::string subdomain_name = exio_helper->get_block_name(i);
206  if (!subdomain_name.empty())
207  mesh.subdomain_name(static_cast<subdomain_id_type>(subdomain_id)) = subdomain_name;
208 
209  // Set any relevant node/edge maps for this element
210  const std::string type_str (exio_helper->get_elem_type());
211  const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(type_str);
212 
213  // Loop over all the faces in this block
214  int jmax = nelem_last_block+exio_helper->num_elem_this_blk;
215  for (int j=nelem_last_block; j<jmax; j++)
216  {
217  Elem * elem = Elem::build (conv.get_canonical_type()).release();
218  libmesh_assert (elem);
219  elem->subdomain_id() = static_cast<subdomain_id_type>(subdomain_id) ;
220 
221  // Use the elem_num_map to obtain the ID of this element in the Exodus file
222  int exodus_id = exio_helper->elem_num_map[j];
223 
224  // Assign this element the same ID it had in the Exodus
225  // file, but make it zero-based by subtracting 1. Note:
226  // some day we could use 1-based numbering in libmesh and
227  // thus match the Exodus numbering exactly, but at the
228  // moment libmesh is zero-based.
229  elem->set_id(exodus_id-1);
230 
231  // Record that we have seen an element of dimension elem->dim()
232  elems_of_dimension[elem->dim()] = true;
233 
234  // Catch the Elem pointer that the Mesh throws back
235  elem = mesh.add_elem (elem);
236 
237  // If the Mesh assigned an ID different from what is in the
238  // Exodus file, we should probably error.
239  if (elem->id() != static_cast<unsigned>(exodus_id-1))
240  libmesh_error_msg("Error! Mesh assigned ID " \
241  << elem->id() \
242  << " which is different from the (zero-based) Exodus ID " \
243  << exodus_id-1 \
244  << "!");
245 
246  // Set all the nodes for this element
247  for (int k=0; k<exio_helper->num_nodes_per_elem; k++)
248  {
249  // global index
250  int gi = (j-nelem_last_block)*exio_helper->num_nodes_per_elem + conv.get_node_map(k);
251 
252  // The entries in 'connect' are actually (1-based)
253  // indices into the node_num_map, so to get the right
254  // node ID we:
255  // 1.) Subtract 1 from connect[gi]
256  // 2.) Pass it through node_num_map to get the corresponding Exodus ID
257  // 3.) Subtract 1 from that, since libmesh node numbering is "zero"-based,
258  // even when the Exodus node numbering doesn't start with 1.
259  int libmesh_node_id = exio_helper->node_num_map[exio_helper->connect[gi] - 1] - 1;
260 
261  // Set the node pointer in the Elem
262  elem->set_node(k) = mesh.node_ptr(libmesh_node_id);
263  }
264  }
265 
266  // running sum of # of elements per block,
267  // (should equal total number of elements in the end)
268  nelem_last_block += exio_helper->num_elem_this_blk;
269  }
270 
271  // This assert isn't valid if the Exodus file's numbering doesn't
272  // start with 1! For example, if Exodus's elem_num_map is 21, 22,
273  // 23, 24, 25, 26, 27, 28, 29, 30, ... 84, then by the time you are
274  // done with the loop above, mesh.n_elem() will report 84 and
275  // nelem_last_block will be 64.
276  // libmesh_assert_equal_to (static_cast<unsigned>(nelem_last_block), mesh.n_elem());
277 
278  // Set the mesh dimension to the largest encountered for an element
279  for (unsigned char i=0; i!=4; ++i)
280  if (elems_of_dimension[i])
281  mesh.set_mesh_dimension(i);
282 
283  // Read in sideset information -- this is useful for applying boundary conditions
284  {
285  // Get basic information about all sidesets
286  exio_helper->read_sideset_info();
287  int offset=0;
288  for (int i=0; i<exio_helper->num_side_sets; i++)
289  {
290  // Compute new offset
291  offset += (i > 0 ? exio_helper->num_sides_per_set[i-1] : 0);
292  exio_helper->read_sideset (i, offset);
293 
294  std::string sideset_name = exio_helper->get_side_set_name(i);
295  if (!sideset_name.empty())
296  mesh.get_boundary_info().sideset_name
297  (cast_int<boundary_id_type>(exio_helper->get_side_set_id(i)))
298  = sideset_name;
299  }
300 
301  for (std::size_t e=0; e<exio_helper->elem_list.size(); e++)
302  {
303  // The numbers in the Exodus file sidesets should be thought
304  // of as (1-based) indices into the elem_num_map array. So,
305  // to get the right element ID we have to:
306  // 1.) Subtract 1 from elem_list[e] (to get a zero-based index)
307  // 2.) Pass it through elem_num_map (to get the corresponding Exodus ID)
308  // 3.) Subtract 1 from that, since libmesh is "zero"-based,
309  // even when the Exodus numbering doesn't start with 1.
310  dof_id_type libmesh_elem_id =
311  cast_int<dof_id_type>(exio_helper->elem_num_map[exio_helper->elem_list[e] - 1] - 1);
312 
313  // Set any relevant node/edge maps for this element
314  Elem & elem = mesh.elem_ref(libmesh_elem_id);
315 
316  const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(elem.type());
317 
318  // Map the zero-based Exodus side numbering to the libmesh side numbering
319  unsigned int raw_side_index = exio_helper->side_list[e]-1;
320  unsigned int side_index_offset = conv.get_shellface_index_offset();
321 
322  if (raw_side_index < side_index_offset)
323  {
324  // We assume this is a "shell face"
325  int mapped_shellface = raw_side_index;
326 
327  // Check for errors
328  if (mapped_shellface == ExodusII_IO_Helper::Conversion::invalid_id)
329  libmesh_error_msg("Invalid 1-based side id: " \
330  << mapped_shellface \
331  << " detected for " \
332  << Utility::enum_to_string(elem.type()));
333 
334  // Add this (elem,shellface,id) triplet to the BoundaryInfo object.
335  mesh.get_boundary_info().add_shellface (libmesh_elem_id,
336  cast_int<unsigned short>(mapped_shellface),
337  cast_int<boundary_id_type>(exio_helper->id_list[e]));
338  }
339  else
340  {
341  unsigned int side_index = static_cast<unsigned int>(raw_side_index - side_index_offset);
342  int mapped_side = conv.get_side_map(side_index);
343 
344  // Check for errors
346  libmesh_error_msg("Invalid 1-based side id: " \
347  << side_index \
348  << " detected for " \
349  << Utility::enum_to_string(elem.type()));
350 
351  // Add this (elem,side,id) triplet to the BoundaryInfo object.
352  mesh.get_boundary_info().add_side (libmesh_elem_id,
353  cast_int<unsigned short>(mapped_side),
354  cast_int<boundary_id_type>(exio_helper->id_list[e]));
355  }
356  }
357  }
358 
359  // Read nodeset info
360  {
361  exio_helper->read_nodeset_info();
362 
363  for (int nodeset=0; nodeset<exio_helper->num_node_sets; nodeset++)
364  {
365  boundary_id_type nodeset_id =
366  cast_int<boundary_id_type>(exio_helper->nodeset_ids[nodeset]);
367 
368  std::string nodeset_name = exio_helper->get_node_set_name(nodeset);
369  if (!nodeset_name.empty())
370  mesh.get_boundary_info().nodeset_name(nodeset_id) = nodeset_name;
371 
372  exio_helper->read_nodeset(nodeset);
373 
374  for (std::size_t node=0; node<exio_helper->node_list.size(); node++)
375  {
376  // As before, the entries in 'node_list' are 1-based
377  // indices into the node_num_map array, so we have to map
378  // them. See comment above.
379  int libmesh_node_id = exio_helper->node_num_map[exio_helper->node_list[node] - 1] - 1;
380  mesh.get_boundary_info().add_node(cast_int<dof_id_type>(libmesh_node_id),
381  nodeset_id);
382  }
383  }
384  }
385 
386 #if LIBMESH_DIM < 3
387  if (mesh.mesh_dimension() > LIBMESH_DIM)
388  libmesh_error_msg("Cannot open dimension " \
389  << mesh.mesh_dimension() \
390  << " mesh file when configured without " \
391  << mesh.mesh_dimension() \
392  << "D support.");
393 #endif
394 }
static UniquePtr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:238
static const int invalid_id
An invalid_id that can be returned to signal failure in case something goes wrong.
std::vector< bool > elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh...
Definition: mesh_input.h:97
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
libmesh_assert(j)
int8_t boundary_id_type
Definition: id_types.h:51
void verbose(bool set_verbosity)
Set the flag indicating if we should be verbose.
Definition: exodusII_io.C:398
std::string enum_to_string(const T e)
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
uint8_t dof_id_type
Definition: id_types.h:64
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.

Deprecated:
As requested by Roy in libmesh PR #90, this function was "deprecated on arrival". There is not really a suitable replacement for it in the works, however. The same effect could be achieved by calling MeshTools::Modification::translate() twice, but that approach seems inefficient in the case of very large problems with millions of nodes. That said, this should probably become a base class API so that it works for all the different IO subclasses.

Definition at line 422 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

423 {
424  libmesh_warning("This method may be deprecated in the future");
425  exio_helper->set_coordinate_offset(p);
426 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
protectedinherited

Sets the number of partitions in the mesh.

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

Definition at line 91 of file mesh_input.h.

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

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

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

References _allow_empty_variables, and _output_variables.

70 {
71  _output_variables = output_variables;
72  _allow_empty_variables = allow_empty;
73 }
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:289
bool _allow_empty_variables
If true, _output_variables is allowed to remain empty.
Definition: exodusII_io.h:304
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 408 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

409 {
410  exio_helper->use_mesh_dimension_instead_of_spatial_dimension(val);
411 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
void libMesh::ExodusII_IO::verbose ( bool  set_verbosity)

Set the flag indicating if we should be verbose.

Definition at line 398 of file exodusII_io.C.

References _verbose, and exio_helper.

Referenced by get_elem_var_names(), and read().

399 {
400  _verbose = set_verbosity;
401 
402  // Set the verbose flag in the helper object as well.
403  exio_helper->verbose = _verbose;
404 }
bool _verbose
should we be verbose?
Definition: exodusII_io.h:276
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
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 789 of file exodusII_io.C.

References _append, _verbose, exio_helper, libMesh::MeshBase::get_boundary_info(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::BoundaryInfo::n_edge_conds(), and libMesh::out.

Referenced by get_elem_var_names(), main(), libMesh::ErrorVector::plot_error(), and libMesh::NameBasedIO::write().

790 {
791  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
792 
793  // We may need to gather a DistributedMesh to output it, making that
794  // const qualifier in our constructor a dirty lie
795  // The "true" specifies that we only need the mesh serialized to processor 0
796  MeshSerializer serialize(MeshInput<MeshBase>::mesh(), !MeshOutput<MeshBase>::_is_parallel_format, true);
797 
798  libmesh_assert( !exio_helper->opened_for_writing );
799 
800  // If the user has set the append flag here, it doesn't really make
801  // sense: the intent of this function is to write a Mesh with no
802  // data, while "appending" is really intended to add data to an
803  // existing file. If we're verbose, print a message to this effect.
804  if (_append && _verbose)
805  libMesh::out << "Warning: Appending in ExodusII_IO::write() does not make sense.\n"
806  << "Creating a new file instead!"
807  << std::endl;
808 
809  exio_helper->create(fname);
810  exio_helper->initialize(fname,mesh);
811  exio_helper->write_nodal_coordinates(mesh);
812  exio_helper->write_elements(mesh);
813  exio_helper->write_sidesets(mesh);
814  exio_helper->write_nodesets(mesh);
815 
816  if ((mesh.get_boundary_info().n_edge_conds() > 0) && _verbose)
817  {
818  libMesh::out << "Warning: Mesh contains edge boundary IDs, but these "
819  << "are not supported by the ExodusII format."
820  << std::endl;
821  }
822 }
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:141
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
bool _verbose
should we be verbose?
Definition: exodusII_io.h:276
bool _append
Default false.
Definition: exodusII_io.h:282
OStreamProxy out
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
void libMesh::ExodusII_IO::write_as_dimension ( unsigned  dim)

Directly control the num_dim which is written to the Exodus file.

If non-zero, this value supersedes all other dimensions, including: 1.) MeshBase::spatial_dimension() 2.) MeshBase::mesh_dimension() 3.) Any value passed to use_mesh_dimension_instead_of_spatial_dimension() This is useful/necessary for working around a bug in Paraview which prevents the "Plot Over Line" filter from working on 1D meshes.

Definition at line 415 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

416 {
417  exio_helper->write_as_dimension(dim);
418 }
unsigned int dim
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
void libMesh::ExodusII_IO::write_discontinuous_exodusII ( const std::string &  name,
const EquationSystems es,
const std::set< std::string > *  system_names = libmesh_nullptr 
)

Writes a exodusII file with discontinuous data.

Definition at line 89 of file exodusII_io.C.

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

Referenced by main().

92 {
93  std::vector<std::string> solution_names;
94  std::vector<Number> v;
95 
96  es.build_variable_names (solution_names, libmesh_nullptr, system_names);
97  es.build_discontinuous_solution_vector (v, system_names);
98 
99  this->write_nodal_data_discontinuous(name, v, solution_names);
100 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
const class libmesh_nullptr_t libmesh_nullptr
void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
Write out a discontinuous nodal solution.
Definition: exodusII_io.C:826
void libMesh::ExodusII_IO::write_element_data ( const EquationSystems es)

Write out element solution.

Definition at line 535 of file exodusII_io.C.

References _output_variables, _timestep, std::abs(), libMesh::EquationSystems::build_variable_names(), libMesh::CONSTANT, exio_helper, libMesh::EquationSystems::get_solution(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MONOMIAL, libMesh::ParallelObject::processor_id(), and value.

Referenced by get_elem_var_names(), and libMesh::ErrorVector::plot_error().

536 {
537  // Be sure the file has been opened for writing!
538  if (MeshOutput<MeshBase>::mesh().processor_id() == 0 && !exio_helper->opened_for_writing)
539  libmesh_error_msg("ERROR, ExodusII file must be initialized before outputting element variables.");
540 
541  // This function currently only works on serialized meshes. We rely
542  // on having a reference to a non-const MeshBase object from our
543  // MeshInput parent class to construct a MeshSerializer object,
544  // similar to what is done in ExodusII_IO::write(). Note that
545  // calling ExodusII_IO::write_timestep() followed by
546  // ExodusII_IO::write_element_data() when the underlying Mesh is a
547  // DistributedMesh will result in an unnecessary additional
548  // serialization/re-parallelization step.
549  // The "true" specifies that we only need the mesh serialized to processor 0
550  MeshSerializer serialize(MeshInput<MeshBase>::mesh(), !MeshOutput<MeshBase>::_is_parallel_format, true);
551 
552  // To be (possibly) filled with a filtered list of variable names to output.
553  std::vector<std::string> names;
554 
555  // If _output_variables is populated, only output the monomials which are
556  // also in the _output_variables vector.
557  if (_output_variables.size() > 0)
558  {
559  std::vector<std::string> monomials;
560  const FEType type(CONSTANT, MONOMIAL);
561 
562  // Create a list of monomial variable names
563  es.build_variable_names(monomials, &type);
564 
565  // Filter that list against the _output_variables list. Note: if names is still empty after
566  // all this filtering, all the monomial variables will be gathered
567  std::vector<std::string>::iterator it = monomials.begin();
568  for (; it!=monomials.end(); ++it)
569  if (std::find(_output_variables.begin(), _output_variables.end(), *it) != _output_variables.end())
570  names.push_back(*it);
571  }
572 
573  // If we pass in a list of names to "get_solution" it'll filter the variables coming back
574  std::vector<Number> soln;
575  es.get_solution(soln, names);
576 
577  if (soln.empty()) // If there is nothing to write just return
578  return;
579 
580  // The data must ultimately be written block by block. This means that this data
581  // must be sorted appropriately.
583  return;
584 
585  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
586 
587 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
588 
589  std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
590 
591  exio_helper->initialize_element_variables(complex_names);
592 
593  unsigned int num_values = soln.size();
594  unsigned int num_vars = names.size();
595  unsigned int num_elems = num_values / num_vars;
596 
597  // This will contain the real and imaginary parts and the magnitude
598  // of the values in soln
599  std::vector<Real> complex_soln(3*num_values);
600 
601  for (unsigned i=0; i<num_vars; ++i)
602  {
603 
604  for (unsigned int j=0; j<num_elems; ++j)
605  {
606  Number value = soln[i*num_vars + j];
607  complex_soln[3*i*num_elems + j] = value.real();
608  }
609  for (unsigned int j=0; j<num_elems; ++j)
610  {
611  Number value = soln[i*num_vars + j];
612  complex_soln[3*i*num_elems + num_elems +j] = value.imag();
613  }
614  for (unsigned int j=0; j<num_elems; ++j)
615  {
616  Number value = soln[i*num_vars + j];
617  complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(value);
618  }
619  }
620 
621  exio_helper->write_element_values(mesh, complex_soln, _timestep);
622 
623 #else
624  exio_helper->initialize_element_variables(names);
625  exio_helper->write_element_values(mesh, soln, _timestep);
626 #endif
627 }
double abs(double a)
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:141
const MeshBase & mesh() const
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:271
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:289
static const bool value
Definition: xdr_io.C:108
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
processor_id_type processor_id() const
virtual void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = libmesh_nullptr 
)
virtualinherited

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

Reimplemented in libMesh::NameBasedIO.

Referenced by libMesh::Nemesis_IO::write_timestep(), and 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 720 of file exodusII_io.C.

References _timestep, std::abs(), exio_helper, libMesh::ParallelObject::processor_id(), and value.

Referenced by get_elem_var_names().

722 {
724  return;
725 
726  if (!exio_helper->opened_for_writing)
727  libmesh_error_msg("ERROR, ExodusII file must be initialized before outputting global variables.");
728 
729 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
730 
731  std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
732 
733  exio_helper->initialize_global_variables(complex_names);
734 
735  unsigned int num_values = soln.size();
736  unsigned int num_vars = names.size();
737  unsigned int num_elems = num_values / num_vars;
738 
739  // This will contain the real and imaginary parts and the magnitude
740  // of the values in soln
741  std::vector<Real> complex_soln(3*num_values);
742 
743  for (unsigned i=0; i<num_vars; ++i)
744  {
745 
746  for (unsigned int j=0; j<num_elems; ++j)
747  {
748  Number value = soln[i*num_vars + j];
749  complex_soln[3*i*num_elems + j] = value.real();
750  }
751  for (unsigned int j=0; j<num_elems; ++j)
752  {
753  Number value = soln[i*num_vars + j];
754  complex_soln[3*i*num_elems + num_elems +j] = value.imag();
755  }
756  for (unsigned int j=0; j<num_elems; ++j)
757  {
758  Number value = soln[i*num_vars + j];
759  complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(value);
760  }
761  }
762 
763  exio_helper->write_global_values(complex_soln, _timestep);
764 
765 #else
766  exio_helper->initialize_global_variables(names);
767  exio_helper->write_global_values(soln, _timestep);
768 #endif
769 }
double abs(double a)
const MeshBase & mesh() const
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:271
static const bool value
Definition: xdr_io.C:108
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
processor_id_type processor_id() const
void libMesh::ExodusII_IO::write_information_records ( const std::vector< std::string > &  records)

Write out information records.

Definition at line 707 of file exodusII_io.C.

References exio_helper, and libMesh::ParallelObject::processor_id().

Referenced by get_elem_var_names().

708 {
710  return;
711 
712  if (!exio_helper->opened_for_writing)
713  libmesh_error_msg("ERROR, ExodusII file must be initialized before outputting information records.");
714 
715  exio_helper->write_information_records(records);
716 }
const MeshBase & mesh() const
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
processor_id_type processor_id() const
virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const NumericVector< Number > &  ,
const std::vector< std::string > &   
)
virtualinherited

This method should be overridden by "parallel" output formats for writing nodal data.

Instead of getting a localized copy of the nodal solution vector, it is passed a NumericVector of type=PARALLEL which is in node-major order i.e. (u0,v0,w0, u1,v1,w1, u2,v2,w2, u3,v3,w3, ...) and contains n_nodes*n_vars total entries. Then, it is up to the individual I/O class to extract the required solution values from this vector and write them in parallel.

If not implemented, localizes the parallel vector into a std::vector and calls the other version of this function.

Reimplemented in libMesh::Nemesis_IO.

void libMesh::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 631 of file exodusII_io.C.

References _allow_empty_variables, _output_variables, _timestep, std::abs(), exio_helper, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::n_nodes(), libMesh::ParallelObject::processor_id(), and write_nodal_data_common().

Referenced by get_elem_var_names(), and libMesh::NameBasedIO::write_nodal_data().

634 {
635  LOG_SCOPE("write_nodal_data()", "ExodusII_IO");
636 
637  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
638 
639  int num_vars = cast_int<int>(names.size());
640  dof_id_type num_nodes = mesh.n_nodes();
641 
642  // The names of the variables to be output
643  std::vector<std::string> output_names;
644 
646  output_names = _output_variables;
647  else
648  output_names = names;
649 
650 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
651 
652  std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
653 
654  // Call helper function for opening/initializing data, giving it the
655  // complex variable names
656  this->write_nodal_data_common(fname, complex_names, /*continuous=*/true);
657 #else
658  // Call helper function for opening/initializing data
659  this->write_nodal_data_common(fname, output_names, /*continuous=*/true);
660 #endif
661 
662  if (mesh.processor_id())
663  return;
664 
665  // This will count the number of variables actually output
666  for (int c=0; c<num_vars; c++)
667  {
668  std::stringstream name_to_find;
669 
670  std::vector<std::string>::iterator pos =
671  std::find(output_names.begin(), output_names.end(), names[c]);
672  if (pos == output_names.end())
673  continue;
674 
675  unsigned int variable_name_position =
676  cast_int<unsigned int>(pos - output_names.begin());
677 
678 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
679  std::vector<Real> real_parts(num_nodes);
680  std::vector<Real> imag_parts(num_nodes);
681  std::vector<Real> magnitudes(num_nodes);
682 
683  for (unsigned int i=0; i<num_nodes; ++i)
684  {
685  real_parts[i] = soln[i*num_vars + c].real();
686  imag_parts[i] = soln[i*num_vars + c].imag();
687  magnitudes[i] = std::abs(soln[i*num_vars + c]);
688  }
689  exio_helper->write_nodal_values(3*variable_name_position+1,real_parts,_timestep);
690  exio_helper->write_nodal_values(3*variable_name_position+2,imag_parts,_timestep);
691  exio_helper->write_nodal_values(3*variable_name_position+3,magnitudes,_timestep);
692 #else
693  std::vector<Number> cur_soln(num_nodes);
694 
695  // Copy out this variable's solution
696  for (dof_id_type i=0; i<num_nodes; i++)
697  cur_soln[i] = soln[i*num_vars + c];
698  exio_helper->write_nodal_values(variable_name_position+1,cur_soln,_timestep);
699 #endif
700 
701  }
702 }
double abs(double a)
const MT & mesh() const
Definition: mesh_output.h:216
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:271
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:289
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_d...
Definition: exodusII_io.C:884
bool _allow_empty_variables
If true, _output_variables is allowed to remain empty.
Definition: exodusII_io.h:304
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
uint8_t dof_id_type
Definition: id_types.h:64
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 884 of file exodusII_io.C.

References _append, _verbose, exio_helper, libMesh::MeshBase::get_boundary_info(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::BoundaryInfo::n_edge_conds(), and libMesh::out.

Referenced by get_elem_var_names(), write_nodal_data(), and write_nodal_data_discontinuous().

887 {
888  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
889 
890  // This function can be called multiple times, we only want to open
891  // the ExodusII file the first time it's called.
892  if (!exio_helper->opened_for_writing)
893  {
894  // If we're appending, open() the file with read_only=false,
895  // otherwise create() it and write the contents of the mesh to
896  // it.
897  if (_append)
898  {
899  exio_helper->open(fname.c_str(), /*read_only=*/false);
900  // If we're appending, it's not valid to call exio_helper->initialize()
901  // or exio_helper->initialize_nodal_variables(), but we do need to set up
902  // certain aspects of the Helper object itself, such as the number of nodes
903  // and elements. We do that by reading the header...
904  exio_helper->read_header();
905 
906  // ...and reading the block info
907  exio_helper->read_block_info();
908  }
909  else
910  {
911  exio_helper->create(fname);
912 
913  exio_helper->initialize(fname, mesh, !continuous);
914  exio_helper->write_nodal_coordinates(mesh, !continuous);
915  exio_helper->write_elements(mesh, !continuous);
916 
917  exio_helper->write_sidesets(mesh);
918  exio_helper->write_nodesets(mesh);
919 
920  if ((mesh.get_boundary_info().n_edge_conds() > 0) && _verbose)
921  {
922  libMesh::out << "Warning: Mesh contains edge boundary IDs, but these "
923  << "are not supported by the ExodusII format."
924  << std::endl;
925  }
926 
927  exio_helper->initialize_nodal_variables(names);
928  }
929  }
930  else
931  {
932  // We are already open for writing, so check that the filename
933  // passed to this function matches the filename currently in use
934  // by the helper.
935  if (fname != exio_helper->current_filename)
936  libmesh_error_msg("Error! This ExodusII_IO object is already associated with file: " \
937  << exio_helper->current_filename \
938  << ", cannot use it with requested file: " \
939  << fname);
940  }
941 }
const MT & mesh() const
Definition: mesh_output.h:216
bool _verbose
should we be verbose?
Definition: exodusII_io.h:276
bool _append
Default false.
Definition: exodusII_io.h:282
OStreamProxy out
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
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 826 of file exodusII_io.C.

References _timestep, std::abs(), libMesh::MeshBase::active_element_ptr_range(), exio_helper, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::ParallelObject::processor_id(), and write_nodal_data_common().

Referenced by get_elem_var_names(), and write_discontinuous_exodusII().

829 {
830  LOG_SCOPE("write_nodal_data_discontinuous()", "ExodusII_IO");
831 
832  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
833 
834  int num_vars = cast_int<int>(names.size());
835  int num_nodes = 0;
836  for (const auto & elem : mesh.active_element_ptr_range())
837  num_nodes += elem->n_nodes();
838 
839 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
840 
841  std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
842 
843  // Call helper function for opening/initializing data, giving it the
844  // complex variable names
845  this->write_nodal_data_common(fname, complex_names, /*continuous=*/false);
846 #else
847  // Call helper function for opening/initializing data
848  this->write_nodal_data_common(fname, names, /*continuous=*/false);
849 #endif
850 
851  if (mesh.processor_id())
852  return;
853 
854  for (int c=0; c<num_vars; c++)
855  {
856 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
857  std::vector<Real> real_parts(num_nodes);
858  std::vector<Real> imag_parts(num_nodes);
859  std::vector<Real> magnitudes(num_nodes);
860 
861  for (int i=0; i<num_nodes; ++i)
862  {
863  real_parts[i] = soln[i*num_vars + c].real();
864  imag_parts[i] = soln[i*num_vars + c].imag();
865  magnitudes[i] = std::abs(soln[i*num_vars + c]);
866  }
867  exio_helper->write_nodal_values(3*c+1,real_parts,_timestep);
868  exio_helper->write_nodal_values(3*c+2,imag_parts,_timestep);
869  exio_helper->write_nodal_values(3*c+3,magnitudes,_timestep);
870 #else
871  // Copy out this variable's solution
872  std::vector<Number> cur_soln(num_nodes);
873 
874  for (int i=0; i<num_nodes; i++)
875  cur_soln[i] = soln[i*num_vars + c];
876 
877  exio_helper->write_nodal_values(c+1,cur_soln,_timestep);
878 #endif
879  }
880 }
double abs(double a)
const MT & mesh() const
Definition: mesh_output.h:216
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:271
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_d...
Definition: exodusII_io.C:884
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
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
fnameName of the file to write to
esEquationSystems object which contains the solution vector.
timestepThe timestep to write out, should be 1 indexed.
timeThe current simulation time.

Definition at line 773 of file exodusII_io.C.

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

Referenced by get_elem_var_names(), main(), and write_output().

777 {
778  _timestep = timestep;
779  write_equation_systems(fname,es);
780 
782  return;
783 
784  exio_helper->write_timestep(timestep, time);
785 }
const MeshBase & mesh() const
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:271
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
UniquePtr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:265
processor_id_type processor_id() const

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 304 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 282 of file exodusII_io.h.

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

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited
const bool libMesh::MeshOutput< MeshBase >::_is_parallel_format
protectedinherited

Flag specifying whether this format is parallel-capable.

If this is false (default) I/O is only permitted when the mesh has been serialized.

Definition at line 141 of file mesh_output.h.

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

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 289 of file exodusII_io.h.

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

const bool libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
protectedinherited

Flag specifying whether this format can be written by only serializing the mesh to processor zero.

If this is false (default) the mesh will be serialized to all processors

Definition at line 150 of file mesh_output.h.

int libMesh::ExodusII_IO::_timestep
private

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

Definition at line 271 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 276 of file exodusII_io.h.

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

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

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