libMesh
Classes | Public Types | Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | List of all members
libMesh::ExodusII_IO_Helper Class Reference

This is the ExodusII_IO_Helper class. More...

#include <exodusII_io_helper.h>

Inheritance diagram for libMesh::ExodusII_IO_Helper:
[legend]

Classes

class  Conversion
 
class  ElementMaps
 
class  NamesData
 This class is useful for managing anything that requires a char ** input/output in ExodusII file. More...
 

Public Types

enum  ExodusVarType { NODAL =0, ELEMENTAL =1, GLOBAL =2 }
 Wraps calls to exII::ex_get_var_names() and exII::ex_get_var_param(). More...
 

Public Member Functions

 ExodusII_IO_Helper (const ParallelObject &parent, bool v=false, bool run_only_on_proc0=true, bool single_precision=false)
 Constructor. More...
 
virtual ~ExodusII_IO_Helper ()
 Destructor. More...
 
const char * get_elem_type () const
 
void open (const char *filename, bool read_only)
 Opens an ExodusII mesh file named filename. More...
 
void read_header ()
 Reads an ExodusII mesh file header. More...
 
void read_qa_records ()
 Reads the QA records from an ExodusII file. More...
 
void 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. More...
 
void read_nodes ()
 Reads the nodal data (x,y,z coordinates) from the ExodusII mesh file. More...
 
void read_node_num_map ()
 Reads the optional node_num_map from the ExodusII mesh file. More...
 
void print_nodes (std::ostream &out=libMesh::out)
 Prints the nodal information, by default to libMesh::out. More...
 
void read_block_info ()
 Reads information for all of the blocks in the ExodusII mesh file. More...
 
int get_block_id (int index)
 Get the block number for the given block index. More...
 
std::string get_block_name (int index)
 Get the block name for the given block index if supplied in the mesh file. More...
 
int get_side_set_id (int index)
 Get the side set id for the given side set index. More...
 
std::string get_side_set_name (int index)
 Get the side set name for the given side set index if supplied in the mesh file. More...
 
int get_node_set_id (int index)
 Get the node set id for the given node set index. More...
 
std::string get_node_set_name (int index)
 Get the node set name for the given node set index if supplied in the mesh file. More...
 
void read_elem_in_block (int block)
 Reads all of the element connectivity for block block in the ExodusII mesh file. More...
 
void read_elem_num_map ()
 Reads the optional node_num_map from the ExodusII mesh file. More...
 
void read_sideset_info ()
 Reads information about all of the sidesets in the ExodusII mesh file. More...
 
void read_nodeset_info ()
 Reads information about all of the nodesets in the ExodusII mesh file. More...
 
void read_sideset (int id, int offset)
 Reads information about sideset id and inserts it into the global sideset array at the position offset. More...
 
void read_nodeset (int id)
 Reads information about nodeset id and inserts it into the global nodeset array at the position offset. More...
 
void close ()
 Closes the ExodusII mesh file. More...
 
int inquire (int req_info, std::string error_msg="")
 
void read_time_steps ()
 Reads and stores the timesteps in the 'time_steps' array. More...
 
void read_num_time_steps ()
 Reads the number of timesteps currently stored in the Exodus file and stores it in the num_time_steps variable. More...
 
void 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. More...
 
void 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. More...
 
virtual void create (std::string filename)
 Opens an ExodusII mesh file named filename for writing. More...
 
virtual void initialize (std::string title, const MeshBase &mesh, bool use_discontinuous=false)
 Initializes the Exodus file. More...
 
virtual void write_nodal_coordinates (const MeshBase &mesh, bool use_discontinuous=false)
 Writes the nodal coordinates contained in "mesh". More...
 
virtual void write_elements (const MeshBase &mesh, bool use_discontinuous=false)
 Writes the elements contained in "mesh". More...
 
virtual void write_sidesets (const MeshBase &mesh)
 Writes the sidesets contained in "mesh". More...
 
virtual void write_nodesets (const MeshBase &mesh)
 Writes the nodesets contained in "mesh". More...
 
void initialize_element_variables (std::vector< std::string > names)
 Sets up the nodal variables. More...
 
void initialize_nodal_variables (std::vector< std::string > names)
 Sets up the nodal variables. More...
 
void initialize_global_variables (std::vector< std::string > names)
 Sets up the global variables. More...
 
void write_timestep (int timestep, Real time)
 Writes the time for the timestep. More...
 
void write_element_values (const MeshBase &mesh, const std::vector< Real > &values, int timestep)
 Writes the vector of values to the element variables. More...
 
void write_nodal_values (int var_id, const std::vector< Real > &values, int timestep)
 Writes the vector of values to a nodal variable. More...
 
void write_information_records (const std::vector< std::string > &records)
 Writes the vector of information records. More...
 
void write_global_values (const std::vector< Real > &values, int timestep)
 Writes the vector of global variables. More...
 
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
 Sets the underlying value of the boolean flag _use_mesh_dimension_instead_of_spatial_dimension. More...
 
void write_as_dimension (unsigned dim)
 Sets the value of _write_as_dimension. More...
 
void set_coordinate_offset (Point p)
 Allows you to set a vector that is added to the coordinates of all of the nodes. More...
 
std::vector< std::string > get_complex_names (const std::vector< std::string > &names) const
 
void message (const std::string &msg)
 Prints the message defined in msg. More...
 
void message (const std::string &msg, int i)
 Prints the message defined in msg, and appends the number i to the end of the message. More...
 
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< intblock_ids
 
std::vector< intconnect
 
std::vector< intss_ids
 
std::vector< intnodeset_ids
 
std::vector< intnum_sides_per_set
 
std::vector< intnum_nodes_per_set
 
std::vector< intnum_df_per_set
 
std::vector< intnum_node_df_per_set
 
std::vector< intelem_list
 
std::vector< intside_list
 
std::vector< intnode_list
 
std::vector< intid_list
 
std::vector< intnode_num_map
 
std::vector< intelem_num_map
 
std::vector< Realx
 
std::vector< Realy
 
std::vector< Realz
 
std::vector< char > title
 
std::vector< char > elem_type
 
std::map< int, intlibmesh_elem_num_to_exodus
 
std::vector< intexodus_elem_num_to_libmesh
 
std::map< int, intlibmesh_node_num_to_exodus
 
std::vector< intexodus_node_num_to_libmesh
 
int num_time_steps
 
std::vector< Realtime_steps
 
int num_nodal_vars
 
std::vector< std::string > nodal_var_names
 
std::vector< Realnodal_var_values
 
int num_elem_vars
 
std::vector< std::string > elem_var_names
 
std::vector< Realelem_var_values
 
std::vector< std::string > global_var_names
 
std::map< int, std::string > id_to_block_names
 
std::map< int, std::string > id_to_ss_names
 
std::map< int, std::string > id_to_ns_names
 
bool verbose
 
bool opened_for_writing
 
bool opened_for_reading
 
std::string current_filename
 

Protected Attributes

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

Private Member Functions

void write_var_names (ExodusVarType type, std::vector< std::string > &names)
 Wraps calls to exII::ex_put_var_names() and exII::ex_put_var_param(). More...
 
void check_existing_vars (ExodusVarType type, std::vector< std::string > &names, std::vector< std::string > &names_from_file)
 When appending: during initialization, check that variable names in the file match those you attempt to initialize with. More...
 
void read_var_names_impl (const char *var_type, int &count, std::vector< std::string > &result)
 read_var_names() dispatches to this function. More...
 
void write_var_names_impl (const char *var_type, int &count, std::vector< std::string > &names)
 write_var_names() dispatches to this function. More...
 

Detailed Description

This is the ExodusII_IO_Helper class.

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

Author
John W. Peterson
Date
2002

Definition at line 86 of file exodusII_io_helper.h.

Member Enumeration Documentation

Wraps calls to exII::ex_get_var_names() and exII::ex_get_var_param().

The enumeration controls whether nodal, elemental, or global variable names are read and which class members are filled in. NODAL: num_nodal_vars nodal_var_names ELEMENTAL: num_elem_vars elem_var_names GLOBAL: num_global_vars global_var_names

Enumerator
NODAL 
ELEMENTAL 
GLOBAL 

Definition at line 575 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 267 of file exodusII_io_helper.C.

References elem_type, and title.

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

Destructor.

Definition at line 305 of file exodusII_io_helper.C.

306 {
307 }

Member Function Documentation

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

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

Definition at line 1791 of file exodusII_io_helper.C.

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

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

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

Closes the ExodusII mesh file.

Definition at line 789 of file exodusII_io_helper.C.

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

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

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

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

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

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

Opens an ExodusII mesh file named filename for writing.

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1073 of file exodusII_io_helper.C.

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

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

Get the block number for the given block index.

Definition at line 538 of file exodusII_io_helper.C.

References block_ids.

Referenced by write_element_values().

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

Get the block name for the given block index if supplied in the mesh file.

Otherwise an empty string is returned.

Definition at line 547 of file exodusII_io_helper.C.

References block_ids, and id_to_block_names.

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

Definition at line 2014 of file exodusII_io_helper.C.

2015 {
2016  std::vector<std::string>::const_iterator names_it = names.begin();
2017  std::vector<std::string>::const_iterator names_end = names.end();
2018 
2019  std::vector<std::string> complex_names;
2020 
2021  // This will loop over all names and create new "complex" names
2022  // (i.e. names that start with r_, i_ or a_
2023  for (; names_it != names_end; ++names_it)
2024  {
2025  std::stringstream name_real, name_imag, name_abs;
2026  name_real << "r_" << *names_it;
2027  name_imag << "i_" << *names_it;
2028  name_abs << "a_" << *names_it;
2029 
2030  complex_names.push_back(name_real.str());
2031  complex_names.push_back(name_imag.str());
2032  complex_names.push_back(name_abs.str());
2033  }
2034 
2035  return complex_names;
2036 }
const char * libMesh::ExodusII_IO_Helper::get_elem_type ( ) const
Returns
The current element type.
Note
The default behavior is for this value to be in all capital letters, e.g. HEX27.

Definition at line 311 of file exodusII_io_helper.C.

References elem_type.

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

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

Definition at line 574 of file exodusII_io_helper.C.

References nodeset_ids.

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

Get the node set name for the given node set index if supplied in the mesh file.

Otherwise an empty string is returned.

Definition at line 583 of file exodusII_io_helper.C.

References id_to_ns_names, and nodeset_ids.

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

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

Definition at line 556 of file exodusII_io_helper.C.

References ss_ids.

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

Get the side set name for the given side set index if supplied in the mesh file.

Otherwise an empty string is returned.

Definition at line 565 of file exodusII_io_helper.C.

References id_to_ss_names, and ss_ids.

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

Initializes the Exodus file.

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1113 of file exodusII_io_helper.C.

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

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

Sets up the nodal variables.

Definition at line 1690 of file exodusII_io_helper.C.

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

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

Sets up the global variables.

Definition at line 1765 of file exodusII_io_helper.C.

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

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

Sets up the nodal variables.

Definition at line 1737 of file exodusII_io_helper.C.

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

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

Definition at line 808 of file exodusII_io_helper.C.

References ex_err, and ex_id.

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

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

Prints the message defined in msg.

Can be turned off if verbosity is set to 0.

Definition at line 318 of file exodusII_io_helper.C.

References libMesh::out, and verbose.

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

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

Prints the message defined in msg, and appends the number i to the end of the message.

Useful for printing messages in loops. Can be turned off if verbosity is set to 0.

Definition at line 325 of file exodusII_io_helper.C.

References libMesh::out, and verbose.

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

Definition at line 93 of file parallel_object.h.

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

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

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:726
const Parallel::Communicator & _communicator
void libMesh::ExodusII_IO_Helper::open ( const char *  filename,
bool  read_only 
)

Opens an ExodusII mesh file named filename.

If read_only==true, the file will be opened with the EX_READ flag, otherwise it will be opened with the EX_WRITE flag.

Definition at line 332 of file exodusII_io_helper.C.

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

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

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

Definition at line 452 of file exodusII_io_helper.C.

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

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

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

Definition at line 503 of file exodusII_io_helper.C.

References num_nodes, x, y, and z.

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

Definition at line 99 of file parallel_object.h.

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

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

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

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

Definition at line 511 of file exodusII_io_helper.C.

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

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

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

Definition at line 593 of file exodusII_io_helper.C.

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

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

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 633 of file exodusII_io_helper.C.

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

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

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

Definition at line 1006 of file exodusII_io_helper.C.

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

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

Reads an ExodusII mesh file header.

Definition at line 372 of file exodusII_io_helper.C.

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

373 {
374  ex_err = exII::ex_get_init(ex_id,
375  &title[0],
376  &num_dim,
377  &num_nodes,
378  &num_elem,
379  &num_elem_blk,
380  &num_node_sets,
381  &num_side_sets);
382 
383  EX_CHECK_ERR(ex_err, "Error retrieving header info.");
384 
385  this->read_num_time_steps();
386 
387  ex_err = exII::ex_get_var_param(ex_id, "n", &num_nodal_vars);
388  EX_CHECK_ERR(ex_err, "Error reading number of nodal variables.");
389 
390  ex_err = exII::ex_get_var_param(ex_id, "e", &num_elem_vars);
391  EX_CHECK_ERR(ex_err, "Error reading number of elemental variables.");
392 
393  ex_err = exII::ex_get_var_param(ex_id, "g", &num_global_vars);
394  EX_CHECK_ERR(ex_err, "Error reading number of global variables.");
395 
396  message("Exodus header info retrieved successfully.");
397 }
void message(const std::string &msg)
Prints the message defined in msg.
void read_num_time_steps()
Reads the number of timesteps currently stored in the Exodus file and stores it in the num_time_steps...
void libMesh::ExodusII_IO_Helper::read_nodal_var_values ( std::string  nodal_var_name,
int  time_step 
)

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

Definition at line 850 of file exodusII_io_helper.C.

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

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

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 483 of file exodusII_io_helper.C.

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

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

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

Definition at line 466 of file exodusII_io_helper.C.

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

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

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

Definition at line 759 of file exodusII_io_helper.C.

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

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

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

Definition at line 688 of file exodusII_io_helper.C.

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

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

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

Definition at line 842 of file exodusII_io_helper.C.

References inquire(), and num_time_steps.

Referenced by read_header(), and read_time_steps().

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

Reads the QA records from an ExodusII file.

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

Definition at line 402 of file exodusII_io_helper.C.

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

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

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

Definition at line 716 of file exodusII_io_helper.C.

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

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

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

Definition at line 655 of file exodusII_io_helper.C.

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

656 {
657  ss_ids.resize(num_side_sets);
658  if (num_side_sets > 0)
659  {
660  ex_err = exII::ex_get_side_set_ids(ex_id,
661  &ss_ids[0]);
662  EX_CHECK_ERR(ex_err, "Error retrieving sideset information.");
663  message("All sideset information retrieved successfully.");
664 
665  // Resize appropriate data structures -- only do this once outside the loop
668 
669  // Inquire about the length of the concatenated side sets element list
670  num_elem_all_sidesets = inquire(exII::EX_INQ_SS_ELEM_LEN, "Error retrieving length of the concatenated side sets element list!");
671 
675  }
676 
677  char name_buffer[MAX_STR_LENGTH+1];
678  for (int i=0; i<num_side_sets; ++i)
679  {
680  ex_err = exII::ex_get_name(ex_id, exII::EX_SIDE_SET,
681  ss_ids[i], name_buffer);
682  EX_CHECK_ERR(ex_err, "Error getting side set name.");
683  id_to_ss_names[ss_ids[i]] = name_buffer;
684  }
685  message("All side set names retrieved successfully.");
686 }
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)
Prints the message defined in msg.
std::vector< int > num_df_per_set
void libMesh::ExodusII_IO_Helper::read_time_steps ( )

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

Definition at line 827 of file exodusII_io_helper.C.

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

828 {
829  // Make sure we have an up-to-date count of the number of time steps in the file.
830  this->read_num_time_steps();
831 
832  if (num_time_steps > 0)
833  {
834  time_steps.resize(num_time_steps);
835  ex_err = exII::ex_get_all_times(ex_id, &time_steps[0]);
836  EX_CHECK_ERR(ex_err, "Error reading timesteps!");
837  }
838 }
std::vector< Real > time_steps
void read_num_time_steps()
Reads the number of timesteps currently stored in the Exodus file and stores it in the num_time_steps...
void libMesh::ExodusII_IO_Helper::read_var_names ( ExodusVarType  type)

Definition at line 890 of file exodusII_io_helper.C.

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

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

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

read_var_names() dispatches to this function.

Definition at line 910 of file exodusII_io_helper.C.

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

Referenced by read_var_names().

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

References _coordinate_offset.

2009 {
2010  _coordinate_offset = p;
2011 }
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 1994 of file exodusII_io_helper.C.

References _use_mesh_dimension_instead_of_spatial_dimension.

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

Sets the value of _write_as_dimension.

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

Definition at line 2001 of file exodusII_io_helper.C.

References _write_as_dimension, and dim.

2002 {
2004 }
unsigned int dim
void libMesh::ExodusII_IO_Helper::write_element_values ( const MeshBase mesh,
const std::vector< Real > &  values,
int  timestep 
)

Writes the vector of values to the element variables.

Definition at line 1842 of file exodusII_io_helper.C.

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

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

Writes the elements contained in "mesh".

FIXME: This only works for Meshes having a single type of element!

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1318 of file exodusII_io_helper.C.

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

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

Writes the vector of global variables.

Definition at line 1972 of file exodusII_io_helper.C.

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

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

Writes the vector of information records.

Definition at line 1933 of file exodusII_io_helper.C.

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

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

Writes the nodal coordinates contained in "mesh".

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1202 of file exodusII_io_helper.C.

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

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

Writes the vector of values to a nodal variable.

Definition at line 1911 of file exodusII_io_helper.C.

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

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

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

Writes the nodesets contained in "mesh".

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1642 of file exodusII_io_helper.C.

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

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

Writes the sidesets contained in "mesh".

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

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

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1522 of file exodusII_io_helper.C.

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

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

Writes the time for the timestep.

Definition at line 1820 of file exodusII_io_helper.C.

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

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

Wraps calls to exII::ex_put_var_names() and exII::ex_put_var_param().

The enumeration controls whether nodal, elemental, or global variable names are read and which class members are filled in.

Definition at line 950 of file exodusII_io_helper.C.

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

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

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

write_var_names() dispatches to this function.

Definition at line 970 of file exodusII_io_helper.C.

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

Referenced by write_var_names().

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

Member Data Documentation

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited
Point libMesh::ExodusII_IO_Helper::_coordinate_offset
protected

Definition at line 601 of file exodusII_io_helper.h.

Referenced by set_coordinate_offset(), and write_nodal_coordinates().

bool libMesh::ExodusII_IO_Helper::_elem_vars_initialized
protected

Definition at line 583 of file exodusII_io_helper.h.

Referenced by initialize_element_variables().

bool libMesh::ExodusII_IO_Helper::_global_vars_initialized
protected

Definition at line 586 of file exodusII_io_helper.h.

Referenced by initialize_global_variables().

bool libMesh::ExodusII_IO_Helper::_nodal_vars_initialized
protected

Definition at line 589 of file exodusII_io_helper.h.

Referenced by initialize_nodal_variables().

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

Definition at line 598 of file exodusII_io_helper.h.

Referenced by initialize(), and write_as_dimension().

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

Definition at line 451 of file exodusII_io_helper.h.

Referenced by read_elem_in_block(), and write_elements().

std::string libMesh::ExodusII_IO_Helper::current_filename

Definition at line 565 of file exodusII_io_helper.h.

Referenced by create(), and open().

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

Definition at line 472 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

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

Definition at line 502 of file exodusII_io_helper.h.

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

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

Definition at line 536 of file exodusII_io_helper.h.

int libMesh::ExodusII_IO_Helper::ex_err
int libMesh::ExodusII_IO_Helper::ex_id

Definition at line 409 of file exodusII_io_helper.h.

Referenced by close(), create(), libMesh::Nemesis_IO_Helper::create(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), initialize(), initialize_element_variables(), inquire(), open(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_eb_info_global(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_init_global(), libMesh::Nemesis_IO_Helper::put_init_info(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_n_coord(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::Nemesis_IO_Helper::put_ns_param_global(), libMesh::Nemesis_IO_Helper::put_ss_param_global(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_elemental_var_values(), read_header(), read_nodal_var_values(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_qa_records(), read_sideset(), read_sideset_info(), read_time_steps(), read_var_names_impl(), write_element_values(), libMesh::Nemesis_IO_Helper::write_elements(), write_elements(), libMesh::Nemesis_IO_Helper::write_exodus_initialization_info(), write_global_values(), write_information_records(), libMesh::Nemesis_IO_Helper::write_nodal_coordinates(), write_nodal_coordinates(), write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), write_nodesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), write_sidesets(), write_timestep(), write_var_names_impl(), and libMesh::Nemesis_IO_Helper::~Nemesis_IO_Helper().

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

Definition at line 539 of file exodusII_io_helper.h.

Referenced by initialize_global_variables(), and read_var_names().

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

Definition at line 481 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

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

Definition at line 542 of file exodusII_io_helper.h.

Referenced by get_block_name(), and read_block_info().

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

Definition at line 544 of file exodusII_io_helper.h.

Referenced by get_node_set_name(), and read_nodeset_info().

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

Definition at line 543 of file exodusII_io_helper.h.

Referenced by get_side_set_name(), and read_sideset_info().

std::map<int, int> libMesh::ExodusII_IO_Helper::libmesh_elem_num_to_exodus
std::map<int, int> libMesh::ExodusII_IO_Helper::libmesh_node_num_to_exodus
std::vector<std::string> libMesh::ExodusII_IO_Helper::nodal_var_names
std::vector<Real> libMesh::ExodusII_IO_Helper::nodal_var_values

Definition at line 527 of file exodusII_io_helper.h.

Referenced by read_nodal_var_values().

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

Definition at line 478 of file exodusII_io_helper.h.

Referenced by read_nodeset().

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

Definition at line 484 of file exodusII_io_helper.h.

Referenced by read_node_num_map(), and write_nodal_coordinates().

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

Definition at line 442 of file exodusII_io_helper.h.

Referenced by read_elem_in_block().

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

Definition at line 466 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

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

Definition at line 445 of file exodusII_io_helper.h.

Referenced by read_sideset_info().

int libMesh::ExodusII_IO_Helper::num_elem_blk
int libMesh::ExodusII_IO_Helper::num_elem_this_blk

Definition at line 436 of file exodusII_io_helper.h.

Referenced by read_elem_in_block(), and read_elemental_var_values().

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

Definition at line 469 of file exodusII_io_helper.h.

Referenced by read_nodeset(), and read_nodeset_info().

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

Definition at line 463 of file exodusII_io_helper.h.

Referenced by read_nodeset(), and read_nodeset_info().

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

Definition at line 460 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

int libMesh::ExodusII_IO_Helper::num_time_steps

Definition at line 515 of file exodusII_io_helper.h.

Referenced by read_num_time_steps(), and read_time_steps().

bool libMesh::ExodusII_IO_Helper::opened_for_reading

Definition at line 555 of file exodusII_io_helper.h.

Referenced by close(), and open().

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

Definition at line 475 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

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

Definition at line 518 of file exodusII_io_helper.h.

Referenced by read_time_steps().

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

Definition at line 499 of file exodusII_io_helper.h.

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

bool libMesh::ExodusII_IO_Helper::verbose

Definition at line 547 of file exodusII_io_helper.h.

Referenced by libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), create(), libMesh::Nemesis_IO_Helper::create(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), message(), open(), print_header(), libMesh::Nemesis_IO_Helper::put_node_cmap(), read_elem_in_block(), read_elem_num_map(), read_node_num_map(), read_qa_records(), read_var_names_impl(), write_elements(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), and write_var_names_impl().

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

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