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)
 
virtual void initialize_element_variables (std::vector< std::string > names, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains)
 
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, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains)
 
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
 
std::vector< std::set< subdomain_id_type > > get_complex_vars_active_subdomains (const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) 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 Member Functions

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

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 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 96 of file exodusII_io_helper.h.

Member Enumeration Documentation

◆ ExodusVarType

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 601 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

◆ ExodusII_IO_Helper()

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 270 of file exodusII_io_helper.C.

References elem_type, and title.

273  :
274  ParallelObject(parent),
275  ex_id(0),
276  ex_err(0),
277  num_dim(0),
278  num_global_vars(0),
279  num_nodes(0),
280  num_elem(0),
281  num_elem_blk(0),
282  num_node_sets(0),
283  num_side_sets(0),
286  num_attr(0),
288  num_time_steps(0),
289  num_nodal_vars(0),
290  num_elem_vars(0),
291  verbose(v),
292  opened_for_writing(false),
293  opened_for_reading(false),
294  _run_only_on_proc0(run_only_on_proc0),
295  _elem_vars_initialized(false),
300  _single_precision(single_precision)
301 {
302  title.resize(MAX_LINE_LENGTH+1);
303  elem_type.resize(MAX_STR_LENGTH);
304 }
ParallelObject(const Parallel::Communicator &comm_in)

◆ ~ExodusII_IO_Helper()

libMesh::ExodusII_IO_Helper::~ExodusII_IO_Helper ( )
virtual

Destructor.

Definition at line 308 of file exodusII_io_helper.C.

309 {
310 }

Member Function Documentation

◆ check_existing_vars()

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

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

Definition at line 1814 of file exodusII_io_helper.C.

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

Referenced by initialize_element_variables(), libMesh::Nemesis_IO_Helper::initialize_element_variables(), initialize_global_variables(), and initialize_nodal_variables().

1817 {
1818  // There may already be global variables in the file (for example,
1819  // if we're appending) and in that case, we
1820  // 1.) Cannot initialize them again.
1821  // 2.) Should check to be sure that the global variable names are the same.
1822 
1823  // Fills up names_from_file for us
1824  this->read_var_names(type);
1825 
1826  // Both the names of the global variables and their order must match
1827  if (names_from_file != names)
1828  {
1829  libMesh::err << "Error! The Exodus file already contains the variables:" << std::endl;
1830  for (const auto & name : names_from_file)
1831  libMesh::out << name << std::endl;
1832 
1833  libMesh::err << "And you asked to write:" << std::endl;
1834  for (const auto & name : names)
1835  libMesh::out << name << std::endl;
1836 
1837  libmesh_error_msg("Cannot overwrite existing variables in Exodus II file.");
1838  }
1839 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
void read_var_names(ExodusVarType type)
OStreamProxy err(std::cerr)
OStreamProxy out(std::cout)

◆ close()

void libMesh::ExodusII_IO_Helper::close ( )

Closes the ExodusII mesh file.

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

796 {
797  // Always call close on processor 0.
798  // If we're running on multiple processors, i.e. as one of several Nemesis files,
799  // we call close on all processors...
800  if ((this->processor_id() == 0) || (!_run_only_on_proc0))
801  {
802  // Don't close the file if it was never opened, this raises an Exodus error
804  {
806  EX_CHECK_ERR(ex_err, "Error closing Exodus file.");
807  message("Exodus file closed successfully.");
808  }
809  }
810 }
void message(const std::string &msg)
EXODUS_EXPORT int ex_close(int exoid)
processor_id_type processor_id() const

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 89 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_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::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::PetscDMWrapper::check_section_n_dofs(), 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::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), 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_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_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::FEMSystem::mesh_position_set(), 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::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

90  { return _communicator; }
const Parallel::Communicator & _communicator

◆ create()

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 1079 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.

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

◆ get_block_id()

int libMesh::ExodusII_IO_Helper::get_block_id ( int  index)

Get the block number for the given block index.

Definition at line 544 of file exodusII_io_helper.C.

References block_ids.

Referenced by write_element_values().

545 {
546  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
547 
548  return block_ids[index];
549 }

◆ get_block_name()

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 553 of file exodusII_io_helper.C.

References block_ids, and id_to_block_names.

554 {
555  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
556 
557  return id_to_block_names[block_ids[index]];
558 }
std::map< int, std::string > id_to_block_names

◆ get_complex_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 2064 of file exodusII_io_helper.C.

2065 {
2066  std::vector<std::string>::const_iterator names_it = names.begin();
2067  std::vector<std::string>::const_iterator names_end = names.end();
2068 
2069  std::vector<std::string> complex_names;
2070 
2071  // This will loop over all names and create new "complex" names
2072  // (i.e. names that start with r_, i_ or a_
2073  for (; names_it != names_end; ++names_it)
2074  {
2075  std::stringstream name_real, name_imag, name_abs;
2076  name_real << "r_" << *names_it;
2077  name_imag << "i_" << *names_it;
2078  name_abs << "a_" << *names_it;
2079 
2080  complex_names.push_back(name_real.str());
2081  complex_names.push_back(name_imag.str());
2082  complex_names.push_back(name_abs.str());
2083  }
2084 
2085  return complex_names;
2086 }

◆ get_complex_vars_active_subdomains()

std::vector< std::set< subdomain_id_type > > libMesh::ExodusII_IO_Helper::get_complex_vars_active_subdomains ( const std::vector< std::set< subdomain_id_type >> &  vars_active_subdomains) const

returns a "tripled" copy of vars_active_subdomains, which is necessary in the complex-valued case.

Definition at line 2090 of file exodusII_io_helper.C.

2092 {
2093  std::vector<std::set<subdomain_id_type>> complex_vars_active_subdomains;
2094 
2095  for (auto & s : vars_active_subdomains)
2096  {
2097  // Push back the same data three times to match the tripling of the variables
2098  // for the real, imag, and modulus for the complex-valued solution.
2099  complex_vars_active_subdomains.push_back(s);
2100  complex_vars_active_subdomains.push_back(s);
2101  complex_vars_active_subdomains.push_back(s);
2102  }
2103 
2104  return complex_vars_active_subdomains;
2105 }

◆ get_elem_type()

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 314 of file exodusII_io_helper.C.

References elem_type.

315 {
316  return elem_type.data();
317 }

◆ get_node_set_id()

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 580 of file exodusII_io_helper.C.

References nodeset_ids.

581 {
582  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
583 
584  return nodeset_ids[index];
585 }

◆ get_node_set_name()

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 589 of file exodusII_io_helper.C.

References id_to_ns_names, and nodeset_ids.

590 {
591  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
592 
593  return id_to_ns_names[nodeset_ids[index]];
594 }
std::map< int, std::string > id_to_ns_names

◆ get_side_set_id()

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 562 of file exodusII_io_helper.C.

References ss_ids.

563 {
564  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
565 
566  return ss_ids[index];
567 }

◆ get_side_set_name()

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 571 of file exodusII_io_helper.C.

References id_to_ss_names, and ss_ids.

572 {
573  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
574 
575  return id_to_ss_names[ss_ids[index]];
576 }
std::map< int, std::string > id_to_ss_names

◆ initialize()

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 1119 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(), mesh, 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().

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

◆ initialize_element_variables()

void libMesh::ExodusII_IO_Helper::initialize_element_variables ( std::vector< std::string >  names,
const std::vector< std::set< subdomain_id_type >> &  vars_active_subdomains 
)
virtual

Sets up the nodal variables

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1695 of file exodusII_io_helper.C.

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

1697 {
1698  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1699  return;
1700 
1701  // Quick return if there are no element variables to write
1702  if (names.size() == 0)
1703  return;
1704 
1705  // Quick return if we have already called this function
1707  return;
1708 
1709  // Be sure that variables in the file match what we are asking for
1710  if (num_elem_vars > 0)
1711  {
1712  this->check_existing_vars(ELEMENTAL, names, this->elem_var_names);
1713  return;
1714  }
1715 
1716  // Set the flag so we can skip this stuff on subsequent calls to
1717  // initialize_element_variables()
1718  _elem_vars_initialized = true;
1719 
1720  this->write_var_names(ELEMENTAL, names);
1721 
1722  // Use the truth table to indicate which subdomain/variable pairs are
1723  // active according to vars_active_subdomains.
1724  std::vector<int> truth_tab(num_elem_blk*num_elem_vars, 0);
1725  for (auto var_num : index_range(vars_active_subdomains))
1726  {
1727  // If the list of active subdomains is empty, it is interpreted as being
1728  // active on *all* subdomains.
1729  std::set<subdomain_id_type> current_set;
1730  if (vars_active_subdomains[var_num].empty())
1731  for (auto block_id : block_ids)
1732  current_set.insert(cast_int<subdomain_id_type>(block_id));
1733  else
1734  current_set = vars_active_subdomains[var_num];
1735 
1736  // Find index into the truth table for each id in current_set.
1737  for (auto block_id : current_set)
1738  {
1739  auto it = std::find(block_ids.begin(), block_ids.end(), block_id);
1740  if (it == block_ids.end())
1741  libmesh_error_msg("ExodusII_IO_Helper: block id " << block_id << " not found in block_ids.");
1742 
1743  std::size_t block_index =
1744  std::distance(block_ids.begin(), it);
1745 
1746  std::size_t truth_tab_index = block_index*num_elem_vars + var_num;
1747  truth_tab[truth_tab_index] = 1;
1748  }
1749  }
1750 
1752  num_elem_blk,
1753  num_elem_vars,
1754  truth_tab.data());
1755  EX_CHECK_ERR(ex_err, "Error writing element truth table.");
1756 }
std::vector< std::string > elem_var_names
void write_var_names(ExodusVarType type, std::vector< std::string > &names)
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Definition: int_range.h:104
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

◆ initialize_global_variables()

void libMesh::ExodusII_IO_Helper::initialize_global_variables ( std::vector< std::string >  names)

Sets up the global variables

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

1789 {
1790  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1791  return;
1792 
1793  // Quick return if there are no global variables to write
1794  if (names.size() == 0)
1795  return;
1796 
1798  return;
1799 
1800  // Be sure that variables in the file match what we are asking for
1801  if (num_global_vars > 0)
1802  {
1803  this->check_existing_vars(GLOBAL, names, this->global_var_names);
1804  return;
1805  }
1806 
1807  _global_vars_initialized = true;
1808 
1809  this->write_var_names(GLOBAL, names);
1810 }
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

◆ initialize_nodal_variables()

void libMesh::ExodusII_IO_Helper::initialize_nodal_variables ( std::vector< std::string >  names)

Sets up the nodal variables

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

1761 {
1762  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1763  return;
1764 
1765  // Quick return if there are no nodal variables to write
1766  if (names.size() == 0)
1767  return;
1768 
1769  // Quick return if we have already called this function
1771  return;
1772 
1773  // Be sure that variables in the file match what we are asking for
1774  if (num_nodal_vars > 0)
1775  {
1776  this->check_existing_vars(NODAL, names, this->nodal_var_names);
1777  return;
1778  }
1779 
1780  // Set the flag so we can skip the rest of this function on subsequent calls.
1781  _nodal_vars_initialized = true;
1782 
1783  this->write_var_names(NODAL, names);
1784 }
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

◆ inquire()

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 814 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().

815 {
816  int ret_int = 0;
817  char ret_char = 0;
818  float ret_float = 0.;
819 
821  req_info_in,
822  &ret_int,
823  &ret_float,
824  &ret_char);
825 
826  EX_CHECK_ERR(ex_err, error_msg);
827 
828  return ret_int;
829 }
EXODUS_EXPORT int ex_inquire(int exoid, int inquiry, void_int *, float *, char *)

◆ message() [1/2]

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 321 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().

322 {
323  if (verbose) libMesh::out << msg << std::endl;
324 }
OStreamProxy out(std::cout)

◆ message() [2/2]

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 328 of file exodusII_io_helper.C.

References libMesh::out, and verbose.

329 {
330  if (verbose) libMesh::out << msg << i << "." << std::endl;
331 }
OStreamProxy out(std::cout)

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 95 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), 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::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), 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::MeshBase::partition(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

96  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ open()

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 335 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.

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

◆ print_header()

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 455 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.

456 {
457  if (verbose)
458  libMesh::out << "Title: \t" << title.data() << std::endl
459  << "Mesh Dimension: \t" << num_dim << std::endl
460  << "Number of Nodes: \t" << num_nodes << std::endl
461  << "Number of elements: \t" << num_elem << std::endl
462  << "Number of elt blocks: \t" << num_elem_blk << std::endl
463  << "Number of node sets: \t" << num_node_sets << std::endl
464  << "Number of side sets: \t" << num_side_sets << std::endl;
465 }
OStreamProxy out(std::cout)

◆ print_nodes()

void libMesh::ExodusII_IO_Helper::print_nodes ( std::ostream &  out = libMesh::out)

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

Definition at line 509 of file exodusII_io_helper.C.

References num_nodes, x, y, and z.

510 {
511  for (int i=0; i<num_nodes; i++)
512  out_stream << "(" << x[i] << ", " << y[i] << ", " << z[i] << ")" << std::endl;
513 }

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 101 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::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), 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::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::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::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), initialize(), initialize_element_variables(), initialize_global_variables(), initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), 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::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), 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(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< T >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), 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::System::write_header(), 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::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::Nemesis_IO_Helper::write_sidesets(), write_sidesets(), libMesh::ExodusII_IO::write_timestep(), write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

102  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
processor_id_type rank() const
Definition: communicator.h:173

◆ read_block_info()

void libMesh::ExodusII_IO_Helper::read_block_info ( )

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

Definition at line 517 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, message(), and num_elem_blk.

518 {
519  block_ids.resize(num_elem_blk);
520  // Get all element block IDs.
522  block_ids.empty() ? nullptr : block_ids.data());
523  // Usually, there is only one
524  // block since there is only
525  // one type of element.
526  // However, there could be more.
527 
528  EX_CHECK_ERR(ex_err, "Error getting block IDs.");
529  message("All block IDs retrieved successfully.");
530 
531  char name_buffer[MAX_STR_LENGTH+1];
532  for (int i=0; i<num_elem_blk; ++i)
533  {
535  block_ids[i], name_buffer);
536  EX_CHECK_ERR(ex_err, "Error getting block name.");
537  id_to_block_names[block_ids[i]] = name_buffer;
538  }
539  message("All block names retrieved successfully.");
540 }
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_elem_blk_ids(int exoid, void_int *ids)
void message(const std::string &msg)
std::map< int, std::string > id_to_block_names

◆ read_elem_in_block()

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 599 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.

600 {
601  libmesh_assert_less (static_cast<unsigned int>(block), block_ids.size());
602 
604  block_ids[block],
605  elem_type.data(),
608  &num_attr);
609  if (verbose)
610  libMesh::out << "Reading a block of " << num_elem_this_blk
611  << " " << elem_type.data() << "(s)"
612  << " having " << num_nodes_per_elem
613  << " nodes per element." << std::endl;
614 
615  EX_CHECK_ERR(ex_err, "Error getting block info.");
616  message("Info retrieved successfully for block: ", block);
617 
618 
619 
620  // Read in the connectivity of the elements of this block,
621  // watching out for the case where we actually have no
622  // elements in this block (possible with parallel files)
624 
625  if (!connect.empty())
626  {
628  block_ids[block],
629  connect.data());
630 
631  EX_CHECK_ERR(ex_err, "Error reading block connectivity.");
632  message("Connectivity retrieved successfully for block: ", block);
633  }
634 }
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)

◆ read_elem_num_map()

void libMesh::ExodusII_IO_Helper::read_elem_num_map ( )

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 639 of file exodusII_io_helper.C.

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

640 {
641  elem_num_map.resize(num_elem);
642 
644  elem_num_map.empty() ? nullptr : elem_num_map.data());
645 
646  EX_CHECK_ERR(ex_err, "Error retrieving element number map.");
647  message("Element numbering map retrieved successfully.");
648 
649 
650  if (verbose)
651  {
652  libMesh::out << "[" << this->processor_id() << "] elem_num_map[i] = ";
653  for (unsigned int i=0; i<static_cast<unsigned int>(std::min(10, num_elem-1)); ++i)
654  libMesh::out << elem_num_map[i] << ", ";
655  libMesh::out << "... " << elem_num_map.back() << std::endl;
656  }
657 }
EXODUS_EXPORT int ex_get_elem_num_map(int exoid, void_int *elem_map)
void message(const std::string &msg)
processor_id_type processor_id() const
OStreamProxy out(std::cout)
long double min(long double a, double b)

◆ read_elemental_var_values()

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 1012 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, num_elem, num_elem_blk, num_elem_this_blk, and read_var_names().

1015 {
1016  this->read_var_names(ELEMENTAL);
1017 
1018  // See if we can find the variable we are looking for
1019  unsigned int var_index = 0;
1020  bool found = false;
1021 
1022  // Do a linear search for nodal_var_name in nodal_var_names
1023  for (; var_index != elem_var_names.size(); ++var_index)
1024  if (elem_var_names[var_index] == elemental_var_name)
1025  {
1026  found = true;
1027  break;
1028  }
1029 
1030  if (!found)
1031  {
1032  libMesh::err << "Available variables: " << std::endl;
1033  for (const auto & var_name : elem_var_names)
1034  libMesh::err << var_name << std::endl;
1035 
1036  libmesh_error_msg("Unable to locate variable named: " << elemental_var_name);
1037  }
1038 
1039  // Sequential index which we can use to look up the element ID in the elem_num_map.
1040  unsigned ex_el_num = 0;
1041 
1042  for (unsigned i=0; i<static_cast<unsigned>(num_elem_blk); i++)
1043  {
1045  block_ids[i],
1046  nullptr,
1048  nullptr,
1049  nullptr);
1050  EX_CHECK_ERR(ex_err, "Error getting number of elements in block.");
1051 
1052  std::vector<Real> block_elem_var_values(num_elem);
1054  time_step,
1055  var_index+1,
1056  block_ids[i],
1058  block_elem_var_values.data());
1059  EX_CHECK_ERR(ex_err, "Error getting elemental values.");
1060 
1061  for (unsigned j=0; j<static_cast<unsigned>(num_elem_this_blk); j++)
1062  {
1063  // Use the elem_num_map to obtain the ID of this element in the Exodus file,
1064  // and remember to subtract 1 since libmesh is zero-based and Exodus is 1-based.
1065  unsigned mapped_elem_id = this->elem_num_map[ex_el_num] - 1;
1066 
1067  // Store the elemental value in the map.
1068  elem_var_value_map[mapped_elem_id] = block_elem_var_values[j];
1069 
1070  // Go to the next sequential element ID.
1071  ex_el_num++;
1072  }
1073  }
1074 }
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
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)

◆ read_global_values()

void libMesh::ExodusII_IO_Helper::read_global_values ( std::vector< Real > &  values,
int  timestep 
)

Reads the vector of global variables.

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

2032 {
2033  if ((_run_only_on_proc0) && (this->processor_id() != 0))
2034  return;
2035 
2036  values.clear();
2037  values.resize(num_global_vars);
2038  ex_err = exII::ex_get_glob_vars(ex_id, timestep, num_global_vars, values.data());
2039  EX_CHECK_ERR(ex_err, "Error reading global values.");
2040 }
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

◆ read_header()

void libMesh::ExodusII_IO_Helper::read_header ( )

Reads an ExodusII mesh file header.

Definition at line 375 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.

376 {
378  title.data(),
379  &num_dim,
380  &num_nodes,
381  &num_elem,
382  &num_elem_blk,
383  &num_node_sets,
384  &num_side_sets);
385 
386  EX_CHECK_ERR(ex_err, "Error retrieving header info.");
387 
388  this->read_num_time_steps();
389 
391  EX_CHECK_ERR(ex_err, "Error reading number of nodal variables.");
392 
394  EX_CHECK_ERR(ex_err, "Error reading number of elemental variables.");
395 
397  EX_CHECK_ERR(ex_err, "Error reading number of global variables.");
398 
399  message("Exodus header info retrieved successfully.");
400 }
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)

◆ read_nodal_var_values()

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 856 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().

857 {
858  // Read the nodal variable names from file, so we can see if we have the one we're looking for
859  this->read_var_names(NODAL);
860 
861  // See if we can find the variable we are looking for
862  unsigned int var_index = 0;
863  bool found = false;
864 
865  // Do a linear search for nodal_var_name in nodal_var_names
866  for (; var_index<nodal_var_names.size(); ++var_index)
867  {
868  found = (nodal_var_names[var_index] == nodal_var_name);
869  if (found)
870  break;
871  }
872 
873  if (!found)
874  {
875  libMesh::err << "Available variables: " << std::endl;
876  for (const auto & var_name : nodal_var_names)
877  libMesh::err << var_name << std::endl;
878 
879  libmesh_error_msg("Unable to locate variable named: " << nodal_var_name);
880  }
881 
882  // Allocate enough space to store the nodal variable values
883  nodal_var_values.resize(num_nodes);
884 
885  // Call the Exodus API to read the nodal variable values
887  time_step,
888  var_index+1,
889  num_nodes,
890  nodal_var_values.data());
891  EX_CHECK_ERR(ex_err, "Error reading nodal variable values!");
892 }
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

◆ read_node_num_map()

void libMesh::ExodusII_IO_Helper::read_node_num_map ( )

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 489 of file exodusII_io_helper.C.

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

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

◆ read_nodes()

void libMesh::ExodusII_IO_Helper::read_nodes ( )

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

Definition at line 469 of file exodusII_io_helper.C.

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

470 {
471  x.resize(num_nodes);
472  y.resize(num_nodes);
473  z.resize(num_nodes);
474 
475  if (num_nodes)
476  {
478  static_cast<void *>(x.data()),
479  static_cast<void *>(y.data()),
480  static_cast<void *>(z.data()));
481 
482  EX_CHECK_ERR(ex_err, "Error retrieving nodal data.");
483  message("Nodal data retrieved successfully.");
484  }
485 }
EXODUS_EXPORT int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
void message(const std::string &msg)

◆ read_nodeset()

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 765 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.

766 {
767  libmesh_assert_less (static_cast<unsigned int>(id), nodeset_ids.size());
768  libmesh_assert_less (static_cast<unsigned int>(id), num_nodes_per_set.size());
769  libmesh_assert_less (static_cast<unsigned int>(id), num_node_df_per_set.size());
770 
772  nodeset_ids[id],
773  &num_nodes_per_set[id],
774  &num_node_df_per_set[id]);
775  EX_CHECK_ERR(ex_err, "Error retrieving nodeset parameters.");
776  message("Parameters retrieved successfully for nodeset: ", id);
777 
778  node_list.resize(num_nodes_per_set[id]);
779 
780  // Don't call ex_get_node_set unless there are actually nodes there to get.
781  // Exodus prints an annoying warning message in DEBUG mode otherwise...
782  if (num_nodes_per_set[id] > 0)
783  {
785  nodeset_ids[id],
786  node_list.data());
787 
788  EX_CHECK_ERR(ex_err, "Error retrieving nodeset data.");
789  message("Data retrieved successfully for nodeset: ", id);
790  }
791 }
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

◆ read_nodeset_info()

void libMesh::ExodusII_IO_Helper::read_nodeset_info ( )

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

Definition at line 694 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.

695 {
696  nodeset_ids.resize(num_node_sets);
697  if (num_node_sets > 0)
698  {
700  nodeset_ids.data());
701  EX_CHECK_ERR(ex_err, "Error retrieving nodeset information.");
702  message("All nodeset information retrieved successfully.");
703 
704  // Resize appropriate data structures -- only do this once outnode the loop
707  }
708 
709  char name_buffer[MAX_STR_LENGTH+1];
710  for (int i=0; i<num_node_sets; ++i)
711  {
713  nodeset_ids[i], name_buffer);
714  EX_CHECK_ERR(ex_err, "Error getting node set name.");
715  id_to_ns_names[nodeset_ids[i]] = name_buffer;
716  }
717  message("All node set names retrieved successfully.");
718 }
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

◆ read_num_time_steps()

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 848 of file exodusII_io_helper.C.

References EX_INQ_TIME, inquire(), and num_time_steps.

Referenced by read_header(), and read_time_steps().

849 {
851  this->inquire(exII::EX_INQ_TIME, "Error retrieving number of time steps");
852 }
int inquire(int req_info, std::string error_msg="")

◆ read_qa_records()

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 405 of file exodusII_io_helper.C.

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

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

◆ read_sideset()

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 722 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.

723 {
724  libmesh_assert_less (static_cast<unsigned int>(id), ss_ids.size());
725  libmesh_assert_less (static_cast<unsigned int>(id), num_sides_per_set.size());
726  libmesh_assert_less (static_cast<unsigned int>(id), num_df_per_set.size());
727  libmesh_assert_less_equal (static_cast<unsigned int>(offset), elem_list.size());
728  libmesh_assert_less_equal (static_cast<unsigned int>(offset), side_list.size());
729 
731  ss_ids[id],
732  &num_sides_per_set[id],
733  &num_df_per_set[id]);
734  EX_CHECK_ERR(ex_err, "Error retrieving sideset parameters.");
735  message("Parameters retrieved successfully for sideset: ", id);
736 
737 
738  // It's OK for offset==elem_list.size() as long as num_sides_per_set[id]==0
739  // because in that case we don't actually read anything...
740 #ifdef DEBUG
741  if (static_cast<unsigned int>(offset) == elem_list.size() ||
742  static_cast<unsigned int>(offset) == side_list.size() )
743  libmesh_assert_equal_to (num_sides_per_set[id], 0);
744 #endif
745 
746 
747  // Don't call ex_get_side_set unless there are actually sides there to get.
748  // Exodus prints an annoying warning in DEBUG mode otherwise...
749  if (num_sides_per_set[id] > 0)
750  {
752  ss_ids[id],
753  &elem_list[offset],
754  &side_list[offset]);
755  EX_CHECK_ERR(ex_err, "Error retrieving sideset data.");
756  message("Data retrieved successfully for sideset: ", id);
757 
758  for (int i=0; i<num_sides_per_set[id]; i++)
759  id_list[i+offset] = ss_ids[id];
760  }
761 }
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

◆ read_sideset_info()

void libMesh::ExodusII_IO_Helper::read_sideset_info ( )

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

Definition at line 661 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.

662 {
663  ss_ids.resize(num_side_sets);
664  if (num_side_sets > 0)
665  {
667  ss_ids.data());
668  EX_CHECK_ERR(ex_err, "Error retrieving sideset information.");
669  message("All sideset information retrieved successfully.");
670 
671  // Resize appropriate data structures -- only do this once outside the loop
674 
675  // Inquire about the length of the concatenated side sets element list
676  num_elem_all_sidesets = inquire(exII::EX_INQ_SS_ELEM_LEN, "Error retrieving length of the concatenated side sets element list!");
677 
681  }
682 
683  char name_buffer[MAX_STR_LENGTH+1];
684  for (int i=0; i<num_side_sets; ++i)
685  {
687  ss_ids[i], name_buffer);
688  EX_CHECK_ERR(ex_err, "Error getting side set name.");
689  id_to_ss_names[ss_ids[i]] = name_buffer;
690  }
691  message("All side set names retrieved successfully.");
692 }
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

◆ read_time_steps()

void libMesh::ExodusII_IO_Helper::read_time_steps ( )

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

Definition at line 833 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.

834 {
835  // Make sure we have an up-to-date count of the number of time steps in the file.
836  this->read_num_time_steps();
837 
838  if (num_time_steps > 0)
839  {
840  time_steps.resize(num_time_steps);
842  EX_CHECK_ERR(ex_err, "Error reading timesteps!");
843  }
844 }
std::vector< Real > time_steps
EXODUS_EXPORT int ex_get_all_times(int exoid, void *time_values)

◆ read_var_names()

void libMesh::ExodusII_IO_Helper::read_var_names ( ExodusVarType  type)

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

897 {
898  switch (type)
899  {
900  case NODAL:
902  break;
903  case ELEMENTAL:
905  break;
906  case GLOBAL:
908  break;
909  default:
910  libmesh_error_msg("Unrecognized ExodusVarType " << type);
911  }
912 }
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

◆ read_var_names_impl()

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 916 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().

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

◆ set_coordinate_offset()

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 2058 of file exodusII_io_helper.C.

References _coordinate_offset.

2059 {
2060  _coordinate_offset = p;
2061 }

◆ use_mesh_dimension_instead_of_spatial_dimension()

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 2044 of file exodusII_io_helper.C.

References _use_mesh_dimension_instead_of_spatial_dimension.

◆ write_as_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 2051 of file exodusII_io_helper.C.

References _write_as_dimension.

2052 {
2053  _write_as_dimension = dim;
2054 }

◆ write_element_values()

void libMesh::ExodusII_IO_Helper::write_element_values ( const MeshBase mesh,
const std::vector< Real > &  values,
int  timestep,
const std::vector< std::set< subdomain_id_type >> &  vars_active_subdomains 
)

Writes the vector of values to the element variables.

Definition at line 1865 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(), mesh, libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), num_elem_vars, and libMesh::ParallelObject::processor_id().

1869 {
1870  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1871  return;
1872 
1873  // Loop over the element blocks and write the data one block at a time
1874  std::map<subdomain_id_type, std::vector<unsigned int>> subdomain_map;
1875 
1876  // Ask the file how many element vars it has, store it in the num_elem_vars variable.
1878  EX_CHECK_ERR(ex_err, "Error reading number of elemental variables.");
1879 
1880  // loop through element and map between block and element vector
1881  for (const auto & elem : mesh.active_element_ptr_range())
1882  subdomain_map[elem->subdomain_id()].push_back(elem->id());
1883 
1884  // Use mesh.n_elem() to access into the values vector rather than
1885  // the number of elements the Exodus writer thinks the mesh has,
1886  // which may not include inactive elements.
1888 
1889  // For each variable, create a 'data' array which holds all the elemental variable
1890  // values *for a given block* on this processor, then write that data vector to file
1891  // before moving onto the next block.
1892  libmesh_assert_equal_to(vars_active_subdomains.size(), static_cast<unsigned>(num_elem_vars));
1893  for (unsigned int i=0; i<static_cast<unsigned>(num_elem_vars); ++i)
1894  {
1895  // The size of the subdomain map is the number of blocks.
1896  std::map<subdomain_id_type, std::vector<unsigned int>>::iterator it = subdomain_map.begin();
1897 
1898  const std::set<subdomain_id_type> & active_subdomains = vars_active_subdomains[i];
1899  for (unsigned int j=0; it!=subdomain_map.end(); ++it, ++j)
1900  {
1901  // Skip any variable/subdomain pairs that are inactive.
1902  // Note that if active_subdomains is empty, it is interpreted
1903  // as being active on *all* subdomains.
1904  if (!active_subdomains.empty())
1905  if (active_subdomains.find(it->first) == active_subdomains.end())
1906  {
1907  continue;
1908  }
1909 
1910  const std::vector<unsigned int> & elem_nums = (*it).second;
1911  const unsigned int num_elems_this_block =
1912  cast_int<unsigned int>(elem_nums.size());
1913  std::vector<Real> data(num_elems_this_block);
1914 
1915  for (unsigned int k=0; k<num_elems_this_block; ++k)
1916  data[k] = values[i*n_elem + elem_nums[k]];
1917 
1918  if (_single_precision)
1919  {
1920  std::vector<float> cast_data(data.begin(), data.end());
1921 
1923  timestep,
1924  i+1,
1925  this->get_block_id(j),
1926  num_elems_this_block,
1927  cast_data.data());
1928  }
1929  else
1930  {
1932  timestep,
1933  i+1,
1934  this->get_block_id(j),
1935  num_elems_this_block,
1936  data.data());
1937  }
1938  EX_CHECK_ERR(ex_err, "Error writing element values.");
1939  }
1940  }
1941 
1943  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1944 }
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Definition: mesh_tools.C:702
MeshBase & mesh
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
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64

◆ write_elements()

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 1324 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::index_range(), libmesh_elem_num_to_exodus, libmesh_node_num_to_exodus, mesh, 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.

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

◆ write_global_values()

void libMesh::ExodusII_IO_Helper::write_global_values ( const std::vector< Real > &  values,
int  timestep 
)

Writes the vector of global variables.

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

2010 {
2011  if ((_run_only_on_proc0) && (this->processor_id() != 0))
2012  return;
2013 
2014  if (_single_precision)
2015  {
2016  std::vector<float> cast_values(values.begin(), values.end());
2017  ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_global_vars, cast_values.data());
2018  }
2019  else
2020  {
2021  ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_global_vars, values.data());
2022  }
2023  EX_CHECK_ERR(ex_err, "Error writing global values.");
2024 
2026  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
2027 }
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

◆ write_information_records()

void libMesh::ExodusII_IO_Helper::write_information_records ( const std::vector< std::string > &  records)

Writes the vector of information records.

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

1971 {
1972  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1973  return;
1974 
1975  // There may already be information records in the file (for
1976  // example, if we're appending) and in that case, according to the
1977  // Exodus documentation, writing more information records is not
1978  // supported.
1979  int num_info = inquire(exII::EX_INQ_INFO, "Error retrieving the number of information records from file!");
1980  if (num_info > 0)
1981  {
1982  libMesh::err << "Warning! The Exodus file already contains information records.\n"
1983  << "Exodus does not support writing additional records in this situation."
1984  << std::endl;
1985  return;
1986  }
1987 
1988  int num_records = cast_int<int>(records.size());
1989 
1990  if (num_records > 0)
1991  {
1992  NamesData info(num_records, MAX_LINE_LENGTH);
1993 
1994  // If an entry is longer than MAX_LINE_LENGTH characters it's not an error, we just
1995  // write the first MAX_LINE_LENGTH characters to the file.
1996  for (const auto & record : records)
1997  info.push_back_entry(record);
1998 
1999  ex_err = exII::ex_put_info(ex_id, num_records, info.get_char_star_star());
2000  EX_CHECK_ERR(ex_err, "Error writing global values.");
2001 
2003  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
2004  }
2005 }
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

◆ write_nodal_coordinates()

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 1208 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, mesh, node_num_map, libMesh::MeshBase::node_ptr_range(), num_nodes, libMesh::ParallelObject::processor_id(), x, y, and z.

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

◆ write_nodal_values()

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 1948 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().

1949 {
1950  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1951  return;
1952 
1953  if (_single_precision)
1954  {
1955  std::vector<float> cast_values(values.begin(), values.end());
1956  ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, cast_values.data());
1957  }
1958  else
1959  {
1960  ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, values.data());
1961  }
1962  EX_CHECK_ERR(ex_err, "Error writing nodal values.");
1963 
1965  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1966 }
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)

◆ write_nodesets()

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 1653 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::BoundaryInfo::build_node_boundary_ids(), libMesh::BoundaryInfo::build_node_list(), data, 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(), mesh, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::NamesData::push_back_entry().

1654 {
1655  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1656  return;
1657 
1658  // Maps from nodeset id to the nodes
1659  std::map<boundary_id_type, std::vector<int>> node;
1660 
1661  // Accumulate the vectors to pass into ex_put_node_set
1662  // build_node_list() builds a list of (node-id, bc-id) tuples.
1663  for (const auto & t : mesh.get_boundary_info().build_node_list())
1664  node[std::get<1>(t)].push_back(std::get<0>(t) + 1);
1665 
1666  std::vector<boundary_id_type> node_boundary_ids;
1667  mesh.get_boundary_info().build_node_boundary_ids(node_boundary_ids);
1668 
1669  // Write out the nodeset names, but only if there is something to write
1670  if (node_boundary_ids.size() > 0)
1671  {
1672  NamesData names_table(node_boundary_ids.size(), MAX_STR_LENGTH);
1673 
1674  for (const auto & nodeset_id : node_boundary_ids)
1675  {
1676  int actual_id = nodeset_id;
1677 
1678  names_table.push_back_entry(mesh.get_boundary_info().get_nodeset_name(nodeset_id));
1679 
1680  ex_err = exII::ex_put_node_set_param(ex_id, actual_id, node[nodeset_id].size(), 0);
1681  EX_CHECK_ERR(ex_err, "Error writing nodeset parameters");
1682 
1683  ex_err = exII::ex_put_node_set(ex_id, actual_id, node[nodeset_id].data());
1684  EX_CHECK_ERR(ex_err, "Error writing nodesets");
1685  }
1686 
1687  // Write out the nodeset names
1688  ex_err = exII::ex_put_names(ex_id, exII::EX_NODE_SET, names_table.get_char_star_star());
1689  EX_CHECK_ERR(ex_err, "Error writing nodeset names");
1690  }
1691 }
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)
MeshBase & mesh
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
EXODUS_EXPORT int ex_put_node_set(int exoid, ex_entity_id node_set_id, const void_int *node_set_node_list)
void build_node_list(std::vector< dof_id_type > &node_id_list, std::vector< boundary_id_type > &bc_id_list) const
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
const std::string & get_nodeset_name(boundary_id_type id) const
void build_node_boundary_ids(std::vector< boundary_id_type > &b_ids) const
IterBase * data
processor_id_type processor_id() const

◆ write_sidesets()

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 1544 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::index_range(), libmesh_elem_num_to_exodus, mesh, libMesh::ParallelObject::processor_id(), libMesh::ExodusII_IO_Helper::NamesData::push_back_entry(), and side.

1545 {
1546  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1547  return;
1548 
1550 
1551  // Maps from sideset id to the element and sides
1552  std::map<int, std::vector<int>> elem;
1553  std::map<int, std::vector<int>> side;
1554  std::vector<boundary_id_type> side_boundary_ids;
1555 
1556  {
1557  // Accumulate the vectors to pass into ex_put_side_set
1558  // build_side_list() returns a vector of (elem, side, bc) tuples.
1559  for (const auto & t : mesh.get_boundary_info().build_side_list())
1560  {
1561  std::vector<const Elem *> family;
1562 #ifdef LIBMESH_ENABLE_AMR
1563 
1567  mesh.elem_ref(std::get<0>(t)).active_family_tree_by_side(family, std::get<1>(t), false);
1568 #else
1569  family.push_back(mesh.elem_ptr(std::get<0>(t)));
1570 #endif
1571 
1572  for (const auto & f : family)
1573  {
1574  const ExodusII_IO_Helper::Conversion conv =
1575  em.assign_conversion(mesh.elem_ptr(f->id())->type());
1576 
1577  // Use the libmesh to exodus data structure map to get the proper sideset IDs
1578  // The data structure contains the "collapsed" contiguous ids
1579  elem[std::get<2>(t)].push_back(libmesh_elem_num_to_exodus[f->id()]);
1580  side[std::get<2>(t)].push_back(conv.get_inverse_side_map(std::get<1>(t)));
1581  }
1582  }
1583 
1584  mesh.get_boundary_info().build_side_boundary_ids(side_boundary_ids);
1585  }
1586 
1587  {
1588  // add data for shell faces, if needed
1589 
1590  // Accumulate the vectors to pass into ex_put_side_set
1591  for (const auto & t : mesh.get_boundary_info().build_shellface_list())
1592  {
1593  std::vector<const Elem *> family;
1594 #ifdef LIBMESH_ENABLE_AMR
1595 
1599  mesh.elem_ref(std::get<0>(t)).active_family_tree_by_side(family, std::get<1>(t), false);
1600 #else
1601  family.push_back(mesh.elem_ptr(std::get<0>(t)));
1602 #endif
1603 
1604  for (const auto & f : family)
1605  {
1606  const ExodusII_IO_Helper::Conversion conv =
1607  em.assign_conversion(mesh.elem_ptr(f->id())->type());
1608 
1609  // Use the libmesh to exodus data structure map to get the proper sideset IDs
1610  // The data structure contains the "collapsed" contiguous ids
1611  elem[std::get<2>(t)].push_back(libmesh_elem_num_to_exodus[f->id()]);
1612  side[std::get<2>(t)].push_back(conv.get_inverse_shellface_map(std::get<1>(t)));
1613  }
1614  }
1615 
1616  std::vector<boundary_id_type> shellface_boundary_ids;
1617  mesh.get_boundary_info().build_shellface_boundary_ids(shellface_boundary_ids);
1618  for (const auto & id : shellface_boundary_ids)
1619  side_boundary_ids.push_back(id);
1620  }
1621 
1622  // Write out the sideset names, but only if there is something to write
1623  if (side_boundary_ids.size() > 0)
1624  {
1625  NamesData names_table(side_boundary_ids.size(), MAX_STR_LENGTH);
1626 
1627  std::vector<exII::ex_set> sets(side_boundary_ids.size());
1628 
1629  for (auto i : index_range(side_boundary_ids))
1630  {
1631  boundary_id_type ss_id = side_boundary_ids[i];
1632  names_table.push_back_entry(mesh.get_boundary_info().get_sideset_name(ss_id));
1633 
1634  sets[i].id = ss_id;
1635  sets[i].type = exII::EX_SIDE_SET;
1636  sets[i].num_entry = elem[ss_id].size();
1637  sets[i].num_distribution_factor = 0;
1638  sets[i].entry_list = elem[ss_id].data();
1639  sets[i].extra_list = side[ss_id].data();
1640  sets[i].distribution_factor_list = nullptr;
1641  }
1642 
1643  ex_err = exII::ex_put_sets(ex_id, side_boundary_ids.size(), sets.data());
1644  EX_CHECK_ERR(ex_err, "Error writing sidesets");
1645 
1646  ex_err = exII::ex_put_names(ex_id, exII::EX_SIDE_SET, names_table.get_char_star_star());
1647  EX_CHECK_ERR(ex_err, "Error writing sideset names");
1648  }
1649 }
unsigned short int side
Definition: xdr_io.C:50
MeshBase & mesh
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Definition: int_range.h:104
ExodusII_IO_Helper::Conversion assign_conversion(std::string type_str)
void build_side_boundary_ids(std::vector< boundary_id_type > &b_ids) const
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:131
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)
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
int8_t boundary_id_type
Definition: id_types.h:51
void active_family_tree_by_side(std::vector< const Elem *> &family, const unsigned int side, const bool reset=true) const
Definition: elem.C:1630
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
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
virtual const Elem * elem_ptr(const dof_id_type i) const =0
const std::string & get_sideset_name(boundary_id_type id) const
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:504
processor_id_type processor_id() const
void build_shellface_boundary_ids(std::vector< boundary_id_type > &b_ids) const

◆ write_timestep()

void libMesh::ExodusII_IO_Helper::write_timestep ( int  timestep,
Real  time 
)

Writes the time for the timestep

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

1844 {
1845  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1846  return;
1847 
1848  if (_single_precision)
1849  {
1850  float cast_time = float(time);
1851  ex_err = exII::ex_put_time(ex_id, timestep, &cast_time);
1852  }
1853  else
1854  {
1855  ex_err = exII::ex_put_time(ex_id, timestep, &time);
1856  }
1857  EX_CHECK_ERR(ex_err, "Error writing timestep.");
1858 
1860  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1861 }
EXODUS_EXPORT int ex_update(int exoid)
processor_id_type processor_id() const
EXODUS_EXPORT int ex_put_time(int exoid, int time_step, const void *time_value)

◆ write_var_names()

void libMesh::ExodusII_IO_Helper::write_var_names ( ExodusVarType  type,
std::vector< std::string > &  names 
)
protected

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 956 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(), libMesh::Nemesis_IO_Helper::initialize_element_variables(), initialize_global_variables(), and initialize_nodal_variables().

957 {
958  switch (type)
959  {
960  case NODAL:
961  this->write_var_names_impl("n", num_nodal_vars, names);
962  break;
963  case ELEMENTAL:
964  this->write_var_names_impl("e", num_elem_vars, names);
965  break;
966  case GLOBAL:
967  this->write_var_names_impl("g", num_global_vars, names);
968  break;
969  default:
970  libmesh_error_msg("Unrecognized ExodusVarType " << type);
971  }
972 }
void write_var_names_impl(const char *var_type, int &count, std::vector< std::string > &names)

◆ write_var_names_impl()

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 976 of file exodusII_io_helper.C.

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

Referenced by write_var_names().

977 {
978  // Update the count variable so that it's available to other parts of the class.
979  count = cast_int<int>(names.size());
980 
981  // Write that number of variables to the file.
982  ex_err = exII::ex_put_var_param(ex_id, var_type, count);
983  EX_CHECK_ERR(ex_err, "Error setting number of vars.");
984 
985  if (count > 0)
986  {
987  NamesData names_table(count, MAX_STR_LENGTH);
988 
989  // Store the input names in the format required by Exodus.
990  for (int i=0; i != count; ++i)
991  names_table.push_back_entry(names[i]);
992 
993  if (verbose)
994  {
995  libMesh::out << "Writing variable name(s) to file: " << std::endl;
996  for (int i=0; i != count; ++i)
997  libMesh::out << names_table.get_char_star(i) << std::endl;
998  }
999 
1001  var_type,
1002  count,
1003  names_table.get_char_star_star()
1004  );
1005 
1006  EX_CHECK_ERR(ex_err, "Error writing variable names.");
1007  }
1008 }
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

◆ _communicator

◆ _coordinate_offset

Point libMesh::ExodusII_IO_Helper::_coordinate_offset
protected

Definition at line 640 of file exodusII_io_helper.h.

Referenced by set_coordinate_offset(), and write_nodal_coordinates().

◆ _elem_vars_initialized

bool libMesh::ExodusII_IO_Helper::_elem_vars_initialized
protected

◆ _global_vars_initialized

bool libMesh::ExodusII_IO_Helper::_global_vars_initialized
protected

Definition at line 625 of file exodusII_io_helper.h.

Referenced by initialize_global_variables().

◆ _nodal_vars_initialized

bool libMesh::ExodusII_IO_Helper::_nodal_vars_initialized
protected

Definition at line 628 of file exodusII_io_helper.h.

Referenced by initialize_nodal_variables().

◆ _run_only_on_proc0

◆ _single_precision

◆ _use_mesh_dimension_instead_of_spatial_dimension

bool libMesh::ExodusII_IO_Helper::_use_mesh_dimension_instead_of_spatial_dimension
protected

◆ _write_as_dimension

unsigned libMesh::ExodusII_IO_Helper::_write_as_dimension
protected

Definition at line 637 of file exodusII_io_helper.h.

Referenced by initialize(), and write_as_dimension().

◆ block_ids

◆ connect

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

Definition at line 477 of file exodusII_io_helper.h.

Referenced by read_elem_in_block(), and write_elements().

◆ current_filename

std::string libMesh::ExodusII_IO_Helper::current_filename

Definition at line 591 of file exodusII_io_helper.h.

Referenced by create(), and open().

◆ elem_list

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

Definition at line 498 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

◆ elem_num_map

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

◆ elem_type

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

Definition at line 528 of file exodusII_io_helper.h.

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

◆ elem_var_names

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

◆ elem_var_values

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

Definition at line 562 of file exodusII_io_helper.h.

◆ ex_err

◆ ex_id

int libMesh::ExodusII_IO_Helper::ex_id

Definition at line 435 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(), libMesh::Nemesis_IO_Helper::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_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().

◆ exodus_elem_num_to_libmesh

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

◆ exodus_node_num_to_libmesh

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

◆ global_var_names

std::vector<std::string> libMesh::ExodusII_IO_Helper::global_var_names

Definition at line 565 of file exodusII_io_helper.h.

Referenced by initialize_global_variables(), and read_var_names().

◆ id_list

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

Definition at line 507 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

◆ id_to_block_names

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

Definition at line 568 of file exodusII_io_helper.h.

Referenced by get_block_name(), and read_block_info().

◆ id_to_ns_names

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

Definition at line 570 of file exodusII_io_helper.h.

Referenced by get_node_set_name(), and read_nodeset_info().

◆ id_to_ss_names

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

Definition at line 569 of file exodusII_io_helper.h.

Referenced by get_side_set_name(), and read_sideset_info().

◆ libmesh_elem_num_to_exodus

◆ libmesh_node_num_to_exodus

◆ nodal_var_names

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

◆ nodal_var_values

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

Definition at line 553 of file exodusII_io_helper.h.

Referenced by read_nodal_var_values().

◆ node_list

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

Definition at line 504 of file exodusII_io_helper.h.

Referenced by read_nodeset().

◆ node_num_map

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

Definition at line 510 of file exodusII_io_helper.h.

Referenced by read_node_num_map(), and write_nodal_coordinates().

◆ nodeset_ids

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

◆ num_attr

int libMesh::ExodusII_IO_Helper::num_attr

Definition at line 468 of file exodusII_io_helper.h.

Referenced by read_elem_in_block().

◆ num_df_per_set

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

Definition at line 492 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

◆ num_dim

int libMesh::ExodusII_IO_Helper::num_dim

◆ num_elem

◆ num_elem_all_sidesets

int libMesh::ExodusII_IO_Helper::num_elem_all_sidesets

Definition at line 471 of file exodusII_io_helper.h.

Referenced by read_sideset_info().

◆ num_elem_blk

◆ num_elem_this_blk

int libMesh::ExodusII_IO_Helper::num_elem_this_blk

Definition at line 462 of file exodusII_io_helper.h.

Referenced by read_elem_in_block(), and read_elemental_var_values().

◆ num_elem_vars

◆ num_global_vars

int libMesh::ExodusII_IO_Helper::num_global_vars

◆ num_nodal_vars

int libMesh::ExodusII_IO_Helper::num_nodal_vars

◆ num_node_df_per_set

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

Definition at line 495 of file exodusII_io_helper.h.

Referenced by read_nodeset(), and read_nodeset_info().

◆ num_node_sets

int libMesh::ExodusII_IO_Helper::num_node_sets

◆ num_nodes

◆ num_nodes_per_elem

int libMesh::ExodusII_IO_Helper::num_nodes_per_elem

◆ num_nodes_per_set

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

Definition at line 489 of file exodusII_io_helper.h.

Referenced by read_nodeset(), and read_nodeset_info().

◆ num_side_sets

int libMesh::ExodusII_IO_Helper::num_side_sets

◆ num_sides_per_set

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

Definition at line 486 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

◆ num_time_steps

int libMesh::ExodusII_IO_Helper::num_time_steps

Definition at line 541 of file exodusII_io_helper.h.

Referenced by read_num_time_steps(), and read_time_steps().

◆ opened_for_reading

bool libMesh::ExodusII_IO_Helper::opened_for_reading

Definition at line 581 of file exodusII_io_helper.h.

Referenced by close(), and open().

◆ opened_for_writing

bool libMesh::ExodusII_IO_Helper::opened_for_writing

◆ side_list

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

Definition at line 501 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

◆ ss_ids

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

◆ time_steps

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

Definition at line 544 of file exodusII_io_helper.h.

Referenced by read_time_steps().

◆ title

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

Definition at line 525 of file exodusII_io_helper.h.

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

◆ verbose

bool libMesh::ExodusII_IO_Helper::verbose

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

◆ x

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

◆ y

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

◆ z

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

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