libMesh::ExodusII_IO_Helper Class Reference

#include <exodusII_io_helper.h>

Inheritance diagram for libMesh::ExodusII_IO_Helper:

Classes

class  Conversion
 
class  ElementMaps
 
class  NamesData
 

Public Types

enum  ExodusVarType { NODAL =0, ELEMENTAL =1, GLOBAL =2 }
 

Public Member Functions

 ExodusII_IO_Helper (const ParallelObject &parent, bool v=false, bool run_only_on_proc0=true, bool single_precision=false)
 
virtual ~ExodusII_IO_Helper ()
 
const char * get_elem_type () const
 
void open (const char *filename, bool read_only)
 
void read_header ()
 
void read_qa_records ()
 
void print_header ()
 
void read_nodes ()
 
void read_node_num_map ()
 
void print_nodes (std::ostream &out=libMesh::out)
 
void read_block_info ()
 
int get_block_id (int index)
 
std::string get_block_name (int index)
 
int get_side_set_id (int index)
 
std::string get_side_set_name (int index)
 
int get_node_set_id (int index)
 
std::string get_node_set_name (int index)
 
void read_elem_in_block (int block)
 
void read_elem_num_map ()
 
void read_sideset_info ()
 
void read_nodeset_info ()
 
void read_sideset (int id, int offset)
 
void read_nodeset (int id)
 
void close ()
 
int inquire (int req_info, std::string error_msg="")
 
void read_time_steps ()
 
void read_num_time_steps ()
 
void read_nodal_var_values (std::string nodal_var_name, int time_step)
 
void read_elemental_var_values (std::string elemental_var_name, int time_step, std::map< dof_id_type, Real > &elem_var_value_map)
 
virtual void create (std::string filename)
 
virtual void initialize (std::string title, const MeshBase &mesh, bool use_discontinuous=false)
 
virtual void write_nodal_coordinates (const MeshBase &mesh, bool use_discontinuous=false)
 
virtual void write_elements (const MeshBase &mesh, bool use_discontinuous=false)
 
virtual void write_sidesets (const MeshBase &mesh)
 
virtual void write_nodesets (const MeshBase &mesh)
 
void initialize_element_variables (std::vector< std::string > names)
 
void initialize_nodal_variables (std::vector< std::string > names)
 
void initialize_global_variables (std::vector< std::string > names)
 
void write_timestep (int timestep, Real time)
 
void write_element_values (const MeshBase &mesh, const std::vector< Real > &values, int timestep)
 
void write_nodal_values (int var_id, const std::vector< Real > &values, int timestep)
 
void write_information_records (const std::vector< std::string > &records)
 
void write_global_values (const std::vector< Real > &values, int timestep)
 
void read_global_values (std::vector< Real > &values, int timestep)
 
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
 
void write_as_dimension (unsigned dim)
 
void set_coordinate_offset (Point p)
 
std::vector< std::string > get_complex_names (const std::vector< std::string > &names) const
 
void message (const std::string &msg)
 
void message (const std::string &msg, int i)
 
void read_var_names (ExodusVarType type)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

int ex_id
 
int ex_err
 
int num_dim
 
int num_global_vars
 
int num_nodes
 
int num_elem
 
int num_elem_blk
 
int num_node_sets
 
int num_side_sets
 
int num_elem_this_blk
 
int num_nodes_per_elem
 
int num_attr
 
int num_elem_all_sidesets
 
std::vector< int > block_ids
 
std::vector< int > connect
 
std::vector< int > ss_ids
 
std::vector< int > nodeset_ids
 
std::vector< int > num_sides_per_set
 
std::vector< int > num_nodes_per_set
 
std::vector< int > num_df_per_set
 
std::vector< int > num_node_df_per_set
 
std::vector< int > elem_list
 
std::vector< int > side_list
 
std::vector< int > node_list
 
std::vector< int > id_list
 
std::vector< int > node_num_map
 
std::vector< int > elem_num_map
 
std::vector< Realx
 
std::vector< Realy
 
std::vector< Realz
 
std::vector< char > title
 
std::vector< char > elem_type
 
std::map< int, int > libmesh_elem_num_to_exodus
 
std::vector< int > exodus_elem_num_to_libmesh
 
std::map< int, int > libmesh_node_num_to_exodus
 
std::vector< int > exodus_node_num_to_libmesh
 
int num_time_steps
 
std::vector< Realtime_steps
 
int num_nodal_vars
 
std::vector< std::string > nodal_var_names
 
std::vector< Realnodal_var_values
 
int num_elem_vars
 
std::vector< std::string > elem_var_names
 
std::vector< Realelem_var_values
 
std::vector< std::string > global_var_names
 
std::map< int, std::string > id_to_block_names
 
std::map< int, std::string > id_to_ss_names
 
std::map< int, std::string > id_to_ns_names
 
bool verbose
 
bool opened_for_writing
 
bool opened_for_reading
 
std::string current_filename
 

Protected Attributes

bool _run_only_on_proc0
 
bool _elem_vars_initialized
 
bool _global_vars_initialized
 
bool _nodal_vars_initialized
 
bool _use_mesh_dimension_instead_of_spatial_dimension
 
unsigned _write_as_dimension
 
Point _coordinate_offset
 
bool _single_precision
 
const Parallel::Communicator_communicator
 

Private Member Functions

void write_var_names (ExodusVarType type, std::vector< std::string > &names)
 
void check_existing_vars (ExodusVarType type, std::vector< std::string > &names, std::vector< std::string > &names_from_file)
 
void read_var_names_impl (const char *var_type, int &count, std::vector< std::string > &result)
 
void write_var_names_impl (const char *var_type, int &count, std::vector< std::string > &names)
 

Detailed Description

This is the ExodusII_IO_Helper class. This class hides the implementation details of interfacing with the Exodus binary format.

Author
John W. Peterson
Date
2002

Definition at line 86 of file exodusII_io_helper.h.

Member Enumeration Documentation

Wraps calls to exII::ex_get_var_names() and exII::ex_get_var_param(). The enumeration controls whether nodal, elemental, or global variable names are read and which class members are filled in. NODAL: num_nodal_vars nodal_var_names ELEMENTAL: num_elem_vars elem_var_names GLOBAL: num_global_vars global_var_names

Enumerator
NODAL 
ELEMENTAL 
GLOBAL 

Definition at line 580 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

libMesh::ExodusII_IO_Helper::ExodusII_IO_Helper ( const ParallelObject parent,
bool  v = false,
bool  run_only_on_proc0 = true,
bool  single_precision = false 
)

Constructor. Automatically initializes all the private members of the class. Also allows you to set the verbosity level to v=true (on) or v=false (off). The second argument, if true, tells the class to only perform its actions if running on processor zero. If you initialize this to false, the writing methods will run on all processors instead.

Definition at line 267 of file exodusII_io_helper.C.

References elem_type, and title.

270  :
271  ParallelObject(parent),
272  ex_id(0),
273  ex_err(0),
274  num_dim(0),
275  num_global_vars(0),
276  num_nodes(0),
277  num_elem(0),
278  num_elem_blk(0),
279  num_node_sets(0),
280  num_side_sets(0),
283  num_attr(0),
285  num_time_steps(0),
286  num_nodal_vars(0),
287  num_elem_vars(0),
288  verbose(v),
289  opened_for_writing(false),
290  opened_for_reading(false),
291  _run_only_on_proc0(run_only_on_proc0),
292  _elem_vars_initialized(false),
297  _single_precision(single_precision)
298 {
299  title.resize(MAX_LINE_LENGTH+1);
300  elem_type.resize(MAX_STR_LENGTH);
301 }
ParallelObject(const Parallel::Communicator &comm_in)
libMesh::ExodusII_IO_Helper::~ExodusII_IO_Helper ( )
virtual

Destructor.

Definition at line 305 of file exodusII_io_helper.C.

306 {
307 }

Member Function Documentation

void libMesh::ExodusII_IO_Helper::check_existing_vars ( ExodusVarType  type,
std::vector< std::string > &  names,
std::vector< std::string > &  names_from_file 
)
private

When appending: during initialization, check that variable names in the file match those you attempt to initialize with.

Definition at line 1791 of file exodusII_io_helper.C.

References libMesh::err, libMesh::out, and read_var_names().

Referenced by initialize_element_variables(), initialize_global_variables(), and initialize_nodal_variables().

1794 {
1795  // There may already be global variables in the file (for example,
1796  // if we're appending) and in that case, we
1797  // 1.) Cannot initialize them again.
1798  // 2.) Should check to be sure that the global variable names are the same.
1799 
1800  // Fills up names_from_file for us
1801  this->read_var_names(type);
1802 
1803  // Both the names of the global variables and their order must match
1804  if (names_from_file != names)
1805  {
1806  libMesh::err << "Error! The Exodus file already contains the variables:" << std::endl;
1807  for (std::size_t i=0; i<names_from_file.size(); ++i)
1808  libMesh::out << names_from_file[i] << std::endl;
1809 
1810  libMesh::err << "And you asked to write:" << std::endl;
1811  for (std::size_t i=0; i<names.size(); ++i)
1812  libMesh::out << names[i] << std::endl;
1813 
1814  libmesh_error_msg("Cannot overwrite existing variables in Exodus II file.");
1815  }
1816 }
void read_var_names(ExodusVarType type)
OStreamProxy err(std::cerr)
OStreamProxy out(std::cout)
void libMesh::ExodusII_IO_Helper::close ( )

Closes the ExodusII mesh file.

Definition at line 789 of file exodusII_io_helper.C.

References _run_only_on_proc0, ex_close(), ex_err, ex_id, message(), opened_for_reading, opened_for_writing, and libMesh::ParallelObject::processor_id().

Referenced by libMesh::Nemesis_IO_Helper::~Nemesis_IO_Helper().

790 {
791  // Always call close on processor 0.
792  // If we're running on multiple processors, i.e. as one of several Nemesis files,
793  // we call close on all processors...
794  if ((this->processor_id() == 0) || (!_run_only_on_proc0))
795  {
796  // Don't close the file if it was never opened, this raises an Exodus error
798  {
800  EX_CHECK_ERR(ex_err, "Error closing Exodus file.");
801  message("Exodus file closed successfully.");
802  }
803  }
804 }
void message(const std::string &msg)
EXODUS_EXPORT int ex_close(int exoid)
processor_id_type processor_id() const
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_fd_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_mffd_residual(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::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::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::TopologyMap::init(), libMesh::TimeSolver::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::LinearPartitioner::partition_range(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::split_mesh(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _communicator
void libMesh::ExodusII_IO_Helper::create ( std::string  filename)
virtual

Opens an ExodusII mesh file named filename for writing.

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1073 of file exodusII_io_helper.C.

References _run_only_on_proc0, _single_precision, current_filename, ex_id, std::min(), opened_for_writing, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::Real, and verbose.

1074 {
1075  // If we're processor 0, always create the file.
1076  // If we running on all procs, e.g. as one of several Nemesis files, also
1077  // call create there.
1078  if ((this->processor_id() == 0) || (!_run_only_on_proc0))
1079  {
1080  int
1081  comp_ws = 0,
1082  io_ws = 0;
1083 
1084  if (_single_precision)
1085  {
1086  comp_ws = cast_int<int>(sizeof(float));
1087  io_ws = cast_int<int>(sizeof(float));
1088  }
1089  // Fall back on double precision when necessary since ExodusII
1090  // doesn't seem to support long double
1091  else
1092  {
1093  comp_ws = cast_int<int>
1094  (std::min(sizeof(Real), sizeof(double)));
1095  io_ws = cast_int<int>
1096  (std::min(sizeof(Real), sizeof(double)));
1097  }
1098 
1099  ex_id = exII::ex_create(filename.c_str(), EX_CLOBBER, &comp_ws, &io_ws);
1100 
1101  EX_CHECK_ERR(ex_id, "Error creating ExodusII mesh file.");
1102 
1103  if (verbose)
1104  libMesh::out << "File created successfully." << std::endl;
1105  }
1106 
1107  opened_for_writing = true;
1108  current_filename = filename;
1109 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out(std::cout)
long double min(long double a, double b)
processor_id_type processor_id() const
int libMesh::ExodusII_IO_Helper::get_block_id ( int  index)

Get the block number for the given block index.

Definition at line 538 of file exodusII_io_helper.C.

References block_ids.

Referenced by write_element_values().

539 {
540  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
541 
542  return block_ids[index];
543 }
std::string libMesh::ExodusII_IO_Helper::get_block_name ( int  index)

Get the block name for the given block index if supplied in the mesh file. Otherwise an empty string is returned.

Definition at line 547 of file exodusII_io_helper.C.

References block_ids, and id_to_block_names.

548 {
549  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
550 
551  return id_to_block_names[block_ids[index]];
552 }
std::map< int, std::string > id_to_block_names
std::vector< std::string > libMesh::ExodusII_IO_Helper::get_complex_names ( const std::vector< std::string > &  names) const
Returns
A vector with three copies of each element in the provided name vector, starting with r_, i_ and a_ respectively.

Definition at line 2027 of file exodusII_io_helper.C.

2028 {
2029  std::vector<std::string>::const_iterator names_it = names.begin();
2030  std::vector<std::string>::const_iterator names_end = names.end();
2031 
2032  std::vector<std::string> complex_names;
2033 
2034  // This will loop over all names and create new "complex" names
2035  // (i.e. names that start with r_, i_ or a_
2036  for (; names_it != names_end; ++names_it)
2037  {
2038  std::stringstream name_real, name_imag, name_abs;
2039  name_real << "r_" << *names_it;
2040  name_imag << "i_" << *names_it;
2041  name_abs << "a_" << *names_it;
2042 
2043  complex_names.push_back(name_real.str());
2044  complex_names.push_back(name_imag.str());
2045  complex_names.push_back(name_abs.str());
2046  }
2047 
2048  return complex_names;
2049 }
const char * libMesh::ExodusII_IO_Helper::get_elem_type ( ) const
Returns
The current element type.
Note
The default behavior is for this value to be in all capital letters, e.g. HEX27.

Definition at line 311 of file exodusII_io_helper.C.

References elem_type.

312 {
313  return &elem_type[0];
314 }
int libMesh::ExodusII_IO_Helper::get_node_set_id ( int  index)

Get the node set id for the given node set index.

Definition at line 574 of file exodusII_io_helper.C.

References nodeset_ids.

575 {
576  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
577 
578  return nodeset_ids[index];
579 }
std::string libMesh::ExodusII_IO_Helper::get_node_set_name ( int  index)

Get the node set name for the given node set index if supplied in the mesh file. Otherwise an empty string is returned.

Definition at line 583 of file exodusII_io_helper.C.

References id_to_ns_names, and nodeset_ids.

584 {
585  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
586 
587  return id_to_ns_names[nodeset_ids[index]];
588 }
std::map< int, std::string > id_to_ns_names
int libMesh::ExodusII_IO_Helper::get_side_set_id ( int  index)

Get the side set id for the given side set index.

Definition at line 556 of file exodusII_io_helper.C.

References ss_ids.

557 {
558  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
559 
560  return ss_ids[index];
561 }
std::string libMesh::ExodusII_IO_Helper::get_side_set_name ( int  index)

Get the side set name for the given side set index if supplied in the mesh file. Otherwise an empty string is returned.

Definition at line 565 of file exodusII_io_helper.C.

References id_to_ss_names, and ss_ids.

566 {
567  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
568 
569  return id_to_ss_names[ss_ids[index]];
570 }
std::map< int, std::string > id_to_ss_names
void libMesh::ExodusII_IO_Helper::initialize ( std::string  title,
const MeshBase mesh,
bool  use_discontinuous = false 
)
virtual

Initializes the Exodus file.

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1113 of file exodusII_io_helper.C.

References _run_only_on_proc0, _use_mesh_dimension_instead_of_spatial_dimension, _write_as_dimension, libMesh::MeshBase::active_element_ptr_range(), libMesh::BoundaryInfo::build_node_boundary_ids(), libMesh::BoundaryInfo::build_shellface_boundary_ids(), libMesh::BoundaryInfo::build_side_boundary_ids(), libMesh::err, ex_err, ex_id, ex_put_init(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), num_dim, num_elem, num_elem_blk, num_node_sets, num_nodes, num_side_sets, libMesh::ParallelObject::processor_id(), and libMesh::MeshBase::spatial_dimension().

1114 {
1115  // n_active_elem() is a parallel_only function
1116  unsigned int n_active_elem = mesh.n_active_elem();
1117 
1118  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1119  return;
1120 
1121  // If _write_as_dimension is nonzero, use it to set num_dim in the Exodus file.
1122  if (_write_as_dimension)
1125  num_dim = mesh.mesh_dimension();
1126  else
1127  num_dim = mesh.spatial_dimension();
1128 
1129  num_elem = mesh.n_elem();
1130 
1131  if (!use_discontinuous)
1132  {
1133  // Don't rely on mesh.n_nodes() here. If nodes have been
1134  // deleted recently, it will be incorrect.
1135  num_nodes = cast_int<int>(std::distance(mesh.nodes_begin(),
1136  mesh.nodes_end()));
1137  }
1138  else
1139  {
1140  for (const auto & elem : mesh.active_element_ptr_range())
1141  num_nodes += elem->n_nodes();
1142  }
1143 
1144  std::vector<boundary_id_type> unique_side_boundaries;
1145  std::vector<boundary_id_type> unique_node_boundaries;
1146 
1147  mesh.get_boundary_info().build_side_boundary_ids(unique_side_boundaries);
1148  {
1149  // Add shell face boundaries to the list of side boundaries, since ExodusII
1150  // treats these the same way.
1151  std::vector<boundary_id_type> shellface_boundaries;
1152  mesh.get_boundary_info().build_shellface_boundary_ids(shellface_boundaries);
1153  for (std::size_t i=0; i<shellface_boundaries.size(); i++)
1154  unique_side_boundaries.push_back(shellface_boundaries[i]);
1155  }
1156  mesh.get_boundary_info().build_node_boundary_ids(unique_node_boundaries);
1157 
1158  num_side_sets = cast_int<int>(unique_side_boundaries.size());
1159  num_node_sets = cast_int<int>(unique_node_boundaries.size());
1160 
1161  //loop through element and map between block and element vector
1162  std::map<subdomain_id_type, std::vector<unsigned int>> subdomain_map;
1163 
1164  for (const auto & elem : mesh.active_element_ptr_range())
1165  {
1166  // We skip writing infinite elements to the Exodus file, so
1167  // don't put them in the subdomain_map. That way the number of
1168  // blocks should be correct.
1169 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1170  if (elem->infinite())
1171  continue;
1172 #endif
1173 
1174  subdomain_id_type cur_subdomain = elem->subdomain_id();
1175  subdomain_map[cur_subdomain].push_back(elem->id());
1176  }
1177  num_elem_blk = cast_int<int>(subdomain_map.size());
1178 
1179  if (str_title.size() > MAX_LINE_LENGTH)
1180  {
1181  libMesh::err << "Warning, Exodus files cannot have titles longer than "
1182  << MAX_LINE_LENGTH
1183  << " characters. Your title will be truncated."
1184  << std::endl;
1185  str_title.resize(MAX_LINE_LENGTH);
1186  }
1187 
1189  str_title.c_str(),
1190  num_dim,
1191  num_nodes,
1192  n_active_elem,
1193  num_elem_blk,
1194  num_node_sets,
1195  num_side_sets);
1196 
1197  EX_CHECK_ERR(ex_err, "Error initializing new Exodus file.");
1198 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
virtual dof_id_type n_active_elem() const =0
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
EXODUS_EXPORT int ex_put_init(int exoid, const char *title, int64_t num_dim, int64_t num_nodes, int64_t num_elem, int64_t num_elem_blk, int64_t num_node_sets, int64_t num_side_sets)
virtual node_iterator nodes_begin()=0
void build_side_boundary_ids(std::vector< boundary_id_type > &b_ids) const
unsigned int spatial_dimension() const
Definition: mesh_base.C:159
OStreamProxy err(std::cerr)
virtual node_iterator nodes_end()=0
unsigned int mesh_dimension() const
Definition: mesh_base.C:150
void build_shellface_boundary_ids(std::vector< boundary_id_type > &b_ids) const
virtual dof_id_type n_elem() const =0
void build_node_boundary_ids(std::vector< boundary_id_type > &b_ids) const
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::initialize_element_variables ( std::vector< std::string >  names)

Sets up the nodal variables

Definition at line 1690 of file exodusII_io_helper.C.

References _elem_vars_initialized, _run_only_on_proc0, check_existing_vars(), elem_var_names, ELEMENTAL, ex_err, ex_id, ex_put_elem_var_tab(), num_elem_blk, num_elem_vars, libMesh::ParallelObject::processor_id(), and write_var_names().

1691 {
1692  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1693  return;
1694 
1695  // Quick return if there are no element variables to write
1696  if (names.size() == 0)
1697  return;
1698 
1699  // Quick return if we have already called this function
1701  return;
1702 
1703  // Be sure that variables in the file match what we are asking for
1704  if (num_elem_vars > 0)
1705  {
1706  this->check_existing_vars(ELEMENTAL, names, this->elem_var_names);
1707  return;
1708  }
1709 
1710  // Set the flag so we can skip this stuff on subsequent calls to
1711  // initialize_element_variables()
1712  _elem_vars_initialized = true;
1713 
1714  this->write_var_names(ELEMENTAL, names);
1715 
1716  // Form the element variable truth table and send to Exodus.
1717  // This tells which variables are written to which blocks,
1718  // and can dramatically speed up writing element variables
1719  //
1720  // We really should initialize all entries in the truth table to 0
1721  // and then loop over all subdomains, setting their entries to 1
1722  // if a given variable exists on that subdomain. However,
1723  // we don't have that information, and the element variables
1724  // passed to us are padded with zeroes for the blocks where
1725  // they aren't defined. To be consistent with that, fill
1726  // the truth table with ones.
1727  std::vector<int> truth_tab(num_elem_blk*num_elem_vars, 1);
1729  num_elem_blk,
1730  num_elem_vars,
1731  &truth_tab[0]);
1732  EX_CHECK_ERR(ex_err, "Error writing element truth table.");
1733 }
std::vector< std::string > elem_var_names
void write_var_names(ExodusVarType type, std::vector< std::string > &names)
void check_existing_vars(ExodusVarType type, std::vector< std::string > &names, std::vector< std::string > &names_from_file)
EXODUS_EXPORT int ex_put_elem_var_tab(int exoid, int num_elem_blk, int num_elem_var, int *elem_var_tab)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::initialize_global_variables ( std::vector< std::string >  names)

Sets up the global variables

Definition at line 1765 of file exodusII_io_helper.C.

References _global_vars_initialized, _run_only_on_proc0, check_existing_vars(), GLOBAL, global_var_names, num_global_vars, libMesh::ParallelObject::processor_id(), and write_var_names().

1766 {
1767  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1768  return;
1769 
1770  // Quick return if there are no global variables to write
1771  if (names.size() == 0)
1772  return;
1773 
1775  return;
1776 
1777  // Be sure that variables in the file match what we are asking for
1778  if (num_global_vars > 0)
1779  {
1780  this->check_existing_vars(GLOBAL, names, this->global_var_names);
1781  return;
1782  }
1783 
1784  _global_vars_initialized = true;
1785 
1786  this->write_var_names(GLOBAL, names);
1787 }
void write_var_names(ExodusVarType type, std::vector< std::string > &names)
void check_existing_vars(ExodusVarType type, std::vector< std::string > &names, std::vector< std::string > &names_from_file)
std::vector< std::string > global_var_names
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::initialize_nodal_variables ( std::vector< std::string >  names)

Sets up the nodal variables

Definition at line 1737 of file exodusII_io_helper.C.

References _nodal_vars_initialized, _run_only_on_proc0, check_existing_vars(), NODAL, nodal_var_names, num_nodal_vars, libMesh::ParallelObject::processor_id(), and write_var_names().

1738 {
1739  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1740  return;
1741 
1742  // Quick return if there are no nodal variables to write
1743  if (names.size() == 0)
1744  return;
1745 
1746  // Quick return if we have already called this function
1748  return;
1749 
1750  // Be sure that variables in the file match what we are asking for
1751  if (num_nodal_vars > 0)
1752  {
1753  this->check_existing_vars(NODAL, names, this->nodal_var_names);
1754  return;
1755  }
1756 
1757  // Set the flag so we can skip the rest of this function on subsequent calls.
1758  _nodal_vars_initialized = true;
1759 
1760  this->write_var_names(NODAL, names);
1761 }
void write_var_names(ExodusVarType type, std::vector< std::string > &names)
void check_existing_vars(ExodusVarType type, std::vector< std::string > &names, std::vector< std::string > &names_from_file)
std::vector< std::string > nodal_var_names
processor_id_type processor_id() const
int libMesh::ExodusII_IO_Helper::inquire ( int  req_info,
std::string  error_msg = "" 
)
Returns
The value obtained from a generic exII::ex_inquire() call.

Definition at line 808 of file exodusII_io_helper.C.

References ex_err, ex_id, and ex_inquire().

Referenced by read_num_time_steps(), read_qa_records(), read_sideset_info(), and write_information_records().

809 {
810  int ret_int = 0;
811  char ret_char = 0;
812  float ret_float = 0.;
813 
815  req_info_in,
816  &ret_int,
817  &ret_float,
818  &ret_char);
819 
820  EX_CHECK_ERR(ex_err, error_msg);
821 
822  return ret_int;
823 }
EXODUS_EXPORT int ex_inquire(int exoid, int inquiry, void_int *, float *, char *)
void libMesh::ExodusII_IO_Helper::message ( const std::string &  msg)

Prints the message defined in msg. Can be turned off if verbosity is set to 0.

Definition at line 318 of file exodusII_io_helper.C.

References libMesh::out, and verbose.

Referenced by close(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_header(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_sideset(), and read_sideset_info().

319 {
320  if (verbose) libMesh::out << msg << std::endl;
321 }
OStreamProxy out(std::cout)
void libMesh::ExodusII_IO_Helper::message ( const std::string &  msg,
int  i 
)

Prints the message defined in msg, and appends the number i to the end of the message. Useful for printing messages in loops. Can be turned off if verbosity is set to 0.

Definition at line 325 of file exodusII_io_helper.C.

References libMesh::out, and verbose.

326 {
327  if (verbose) libMesh::out << msg << i << "." << std::endl;
328 }
OStreamProxy out(std::cout)
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), 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(), 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:725
const Parallel::Communicator & _communicator
void libMesh::ExodusII_IO_Helper::open ( const char *  filename,
bool  read_only 
)

Opens an ExodusII mesh file named filename. If read_only==true, the file will be opened with the EX_READ flag, otherwise it will be opened with the EX_WRITE flag.

Definition at line 332 of file exodusII_io_helper.C.

References _single_precision, current_filename, ex_id, std::min(), opened_for_reading, opened_for_writing, libMesh::out, libMesh::Real, and verbose.

333 {
334  // Version of Exodus you are using
335  float ex_version = 0.;
336 
337  int comp_ws = 0;
338 
339  if (_single_precision)
340  comp_ws = cast_int<int>(sizeof(float));
341 
342  // Fall back on double precision when necessary since ExodusII
343  // doesn't seem to support long double
344  else
345  comp_ws = cast_int<int>(std::min(sizeof(Real), sizeof(double)));
346 
347  // Word size in bytes of the floating point data as they are stored
348  // in the ExodusII file. "If this argument is 0, the word size of the
349  // floating point data already stored in the file is returned"
350  int io_ws = 0;
351 
352  ex_id = exII::ex_open(filename,
353  read_only ? EX_READ : EX_WRITE,
354  &comp_ws,
355  &io_ws,
356  &ex_version);
357 
358  std::string err_msg = std::string("Error opening ExodusII mesh file: ") + std::string(filename);
359  EX_CHECK_ERR(ex_id, err_msg);
360  if (verbose) libMesh::out << "File opened successfully." << std::endl;
361 
362  if (read_only)
363  opened_for_reading = true;
364  else
365  opened_for_writing = true;
366 
367  current_filename = std::string(filename);
368 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out(std::cout)
long double min(long double a, double b)
void libMesh::ExodusII_IO_Helper::print_header ( )

Prints the ExodusII mesh file header, which includes the mesh title, the number of nodes, number of elements, mesh dimension, number of sidesets, and number of nodesets.

Definition at line 452 of file exodusII_io_helper.C.

References num_dim, num_elem, num_elem_blk, num_node_sets, num_nodes, num_side_sets, libMesh::out, title, and verbose.

453 {
454  if (verbose)
455  libMesh::out << "Title: \t" << &title[0] << std::endl
456  << "Mesh Dimension: \t" << num_dim << std::endl
457  << "Number of Nodes: \t" << num_nodes << std::endl
458  << "Number of elements: \t" << num_elem << std::endl
459  << "Number of elt blocks: \t" << num_elem_blk << std::endl
460  << "Number of node sets: \t" << num_node_sets << std::endl
461  << "Number of side sets: \t" << num_side_sets << std::endl;
462 }
OStreamProxy out(std::cout)
void libMesh::ExodusII_IO_Helper::print_nodes ( std::ostream &  out = libMesh::out)

Prints the nodal information, by default to libMesh::out.

Definition at line 503 of file exodusII_io_helper.C.

References num_nodes, x, y, and z.

504 {
505  for (int i=0; i<num_nodes; i++)
506  out_stream << "(" << x[i] << ", " << y[i] << ", " << z[i] << ")" << std::endl;
507 }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), libMesh::DistributedMesh::clear(), close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::EquationSystems::get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), initialize(), initialize_element_variables(), initialize_global_variables(), initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), read_elem_num_map(), read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), read_node_num_map(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), write_element_values(), write_elements(), libMesh::ExodusII_IO::write_global_data(), write_global_values(), libMesh::ExodusII_IO::write_information_records(), write_information_records(), write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), write_nodesets(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), write_sidesets(), libMesh::ExodusII_IO::write_timestep(), write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:723
void libMesh::ExodusII_IO_Helper::read_block_info ( )

Reads information for all of the blocks in the ExodusII mesh file.

Definition at line 511 of file exodusII_io_helper.C.

References block_ids, EX_ELEM_BLOCK, ex_err, ex_get_elem_blk_ids(), ex_get_name(), ex_id, id_to_block_names, libmesh_nullptr, message(), and num_elem_blk.

512 {
513  block_ids.resize(num_elem_blk);
514  // Get all element block IDs.
516  block_ids.empty() ? libmesh_nullptr : &block_ids[0]);
517  // Usually, there is only one
518  // block since there is only
519  // one type of element.
520  // However, there could be more.
521 
522  EX_CHECK_ERR(ex_err, "Error getting block IDs.");
523  message("All block IDs retrieved successfully.");
524 
525  char name_buffer[MAX_STR_LENGTH+1];
526  for (int i=0; i<num_elem_blk; ++i)
527  {
529  block_ids[i], name_buffer);
530  EX_CHECK_ERR(ex_err, "Error getting block name.");
531  id_to_block_names[block_ids[i]] = name_buffer;
532  }
533  message("All block names retrieved successfully.");
534 }
EXODUS_EXPORT int ex_get_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, char *name)
const class libmesh_nullptr_t libmesh_nullptr
EXODUS_EXPORT int ex_get_elem_blk_ids(int exoid, void_int *ids)
void message(const std::string &msg)
std::map< int, std::string > id_to_block_names
void libMesh::ExodusII_IO_Helper::read_elem_in_block ( int  block)

Reads all of the element connectivity for block block in the ExodusII mesh file.

Definition at line 593 of file exodusII_io_helper.C.

References block_ids, connect, elem_type, ex_err, ex_get_elem_block(), ex_get_elem_conn(), ex_id, message(), num_attr, num_elem_this_blk, num_nodes_per_elem, libMesh::out, and verbose.

594 {
595  libmesh_assert_less (static_cast<unsigned int>(block), block_ids.size());
596 
598  block_ids[block],
599  &elem_type[0],
602  &num_attr);
603  if (verbose)
604  libMesh::out << "Reading a block of " << num_elem_this_blk
605  << " " << &elem_type[0] << "(s)"
606  << " having " << num_nodes_per_elem
607  << " nodes per element." << std::endl;
608 
609  EX_CHECK_ERR(ex_err, "Error getting block info.");
610  message("Info retrieved successfully for block: ", block);
611 
612 
613 
614  // Read in the connectivity of the elements of this block,
615  // watching out for the case where we actually have no
616  // elements in this block (possible with parallel files)
618 
619  if (!connect.empty())
620  {
621  ex_err = exII::ex_get_elem_conn(ex_id,
622  block_ids[block],
623  &connect[0]);
624 
625  EX_CHECK_ERR(ex_err, "Error reading block connectivity.");
626  message("Connectivity retrieved successfully for block: ", block);
627  }
628 }
EXODUS_EXPORT int ex_get_elem_block(int exoid, ex_entity_id elem_blk_id, char *elem_type, void_int *num_elem_this_blk, void_int *num_nodes_per_elem, void_int *num_attr)
void message(const std::string &msg)
EXODUS_EXPORT int ex_get_elem_conn(int exoid, ex_entity_id elem_blk_id, void_int *connect)
OStreamProxy out(std::cout)
void libMesh::ExodusII_IO_Helper::read_elem_num_map ( )

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 633 of file exodusII_io_helper.C.

References elem_num_map, ex_err, ex_get_elem_num_map(), ex_id, libmesh_nullptr, message(), std::min(), num_elem, libMesh::out, libMesh::ParallelObject::processor_id(), and verbose.

634 {
635  elem_num_map.resize(num_elem);
636 
638  elem_num_map.empty() ? libmesh_nullptr : &elem_num_map[0]);
639 
640  EX_CHECK_ERR(ex_err, "Error retrieving element number map.");
641  message("Element numbering map retrieved successfully.");
642 
643 
644  if (verbose)
645  {
646  libMesh::out << "[" << this->processor_id() << "] elem_num_map[i] = ";
647  for (unsigned int i=0; i<static_cast<unsigned int>(std::min(10, num_elem-1)); ++i)
648  libMesh::out << elem_num_map[i] << ", ";
649  libMesh::out << "... " << elem_num_map.back() << std::endl;
650  }
651 }
const class libmesh_nullptr_t libmesh_nullptr
EXODUS_EXPORT int ex_get_elem_num_map(int exoid, void_int *elem_map)
void message(const std::string &msg)
OStreamProxy out(std::cout)
long double min(long double a, double b)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::read_elemental_var_values ( std::string  elemental_var_name,
int  time_step,
std::map< dof_id_type, Real > &  elem_var_value_map 
)

Reads elemental values for the variable 'elemental_var_name' at the specified timestep into the 'elem_var_value_map' which is passed in.

Definition at line 1006 of file exodusII_io_helper.C.

References block_ids, elem_num_map, elem_var_names, ELEMENTAL, libMesh::err, ex_err, ex_get_elem_block(), ex_get_elem_var(), ex_id, libmesh_nullptr, num_elem, num_elem_blk, num_elem_this_blk, and read_var_names().

1009 {
1010  this->read_var_names(ELEMENTAL);
1011 
1012  // See if we can find the variable we are looking for
1013  std::size_t var_index = 0;
1014  bool found = false;
1015 
1016  // Do a linear search for nodal_var_name in nodal_var_names
1017  for (; var_index<elem_var_names.size(); ++var_index)
1018  if (elem_var_names[var_index] == elemental_var_name)
1019  {
1020  found = true;
1021  break;
1022  }
1023 
1024  if (!found)
1025  {
1026  libMesh::err << "Available variables: " << std::endl;
1027  for (std::size_t i=0; i<elem_var_names.size(); ++i)
1028  libMesh::err << elem_var_names[i] << std::endl;
1029 
1030  libmesh_error_msg("Unable to locate variable named: " << elemental_var_name);
1031  }
1032 
1033  // Sequential index which we can use to look up the element ID in the elem_num_map.
1034  unsigned ex_el_num = 0;
1035 
1036  for (unsigned i=0; i<static_cast<unsigned>(num_elem_blk); i++)
1037  {
1039  block_ids[i],
1043  libmesh_nullptr);
1044  EX_CHECK_ERR(ex_err, "Error getting number of elements in block.");
1045 
1046  std::vector<Real> block_elem_var_values(num_elem);
1048  time_step,
1049  var_index+1,
1050  block_ids[i],
1052  &block_elem_var_values[0]);
1053  EX_CHECK_ERR(ex_err, "Error getting elemental values.");
1054 
1055  for (unsigned j=0; j<static_cast<unsigned>(num_elem_this_blk); j++)
1056  {
1057  // Use the elem_num_map to obtain the ID of this element in the Exodus file,
1058  // and remember to subtract 1 since libmesh is zero-based and Exodus is 1-based.
1059  unsigned mapped_elem_id = this->elem_num_map[ex_el_num] - 1;
1060 
1061  // Store the elemental value in the map.
1062  elem_var_value_map[mapped_elem_id] = block_elem_var_values[j];
1063 
1064  // Go to the next sequential element ID.
1065  ex_el_num++;
1066  }
1067  }
1068 }
EXODUS_EXPORT int ex_get_elem_block(int exoid, ex_entity_id elem_blk_id, char *elem_type, void_int *num_elem_this_blk, void_int *num_nodes_per_elem, void_int *num_attr)
std::vector< std::string > elem_var_names
const class libmesh_nullptr_t libmesh_nullptr
void read_var_names(ExodusVarType type)
OStreamProxy err(std::cerr)
EXODUS_EXPORT int ex_get_elem_var(int exoid, int time_step, int elem_var_index, ex_entity_id elem_blk_id, int64_t num_elem_this_blk, void *elem_var_vals)
void libMesh::ExodusII_IO_Helper::read_global_values ( std::vector< Real > &  values,
int  timestep 
)

Reads the vector of global variables.

Definition at line 1994 of file exodusII_io_helper.C.

References _run_only_on_proc0, ex_err, ex_get_glob_vars(), ex_id, num_global_vars, and libMesh::ParallelObject::processor_id().

1995 {
1996  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1997  return;
1998 
1999  values.clear();
2000  values.resize(num_global_vars);
2001  ex_err = exII::ex_get_glob_vars(ex_id, timestep, num_global_vars, &values[0]);
2002  EX_CHECK_ERR(ex_err, "Error reading global values.");
2003 }
EXODUS_EXPORT int ex_get_glob_vars(int exoid, int time_step, int num_glob_vars, void *glob_var_vals)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::read_header ( )

Reads an ExodusII mesh file header.

Definition at line 372 of file exodusII_io_helper.C.

References ex_err, ex_get_init(), ex_get_var_param(), ex_id, message(), num_dim, num_elem, num_elem_blk, num_elem_vars, num_global_vars, num_nodal_vars, num_node_sets, num_nodes, num_side_sets, read_num_time_steps(), and title.

373 {
375  &title[0],
376  &num_dim,
377  &num_nodes,
378  &num_elem,
379  &num_elem_blk,
380  &num_node_sets,
381  &num_side_sets);
382 
383  EX_CHECK_ERR(ex_err, "Error retrieving header info.");
384 
385  this->read_num_time_steps();
386 
388  EX_CHECK_ERR(ex_err, "Error reading number of nodal variables.");
389 
391  EX_CHECK_ERR(ex_err, "Error reading number of elemental variables.");
392 
394  EX_CHECK_ERR(ex_err, "Error reading number of global variables.");
395 
396  message("Exodus header info retrieved successfully.");
397 }
EXODUS_EXPORT int ex_get_init(int exoid, char *title, void_int *num_dim, void_int *num_nodes, void_int *num_elem, void_int *num_elem_blk, void_int *num_node_sets, void_int *num_side_sets)
void message(const std::string &msg)
EXODUS_EXPORT int ex_get_var_param(int exoid, const char *var_type, int *num_vars)
void libMesh::ExodusII_IO_Helper::read_nodal_var_values ( std::string  nodal_var_name,
int  time_step 
)

Reads the nodal values for the variable 'nodal_var_name' at the specified time into the 'nodal_var_values' array.

Definition at line 850 of file exodusII_io_helper.C.

References libMesh::err, ex_err, ex_get_nodal_var(), ex_id, NODAL, nodal_var_names, nodal_var_values, num_nodes, and read_var_names().

851 {
852  // Read the nodal variable names from file, so we can see if we have the one we're looking for
853  this->read_var_names(NODAL);
854 
855  // See if we can find the variable we are looking for
856  std::size_t var_index = 0;
857  bool found = false;
858 
859  // Do a linear search for nodal_var_name in nodal_var_names
860  for (; var_index<nodal_var_names.size(); ++var_index)
861  {
862  found = (nodal_var_names[var_index] == nodal_var_name);
863  if (found)
864  break;
865  }
866 
867  if (!found)
868  {
869  libMesh::err << "Available variables: " << std::endl;
870  for (std::size_t i=0; i<nodal_var_names.size(); ++i)
871  libMesh::err << nodal_var_names[i] << std::endl;
872 
873  libmesh_error_msg("Unable to locate variable named: " << nodal_var_name);
874  }
875 
876  // Allocate enough space to store the nodal variable values
877  nodal_var_values.resize(num_nodes);
878 
879  // Call the Exodus API to read the nodal variable values
881  time_step,
882  var_index+1,
883  num_nodes,
884  &nodal_var_values[0]);
885  EX_CHECK_ERR(ex_err, "Error reading nodal variable values!");
886 }
std::vector< Real > nodal_var_values
EXODUS_EXPORT int ex_get_nodal_var(int exoid, int time_step, int nodal_var_index, int64_t num_nodes, void *nodal_var_vals)
void read_var_names(ExodusVarType type)
OStreamProxy err(std::cerr)
std::vector< std::string > nodal_var_names
void libMesh::ExodusII_IO_Helper::read_node_num_map ( )

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 483 of file exodusII_io_helper.C.

References ex_err, ex_get_node_num_map(), ex_id, libmesh_nullptr, message(), std::min(), node_num_map, num_nodes, libMesh::out, libMesh::ParallelObject::processor_id(), and verbose.

484 {
485  node_num_map.resize(num_nodes);
486 
488  node_num_map.empty() ? libmesh_nullptr : &node_num_map[0]);
489 
490  EX_CHECK_ERR(ex_err, "Error retrieving nodal number map.");
491  message("Nodal numbering map retrieved successfully.");
492 
493  if (verbose)
494  {
495  libMesh::out << "[" << this->processor_id() << "] node_num_map[i] = ";
496  for (unsigned int i=0; i<static_cast<unsigned int>(std::min(10, num_nodes-1)); ++i)
497  libMesh::out << node_num_map[i] << ", ";
498  libMesh::out << "... " << node_num_map.back() << std::endl;
499  }
500 }
EXODUS_EXPORT int ex_get_node_num_map(int exoid, void_int *node_map)
const class libmesh_nullptr_t libmesh_nullptr
void message(const std::string &msg)
OStreamProxy out(std::cout)
long double min(long double a, double b)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::read_nodes ( )

Reads the nodal data (x,y,z coordinates) from the ExodusII mesh file.

Definition at line 466 of file exodusII_io_helper.C.

References ex_err, ex_get_coord(), ex_id, message(), num_nodes, x, y, and z.

467 {
468  x.resize(num_nodes);
469  y.resize(num_nodes);
470  z.resize(num_nodes);
471 
473  static_cast<void *>(&x[0]),
474  static_cast<void *>(&y[0]),
475  static_cast<void *>(&z[0]));
476 
477  EX_CHECK_ERR(ex_err, "Error retrieving nodal data.");
478  message("Nodal data retrieved successfully.");
479 }
EXODUS_EXPORT int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
void message(const std::string &msg)
void libMesh::ExodusII_IO_Helper::read_nodeset ( int  id)

Reads information about nodeset id and inserts it into the global nodeset array at the position offset.

Definition at line 759 of file exodusII_io_helper.C.

References ex_err, ex_get_node_set(), ex_get_node_set_param(), ex_id, message(), node_list, nodeset_ids, num_node_df_per_set, and num_nodes_per_set.

760 {
761  libmesh_assert_less (static_cast<unsigned int>(id), nodeset_ids.size());
762  libmesh_assert_less (static_cast<unsigned int>(id), num_nodes_per_set.size());
763  libmesh_assert_less (static_cast<unsigned int>(id), num_node_df_per_set.size());
764 
766  nodeset_ids[id],
767  &num_nodes_per_set[id],
768  &num_node_df_per_set[id]);
769  EX_CHECK_ERR(ex_err, "Error retrieving nodeset parameters.");
770  message("Parameters retrieved successfully for nodeset: ", id);
771 
772  node_list.resize(num_nodes_per_set[id]);
773 
774  // Don't call ex_get_node_set unless there are actually nodes there to get.
775  // Exodus prints an annoying warning message in DEBUG mode otherwise...
776  if (num_nodes_per_set[id] > 0)
777  {
778  ex_err = exII::ex_get_node_set(ex_id,
779  nodeset_ids[id],
780  &node_list[0]);
781 
782  EX_CHECK_ERR(ex_err, "Error retrieving nodeset data.");
783  message("Data retrieved successfully for nodeset: ", id);
784  }
785 }
EXODUS_EXPORT int ex_get_node_set_param(int exoid, ex_entity_id node_set_id, void_int *num_nodes_in_set, void_int *num_df_in_set)
EXODUS_EXPORT int ex_get_node_set(int exoid, ex_entity_id node_set_id, void_int *node_set_node_list)
std::vector< int > num_node_df_per_set
void message(const std::string &msg)
std::vector< int > num_nodes_per_set
void libMesh::ExodusII_IO_Helper::read_nodeset_info ( )

Reads information about all of the nodesets in the ExodusII mesh file.

Definition at line 688 of file exodusII_io_helper.C.

References ex_err, ex_get_name(), ex_get_node_set_ids(), ex_id, EX_NODE_SET, id_to_ns_names, message(), nodeset_ids, num_node_df_per_set, num_node_sets, and num_nodes_per_set.

689 {
690  nodeset_ids.resize(num_node_sets);
691  if (num_node_sets > 0)
692  {
694  &nodeset_ids[0]);
695  EX_CHECK_ERR(ex_err, "Error retrieving nodeset information.");
696  message("All nodeset information retrieved successfully.");
697 
698  // Resize appropriate data structures -- only do this once outnode the loop
701  }
702 
703  char name_buffer[MAX_STR_LENGTH+1];
704  for (int i=0; i<num_node_sets; ++i)
705  {
707  nodeset_ids[i], name_buffer);
708  EX_CHECK_ERR(ex_err, "Error getting node set name.");
709  id_to_ns_names[nodeset_ids[i]] = name_buffer;
710  }
711  message("All node set names retrieved successfully.");
712 }
EXODUS_EXPORT int ex_get_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, char *name)
EXODUS_EXPORT int ex_get_node_set_ids(int exoid, void_int *ids)
std::vector< int > num_node_df_per_set
void message(const std::string &msg)
std::map< int, std::string > id_to_ns_names
std::vector< int > num_nodes_per_set
void libMesh::ExodusII_IO_Helper::read_num_time_steps ( )

Reads the number of timesteps currently stored in the Exodus file and stores it in the num_time_steps variable.

Definition at line 842 of file exodusII_io_helper.C.

References EX_INQ_TIME, inquire(), and num_time_steps.

Referenced by read_header(), and read_time_steps().

843 {
845  this->inquire(exII::EX_INQ_TIME, "Error retrieving number of time steps");
846 }
int inquire(int req_info, std::string error_msg="")
void libMesh::ExodusII_IO_Helper::read_qa_records ( )

Reads the QA records from an ExodusII file. We can use this to detect when e.g. CUBIT 14+ was used to generate a Mesh file, and work around certain known bugs in that version.

Definition at line 402 of file exodusII_io_helper.C.

References ex_err, ex_get_qa(), ex_id, EX_INQ_QA, inquire(), libMesh::out, and verbose.

403 {
404  // The QA records are four MAX_STR_LENGTH-byte character strings.
405  int num_qa_rec =
406  this->inquire(exII::EX_INQ_QA, "Error retrieving number of QA records");
407 
408  if (verbose)
409  libMesh::out << "Found "
410  << num_qa_rec
411  << " QA record(s) in the Exodus file."
412  << std::endl;
413 
414  if (num_qa_rec > 0)
415  {
416  // How to dynamically allocate an array of fixed-size char * arrays in C++.
417  // http://stackoverflow.com/questions/8529359/creating-a-dynamic-sized-array-of-fixed-sized-int-arrays-in-c
418  typedef char * inner_array_t[4];
419  inner_array_t * qa_record = new inner_array_t[num_qa_rec];
420 
421  for (int i=0; i<num_qa_rec; i++)
422  for (int j=0; j<4; j++)
423  qa_record[i][j] = new char[MAX_STR_LENGTH+1];
424 
425  ex_err = exII::ex_get_qa (ex_id, qa_record);
426  EX_CHECK_ERR(ex_err, "Error reading the QA records.");
427 
428  // Print the QA records
429  if (verbose)
430  {
431  for (int i=0; i<num_qa_rec; i++)
432  {
433  libMesh::out << "QA Record: " << i << std::endl;
434  for (int j=0; j<4; j++)
435  libMesh::out << qa_record[i][j] << std::endl;
436  }
437  }
438 
439 
440  // Clean up dynamically-allocated memory
441  for (int i=0; i<num_qa_rec; i++)
442  for (int j=0; j<4; j++)
443  delete [] qa_record[i][j];
444 
445  delete [] qa_record;
446  }
447 }
EXODUS_EXPORT int ex_get_qa(int exoid, char *qa_record[][4])
int inquire(int req_info, std::string error_msg="")
OStreamProxy out(std::cout)
void libMesh::ExodusII_IO_Helper::read_sideset ( int  id,
int  offset 
)

Reads information about sideset id and inserts it into the global sideset array at the position offset.

Definition at line 716 of file exodusII_io_helper.C.

References elem_list, ex_err, ex_get_side_set(), ex_get_side_set_param(), ex_id, id_list, message(), num_df_per_set, num_sides_per_set, side_list, and ss_ids.

717 {
718  libmesh_assert_less (static_cast<unsigned int>(id), ss_ids.size());
719  libmesh_assert_less (static_cast<unsigned int>(id), num_sides_per_set.size());
720  libmesh_assert_less (static_cast<unsigned int>(id), num_df_per_set.size());
721  libmesh_assert_less_equal (static_cast<unsigned int>(offset), elem_list.size());
722  libmesh_assert_less_equal (static_cast<unsigned int>(offset), side_list.size());
723 
725  ss_ids[id],
726  &num_sides_per_set[id],
727  &num_df_per_set[id]);
728  EX_CHECK_ERR(ex_err, "Error retrieving sideset parameters.");
729  message("Parameters retrieved successfully for sideset: ", id);
730 
731 
732  // It's OK for offset==elem_list.size() as long as num_sides_per_set[id]==0
733  // because in that case we don't actually read anything...
734 #ifdef DEBUG
735  if (static_cast<unsigned int>(offset) == elem_list.size() ||
736  static_cast<unsigned int>(offset) == side_list.size() )
737  libmesh_assert_equal_to (num_sides_per_set[id], 0);
738 #endif
739 
740 
741  // Don't call ex_get_side_set unless there are actually sides there to get.
742  // Exodus prints an annoying warning in DEBUG mode otherwise...
743  if (num_sides_per_set[id] > 0)
744  {
745  ex_err = exII::ex_get_side_set(ex_id,
746  ss_ids[id],
747  &elem_list[offset],
748  &side_list[offset]);
749  EX_CHECK_ERR(ex_err, "Error retrieving sideset data.");
750  message("Data retrieved successfully for sideset: ", id);
751 
752  for (int i=0; i<num_sides_per_set[id]; i++)
753  id_list[i+offset] = ss_ids[id];
754  }
755 }
std::vector< int > num_sides_per_set
EXODUS_EXPORT int ex_get_side_set(int exoid, ex_entity_id side_set_id, void_int *side_set_elem_list, void_int *side_set_side_list)
EXODUS_EXPORT int ex_get_side_set_param(int exoid, ex_entity_id side_set_id, void_int *num_side_in_set, void_int *num_dist_fact_in_set)
void message(const std::string &msg)
std::vector< int > num_df_per_set
void libMesh::ExodusII_IO_Helper::read_sideset_info ( )

Reads information about all of the sidesets in the ExodusII mesh file.

Definition at line 655 of file exodusII_io_helper.C.

References elem_list, ex_err, ex_get_name(), ex_get_side_set_ids(), ex_id, EX_INQ_SS_ELEM_LEN, EX_SIDE_SET, id_list, id_to_ss_names, inquire(), message(), num_df_per_set, num_elem_all_sidesets, num_side_sets, num_sides_per_set, side_list, and ss_ids.

656 {
657  ss_ids.resize(num_side_sets);
658  if (num_side_sets > 0)
659  {
661  &ss_ids[0]);
662  EX_CHECK_ERR(ex_err, "Error retrieving sideset information.");
663  message("All sideset information retrieved successfully.");
664 
665  // Resize appropriate data structures -- only do this once outside the loop
668 
669  // Inquire about the length of the concatenated side sets element list
670  num_elem_all_sidesets = inquire(exII::EX_INQ_SS_ELEM_LEN, "Error retrieving length of the concatenated side sets element list!");
671 
675  }
676 
677  char name_buffer[MAX_STR_LENGTH+1];
678  for (int i=0; i<num_side_sets; ++i)
679  {
681  ss_ids[i], name_buffer);
682  EX_CHECK_ERR(ex_err, "Error getting side set name.");
683  id_to_ss_names[ss_ids[i]] = name_buffer;
684  }
685  message("All side set names retrieved successfully.");
686 }
EXODUS_EXPORT int ex_get_side_set_ids(int exoid, void_int *ids)
EXODUS_EXPORT int ex_get_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, char *name)
std::vector< int > num_sides_per_set
std::map< int, std::string > id_to_ss_names
int inquire(int req_info, std::string error_msg="")
void message(const std::string &msg)
std::vector< int > num_df_per_set
void libMesh::ExodusII_IO_Helper::read_time_steps ( )

Reads and stores the timesteps in the 'time_steps' array.

Definition at line 827 of file exodusII_io_helper.C.

References ex_err, ex_get_all_times(), ex_id, num_time_steps, read_num_time_steps(), and time_steps.

828 {
829  // Make sure we have an up-to-date count of the number of time steps in the file.
830  this->read_num_time_steps();
831 
832  if (num_time_steps > 0)
833  {
834  time_steps.resize(num_time_steps);
836  EX_CHECK_ERR(ex_err, "Error reading timesteps!");
837  }
838 }
std::vector< Real > time_steps
EXODUS_EXPORT int ex_get_all_times(int exoid, void *time_values)
void libMesh::ExodusII_IO_Helper::read_var_names ( ExodusVarType  type)

Definition at line 890 of file exodusII_io_helper.C.

References elem_var_names, ELEMENTAL, GLOBAL, global_var_names, NODAL, nodal_var_names, num_elem_vars, num_global_vars, num_nodal_vars, and read_var_names_impl().

Referenced by check_existing_vars(), read_elemental_var_values(), and read_nodal_var_values().

891 {
892  switch (type)
893  {
894  case NODAL:
896  break;
897  case ELEMENTAL:
899  break;
900  case GLOBAL:
902  break;
903  default:
904  libmesh_error_msg("Unrecognized ExodusVarType " << type);
905  }
906 }
std::vector< std::string > elem_var_names
void read_var_names_impl(const char *var_type, int &count, std::vector< std::string > &result)
std::vector< std::string > global_var_names
std::vector< std::string > nodal_var_names
void libMesh::ExodusII_IO_Helper::read_var_names_impl ( const char *  var_type,
int &  count,
std::vector< std::string > &  result 
)
private

read_var_names() dispatches to this function.

Definition at line 910 of file exodusII_io_helper.C.

References ex_err, ex_get_var_names(), ex_get_var_param(), ex_id, libMesh::ExodusII_IO_Helper::NamesData::get_char_star(), libMesh::ExodusII_IO_Helper::NamesData::get_char_star_star(), libMesh::out, and verbose.

Referenced by read_var_names().

913 {
914  // First read and store the number of names we have
915  ex_err = exII::ex_get_var_param(ex_id, var_type, &count);
916  EX_CHECK_ERR(ex_err, "Error reading number of variables.");
917 
918  // Do nothing if no variables are detected
919  if (count == 0)
920  return;
921 
922  // Second read the actual names and convert them into a format we can use
923  NamesData names_table(count, MAX_STR_LENGTH);
924 
926  var_type,
927  count,
928  names_table.get_char_star_star()
929  );
930  EX_CHECK_ERR(ex_err, "Error reading variable names!");
931 
932  if (verbose)
933  {
934  libMesh::out << "Read the variable(s) from the file:" << std::endl;
935  for (int i=0; i<count; i++)
936  libMesh::out << names_table.get_char_star(i) << std::endl;
937  }
938 
939  // Allocate enough space for our variable name strings.
940  result.resize(count);
941 
942  // Copy the char buffers into strings.
943  for (int i=0; i<count; i++)
944  result[i] = names_table.get_char_star(i); // calls string::op=(const char *)
945 }
EXODUS_EXPORT int ex_get_var_names(int exoid, const char *var_type, int num_vars, char *var_names[])
EXODUS_EXPORT int ex_get_var_param(int exoid, const char *var_type, int *num_vars)
OStreamProxy out(std::cout)
void libMesh::ExodusII_IO_Helper::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 2021 of file exodusII_io_helper.C.

References _coordinate_offset.

2022 {
2023  _coordinate_offset = p;
2024 }
void libMesh::ExodusII_IO_Helper::use_mesh_dimension_instead_of_spatial_dimension ( bool  val)

Sets the underlying value of the boolean flag _use_mesh_dimension_instead_of_spatial_dimension. By default, the value of this flag is false.

See the ExodusII_IO class documentation for a detailed description of this flag.

Definition at line 2007 of file exodusII_io_helper.C.

References _use_mesh_dimension_instead_of_spatial_dimension.

void libMesh::ExodusII_IO_Helper::write_as_dimension ( unsigned  dim)

Sets the value of _write_as_dimension.

This directly controls 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 2014 of file exodusII_io_helper.C.

References _write_as_dimension.

2015 {
2016  _write_as_dimension = dim;
2017 }
void libMesh::ExodusII_IO_Helper::write_element_values ( const MeshBase mesh,
const std::vector< Real > &  values,
int  timestep 
)

Writes the vector of values to the element variables.

Definition at line 1842 of file exodusII_io_helper.C.

References _run_only_on_proc0, _single_precision, libMesh::MeshBase::active_element_ptr_range(), data, ex_err, ex_get_var_param(), ex_id, ex_put_elem_var(), ex_update(), get_block_id(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), num_elem_vars, and libMesh::ParallelObject::processor_id().

1843 {
1844  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1845  return;
1846 
1847  // Loop over the element blocks and write the data one block at a time
1848  std::map<unsigned int, std::vector<unsigned int>> subdomain_map;
1849 
1850  // Ask the file how many element vars it has, store it in the num_elem_vars variable.
1852  EX_CHECK_ERR(ex_err, "Error reading number of elemental variables.");
1853 
1854  // loop through element and map between block and element vector
1855  for (const auto & elem : mesh.active_element_ptr_range())
1856  subdomain_map[elem->subdomain_id()].push_back(elem->id());
1857 
1858  // Use mesh.n_elem() to access into the values vector rather than
1859  // the number of elements the Exodus writer thinks the mesh has,
1860  // which may not include inactive elements.
1861  dof_id_type n_elem = mesh.n_elem();
1862 
1863  // For each variable, create a 'data' array which holds all the elemental variable
1864  // values *for a given block* on this processor, then write that data vector to file
1865  // before moving onto the next block.
1866  for (unsigned int i=0; i<static_cast<unsigned>(num_elem_vars); ++i)
1867  {
1868  // The size of the subdomain map is the number of blocks.
1869  std::map<unsigned int, std::vector<unsigned int>>::iterator it = subdomain_map.begin();
1870 
1871  for (unsigned int j=0; it!=subdomain_map.end(); ++it, ++j)
1872  {
1873  const std::vector<unsigned int> & elem_nums = (*it).second;
1874  const unsigned int num_elems_this_block =
1875  cast_int<unsigned int>(elem_nums.size());
1876  std::vector<Real> data(num_elems_this_block);
1877 
1878  for (unsigned int k=0; k<num_elems_this_block; ++k)
1879  data[k] = values[i*n_elem + elem_nums[k]];
1880 
1881  if (_single_precision)
1882  {
1883  std::vector<float> cast_data(data.begin(), data.end());
1884 
1886  timestep,
1887  i+1,
1888  this->get_block_id(j),
1889  num_elems_this_block,
1890  &cast_data[0]);
1891  }
1892  else
1893  {
1894  ex_err = exII::ex_put_elem_var(ex_id,
1895  timestep,
1896  i+1,
1897  this->get_block_id(j),
1898  num_elems_this_block,
1899  &data[0]);
1900  }
1901  EX_CHECK_ERR(ex_err, "Error writing element values.");
1902  }
1903  }
1904 
1906  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1907 }
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Definition: mesh_tools.C:656
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
EXODUS_EXPORT int ex_put_elem_var(int exoid, int time_step, int elem_var_index, ex_entity_id elem_blk_id, int64_t num_elem_this_blk, const void *elem_var_vals)
EXODUS_EXPORT int ex_get_var_param(int exoid, const char *var_type, int *num_vars)
EXODUS_EXPORT int ex_update(int exoid)
IterBase * data
virtual dof_id_type n_elem() const =0
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_elements ( const MeshBase mesh,
bool  use_discontinuous = false 
)
virtual

Writes the elements contained in "mesh". FIXME: This only works for Meshes having a single type of element!

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1318 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::MeshBase::active_element_ptr_range(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), block_ids, connect, elem_num_map, libMesh::MeshBase::elem_ref(), libMesh::Utility::enum_to_string(), EX_ELEM_BLOCK, ex_err, ex_id, ex_put_concat_elem_block(), ex_put_elem_conn(), ex_put_elem_num_map(), ex_put_names(), libMesh::ExodusII_IO_Helper::Conversion::exodus_elem_type(), libMesh::ExodusII_IO_Helper::Conversion::get_canonical_type(), libMesh::ExodusII_IO_Helper::NamesData::get_char_star_star(), libMesh::ExodusII_IO_Helper::Conversion::get_inverse_node_map(), libmesh_elem_num_to_exodus, libmesh_node_num_to_exodus, libMesh::MeshBase::n_active_elem(), libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), num_elem_blk, num_nodes_per_elem, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::ExodusII_IO_Helper::NamesData::push_back_entry(), libMesh::MeshBase::subdomain_name(), libMesh::Elem::type(), and verbose.

1319 {
1320  // n_active_elem() is a parallel_only function
1321  unsigned int n_active_elem = mesh.n_active_elem();
1322 
1323  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1324  return;
1325 
1326  // Map from block ID to a vector of element IDs in that block. Element
1327  // IDs are now of type dof_id_type, subdomain IDs are of type subdomain_id_type.
1328  typedef std::map<subdomain_id_type, std::vector<dof_id_type>> subdomain_map_type;
1329  subdomain_map_type subdomain_map;
1330 
1331  // Loop through element and map between block and element vector.
1332  for (const auto & elem : mesh.active_element_ptr_range())
1333  {
1334  // We skip writing infinite elements to the Exodus file, so
1335  // don't put them in the subdomain_map. That way the number of
1336  // blocks should be correct.
1337 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1338  if (elem->infinite())
1339  continue;
1340 #endif
1341 
1342  subdomain_map[ elem->subdomain_id() ].push_back(elem->id());
1343  }
1344 
1345  // element map vector
1346  num_elem_blk = cast_int<int>(subdomain_map.size());
1347  block_ids.resize(num_elem_blk);
1348  elem_num_map.resize(n_active_elem);
1349  std::vector<int>::iterator curr_elem_map_end = elem_num_map.begin();
1350 
1351  std::vector<int> elem_blk_id;
1352  std::vector<int> num_elem_this_blk_vec;
1353  std::vector<int> num_nodes_per_elem_vec;
1354  std::vector<int> num_attr_vec;
1355  NamesData elem_type_table(num_elem_blk, MAX_STR_LENGTH);
1356 
1357  // Note: It appears that there is a bug in exodusII::ex_put_name where
1358  // the index returned from the ex_id_lkup is erroneously used. For now
1359  // the work around is to use the alternative function ex_put_names, but
1360  // this function requires a char ** data structure.
1361  NamesData names_table(num_elem_blk, MAX_STR_LENGTH);
1362 
1363  // counter indexes into the block_ids vector
1364  unsigned int counter = 0;
1365  for (subdomain_map_type::iterator it=subdomain_map.begin(); it!=subdomain_map.end(); ++it, ++counter)
1366  {
1367  block_ids[counter] = (*it).first;
1368  names_table.push_back_entry(mesh.subdomain_name((*it).first));
1369 
1370  // Get a reference to a vector of element IDs for this subdomain.
1371  subdomain_map_type::mapped_type & tmp_vec = (*it).second;
1372 
1373  // Use the first element in this block to get representative information.
1374  // Note that Exodus assumes all elements in a block are of the same type!
1375  // We are using that same assumption here!
1377  const ExodusII_IO_Helper::Conversion conv =
1378  em.assign_conversion(mesh.elem_ref(tmp_vec[0]).type());
1379  num_nodes_per_elem = mesh.elem_ref(tmp_vec[0]).n_nodes();
1380 
1381  elem_blk_id.push_back((*it).first);
1382  elem_type_table.push_back_entry(conv.exodus_elem_type().c_str());
1383  num_elem_this_blk_vec.push_back(tmp_vec.size());
1384  num_nodes_per_elem_vec.push_back(num_nodes_per_elem);
1385  num_attr_vec.push_back(0); // we don't currently use elem block attributes.
1386  }
1387 
1388  // The "define_maps" parameter should be 0 if node_number_map and
1389  // elem_number_map will not be written later, and nonzero otherwise.
1391  &elem_blk_id[0],
1392  elem_type_table.get_char_star_star(),
1393  &num_elem_this_blk_vec[0],
1394  &num_nodes_per_elem_vec[0],
1395  &num_attr_vec[0],
1396  /*define_maps=*/0);
1397  EX_CHECK_ERR(ex_err, "Error writing element blocks.");
1398 
1399  // This counter is used to fill up the libmesh_elem_num_to_exodus map in the loop below.
1400  unsigned libmesh_elem_num_to_exodus_counter = 0;
1401 
1402  // node counter for discontinuous plotting
1403  unsigned int node_counter = 0;
1404  for (subdomain_map_type::iterator it=subdomain_map.begin(); it!=subdomain_map.end(); ++it)
1405  {
1406  // Get a reference to a vector of element IDs for this subdomain.
1407  subdomain_map_type::mapped_type & tmp_vec = (*it).second;
1408 
1409  //Use the first element in this block to get representative information.
1410  //Note that Exodus assumes all elements in a block are of the same type!
1411  //We are using that same assumption here!
1413  const ExodusII_IO_Helper::Conversion conv =
1414  em.assign_conversion(mesh.elem_ref(tmp_vec[0]).type());
1415  num_nodes_per_elem = mesh.elem_ref(tmp_vec[0]).n_nodes();
1416 
1417  connect.resize(tmp_vec.size()*num_nodes_per_elem);
1418 
1419  for (std::size_t i=0; i<tmp_vec.size(); i++)
1420  {
1421  unsigned int elem_id = tmp_vec[i];
1422  libmesh_elem_num_to_exodus[elem_id] = ++libmesh_elem_num_to_exodus_counter; // 1-based indexing for Exodus
1423 
1424  const Elem & elem = mesh.elem_ref(elem_id);
1425 
1426  // We *might* be able to get away with writing mixed element
1427  // types which happen to have the same number of nodes, but
1428  // do we actually *want* to get away with that?
1429  // .) No visualization software would be able to handle it.
1430  // .) There'd be no way for us to read it back in reliably.
1431  // .) Even elements with the same number of nodes may have different connectivities (?)
1432 
1433  // This needs to be more than an assert so we don't fail
1434  // with a mysterious segfault while trying to write mixed
1435  // element meshes in optimized mode.
1436  if (elem.type() != conv.get_canonical_type())
1437  libmesh_error_msg("Error: Exodus requires all elements with a given subdomain ID to be the same type.\n" \
1438  << "Can't write both " \
1439  << Utility::enum_to_string(elem.type()) \
1440  << " and " \
1442  << " in the same block!");
1443 
1444 
1445  for (unsigned int j=0; j<static_cast<unsigned int>(num_nodes_per_elem); ++j)
1446  {
1447  unsigned connect_index = (i*num_nodes_per_elem)+j;
1448  unsigned elem_node_index = conv.get_inverse_node_map(j); // inverse node map is for writing.
1449  if (verbose)
1450  {
1451  libMesh::out << "Exodus node index " << j
1452  << " = LibMesh node index " << elem_node_index << std::endl;
1453  }
1454 
1455  if (!use_discontinuous)
1456  {
1457  // The global id for the current node in libmesh.
1458  dof_id_type libmesh_node_id = elem.node_id(elem_node_index);
1459 
1460  // Find the zero-based libmesh id in the map, this
1461  // should be faster than doing linear searches on
1462  // the node_num_map.
1463  std::map<int, int>::iterator pos =
1464  libmesh_node_num_to_exodus.find(cast_int<int>(libmesh_node_id));
1465 
1466  // Make sure it was found.
1467  if (pos == libmesh_node_num_to_exodus.end())
1468  libmesh_error_msg("libmesh node id " << libmesh_node_id << " not found in node_num_map.");
1469 
1470  // Write the Exodus global node id associated with
1471  // this libmesh node number to the connectivity
1472  // array.
1473  connect[connect_index] = pos->second;
1474  }
1475  else
1476  {
1477  // FIXME: We are hard-coding the 1-based node
1478  // numbering assumption here, so writing
1479  // "discontinuous" Exodus files won't work with node
1480  // numberings that have "holes".
1481  connect[connect_index] = node_counter + elem_node_index + 1;
1482  }
1483  }
1484 
1485  node_counter += num_nodes_per_elem;
1486  }
1487 
1488  ex_err = exII::ex_put_elem_conn(ex_id, (*it).first, &connect[0]);
1489  EX_CHECK_ERR(ex_err, "Error writing element connectivities");
1490 
1491  // This transform command stores its result in a range that begins at the third argument,
1492  // so this command is adding values to the elem_num_map vector starting from curr_elem_map_end.
1493  curr_elem_map_end = std::transform(tmp_vec.begin(),
1494  tmp_vec.end(),
1495  curr_elem_map_end,
1496  std::bind2nd(std::plus<subdomain_map_type::mapped_type::value_type>(), 1)); // Adds one to each id to make a 1-based exodus file!
1497 
1498  // But if we don't want to add one, we just want to put the values
1499  // of tmp_vec into elem_map in the right location, we can use
1500  // std::copy().
1501  // curr_elem_map_end = std::copy(tmp_vec.begin(), tmp_vec.end(), curr_elem_map_end);
1502 
1503  counter++;
1504  }
1505 
1506  // write out the element number map that we created
1508  EX_CHECK_ERR(ex_err, "Error writing element map");
1509 
1510  // Write out the block names
1511  if (num_elem_blk > 0)
1512  {
1513  ex_err = exII::ex_put_names(ex_id, exII::EX_ELEM_BLOCK, names_table.get_char_star_star());
1514  EX_CHECK_ERR(ex_err, "Error writing element names");
1515  }
1516 
1517 }
virtual dof_id_type n_active_elem() const =0
virtual ElemType type() const =0
EXODUS_EXPORT int ex_put_concat_elem_block(int exoid, const void_int *elem_blk_id, char *elem_type[], const void_int *num_elem_this_blk, const void_int *num_nodes_per_elem, const void_int *num_attr, int define_maps)
The base class for all geometric element types.
Definition: elem.h:90
ExodusII_IO_Helper::Conversion assign_conversion(std::string type_str)
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
std::map< int, int > libmesh_elem_num_to_exodus
virtual unsigned int n_nodes() const =0
std::string & subdomain_name(subdomain_id_type id)
Definition: mesh_base.C:578
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
std::map< int, int > libmesh_node_num_to_exodus
std::string enum_to_string(const T e)
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:491
EXODUS_EXPORT int ex_put_elem_conn(int exoid, ex_entity_id elem_blk_id, const void_int *connect)
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1832
EXODUS_EXPORT int ex_put_elem_num_map(int exoid, const void_int *elem_map)
OStreamProxy out(std::cout)
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_global_values ( const std::vector< Real > &  values,
int  timestep 
)

Writes the vector of global variables.

Definition at line 1972 of file exodusII_io_helper.C.

References _run_only_on_proc0, _single_precision, ex_err, ex_id, ex_put_glob_vars(), ex_update(), num_global_vars, and libMesh::ParallelObject::processor_id().

1973 {
1974  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1975  return;
1976 
1977  if (_single_precision)
1978  {
1979  std::vector<float> cast_values(values.begin(), values.end());
1980  ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_global_vars, &cast_values[0]);
1981  }
1982  else
1983  {
1984  ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_global_vars, &values[0]);
1985  }
1986  EX_CHECK_ERR(ex_err, "Error writing global values.");
1987 
1989  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1990 }
EXODUS_EXPORT int ex_put_glob_vars(int exoid, int time_step, int num_glob_vars, const void *glob_var_vals)
EXODUS_EXPORT int ex_update(int exoid)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_information_records ( const std::vector< std::string > &  records)

Writes the vector of information records.

Definition at line 1933 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::err, ex_err, ex_id, EX_INQ_INFO, ex_put_info(), ex_update(), libMesh::ExodusII_IO_Helper::NamesData::get_char_star_star(), inquire(), libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::NamesData::push_back_entry().

1934 {
1935  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1936  return;
1937 
1938  // There may already be information records in the file (for
1939  // example, if we're appending) and in that case, according to the
1940  // Exodus documentation, writing more information records is not
1941  // supported.
1942  int num_info = inquire(exII::EX_INQ_INFO, "Error retrieving the number of information records from file!");
1943  if (num_info > 0)
1944  {
1945  libMesh::err << "Warning! The Exodus file already contains information records.\n"
1946  << "Exodus does not support writing additional records in this situation."
1947  << std::endl;
1948  return;
1949  }
1950 
1951  int num_records = cast_int<int>(records.size());
1952 
1953  if (num_records > 0)
1954  {
1955  NamesData info(num_records, MAX_LINE_LENGTH);
1956 
1957  // If an entry is longer than MAX_LINE_LENGTH characters it's not an error, we just
1958  // write the first MAX_LINE_LENGTH characters to the file.
1959  for (std::size_t i=0; i<records.size(); ++i)
1960  info.push_back_entry(records[i]);
1961 
1962  ex_err = exII::ex_put_info(ex_id, num_records, info.get_char_star_star());
1963  EX_CHECK_ERR(ex_err, "Error writing global values.");
1964 
1966  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1967  }
1968 }
EXODUS_EXPORT int ex_put_info(int exoid, int num_info, char *info[])
int inquire(int req_info, std::string error_msg="")
OStreamProxy err(std::cerr)
EXODUS_EXPORT int ex_update(int exoid)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_nodal_coordinates ( const MeshBase mesh,
bool  use_discontinuous = false 
)
virtual

Writes the nodal coordinates contained in "mesh"

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1202 of file exodusII_io_helper.C.

References _coordinate_offset, _run_only_on_proc0, _single_precision, libMesh::MeshBase::active_element_ptr_range(), ex_err, ex_id, ex_put_coord(), ex_put_node_num_map(), libMesh::DofObject::id(), libmesh_node_num_to_exodus, libmesh_nullptr, node_num_map, libMesh::MeshBase::node_ptr_range(), num_nodes, libMesh::ParallelObject::processor_id(), x, y, and z.

1203 {
1204  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1205  return;
1206 
1207  // Clear existing data from any previous calls.
1208  x.clear();
1209  y.clear();
1210  z.clear();
1211  node_num_map.clear();
1212 
1213  // Reserve space in the nodal coordinate vectors. num_nodes is
1214  // exact, this just allows us to do away with one potentially
1215  // error-inducing loop index.
1216  x.reserve(num_nodes);
1217  y.reserve(num_nodes);
1218  z.reserve(num_nodes);
1219 
1220  // And in the node_num_map - since the nodes aren't organized in
1221  // blocks, libmesh will always write out the identity map
1222  // here... unless there has been some refinement and coarsening, or
1223  // node deletion without a corresponding call to contract(). You
1224  // need to write this any time there could be 'holes' in the node
1225  // numbering, so we write it every time.
1226  node_num_map.reserve(num_nodes);
1227 
1228  // Clear out any previously-mapped node IDs.
1230 
1231  if (!use_discontinuous)
1232  {
1233  for (const auto & node_ptr : mesh.node_ptr_range())
1234  {
1235  const Node & node = *node_ptr;
1236 
1237  x.push_back(node(0) + _coordinate_offset(0));
1238 
1239 #if LIBMESH_DIM > 1
1240  y.push_back(node(1) + _coordinate_offset(1));
1241 #else
1242  y.push_back(0.);
1243 #endif
1244 #if LIBMESH_DIM > 2
1245  z.push_back(node(2) + _coordinate_offset(2));
1246 #else
1247  z.push_back(0.);
1248 #endif
1249 
1250  // Fill in node_num_map entry with the proper (1-based) node id
1251  node_num_map.push_back(node.id() + 1);
1252 
1253  // Also map the zero-based libmesh node id to the 1-based
1254  // Exodus ID it will be assigned (this is equivalent to the
1255  // current size of the x vector).
1256  libmesh_node_num_to_exodus[ cast_int<int>(node.id()) ] = cast_int<int>(x.size());
1257  }
1258  }
1259  else
1260  {
1261  for (const auto & elem : mesh.active_element_ptr_range())
1262  for (unsigned int n=0; n<elem->n_nodes(); n++)
1263  {
1264  x.push_back(elem->point(n)(0));
1265 #if LIBMESH_DIM > 1
1266  y.push_back(elem->point(n)(1));
1267 #else
1268  y.push_back(0.);
1269 #endif
1270 #if LIBMESH_DIM > 2
1271  z.push_back(elem->point(n)(2));
1272 #else
1273  z.push_back(0.);
1274 #endif
1275 
1276  // Let's skip the node_num_map in the discontinuous
1277  // case, since we're effectively duplicating nodes for
1278  // the sake of discontinuous visualization, so it isn't
1279  // clear how to deal with node_num_map here. This means
1280  // that writing discontinuous meshes won't work with
1281  // element numberings that have "holes".
1282  }
1283  }
1284 
1285  if (_single_precision)
1286  {
1287  std::vector<float>
1288  x_single(x.begin(), x.end()),
1289  y_single(y.begin(), y.end()),
1290  z_single(z.begin(), z.end());
1291 
1293  x_single.empty() ? libmesh_nullptr : &x_single[0],
1294  y_single.empty() ? libmesh_nullptr : &y_single[0],
1295  z_single.empty() ? libmesh_nullptr : &z_single[0]);
1296  }
1297  else
1298  {
1299  ex_err = exII::ex_put_coord(ex_id,
1300  x.empty() ? libmesh_nullptr : &x[0],
1301  y.empty() ? libmesh_nullptr : &y[0],
1302  z.empty() ? libmesh_nullptr : &z[0]);
1303  }
1304 
1305 
1306  EX_CHECK_ERR(ex_err, "Error writing coordinates to Exodus file.");
1307 
1308  if (!use_discontinuous)
1309  {
1310  // Also write the (1-based) node_num_map to the file.
1312  EX_CHECK_ERR(ex_err, "Error writing node_num_map");
1313  }
1314 }
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
const class libmesh_nullptr_t libmesh_nullptr
EXODUS_EXPORT int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *z_coor)
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
virtual SimpleRange< node_iterator > node_ptr_range()=0
std::map< int, int > libmesh_node_num_to_exodus
EXODUS_EXPORT int ex_put_node_num_map(int exoid, const void_int *node_map)
dof_id_type id() const
Definition: dof_object.h:632
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_nodal_values ( int  var_id,
const std::vector< Real > &  values,
int  timestep 
)

Writes the vector of values to a nodal variable.

Definition at line 1911 of file exodusII_io_helper.C.

References _run_only_on_proc0, _single_precision, ex_err, ex_id, ex_put_nodal_var(), ex_update(), num_nodes, and libMesh::ParallelObject::processor_id().

Referenced by libMesh::Nemesis_IO_Helper::write_nodal_solution().

1912 {
1913  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1914  return;
1915 
1916  if (_single_precision)
1917  {
1918  std::vector<float> cast_values(values.begin(), values.end());
1919  ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, &cast_values[0]);
1920  }
1921  else
1922  {
1923  ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, &values[0]);
1924  }
1925  EX_CHECK_ERR(ex_err, "Error writing nodal values.");
1926 
1928  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1929 }
EXODUS_EXPORT int ex_update(int exoid)
processor_id_type processor_id() const
EXODUS_EXPORT int ex_put_nodal_var(int exoid, int time_step, int nodal_var_index, int64_t num_nodes, const void *nodal_var_vals)
void libMesh::ExodusII_IO_Helper::write_nodesets ( const MeshBase mesh)
virtual

Writes the nodesets contained in "mesh"

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1642 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::BoundaryInfo::build_node_boundary_ids(), libMesh::BoundaryInfo::build_node_list(), ex_err, ex_id, EX_NODE_SET, ex_put_names(), ex_put_node_set(), ex_put_node_set_param(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_nodeset_name(), libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::NamesData::push_back_entry().

1643 {
1644  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1645  return;
1646 
1647  std::vector<dof_id_type > nl;
1648  std::vector<boundary_id_type > il;
1649 
1650  mesh.get_boundary_info().build_node_list(nl, il);
1651 
1652  // Maps from nodeset id to the nodes
1653  std::map<boundary_id_type, std::vector<int>> node;
1654 
1655  // Accumulate the vectors to pass into ex_put_node_set
1656  for (std::size_t i=0; i<nl.size(); i++)
1657  node[il[i]].push_back(nl[i]+1);
1658 
1659  std::vector<boundary_id_type> node_boundary_ids;
1660  mesh.get_boundary_info().build_node_boundary_ids(node_boundary_ids);
1661 
1662  // Write out the nodeset names, but only if there is something to write
1663  if (node_boundary_ids.size() > 0)
1664  {
1665  NamesData names_table(node_boundary_ids.size(), MAX_STR_LENGTH);
1666 
1667  for (std::size_t i=0; i<node_boundary_ids.size(); i++)
1668  {
1669  boundary_id_type nodeset_id = node_boundary_ids[i];
1670 
1671  int actual_id = nodeset_id;
1672 
1673  names_table.push_back_entry(mesh.get_boundary_info().get_nodeset_name(nodeset_id));
1674 
1675  ex_err = exII::ex_put_node_set_param(ex_id, actual_id, node[nodeset_id].size(), 0);
1676  EX_CHECK_ERR(ex_err, "Error writing nodeset parameters");
1677 
1678  ex_err = exII::ex_put_node_set(ex_id, actual_id, &node[nodeset_id][0]);
1679  EX_CHECK_ERR(ex_err, "Error writing nodesets");
1680  }
1681 
1682  // Write out the nodeset names
1683  ex_err = exII::ex_put_names(ex_id, exII::EX_NODE_SET, names_table.get_char_star_star());
1684  EX_CHECK_ERR(ex_err, "Error writing nodeset names");
1685  }
1686 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
EXODUS_EXPORT int ex_put_node_set_param(int exoid, ex_entity_id node_set_id, int64_t num_nodes_in_set, int64_t num_dist_in_set)
const std::string & get_nodeset_name(boundary_id_type id) const
EXODUS_EXPORT int ex_put_node_set(int exoid, ex_entity_id node_set_id, const void_int *node_set_node_list)
int8_t boundary_id_type
Definition: id_types.h:51
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
void build_node_list(std::vector< dof_id_type > &node_id_list, std::vector< boundary_id_type > &bc_id_list) const
void build_node_boundary_ids(std::vector< boundary_id_type > &b_ids) const
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_sidesets ( const MeshBase mesh)
virtual

Writes the sidesets contained in "mesh"

We need to build up active elements if AMR is enabled and add them to the exodus sidesets instead of the potentially inactive "parent" elements

We need to build up active elements if AMR is enabled and add them to the exodus sidesets instead of the potentially inactive "parent" elements

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1522 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::Elem::active_family_tree_by_side(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), libMesh::BoundaryInfo::build_shellface_boundary_ids(), libMesh::BoundaryInfo::build_shellface_list(), libMesh::BoundaryInfo::build_side_boundary_ids(), libMesh::BoundaryInfo::build_side_list(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::elem_ref(), ex_err, ex_id, ex_put_names(), ex_put_sets(), EX_SIDE_SET, libMesh::MeshBase::get_boundary_info(), libMesh::ExodusII_IO_Helper::Conversion::get_inverse_shellface_map(), libMesh::ExodusII_IO_Helper::Conversion::get_inverse_side_map(), libMesh::BoundaryInfo::get_sideset_name(), libmesh_elem_num_to_exodus, libmesh_nullptr, libMesh::ParallelObject::processor_id(), libMesh::ExodusII_IO_Helper::NamesData::push_back_entry(), and side.

1523 {
1524  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1525  return;
1526 
1528 
1529  // Maps from sideset id to the element and sides
1530  std::map<int, std::vector<int>> elem;
1531  std::map<int, std::vector<int>> side;
1532  std::vector<boundary_id_type> side_boundary_ids;
1533 
1534  {
1535  std::vector<dof_id_type > el;
1536  std::vector<unsigned short int > sl;
1537  std::vector<boundary_id_type > il;
1538 
1539  mesh.get_boundary_info().build_side_list(el, sl, il);
1540 
1541  // Accumulate the vectors to pass into ex_put_side_set
1542  for (std::size_t i=0; i<el.size(); i++)
1543  {
1544  std::vector<const Elem *> family;
1545 #ifdef LIBMESH_ENABLE_AMR
1546 
1550  mesh.elem_ref(el[i]).active_family_tree_by_side(family, sl[i], false);
1551 #else
1552  family.push_back(mesh.elem_ptr(el[i]));
1553 #endif
1554 
1555  for (std::size_t j=0; j<family.size(); ++j)
1556  {
1557  const ExodusII_IO_Helper::Conversion conv =
1558  em.assign_conversion(mesh.elem_ptr(family[j]->id())->type());
1559 
1560  // Use the libmesh to exodus data structure map to get the proper sideset IDs
1561  // The data structure contains the "collapsed" contiguous ids
1562  elem[il[i]].push_back(libmesh_elem_num_to_exodus[family[j]->id()]);
1563  side[il[i]].push_back(conv.get_inverse_side_map(sl[i]));
1564  }
1565  }
1566 
1567  mesh.get_boundary_info().build_side_boundary_ids(side_boundary_ids);
1568  }
1569 
1570  {
1571  // add data for shell faces, if needed
1572 
1573  std::vector<dof_id_type > el;
1574  std::vector<unsigned short int > sl;
1575  std::vector<boundary_id_type > il;
1576 
1577  mesh.get_boundary_info().build_shellface_list(el, sl, il);
1578 
1579  // Accumulate the vectors to pass into ex_put_side_set
1580  for (std::size_t i=0; i<el.size(); i++)
1581  {
1582  std::vector<const Elem *> family;
1583 #ifdef LIBMESH_ENABLE_AMR
1584 
1588  mesh.elem_ref(el[i]).active_family_tree_by_side(family, sl[i], false);
1589 #else
1590  family.push_back(mesh.elem_ptr(el[i]));
1591 #endif
1592 
1593  for (std::size_t j=0; j<family.size(); ++j)
1594  {
1595  const ExodusII_IO_Helper::Conversion conv =
1596  em.assign_conversion(mesh.elem_ptr(family[j]->id())->type());
1597 
1598  // Use the libmesh to exodus data structure map to get the proper sideset IDs
1599  // The data structure contains the "collapsed" contiguous ids
1600  elem[il[i]].push_back(libmesh_elem_num_to_exodus[family[j]->id()]);
1601  side[il[i]].push_back(conv.get_inverse_shellface_map(sl[i]));
1602  }
1603  }
1604 
1605  std::vector<boundary_id_type> shellface_boundary_ids;
1606  mesh.get_boundary_info().build_shellface_boundary_ids(shellface_boundary_ids);
1607  for (std::size_t i=0; i<shellface_boundary_ids.size(); i++)
1608  side_boundary_ids.push_back(shellface_boundary_ids[i]);
1609  }
1610 
1611  // Write out the sideset names, but only if there is something to write
1612  if (side_boundary_ids.size() > 0)
1613  {
1614  NamesData names_table(side_boundary_ids.size(), MAX_STR_LENGTH);
1615 
1616  std::vector<exII::ex_set> sets(side_boundary_ids.size());
1617 
1618  for (std::size_t i=0; i<side_boundary_ids.size(); i++)
1619  {
1620  boundary_id_type ss_id = side_boundary_ids[i];
1621  names_table.push_back_entry(mesh.get_boundary_info().get_sideset_name(ss_id));
1622 
1623  sets[i].id = ss_id;
1624  sets[i].type = exII::EX_SIDE_SET;
1625  sets[i].num_entry = elem[ss_id].size();
1626  sets[i].num_distribution_factor = 0;
1627  sets[i].entry_list = &elem[ss_id][0];
1628  sets[i].extra_list = &side[ss_id][0];
1629  sets[i].distribution_factor_list = libmesh_nullptr;
1630  }
1631 
1632  ex_err = exII::ex_put_sets(ex_id, side_boundary_ids.size(), &sets[0]);
1633  EX_CHECK_ERR(ex_err, "Error writing sidesets");
1634 
1635  ex_err = exII::ex_put_names(ex_id, exII::EX_SIDE_SET, names_table.get_char_star_star());
1636  EX_CHECK_ERR(ex_err, "Error writing sideset names");
1637  }
1638 }
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:118
unsigned short int side
Definition: xdr_io.C:49
const class libmesh_nullptr_t libmesh_nullptr
ExodusII_IO_Helper::Conversion assign_conversion(std::string type_str)
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
std::map< int, int > libmesh_elem_num_to_exodus
EXODUS_EXPORT int ex_put_sets(int exoid, size_t set_count, const struct ex_set *sets)
int8_t boundary_id_type
Definition: id_types.h:51
void build_side_boundary_ids(std::vector< boundary_id_type > &b_ids) const
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:491
void active_family_tree_by_side(std::vector< const Elem * > &family, const unsigned int side, const bool reset=true) const
Definition: elem.C:1666
void build_shellface_boundary_ids(std::vector< boundary_id_type > &b_ids) const
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const std::string & get_sideset_name(boundary_id_type id) const
void build_shellface_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &shellface_list, std::vector< boundary_id_type > &bc_id_list) const
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_timestep ( int  timestep,
Real  time 
)

Writes the time for the timestep

Definition at line 1820 of file exodusII_io_helper.C.

References _run_only_on_proc0, _single_precision, ex_err, ex_id, ex_put_time(), ex_update(), and libMesh::ParallelObject::processor_id().

1821 {
1822  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1823  return;
1824 
1825  if (_single_precision)
1826  {
1827  float cast_time = time;
1828  ex_err = exII::ex_put_time(ex_id, timestep, &cast_time);
1829  }
1830  else
1831  {
1832  ex_err = exII::ex_put_time(ex_id, timestep, &time);
1833  }
1834  EX_CHECK_ERR(ex_err, "Error writing timestep.");
1835 
1837  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1838 }
EXODUS_EXPORT int ex_update(int exoid)
EXODUS_EXPORT int ex_put_time(int exoid, int time_step, const void *time_value)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::write_var_names ( ExodusVarType  type,
std::vector< std::string > &  names 
)
private

Wraps calls to exII::ex_put_var_names() and exII::ex_put_var_param(). The enumeration controls whether nodal, elemental, or global variable names are read and which class members are filled in.

Definition at line 950 of file exodusII_io_helper.C.

References ELEMENTAL, GLOBAL, NODAL, num_elem_vars, num_global_vars, num_nodal_vars, and write_var_names_impl().

Referenced by initialize_element_variables(), initialize_global_variables(), and initialize_nodal_variables().

951 {
952  switch (type)
953  {
954  case NODAL:
955  this->write_var_names_impl("n", num_nodal_vars, names);
956  break;
957  case ELEMENTAL:
958  this->write_var_names_impl("e", num_elem_vars, names);
959  break;
960  case GLOBAL:
961  this->write_var_names_impl("g", num_global_vars, names);
962  break;
963  default:
964  libmesh_error_msg("Unrecognized ExodusVarType " << type);
965  }
966 }
void write_var_names_impl(const char *var_type, int &count, std::vector< std::string > &names)
void libMesh::ExodusII_IO_Helper::write_var_names_impl ( const char *  var_type,
int &  count,
std::vector< std::string > &  names 
)
private

write_var_names() dispatches to this function.

Definition at line 970 of file exodusII_io_helper.C.

References ex_err, ex_id, ex_put_var_names(), ex_put_var_param(), libMesh::out, libMesh::ExodusII_IO_Helper::NamesData::push_back_entry(), and verbose.

Referenced by write_var_names().

971 {
972  // Update the count variable so that it's available to other parts of the class.
973  count = cast_int<int>(names.size());
974 
975  // Write that number of variables to the file.
976  ex_err = exII::ex_put_var_param(ex_id, var_type, count);
977  EX_CHECK_ERR(ex_err, "Error setting number of vars.");
978 
979  if (names.size() > 0)
980  {
981  NamesData names_table(names.size(), MAX_STR_LENGTH);
982 
983  // Store the input names in the format required by Exodus.
984  for (std::size_t i=0; i<names.size(); ++i)
985  names_table.push_back_entry(names[i]);
986 
987  if (verbose)
988  {
989  libMesh::out << "Writing variable name(s) to file: " << std::endl;
990  for (std::size_t i=0; i<names.size(); ++i)
991  libMesh::out << names_table.get_char_star(i) << std::endl;
992  }
993 
994  ex_err = exII::ex_put_var_names(ex_id,
995  var_type,
996  cast_int<int>(names.size()),
997  names_table.get_char_star_star()
998  );
999 
1000  EX_CHECK_ERR(ex_err, "Error writing variable names.");
1001  }
1002 }
EXODUS_EXPORT int ex_put_var_param(int exoid, const char *var_type, int num_vars)
EXODUS_EXPORT int ex_put_var_names(int exoid, const char *var_type, int num_vars, char *var_names[])
OStreamProxy out(std::cout)

Member Data Documentation

Point libMesh::ExodusII_IO_Helper::_coordinate_offset
protected

Definition at line 606 of file exodusII_io_helper.h.

Referenced by set_coordinate_offset(), and write_nodal_coordinates().

bool libMesh::ExodusII_IO_Helper::_elem_vars_initialized
protected

Definition at line 588 of file exodusII_io_helper.h.

Referenced by initialize_element_variables().

bool libMesh::ExodusII_IO_Helper::_global_vars_initialized
protected

Definition at line 591 of file exodusII_io_helper.h.

Referenced by initialize_global_variables().

bool libMesh::ExodusII_IO_Helper::_nodal_vars_initialized
protected

Definition at line 594 of file exodusII_io_helper.h.

Referenced by initialize_nodal_variables().

bool libMesh::ExodusII_IO_Helper::_use_mesh_dimension_instead_of_spatial_dimension
protected
unsigned libMesh::ExodusII_IO_Helper::_write_as_dimension
protected

Definition at line 603 of file exodusII_io_helper.h.

Referenced by initialize(), and write_as_dimension().

std::vector<int> libMesh::ExodusII_IO_Helper::connect

Definition at line 456 of file exodusII_io_helper.h.

Referenced by read_elem_in_block(), and write_elements().

std::string libMesh::ExodusII_IO_Helper::current_filename

Definition at line 570 of file exodusII_io_helper.h.

Referenced by create(), and open().

std::vector<int> libMesh::ExodusII_IO_Helper::elem_list

Definition at line 477 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

std::vector<int> libMesh::ExodusII_IO_Helper::elem_num_map
std::vector<char> libMesh::ExodusII_IO_Helper::elem_type

Definition at line 507 of file exodusII_io_helper.h.

Referenced by ExodusII_IO_Helper(), get_elem_type(), and read_elem_in_block().

std::vector<std::string> libMesh::ExodusII_IO_Helper::elem_var_names
std::vector<Real> libMesh::ExodusII_IO_Helper::elem_var_values

Definition at line 541 of file exodusII_io_helper.h.

int libMesh::ExodusII_IO_Helper::ex_id

Definition at line 414 of file exodusII_io_helper.h.

Referenced by close(), create(), libMesh::Nemesis_IO_Helper::create(), 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::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(), initialize(), initialize_element_variables(), inquire(), open(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_eb_info_global(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_init_global(), libMesh::Nemesis_IO_Helper::put_init_info(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_n_coord(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::Nemesis_IO_Helper::put_ns_param_global(), libMesh::Nemesis_IO_Helper::put_ss_param_global(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_elemental_var_values(), read_global_values(), read_header(), read_nodal_var_values(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_qa_records(), read_sideset(), read_sideset_info(), read_time_steps(), read_var_names_impl(), write_element_values(), libMesh::Nemesis_IO_Helper::write_elements(), write_elements(), libMesh::Nemesis_IO_Helper::write_exodus_initialization_info(), write_global_values(), write_information_records(), libMesh::Nemesis_IO_Helper::write_nodal_coordinates(), write_nodal_coordinates(), write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), write_nodesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), write_sidesets(), write_timestep(), write_var_names_impl(), and libMesh::Nemesis_IO_Helper::~Nemesis_IO_Helper().

std::vector<int> libMesh::ExodusII_IO_Helper::exodus_elem_num_to_libmesh
std::vector<int> libMesh::ExodusII_IO_Helper::exodus_node_num_to_libmesh
std::vector<std::string> libMesh::ExodusII_IO_Helper::global_var_names

Definition at line 544 of file exodusII_io_helper.h.

Referenced by initialize_global_variables(), and read_var_names().

std::vector<int> libMesh::ExodusII_IO_Helper::id_list

Definition at line 486 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

std::map<int, std::string> libMesh::ExodusII_IO_Helper::id_to_block_names

Definition at line 547 of file exodusII_io_helper.h.

Referenced by get_block_name(), and read_block_info().

std::map<int, std::string> libMesh::ExodusII_IO_Helper::id_to_ns_names

Definition at line 549 of file exodusII_io_helper.h.

Referenced by get_node_set_name(), and read_nodeset_info().

std::map<int, std::string> libMesh::ExodusII_IO_Helper::id_to_ss_names

Definition at line 548 of file exodusII_io_helper.h.

Referenced by get_side_set_name(), and read_sideset_info().

std::vector<std::string> libMesh::ExodusII_IO_Helper::nodal_var_names
std::vector<Real> libMesh::ExodusII_IO_Helper::nodal_var_values

Definition at line 532 of file exodusII_io_helper.h.

Referenced by read_nodal_var_values().

std::vector<int> libMesh::ExodusII_IO_Helper::node_list

Definition at line 483 of file exodusII_io_helper.h.

Referenced by read_nodeset().

std::vector<int> libMesh::ExodusII_IO_Helper::node_num_map

Definition at line 489 of file exodusII_io_helper.h.

Referenced by read_node_num_map(), and write_nodal_coordinates().

std::vector<int> libMesh::ExodusII_IO_Helper::nodeset_ids
int libMesh::ExodusII_IO_Helper::num_attr

Definition at line 447 of file exodusII_io_helper.h.

Referenced by read_elem_in_block().

std::vector<int> libMesh::ExodusII_IO_Helper::num_df_per_set

Definition at line 471 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

int libMesh::ExodusII_IO_Helper::num_dim
int libMesh::ExodusII_IO_Helper::num_elem_all_sidesets

Definition at line 450 of file exodusII_io_helper.h.

Referenced by read_sideset_info().

int libMesh::ExodusII_IO_Helper::num_elem_this_blk

Definition at line 441 of file exodusII_io_helper.h.

Referenced by read_elem_in_block(), and read_elemental_var_values().

int libMesh::ExodusII_IO_Helper::num_elem_vars
int libMesh::ExodusII_IO_Helper::num_global_vars
int libMesh::ExodusII_IO_Helper::num_nodal_vars
std::vector<int> libMesh::ExodusII_IO_Helper::num_node_df_per_set

Definition at line 474 of file exodusII_io_helper.h.

Referenced by read_nodeset(), and read_nodeset_info().

int libMesh::ExodusII_IO_Helper::num_node_sets
int libMesh::ExodusII_IO_Helper::num_nodes_per_elem
std::vector<int> libMesh::ExodusII_IO_Helper::num_nodes_per_set

Definition at line 468 of file exodusII_io_helper.h.

Referenced by read_nodeset(), and read_nodeset_info().

int libMesh::ExodusII_IO_Helper::num_side_sets
std::vector<int> libMesh::ExodusII_IO_Helper::num_sides_per_set

Definition at line 465 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

int libMesh::ExodusII_IO_Helper::num_time_steps

Definition at line 520 of file exodusII_io_helper.h.

Referenced by read_num_time_steps(), and read_time_steps().

bool libMesh::ExodusII_IO_Helper::opened_for_reading

Definition at line 560 of file exodusII_io_helper.h.

Referenced by close(), and open().

bool libMesh::ExodusII_IO_Helper::opened_for_writing
std::vector<int> libMesh::ExodusII_IO_Helper::side_list

Definition at line 480 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

std::vector<int> libMesh::ExodusII_IO_Helper::ss_ids
std::vector<Real> libMesh::ExodusII_IO_Helper::time_steps

Definition at line 523 of file exodusII_io_helper.h.

Referenced by read_time_steps().

std::vector<char> libMesh::ExodusII_IO_Helper::title

Definition at line 504 of file exodusII_io_helper.h.

Referenced by ExodusII_IO_Helper(), print_header(), and read_header().

bool libMesh::ExodusII_IO_Helper::verbose

Definition at line 552 of file exodusII_io_helper.h.

Referenced by libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), 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(), create(), libMesh::Nemesis_IO_Helper::create(), 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::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(), message(), open(), print_header(), libMesh::Nemesis_IO_Helper::put_node_cmap(), read_elem_in_block(), read_elem_num_map(), read_node_num_map(), read_qa_records(), read_var_names_impl(), write_elements(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), and write_var_names_impl().

std::vector<Real> libMesh::ExodusII_IO_Helper::x
std::vector<Real> libMesh::ExodusII_IO_Helper::y
std::vector<Real> libMesh::ExodusII_IO_Helper::z

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