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

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

#include <exodusII_io.h>

Inheritance diagram for libMesh::ExodusII_IO:
[legend]

Public Member Functions

 ExodusII_IO (MeshBase &mesh, bool single_precision=false)
 Constructor. More...
 
 ExodusII_IO (ExodusII_IO &&)=default
 ExodusII_IO special functions: More...
 
 ExodusII_IO (const ExodusII_IO &)=delete
 
ExodusII_IOoperator= (const ExodusII_IO &)=delete
 
ExodusII_IOoperator= (ExodusII_IO &&)=delete
 
virtual ~ExodusII_IO ()
 
virtual void read (const std::string &name) override
 This method implements reading a mesh from a specified file. More...
 
ExodusHeaderInfo read_header (const std::string &name)
 Read only the header information, instead of the entire mesh. More...
 
virtual void write (const std::string &fname) override
 This method implements writing a mesh to a specified file. More...
 
void verbose (bool set_verbosity)
 Set the flag indicating if we should be verbose. More...
 
void write_complex_magnitude (bool val)
 Set the flag indicating whether the complex modulus should be written when complex numbers are enabled. More...
 
void write_added_sides (bool val)
 By default, we only write out the elements physically stored in the mesh. More...
 
virtual bool get_add_sides () override
 
const std::vector< Real > & get_time_steps ()
 
int get_num_time_steps ()
 
void copy_nodal_solution (System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
 If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution into an EquationSystems object. More...
 
void copy_elemental_solution (System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
 If we read in a elemental solution while reading in a mesh, we can attempt to copy that elemental solution into an EquationSystems object. More...
 
void copy_scalar_solution (System &system, std::vector< std::string > system_var_names, std::vector< std::string > exodus_var_names, unsigned int timestep=1)
 Copy global variables into scalar variables of a System object. More...
 
void read_elemental_variable (std::string elemental_var_name, unsigned int timestep, std::map< unsigned int, Real > &unique_id_to_value_map)
 Given an elemental variable and a time step, returns a mapping from the elements (top parent) unique IDs to the value of the elemental variable at the corresponding time step index. More...
 
void read_global_variable (std::vector< std::string > global_var_names, unsigned int timestep, std::vector< Real > &global_values)
 Given a vector of global variables and a time step, returns the values of the global variable at the corresponding time step index. More...
 
void write_discontinuous_exodusII (const std::string &name, const EquationSystems &es, const std::set< std::string > *system_names=nullptr)
 Writes a exodusII file with discontinuous data. More...
 
void write_timestep_discontinuous (const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
 Writes a discontinuous solution at a specific timestep. More...
 
void write_element_data (const EquationSystems &es)
 Write out element solution. More...
 
void write_element_data_from_discontinuous_nodal_data (const EquationSystems &es, const std::set< std::string > *system_names=nullptr, const std::string &var_suffix="_elem_node_")
 Similar to the function above, but instead of only handling (CONSTANT, MONOMIAL) data, writes out a general discontinuous solution field, e.g. More...
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
 Write out a nodal solution. More...
 
void write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
 Write out a discontinuous nodal solution. More...
 
void write_global_data (const std::vector< Number > &, const std::vector< std::string > &)
 Write out global variables. More...
 
void write_information_records (const std::vector< std::string > &)
 Write out information records. More...
 
void write_timestep (const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
 Writes out the solution at a specific timestep. More...
 
void write_elemsets ()
 Write elemsets stored on the Mesh to file. More...
 
void write_sideset_data (int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< boundary_id_type >> &side_ids, const std::vector< std::map< BoundaryInfo::BCTuple, Real >> &bc_vals)
 The Exodus format can also store values on sidesets. More...
 
void read_sideset_data (int timestep, std::vector< std::string > &var_names, std::vector< std::set< boundary_id_type >> &side_ids, std::vector< std::map< BoundaryInfo::BCTuple, Real >> &bc_vals)
 Similar to write_sideset_data(), this function is used to read the data at a particular timestep. More...
 
void get_sideset_data_indices (std::map< BoundaryInfo::BCTuple, unsigned int > &bc_array_indices)
 Similar to read_sideset_data(), but instead of creating one std::map per sideset per variable, creates a single map of (elem, side, boundary_id) tuples, and stores the exo file array indices for any/all sideset variables on that sideset (they are all the same). More...
 
void write_nodeset_data (int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< boundary_id_type >> &node_boundary_ids, const std::vector< std::map< BoundaryInfo::NodeBCTuple, Real >> &bc_vals)
 The Exodus format can also store values on nodesets. More...
 
void read_nodeset_data (int timestep, std::vector< std::string > &var_names, std::vector< std::set< boundary_id_type >> &node_boundary_ids, std::vector< std::map< BoundaryInfo::NodeBCTuple, Real >> &bc_vals)
 Read all the nodeset data at a particular timestep. More...
 
void get_nodeset_data_indices (std::map< BoundaryInfo::NodeBCTuple, unsigned int > &bc_array_indices)
 Similar to read_nodeset_data(), but instead of creating one std::map per nodeset per variable, creates a single map of (node_id, boundary_id) tuples, and stores the exo file array indices for any/all nodeset variables on that nodeset (they are all the same). More...
 
void write_elemset_data (int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< elemset_id_type >> &elemset_ids_in, const std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real >> &elemset_vals)
 The Exodus format can also store values on elemsets. More...
 
void read_elemset_data (int timestep, std::vector< std::string > &var_names, std::vector< std::set< elemset_id_type >> &elemset_ids_in, std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real >> &elemset_vals)
 Read all the elemset data at a particular timestep. More...
 
void get_elemset_data_indices (std::map< std::pair< dof_id_type, elemset_id_type >, unsigned int > &elemset_array_indices)
 Similar to read_elemset_data(), but instead of creating one std::map per nodeset per variable, creates a single map of (elem_id, elemset_id) pairs -> exo file array indices for any/all variables on that elemset (they are all the same). More...
 
void set_extra_integer_vars (const std::vector< std::string > &extra_integer_vars)
 Set the elemental variables in the Exodus file to be read into extra element integers. More...
 
void set_output_variables (const std::vector< std::string > &output_variables, bool allow_empty=true)
 Sets the list of variable names to be included in the output. More...
 
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
 In the general case, meshes containing 2D elements can be manifolds living in 3D space, thus by default we write all meshes with the Exodus dimension set to LIBMESH_DIM = mesh.spatial_dimension(). More...
 
void write_as_dimension (unsigned dim)
 Directly control the num_dim which is written to the Exodus file. More...
 
void set_coordinate_offset (Point p)
 Allows you to set a vector that is added to the coordinates of all of the nodes. More...
 
void append (bool val)
 If true, this flag will cause the ExodusII_IO object to attempt to open an existing file for writing, rather than creating a new file. More...
 
const std::vector< std::string > & get_elem_var_names ()
 Return list of the elemental variable names. More...
 
const std::vector< std::string > & get_nodal_var_names ()
 Return list of the nodal variable names. More...
 
const std::vector< std::string > & get_global_var_names ()
 Return list of the global variable names. More...
 
const std::vector< int > & get_elem_num_map () const
 Returns a const reference to the elem_num_map, which is a vector that is created when a Mesh is read from file. More...
 
const std::vector< int > & get_node_num_map () const
 Identical to the behavior of get_elem_num_map(), but for the node_num_map instead. More...
 
ExodusII_IO_Helperget_exio_helper ()
 Return a reference to the ExodusII_IO_Helper object. More...
 
void set_hdf5_writing (bool write_hdf5)
 Set to true (the default) to write files in an HDF5-based file format (when HDF5 is available), or to false to write files in the old NetCDF3-based format. More...
 
void set_discontinuous_bex (bool disc_bex)
 Set to true (false is the default) to generate independent nodes for every Bezier Extraction element in an input file containing them, causing those elements to be disconnected from each other. More...
 
void write_nodal_data_common (std::string fname, const std::vector< std::string > &names, bool continuous=true)
 This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_data_discontinuous() functions. More...
 
bool is_parallel_format () const
 Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once. More...
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
 This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_discontinuous_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
 This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 This method may be overridden by "parallel" output formats for writing nodal data. More...
 
virtual void write_nodal_data (const std::string &, const EquationSystems &, const std::set< std::string > *)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static int get_exodus_version ()
 

Protected Member Functions

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

Protected Attributes

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

Private Attributes

std::unique_ptr< ExodusII_IO_Helperexio_helper
 Only attempt to instantiate an ExodusII helper class if the Exodus API is defined. More...
 
int _timestep
 Stores the current value of the timestep when calling ExodusII_IO::write_timestep(). More...
 
bool _verbose
 should we be verbose? More...
 
bool _append
 Default false. More...
 
std::vector< std::string > _extra_integer_vars
 An optional list of variables in the EXODUS file that are to be used to set extra integers when loading the file into a mesh. More...
 
std::vector< std::string > _output_variables
 The names of the variables to be output. More...
 
bool _allow_empty_variables
 Flag which controls the behavior of _output_variables: .) If true, _output_variables is allowed to remain empty. More...
 
bool _write_complex_abs
 By default, when complex numbers are enabled, for each variable we write out three values: the real part, "r_u" the imaginary part, "i_u", and the complex modulus, a_u := sqrt(r_u*r_u + i_u*i_u), which is also the value returned by std::abs(std::complex). More...
 
bool _disc_bex
 Set to true (false is the default) to generate independent nodes for every Bezier Extraction element. More...
 

Detailed Description

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

By default, LibMesh expects ExodusII files to have a ".exd" or ".e" file extension.

Author
Benjamin Kirk
John Peterson
Date
2004 Handles reading and writing of Exodus binary files.

Definition at line 52 of file exodusII_io.h.

Constructor & Destructor Documentation

◆ ExodusII_IO() [1/3]

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

Constructor.

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

◆ ExodusII_IO() [2/3]

libMesh::ExodusII_IO::ExodusII_IO ( ExodusII_IO &&  )
default

ExodusII_IO special functions:

  • Can't be (default) copy constructed or assigned since they contain a unique_ptr member.
  • Can't be (default) move assigned because the helper class contains references.
  • The destructor is responsible for closing the file

◆ ExodusII_IO() [3/3]

libMesh::ExodusII_IO::ExodusII_IO ( const ExodusII_IO )
delete

◆ ~ExodusII_IO()

libMesh::ExodusII_IO::~ExodusII_IO ( )
virtualdefault

Definition at line 217 of file exodusII_io.C.

References exio_helper.

218 {
219  exio_helper->close();
220 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

Member Function Documentation

◆ append()

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

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

Obviously this will only work if the file already exists.

Definition at line 976 of file exodusII_io.C.

References _append.

Referenced by main().

977 {
978  _append = val;
979 }
bool _append
Default false.
Definition: exodusII_io.h:618

◆ ascii_precision()

unsigned int & libMesh::MeshOutput< MeshBase >::ascii_precision ( )
inlineinherited

Return/set the precision to use when writing ASCII files.

By default we use numeric_limits<Real>::max_digits10, which should be enough to write out to ASCII and get the exact same Real back when reading in.

Definition at line 269 of file mesh_output.h.

Referenced by libMesh::UNVIO::nodes_out(), libMesh::FroIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

270 {
271  return _ascii_precision;
272 }
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:207

◆ comm()

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

Definition at line 97 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), 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::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), copy_elemental_solution(), copy_nodal_solution(), copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), 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::PetscMatrix< libMesh::Number >::create_submatrix_nosort(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::RBEIMEvaluation::distribute_bfs(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::MeshBase::get_info(), libMesh::System::get_info(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), 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_bcids_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::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SparsityPattern::Build::n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::MeshBase::operator==(), 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::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), 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::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), 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::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), 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().

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

◆ copy_elemental_solution()

void libMesh::ExodusII_IO::copy_elemental_solution ( System system,
std::string  system_var_name,
std::string  exodus_var_name,
unsigned int  timestep = 1 
)

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

Definition at line 1125 of file exodusII_io.C.

References libMesh::ParallelObject::comm(), libMesh::CONSTANT, libMesh::DofObject::dof_number(), exio_helper, libMesh::System::get_dof_map(), libMesh::MeshBase::is_serial_on_zero(), libMesh::libmesh_isnan(), libMesh::DofMap::local_index(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::MONOMIAL, libMesh::MONOMIAL_VEC, libMesh::DofObject::n_comp(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::MeshBase::query_elem_ptr(), TIMPI::Communicator::rank(), libMesh::Real, libMesh::System::solution, libMesh::System::update(), libMesh::System::variable_number(), and libMesh::System::variable_type().

Referenced by MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData().

1129 {
1130  LOG_SCOPE("copy_elemental_solution()", "ExodusII_IO");
1131 
1132  const unsigned int var_num = system.variable_number(system_var_name);
1133  // Assert that variable is an elemental one.
1134  //
1135  // NOTE: Currently, this reader is capable of reading only individual components of MONOMIAL_VEC
1136  // types, and each must be written out to its own CONSTANT MONOMIAL variable
1137  libmesh_error_msg_if((system.variable_type(var_num) != FEType(CONSTANT, MONOMIAL))
1138  && (system.variable_type(var_num) != FEType(CONSTANT, MONOMIAL_VEC)),
1139  "Error! Trying to copy elemental solution into a variable that is not of CONSTANT MONOMIAL nor CONSTANT MONOMIAL_VEC type.");
1140 
1142  const DofMap & dof_map = system.get_dof_map();
1143 
1144  // Map from element ID to elemental variable value. We need to use
1145  // a map here rather than a vector (e.g. elem_var_values) since the
1146  // libmesh element numbering can contain "holes". This is the case
1147  // if we are reading elemental var values from an adaptively refined
1148  // mesh that has not been sequentially renumbered.
1149  std::map<dof_id_type, Real> elem_var_value_map;
1150 
1151  // With Exodus files we only open them on processor 0, so that's the
1152  // where we have to do the data read too.
1153  if (system.comm().rank() == 0)
1154  {
1155  libmesh_error_msg_if(!exio_helper->opened_for_reading,
1156  "ERROR, ExodusII file must be opened for reading before copying an elemental solution!");
1157 
1158  exio_helper->read_elemental_var_values(exodus_var_name, timestep, elem_var_value_map);
1159  }
1160 
1161  const bool serial_on_zero = mesh.is_serial_on_zero();
1162 
1163  // If our mesh isn't serial, then non-root processors need to
1164  // request the data for their parts of the mesh and insert it
1165  // themselves.
1166  if (!serial_on_zero)
1167  {
1168  std::unordered_map<processor_id_type, std::vector<dof_id_type>> elem_ids_to_request;
1169  if (this->processor_id() != 0)
1170  {
1171  std::vector<dof_id_type> elem_ids;
1172  for (auto & elem : mesh.active_local_element_ptr_range())
1173  elem_ids.push_back(elem->id());
1174 
1175  if (!elem_ids.empty())
1176  elem_ids_to_request[0] = std::move(elem_ids);
1177  }
1178 
1179  auto value_gather_functor =
1180  [& elem_var_value_map]
1182  const std::vector<dof_id_type> & ids,
1183  std::vector<Real> & values)
1184  {
1185  const std::size_t query_size = ids.size();
1186  values.resize(query_size);
1187  for (std::size_t i=0; i != query_size; ++i)
1188  {
1189  const auto it = elem_var_value_map.find(ids[i]);
1190  if (it != elem_var_value_map.end())
1191  {
1192  values[i] = it->second;
1193  elem_var_value_map.erase(it);
1194  }
1195  else
1196  values[i] = std::numeric_limits<Real>::quiet_NaN();
1197  }
1198  };
1199 
1200  auto value_action_functor =
1201  [& elem_var_value_map]
1203  const std::vector<dof_id_type> & ids,
1204  const std::vector<Real> & values)
1205  {
1206  const std::size_t query_size = ids.size();
1207  for (std::size_t i=0; i != query_size; ++i)
1208  if (!libmesh_isnan(values[i]))
1209  elem_var_value_map[ids[i]] = values[i];
1210  };
1211 
1212  Real * value_ex = nullptr;
1213  Parallel::pull_parallel_vector_data
1214  (system.comm(), elem_ids_to_request, value_gather_functor,
1215  value_action_functor, value_ex);
1216  }
1217 
1218  std::map<dof_id_type, Real>::iterator
1219  it = elem_var_value_map.begin(),
1220  end = elem_var_value_map.end();
1221 
1222  // Everybody inserts the data they've received. If we're
1223  // serial_on_zero then proc 0 inserts everybody's data and other
1224  // procs have empty map ranges.
1225  for (; it!=end; ++it)
1226  {
1227  const Elem * elem = mesh.query_elem_ptr(it->first);
1228 
1229  if (elem && elem->n_comp(system.number(), var_num) > 0)
1230  {
1231  dof_id_type dof_index = elem->dof_number(system.number(), var_num, 0);
1232  if (serial_on_zero || dof_map.local_index(dof_index ))
1233  system.solution->set (dof_index, it->second);
1234  }
1235  }
1236 
1237  system.solution->close();
1238  system.update();
1239 }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:182
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Definition: dof_object.h:1025
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition: dof_object.h:995
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
processor_id_type rank() const
const Parallel::Communicator & comm() const
bool libmesh_isnan(T x)
uint8_t processor_id_type
Definition: id_types.h:104
This is the MeshBase class.
Definition: mesh_base.h:74
unsigned int variable_number(std::string_view var) const
Definition: system.C:1557
virtual bool is_serial_on_zero() const
Definition: mesh_base.h:212
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
unsigned int number() const
Definition: system.h:2269
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:493
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2427
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
uint8_t dof_id_type
Definition: id_types.h:67
bool local_index(dof_id_type dof_index) const
Definition: dof_map.h:831

◆ copy_nodal_solution()

void libMesh::ExodusII_IO::copy_nodal_solution ( System system,
std::string  system_var_name,
std::string  exodus_var_name,
unsigned int  timestep = 1 
)

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

Definition at line 1021 of file exodusII_io.C.

References libMesh::ParallelObject::comm(), libMesh::DofObject::dof_number(), exio_helper, libMesh::MeshBase::is_serial_on_zero(), libMesh::libmesh_isnan(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::DofObject::n_comp(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), TIMPI::Communicator::rank(), libMesh::Real, libMesh::System::solution, libMesh::System::update(), and libMesh::System::variable_number().

Referenced by WriteVecAndScalar::testWriteExodus().

1025 {
1026  LOG_SCOPE("copy_nodal_solution()", "ExodusII_IO");
1027 
1028  const unsigned int var_num = system.variable_number(system_var_name);
1029 
1031 
1032  // With Exodus files we only open them on processor 0, so that's the
1033  // where we have to do the data read too.
1034  if (system.comm().rank() == 0)
1035  {
1036  libmesh_error_msg_if(!exio_helper->opened_for_reading,
1037  "ERROR, ExodusII file must be opened for reading before copying a nodal solution!");
1038 
1039  exio_helper->read_nodal_var_values(exodus_var_name, timestep);
1040  }
1041 
1042  auto & node_var_value_map = exio_helper->nodal_var_values;
1043 
1044  const bool serial_on_zero = mesh.is_serial_on_zero();
1045 
1046  // If our mesh isn't serial, then non-root processors need to
1047  // request the data for their parts of the mesh and insert it
1048  // themselves.
1049  if (!serial_on_zero)
1050  {
1051  std::unordered_map<processor_id_type, std::vector<dof_id_type>> node_ids_to_request;
1052  if (this->processor_id() != 0)
1053  {
1054  std::vector<dof_id_type> node_ids;
1055  for (auto & node : mesh.local_node_ptr_range())
1056  node_ids.push_back(node->id());
1057  if (!node_ids.empty())
1058  node_ids_to_request[0] = std::move(node_ids);
1059  }
1060 
1061  auto value_gather_functor =
1062  [& node_var_value_map]
1064  const std::vector<dof_id_type> & ids,
1065  std::vector<Real> & values)
1066  {
1067  const std::size_t query_size = ids.size();
1068  values.resize(query_size);
1069  for (std::size_t i=0; i != query_size; ++i)
1070  {
1071  const auto it = node_var_value_map.find(ids[i]);
1072  if (it != node_var_value_map.end())
1073  {
1074  values[i] = it->second;
1075  node_var_value_map.erase(it);
1076  }
1077  else
1078  values[i] = std::numeric_limits<Real>::quiet_NaN();
1079  }
1080  };
1081 
1082  auto value_action_functor =
1083  [& node_var_value_map]
1085  const std::vector<dof_id_type> & ids,
1086  const std::vector<Real> & values)
1087  {
1088  const std::size_t query_size = ids.size();
1089  for (std::size_t i=0; i != query_size; ++i)
1090  if (!libmesh_isnan(values[i]))
1091  node_var_value_map[ids[i]] = values[i];
1092  };
1093 
1094  Real * value_ex = nullptr;
1095  Parallel::pull_parallel_vector_data
1096  (system.comm(), node_ids_to_request, value_gather_functor,
1097  value_action_functor, value_ex);
1098  }
1099 
1100  // Everybody inserts the data they've received. If we're
1101  // serial_on_zero then proc 0 inserts everybody's data and other
1102  // procs have empty map ranges.
1103  for (auto p : exio_helper->nodal_var_values)
1104  {
1105  dof_id_type i = p.first;
1106  const Node * node = MeshInput<MeshBase>::mesh().query_node_ptr(i);
1107 
1108  if (node &&
1109  (serial_on_zero || node->processor_id() == system.processor_id()) &&
1110  node->n_comp(system.number(), var_num) > 0)
1111  {
1112  dof_id_type dof_index = node->dof_number(system.number(), var_num, 0);
1113 
1114  // If the dof_index is local to this processor, set the value
1115  system.solution->set (dof_index, p.second);
1116  }
1117  }
1118 
1119  system.solution->close();
1120  system.update();
1121 }
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Definition: dof_object.h:1025
A Node is like a Point, but with more information.
Definition: node.h:52
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition: dof_object.h:995
processor_id_type rank() const
const Parallel::Communicator & comm() const
bool libmesh_isnan(T x)
uint8_t processor_id_type
Definition: id_types.h:104
This is the MeshBase class.
Definition: mesh_base.h:74
unsigned int variable_number(std::string_view var) const
Definition: system.C:1557
virtual bool is_serial_on_zero() const
Definition: mesh_base.h:212
unsigned int number() const
Definition: system.h:2269
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:493
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
processor_id_type processor_id() const
processor_id_type processor_id() const
Definition: dof_object.h:898
uint8_t dof_id_type
Definition: id_types.h:67

◆ copy_scalar_solution()

void libMesh::ExodusII_IO::copy_scalar_solution ( System system,
std::vector< std::string >  system_var_names,
std::vector< std::string >  exodus_var_names,
unsigned int  timestep = 1 
)

Copy global variables into scalar variables of a System object.

Definition at line 1241 of file exodusII_io.C.

References libMesh::ParallelObject::comm(), exio_helper, libMesh::System::get_dof_map(), TIMPI::Communicator::get_unique_tag(), libMesh::index_range(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), read_global_variable(), TIMPI::Communicator::receive(), libMesh::DofMap::SCALAR_dof_indices(), TIMPI::Communicator::send(), libMesh::System::solution, libMesh::System::update(), and libMesh::System::variable_scalar_number().

1245 {
1246  LOG_SCOPE("copy_scalar_solution()", "ExodusII_IO");
1247 
1248  libmesh_error_msg_if(!exio_helper->opened_for_reading,
1249  "ERROR, ExodusII file must be opened for reading before copying a scalar solution!");
1250 
1251  libmesh_error_msg_if(system_var_names.size() != exodus_var_names.size(),
1252  "ERROR, the number of system_var_names must match exodus_var_names.");
1253 
1254  std::vector<Real> values_from_exodus;
1255  read_global_variable(exodus_var_names, timestep, values_from_exodus);
1256 
1257 #ifdef LIBMESH_HAVE_MPI
1258  if (this->n_processors() > 1)
1259  {
1260  const Parallel::MessageTag tag = this->comm().get_unique_tag(1);
1261  if (this->processor_id() == this->n_processors()-1)
1262  this->comm().receive(0, values_from_exodus, tag);
1263  if (this->processor_id() == 0)
1264  this->comm().send(this->n_processors()-1, values_from_exodus, tag);
1265  }
1266 #endif
1267 
1268  if (system.processor_id() == (system.n_processors()-1))
1269  {
1270  const DofMap & dof_map = system.get_dof_map();
1271 
1272  for (auto i : index_range(system_var_names))
1273  {
1274  const unsigned int var_num = system.variable_scalar_number(system_var_names[i], 0);
1275 
1276  std::vector<dof_id_type> SCALAR_dofs;
1277  dof_map.SCALAR_dof_indices(SCALAR_dofs, var_num);
1278 
1279  system.solution->set (SCALAR_dofs[0], values_from_exodus[i]);
1280  }
1281  }
1282 
1283  system.solution->close();
1284  system.update();
1285 }
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition: system.h:2408
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
const Parallel::Communicator & comm() const
void SCALAR_dof_indices(std::vector< dof_id_type > &di, const unsigned int vn, const bool old_dofs=false) const
Fills the vector di with the global degree of freedom indices corresponding to the SCALAR variable vn...
Definition: dof_map.C:2544
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
void read_global_variable(std::vector< std::string > global_var_names, unsigned int timestep, std::vector< Real > &global_values)
Given a vector of global variables and a time step, returns the values of the global variable at the ...
Definition: exodusII_io.C:1304
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:493
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111

◆ get_add_sides()

bool libMesh::ExodusII_IO::get_add_sides ( )
overridevirtual
Returns
Whether or not added sides are expected to be output, to plot SIDE_DISCONTINUOUS data. Subclasses should override this if they are capable of plotting such data.

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 990 of file exodusII_io.C.

References exio_helper.

Referenced by write_discontinuous_exodusII(), and write_nodal_data_discontinuous().

991 {
992  return exio_helper->get_add_sides();
993 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_elem_num_map()

const std::vector< int > & libMesh::ExodusII_IO::get_elem_num_map ( ) const

Returns a const reference to the elem_num_map, which is a vector that is created when a Mesh is read from file.

LibMesh will number its mesh elements consistently with the elem_num_map array, except that the indices in this array are 1-based, and libmesh always uses a 0-based numbering. For example, given: elem_num_map = [4,2,3,1] libmesh will assign the first element it reads from the Exodus file elem->id() == 3, the second will get elem->id() == 1, and so on. We note that not all Exodus files contain an elem_num_map, and in that case, calling this function will return a reference to a vector containing the 1-based identity array, [1,2,3,...]

Definition at line 2349 of file exodusII_io.C.

References exio_helper.

Referenced by ExtraIntegersTest::testExtraIntegersExodusReading().

2350 {
2351  // We could make this function non-const and have it call
2352  // exio_helper->read_elem_num_map() before returning a reference...
2353  // but the intention is that this will be called some time after a
2354  // mesh is read in, in which case it would be doing extra work to
2355  // read in the elem_num_map twice.
2356  return exio_helper->elem_num_map;
2357 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_elem_var_names()

const std::vector< std::string > & libMesh::ExodusII_IO::get_elem_var_names ( )

Return list of the elemental variable names.

Definition at line 2337 of file exodusII_io.C.

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

2338 {
2339  exio_helper->read_var_names(ExodusII_IO_Helper::ELEMENTAL);
2340  return exio_helper->elem_var_names;
2341 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_elemset_data_indices()

void libMesh::ExodusII_IO::get_elemset_data_indices ( std::map< std::pair< dof_id_type, elemset_id_type >, unsigned int > &  elemset_array_indices)

Similar to read_elemset_data(), but instead of creating one std::map per nodeset per variable, creates a single map of (elem_id, elemset_id) pairs -> exo file array indices for any/all variables on that elemset (they are all the same).

In cases where there are hundreds of elemset variables on a single elemset, it is more efficient to store the array indices in a quickly searchable data structure than to repeat the indexing once per variable as is done in the read_elemset_data() case.

Definition at line 2140 of file exodusII_io.C.

References exio_helper.

2141 {
2142  libmesh_error_msg_if(!exio_helper->opened_for_reading,
2143  "ERROR, ExodusII file must be opened for reading "
2144  "before calling ExodusII_IO::get_elemset_data_indices()!");
2145 
2146  exio_helper->get_elemset_data_indices(elemset_array_indices);
2147 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_exio_helper()

ExodusII_IO_Helper & libMesh::ExodusII_IO::get_exio_helper ( )

Return a reference to the ExodusII_IO_Helper object.

Definition at line 2364 of file exodusII_io.C.

References exio_helper.

2365 {
2366  // Provide a warning when accessing the helper object
2367  // since it is a non-public API and is likely to see
2368  // future API changes
2369  libmesh_experimental();
2370 
2371  return *exio_helper;
2372 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_exodus_version()

int libMesh::ExodusII_IO::get_exodus_version ( )
static
Returns
The ExodusII API version, in "nodot" format (e.g. 822 for 8.22), or 0 if ExodusII support is not available.

Definition at line 147 of file exodusII_io.C.

References libMesh::ExodusII_IO_Helper::get_exodus_version().

Referenced by MeshInputTest::testExodusFileMappings(), and MeshInputTest::testExodusIGASidesets().

148 {
149 #ifdef LIBMESH_HAVE_EXODUS_API
151 #else
152  return 0;
153 #endif
154 }

◆ get_global_var_names()

const std::vector< std::string > & libMesh::ExodusII_IO::get_global_var_names ( )

Return list of the global variable names.

Definition at line 2343 of file exodusII_io.C.

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

2344 {
2345  exio_helper->read_var_names(ExodusII_IO_Helper::GLOBAL);
2346  return exio_helper->global_var_names;
2347 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_nodal_var_names()

const std::vector< std::string > & libMesh::ExodusII_IO::get_nodal_var_names ( )

Return list of the nodal variable names.

Definition at line 2331 of file exodusII_io.C.

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

Referenced by WriteVecAndScalar::testWriteExodus().

2332 {
2333  exio_helper->read_var_names(ExodusII_IO_Helper::NODAL);
2334  return exio_helper->nodal_var_names;
2335 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_node_num_map()

const std::vector< int > & libMesh::ExodusII_IO::get_node_num_map ( ) const

Identical to the behavior of get_elem_num_map(), but for the node_num_map instead.

Definition at line 2359 of file exodusII_io.C.

References exio_helper.

Referenced by ExtraIntegersTest::testExtraIntegersExodusReading().

2360 {
2361  return exio_helper->node_num_map;
2362 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_nodeset_data_indices()

void libMesh::ExodusII_IO::get_nodeset_data_indices ( std::map< BoundaryInfo::NodeBCTuple, unsigned int > &  bc_array_indices)

Similar to read_nodeset_data(), but instead of creating one std::map per nodeset per variable, creates a single map of (node_id, boundary_id) tuples, and stores the exo file array indices for any/all nodeset variables on that nodeset (they are all the same).

In cases where there are hundreds of nodeset variables on a single nodeset, it is more efficient to store the array indices in a quickly searchable data structure than to repeat the indexing once per variable as is done in the read_nodeset_data() case.

Definition at line 2070 of file exodusII_io.C.

References exio_helper.

2071 {
2072  libmesh_error_msg_if(!exio_helper->opened_for_reading,
2073  "ERROR, ExodusII file must be opened for reading "
2074  "before calling ExodusII_IO::get_nodeset_data_indices()!");
2075 
2076  exio_helper->get_nodeset_data_indices(bc_array_indices);
2077 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_num_time_steps()

int libMesh::ExodusII_IO::get_num_time_steps ( )
Returns
The number of timesteps currently stored in the Exodus file.

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

Definition at line 1010 of file exodusII_io.C.

References exio_helper.

1011 {
1012  libmesh_error_msg_if(!exio_helper->opened_for_reading && !exio_helper->opened_for_writing,
1013  "ERROR, ExodusII file must be opened for reading or writing before calling ExodusII_IO::get_num_time_steps()!");
1014 
1015  exio_helper->read_num_time_steps();
1016  return exio_helper->num_time_steps;
1017 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_sideset_data_indices()

void libMesh::ExodusII_IO::get_sideset_data_indices ( std::map< BoundaryInfo::BCTuple, unsigned int > &  bc_array_indices)

Similar to read_sideset_data(), but instead of creating one std::map per sideset per variable, creates a single map of (elem, side, boundary_id) tuples, and stores the exo file array indices for any/all sideset variables on that sideset (they are all the same).

In cases where there are hundreds of sideset variables on a single sideset, it is more efficient to store the array indices in a quickly searchable data structure than to repeat the indexing once per variable as is done in the read_sideset_data() case.

Definition at line 2057 of file exodusII_io.C.

References exio_helper, libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshOutput< MT >::mesh().

2059 {
2060  libmesh_error_msg_if(!exio_helper->opened_for_reading,
2061  "ERROR, ExodusII file must be opened for reading "
2062  "before calling ExodusII_IO::get_sideset_data_indices()!");
2063 
2065  exio_helper->get_sideset_data_indices(mesh, bc_array_indices);
2066 }
const MT & mesh() const
Definition: mesh_output.h:259
This is the MeshBase class.
Definition: mesh_base.h:74
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ get_time_steps()

const std::vector< Real > & libMesh::ExodusII_IO::get_time_steps ( )
Returns
An array containing the timesteps in the file.

Definition at line 998 of file exodusII_io.C.

References exio_helper.

999 {
1000  libmesh_error_msg_if
1001  (!exio_helper->opened_for_reading,
1002  "ERROR, ExodusII file must be opened for reading before calling ExodusII_IO::get_time_steps()!");
1003 
1004  exio_helper->read_time_steps();
1005  return exio_helper->time_steps;
1006 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ is_parallel_format()

bool libMesh::MeshInput< MeshBase >::is_parallel_format ( ) const
inlineinherited

Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once.

Definition at line 87 of file mesh_input.h.

References libMesh::MeshInput< MT >::_is_parallel_format.

87 { return this->_is_parallel_format; }
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_input.h:130

◆ mesh() [1/2]

MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
inlineprotectedinherited
Returns
The object as a writable reference.

Definition at line 178 of file mesh_input.h.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::VTKIO::cells_to_vtk(), copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), copy_nodal_solution(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::UNVIO::elements_out(), libMesh::VTKIO::get_local_node_values(), get_sideset_data_indices(), libMesh::UNVIO::groups_in(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::UNVIO::nodes_out(), libMesh::VTKIO::nodes_to_vtk(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::CheckpointIO::read_remote_elem(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), read_sideset_data(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::TetGenIO::write(), libMesh::Nemesis_IO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::Nemesis_IO::write_element_data(), write_element_data(), write_elemsets(), libMesh::UCDIO::write_header(), libMesh::UCDIO::write_implementation(), libMesh::UCDIO::write_interior_elems(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), write_nodal_data(), write_nodal_data_common(), write_nodal_data_discontinuous(), libMesh::UCDIO::write_nodes(), libMesh::CheckpointIO::write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), write_sideset_data(), libMesh::UCDIO::write_soln(), and libMesh::CheckpointIO::write_subdomain_names().

179 {
180  libmesh_error_msg_if(_obj == nullptr, "ERROR: _obj should not be nullptr!");
181  return *_obj;
182 }
MeshBase * _obj
A pointer to a non-const object object.
Definition: mesh_input.h:123

◆ mesh() [2/2]

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
inlineprotectedinherited

◆ n_processors()

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

Definition at line 103 of file parallel_object.h.

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

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

104  {
105  processor_id_type returnval =
106  cast_int<processor_id_type>(_communicator.size());
107  libmesh_assert(returnval); // We never have an empty comm
108  return returnval;
109  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ operator=() [1/2]

ExodusII_IO& libMesh::ExodusII_IO::operator= ( const ExodusII_IO )
delete

◆ operator=() [2/2]

ExodusII_IO& libMesh::ExodusII_IO::operator= ( ExodusII_IO &&  )
delete

◆ processor_id()

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

Definition at line 114 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), copy_elemental_solution(), copy_nodal_solution(), copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), 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::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), write_nodal_data(), write_nodal_data_common(), write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and write_timestep_discontinuous().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

◆ read()

void libMesh::ExodusII_IO::read ( const std::string &  name)
overridevirtual

This method implements reading a mesh from a specified file.

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

Implements libMesh::MeshInput< MeshBase >.

Definition at line 223 of file exodusII_io.C.

References _disc_bex, _extra_integer_vars, libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_elem_integer(), libMesh::MeshBase::add_elemset_code(), libMesh::BoundaryInfo::add_node(), libMesh::MeshBase::add_node_datum(), libMesh::MeshBase::add_point(), libMesh::TypeVector< T >::add_scaled(), libMesh::BoundaryInfo::add_shellface(), libMesh::BoundaryInfo::add_side(), libMesh::Elem::build(), libMesh::MeshBase::clear(), libMesh::Elem::default_order(), libMesh::Elem::dim(), libMesh::MeshBase::elem_ptr(), libMesh::MeshBase::elem_ref(), libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::Utility::enum_to_string(), exio_helper, libMesh::DynaIO::find_elem_definition(), libMesh::MeshBase::get_boundary_info(), libMesh::MeshBase::get_constraint_rows(), libMesh::MeshBase::get_elemset_code(), libMesh::DofObject::id(), libMesh::if(), libMesh::index_range(), int, libMesh::DofObject::invalid_id, libMesh::ExodusII_IO_Helper::Conversion::invalid_id, libMesh::make_range(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elemsets(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::Elem::n_nodes(), libMesh::Quality::name(), libMesh::MeshBase::node_ptr(), libMesh::MeshBase::node_ref(), libMesh::NODEELEM, libMesh::DynaIO::ElementDefinition::nodes, libMesh::BoundaryInfo::nodeset_name(), libMesh::RATIONAL_BERNSTEIN_MAP, libMesh::Real, libMesh::MeshBase::reserve_elem(), libMesh::MeshBase::reserve_nodes(), libMesh::MeshBase::set_default_mapping_data(), libMesh::MeshBase::set_default_mapping_type(), libMesh::DofObject::set_extra_datum(), libMesh::DofObject::set_extra_integer(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::BoundaryInfo::sideset_name(), libMesh::MeshBase::subdomain_name(), and libMesh::Elem::type().

Referenced by libMesh::NameBasedIO::read(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), ExtraIntegersTest::testBadExtraIntegersExodusReading(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), ExtraIntegersTest::testExtraIntegersExodusReading(), MeshInputTest::testLowOrderEdgeBlocks(), and WriteVecAndScalar::testWriteExodus().

224 {
225  LOG_SCOPE("read()", "ExodusII_IO");
226 
227  // Get a reference to the mesh we are reading
229 
230  // Add extra integers into the mesh
231  std::vector<unsigned int> extra_ids;
232  for (auto & name : _extra_integer_vars)
233  extra_ids.push_back(mesh.add_elem_integer(name));
234 
235  // Clear any existing mesh data
236  mesh.clear();
237 
238  // Keep track of what kinds of elements this file contains
239  elems_of_dimension.clear();
240  elems_of_dimension.resize(4, false);
241 
242  // Open the exodus file in EX_READ mode
243  exio_helper->open(fname.c_str(), /*read_only=*/true);
244 
245  // Get header information from exodus file
246  exio_helper->read_and_store_header_info();
247 
248  // Read the QA records
249  exio_helper->read_qa_records();
250 
251  // Print header information
252  exio_helper->print_header();
253 
254  // Read nodes from the exodus file
255  exio_helper->read_nodes();
256 
257  // Reserve space for the nodes.
258  mesh.reserve_nodes(exio_helper->num_nodes);
259 
260  // Read the node number map from the Exodus file. This is
261  // required if we want to preserve the numbering of nodes as it
262  // exists in the Exodus file. If the Exodus file does not contain
263  // a node_num_map, the identity map is returned by this call.
264  exio_helper->read_node_num_map();
265 
266  // Read the element number map from the Exodus file. This is
267  // required if we want to preserve the numbering of elements as it
268  // exists in the Exodus file. If the Exodus file does not contain
269  // an elem_num_map, the identity map is returned by this call.
270  //
271  // We now do this before creating nodes, so if we have any spline
272  // nodes that need a NodeElem attached we can give them unused elem
273  // ids.
274  exio_helper->read_elem_num_map();
275 
276  // Read any Bezier Extraction coefficient vectors from the file,
277  // such as might occur in an IsoGeometric Analysis (IGA) mesh.
278  exio_helper->read_bex_cv_blocks();
279 
280  // If we have Rational Bezier weights, we'll need to
281  // store them.
282  unsigned char weight_index = 0;
283  const bool weights_exist = !exio_helper->w.empty();
284 
285  // If we have Bezier extraction coefficients, we'll need to put
286  // NODEELEM elements on spline nodes, since our Rational Bezier
287  // elements will be connected to nodes derived from those; nothing
288  // else will be directly connected to the spline nodes.
289  const bool bex_cv_exist = !exio_helper->bex_dense_constraint_vecs.empty();
290 
291  // Even if weights don't exist, we still use RATIONAL_BERNSTEIN for
292  // Bezier-Bernstein BEX elements, we just use 1.0 as the weight on
293  // every node.
294  if (bex_cv_exist)
295  {
296  const Real default_weight = 1.0;
297  weight_index = cast_int<unsigned char>
298  (mesh.add_node_datum<Real>("rational_weight", true,
299  &default_weight));
301  mesh.set_default_mapping_data(weight_index);
302  }
303 
304  std::unordered_map<const Node *, Elem *> spline_nodeelem_ptrs;
305 
306  // Loop over the nodes, create Nodes with local processor_id 0.
307  for (int i=0; i<exio_helper->num_nodes; i++)
308  {
309  // Use the node_num_map to get the correct ID for Exodus
310  int exodus_id = exio_helper->node_num_map[i];
311 
312  // Catch the node that was added to the mesh
313  Node * added_node = mesh.add_point (Point(exio_helper->x[i], exio_helper->y[i], exio_helper->z[i]), exodus_id-1);
314 
315  // If the Mesh assigned an ID different from what is in the
316  // Exodus file, we should probably error.
317  libmesh_error_msg_if(added_node->id() != static_cast<unsigned>(exodus_id-1),
318  "Error! Mesh assigned node ID "
319  << added_node->id()
320  << " which is different from the (zero-based) Exodus ID "
321  << exodus_id-1
322  << "!");
323 
324  // If we have a set of spline weights, these nodes are going to
325  // be used as control points for Bezier elements, and we need
326  // to attach a NodeElem to each to make sure it doesn't get
327  // flagged as an unused node.
328  if (weights_exist)
329  {
330  const auto w = exio_helper->w[i];
331  Point & p = *added_node;
332  p /= w; // Exodus Bezier Extraction stores spline nodes in projective space
333 
334  added_node->set_extra_datum<Real>(weight_index, exio_helper->w[i]);
335  }
336 
337  if (bex_cv_exist)
338  {
339  std::unique_ptr<Elem> elem = Elem::build(NODEELEM);
340 
341  // Give the NodeElem ids at the end, so we can match any
342  // existing ids in the file for other elements
343  elem->set_id() = exio_helper->end_elem_id() + i;
344 
345  elem->set_node(0) = added_node;
346  Elem * added_elem = mesh.add_elem(std::move(elem));
347  spline_nodeelem_ptrs[added_node] = added_elem;
348  }
349  }
350 
351  // This assert is no longer valid if the nodes are not numbered
352  // sequentially starting from 1 in the Exodus file.
353  // libmesh_assert_equal_to (static_cast<unsigned int>(exio_helper->num_nodes), mesh.n_nodes());
354 
355  // Get information about all the element and edge blocks
356  exio_helper->read_block_info();
357 
358  // Reserve space for the elements. Account for any NodeElem that
359  // have already been attached to spline control nodes.
360  mesh.reserve_elem(exio_helper->w.size() + exio_helper->num_elem);
361 
362  // Read variables for extra integer IDs
363  std::vector<std::map<dof_id_type, Real>> elem_ids(extra_ids.size());
364  // We use the last time step to load the IDs
365  exio_helper->read_num_time_steps();
366  unsigned int last_step = exio_helper->num_time_steps;
367  for (auto i : index_range(extra_ids))
368  exio_helper->read_elemental_var_values(_extra_integer_vars[i], last_step, elem_ids[i]);
369 
370  // Read in the element connectivity for each block.
371  int nelem_last_block = 0;
372 
373  // If we're building Bezier elements from spline nodes, we need to
374  // calculate those elements' local nodes on the fly, and we'll be
375  // calculating them from constraint matrix columns, and we'll need
376  // to make sure that the same node is found each time it's
377  // calculated from multiple neighboring elements.
378  std::map<std::vector<std::pair<dof_id_type, Real>>, Node *> local_nodes;
379 
380  // We'll set any spline NodeElem subdomain_id() values to exceed the
381  // maximum of subdomain_id() values set via Exodus block ids.
382  int max_subdomain_id = std::numeric_limits<int>::min();
383 
384  // We've already added all the nodes explicitly specified in the
385  // file, but if we have spline nodes we may need to add assembly
386  // element nodes based on them. Add them contiguously so we're
387  // compatible with any subsequent code paths (including our
388  // ExodusII_IO::write()!) that don't support sparse ids.
390 
391  // Loop over all the element blocks
392  for (int i=0; i<exio_helper->num_elem_blk; i++)
393  {
394  // Read the information for block i
395  exio_helper->read_elem_in_block (i);
396  const int subdomain_id = exio_helper->get_block_id(i);
397  max_subdomain_id = std::max(max_subdomain_id, subdomain_id);
398 
399  // populate the map of names
400  std::string subdomain_name = exio_helper->get_block_name(i);
401  if (!subdomain_name.empty())
402  mesh.subdomain_name(static_cast<subdomain_id_type>(subdomain_id)) = subdomain_name;
403 
404  // Set any relevant node/edge maps for this element
405  const std::string type_str (exio_helper->get_elem_type());
406  const auto & conv = exio_helper->get_conversion(type_str);
407 
408  // Loop over all the faces in this block
409  int jmax = nelem_last_block+exio_helper->num_elem_this_blk;
410  for (int j=nelem_last_block; j<jmax; j++)
411  {
412  auto uelem = Elem::build(conv.libmesh_elem_type());
413 
414  const int elem_num = j - nelem_last_block;
415 
416  // Make sure that Exodus's number of nodes per Elem matches
417  // the number of Nodes for this type of Elem. We only check
418  // this for the first Elem in each block, since these values
419  // are the same for every Elem in the block.
420  if (!elem_num)
421  libmesh_error_msg_if(exio_helper->num_nodes_per_elem != static_cast<int>(uelem->n_nodes()),
422  "Error: Exodus file says "
423  << exio_helper->num_nodes_per_elem
424  << " nodes per Elem, but Elem type "
425  << Utility::enum_to_string(uelem->type())
426  << " has " << uelem->n_nodes() << " nodes.");
427 
428  // Assign the current subdomain to this Elem
429  uelem->subdomain_id() = static_cast<subdomain_id_type>(subdomain_id);
430 
431  // Use the elem_num_map to obtain the ID of this element in
432  // the Exodus file. Make sure we aren't reading garbage if
433  // the file is corrupt.
434  libmesh_error_msg_if(std::size_t(j) >= exio_helper->elem_num_map.size(),
435  "Error: Trying to read Exodus file with more elements than elem_num_map entries.\n");
436  int exodus_id = exio_helper->elem_num_map[j];
437 
438  // Assign this element the same ID it had in the Exodus
439  // file, but make it zero-based by subtracting 1. Note:
440  // some day we could use 1-based numbering in libmesh and
441  // thus match the Exodus numbering exactly, but at the
442  // moment libmesh is zero-based.
443  uelem->set_id(exodus_id-1);
444 
445  // Record that we have seen an element of dimension uelem->dim()
446  elems_of_dimension[uelem->dim()] = true;
447 
448  // Catch the Elem pointer that the Mesh throws back
449  Elem * elem = mesh.add_elem(std::move(uelem));
450 
451  // If the Mesh assigned an ID different from what is in the
452  // Exodus file, we should probably error.
453  libmesh_error_msg_if(elem->id() != static_cast<unsigned>(exodus_id-1),
454  "Error! Mesh assigned ID "
455  << elem->id()
456  << " which is different from the (zero-based) Exodus ID "
457  << exodus_id-1
458  << "!");
459 
460  // Assign extra integer IDs
461  for (auto & id : extra_ids)
462  {
463  const Real v = elem_ids[id][elem->id()];
464 
465  if (v == Real(-1))
466  {
468  continue;
469  }
470 
471  const long long iv = std::llround(v);
472 
473  // Check if the real number is outside of the range we can
474  // convert exactly
475 
476  long long max_representation = 1;
477  max_representation = (max_representation << std::min(std::numeric_limits<Real>::digits,
478  std::numeric_limits<double>::digits));
479  libmesh_error_msg_if(iv > max_representation,
480  "Error! An element integer value higher than "
481  << max_representation
482  << " was found! Exodus uses real numbers for storing element "
483  " integers, which can only represent integers from 0 to "
484  << max_representation
485  << ".");
486 
487  libmesh_error_msg_if(iv < 0,
488  "Error! An element integer value less than -1"
489  << " was found! Exodus uses real numbers for storing element "
490  " integers, which can only represent integers from 0 to "
491  << max_representation
492  << ".");
493 
494 
495  elem->set_extra_integer(id, cast_int<dof_id_type>(iv));
496  }
497 
498  // Set all the nodes for this element
499  //
500  // If we don't have any Bezier extraction operators, this
501  // is easy: we've already built all our nodes and just need
502  // to link to them.
503  if (exio_helper->bex_cv_conn.empty())
504  {
505  for (int k=0; k<exio_helper->num_nodes_per_elem; k++)
506  {
507  // global index
508  int gi = (elem_num)*exio_helper->num_nodes_per_elem + conv.get_node_map(k);
509 
510  // The entries in 'connect' are actually (1-based)
511  // indices into the node_num_map, so to get the right
512  // node ID we:
513  // 1.) Subtract 1 from connect[gi]
514  // 2.) Pass it through node_num_map to get the corresponding Exodus ID
515  // 3.) Subtract 1 from that, since libmesh node numbering is "zero"-based,
516  // even when the Exodus node numbering doesn't start with 1.
517  int libmesh_node_id = exio_helper->node_num_map[exio_helper->connect[gi] - 1] - 1;
518 
519  // Set the node pointer in the Elem
520  elem->set_node(k) = mesh.node_ptr(libmesh_node_id);
521  }
522  }
523  else // We have Bezier Extraction data
524  {
525  auto & constraint_rows = mesh.get_constraint_rows();
526 
527  const DynaIO::ElementDefinition & dyna_elem_defn =
529  elem->dim(),
530  int(elem->default_order()));
531 
532  std::vector<std::vector<Real>>
533  my_constraint_mat(exio_helper->bex_num_elem_cvs);
534  for (auto spline_node_index :
535  make_range(exio_helper->bex_num_elem_cvs))
536  {
537  my_constraint_mat[spline_node_index].resize(elem->n_nodes());
538 
539  const auto & my_constraint_rows = exio_helper->bex_cv_conn[elem_num];
540  const unsigned long elem_coef_vec_index =
541  my_constraint_rows[spline_node_index] - 1; // Exodus isn't 0-based
542  const auto & my_vec = bex_constraint_vec(elem_coef_vec_index, *exio_helper);
543  for (auto elem_node_index :
544  make_range(elem->n_nodes()))
545  {
546  my_constraint_mat[spline_node_index][elem_node_index] =
547  my_vec[elem_node_index];
548  }
549 
550  }
551 
552  for (auto elem_node_index :
553  make_range(elem->n_nodes()))
554  {
555  const auto & my_constraint_rows = exio_helper->bex_cv_conn[elem_num];
556 
557  // New finite element node data: dot product of
558  // constraint matrix columns with spline node data.
559  // Store that column as a key.
560  std::vector<std::pair<dof_id_type, Real>> key;
561 
562  for (auto spline_node_index :
563  make_range(exio_helper->bex_num_elem_cvs))
564  {
565  const unsigned long elem_coef_vec_index =
566  my_constraint_rows[spline_node_index] - 1; // Exodus isn't 0-based
567 
568  auto & coef_vec =
569  bex_constraint_vec(elem_coef_vec_index, *exio_helper);
570 
571  const Real coef =
572  libmesh_vector_at(coef_vec, elem_node_index);
573 
574  const int gi = (elem_num)*exio_helper->bex_num_elem_cvs +
575  spline_node_index;
576  const dof_id_type libmesh_node_id =
577  exio_helper->node_num_map[exio_helper->connect[gi] - 1] - 1;
578 
579  if (coef != 0) // Ignore irrelevant spline nodes
580  key.emplace_back(libmesh_node_id, coef);
581  }
582 
583  auto local_node_it = local_nodes.find(key);
584 
585  if (local_node_it != local_nodes.end())
586  elem->set_node(dyna_elem_defn.nodes[elem_node_index]) =
587  local_node_it->second;
588  else
589  {
590  Point p(0);
591  Real w = 0;
592  std::vector<std::pair<std::pair<const Elem *, unsigned int>, Real>> constraint_row;
593 
594  for (auto spline_node_index :
595  make_range(exio_helper->bex_num_elem_cvs))
596  {
597  // global => libMesh index, with crazy 1-based data - see comments above
598  const int gi = (elem_num)*exio_helper->bex_num_elem_cvs +
599  spline_node_index;
600  const dof_id_type libmesh_node_id =
601  exio_helper->node_num_map[exio_helper->connect[gi] - 1] - 1;
602 
603  const unsigned long elem_coef_vec_index =
604  my_constraint_rows[spline_node_index] - 1; // Exodus isn't 0-based
605 
606  const Node & spline_node = mesh.node_ref(libmesh_node_id);
607 
608  auto & coef_vec =
609  bex_constraint_vec(elem_coef_vec_index, *exio_helper);
610  const Real coef =
611  libmesh_vector_at(coef_vec, elem_node_index);
612 
613  // We don't need to store 0 entries;
614  // constraint_rows is a sparse structure.
615  if (coef)
616  {
617  p.add_scaled(spline_node, coef);
618  const Real spline_w = weights_exist ?
619  spline_node.get_extra_datum<Real>(weight_index) : 1;
620  w += coef * spline_w;
621 
622  const Elem * nodeelem =
623  libmesh_map_find(spline_nodeelem_ptrs, &spline_node);
624  constraint_row.emplace_back(std::make_pair(nodeelem, 0), coef);
625  }
626  }
627 
628  Node *n = mesh.add_point(p, n_nodes++);
629  if (weights_exist)
630  n->set_extra_datum<Real>(weight_index, w);
631 
632  // If we're building disconnected Bezier
633  // extraction elements then we don't want to
634  // find the new nodes to reuse later.
635  if (!_disc_bex)
636  local_nodes[key] = n;
637  elem->set_node(dyna_elem_defn.nodes[elem_node_index]) = n;
638 
639  constraint_rows[n] = constraint_row;
640  }
641  }
642  }
643  }
644 
645  // running sum of # of elements per block,
646  // (should equal total number of elements in the end)
647  nelem_last_block += exio_helper->num_elem_this_blk;
648  }
649 
650  // Now we know enough to fix any spline NodeElem subdomains
651  max_subdomain_id++;
652  for (auto p : spline_nodeelem_ptrs)
653  p.second->subdomain_id() = max_subdomain_id;
654 
655  // Read in edge blocks, storing information in the BoundaryInfo object.
656  // Edge blocks are treated as BCs.
657  exio_helper->read_edge_blocks(mesh);
658 
659  // Set the mesh dimension to the largest encountered for an element
660  for (unsigned char i=0; i!=4; ++i)
661  if (elems_of_dimension[i])
663 
664  // Read in sideset information -- this is useful for applying boundary conditions
665  {
666  // Get basic information about all sidesets
667  exio_helper->read_sideset_info();
668  int offset=0;
669  for (int i=0; i<exio_helper->num_side_sets; i++)
670  {
671  // Compute new offset
672  offset += (i > 0 ? exio_helper->num_sides_per_set[i-1] : 0);
673  exio_helper->read_sideset (i, offset);
674 
675  std::string sideset_name = exio_helper->get_side_set_name(i);
676  if (!sideset_name.empty())
678  (cast_int<boundary_id_type>(exio_helper->get_side_set_id(i)))
679  = sideset_name;
680  }
681 
682  for (auto e : index_range(exio_helper->elem_list))
683  {
684  // The numbers in the Exodus file sidesets should be thought
685  // of as (1-based) indices into the elem_num_map array. So,
686  // to get the right element ID we have to:
687  // 1.) Subtract 1 from elem_list[e] (to get a zero-based index)
688  // 2.) Pass it through elem_num_map (to get the corresponding Exodus ID)
689  // 3.) Subtract 1 from that, since libmesh is "zero"-based,
690  // even when the Exodus numbering doesn't start with 1.
691  dof_id_type libmesh_elem_id =
692  cast_int<dof_id_type>(exio_helper->elem_num_map[exio_helper->elem_list[e] - 1] - 1);
693 
694  // Set any relevant node/edge maps for this element
695  Elem & elem = mesh.elem_ref(libmesh_elem_id);
696 
697  const auto & conv = exio_helper->get_conversion(elem.type());
698 
699  // Map the zero-based Exodus side numbering to the libmesh side numbering
700  unsigned int raw_side_index = exio_helper->side_list[e]-1;
701  std::size_t side_index_offset = conv.get_shellface_index_offset();
702 
703  if (raw_side_index < side_index_offset)
704  {
705  // We assume this is a "shell face"
706  int mapped_shellface = raw_side_index;
707 
708  // Check for errors
709  libmesh_error_msg_if(mapped_shellface < 0 || mapped_shellface >= 2,
710  "Bad 0-based shellface id: "
711  << mapped_shellface
712  << " detected in Exodus file "
713  << exio_helper->current_filename);
714 
715  // Add this (elem,shellface,id) triplet to the BoundaryInfo object.
716  mesh.get_boundary_info().add_shellface (libmesh_elem_id,
717  cast_int<unsigned short>(mapped_shellface),
718  cast_int<boundary_id_type>(exio_helper->id_list[e]));
719  }
720  else
721  {
722  unsigned int side_index = static_cast<unsigned int>(raw_side_index - side_index_offset);
723  int mapped_side = conv.get_side_map(side_index);
724 
725  // Check for errors
726  libmesh_error_msg_if(mapped_side == ExodusII_IO_Helper::Conversion::invalid_id,
727  "Invalid 1-based side id: "
728  << side_index
729  << " detected for "
730  << Utility::enum_to_string(elem.type())
731  << " in Exodus file "
732  << exio_helper->current_filename);
733 
734  libmesh_error_msg_if(mapped_side < 0 ||
735  cast_int<unsigned int>(mapped_side) >= elem.n_sides(),
736  "Bad 0-based side id: "
737  << mapped_side
738  << " detected for "
739  << Utility::enum_to_string(elem.type())
740  << " in Exodus file "
741  << exio_helper->current_filename);
742 
743  // Add this (elem,side,id) triplet to the BoundaryInfo object.
744  mesh.get_boundary_info().add_side (libmesh_elem_id,
745  cast_int<unsigned short>(mapped_side),
746  cast_int<boundary_id_type>(exio_helper->id_list[e]));
747  }
748  } // end for (elem_list)
749  } // end read sideset info
750 
751  // Read in elemset information and apply to Mesh elements if present
752  {
753  exio_helper->read_elemset_info();
754 
755  // Mimic behavior of sideset case where we store all the set
756  // information in a single array with offsets.
757  int offset=0;
758  for (int i=0; i<exio_helper->num_elem_sets; i++)
759  {
760  // Compute new offset
761  offset += (i > 0 ? exio_helper->num_elems_per_set[i-1] : 0);
762  exio_helper->read_elemset (i, offset);
763 
764  // TODO: add support for elemset names
765  // std::string elemset_name = exio_helper->get_elem_set_name(i);
766  // if (!elemset_name.empty())
767  // mesh.get_boundary_info().elemset_name(cast_int<boundary_id_type>(exio_helper->get_elem_set_id(i))) = elemset_name;
768  }
769 
770  // Debugging: print the concatenated list of elemset ids
771  // libMesh::out << "Concatenated list of elemset Elem ids (Exodus numbering):" << std::endl;
772  // for (const auto & id : exio_helper->elemset_list)
773  // libMesh::out << id << " ";
774  // libMesh::out << std::endl;
775 
776  // Next we need to assign the elemset ids to the mesh using the
777  // Elem's "extra_integers" support, if we have any.
778  if (exio_helper->num_elem_all_elemsets)
779  {
780  // Build map from Elem -> {elemsets}. This is needed only
781  // temporarily to determine a unique set of elemset codes.
782  std::map<Elem *, MeshBase::elemset_type> elem_to_elemsets;
783  for (auto e : index_range(exio_helper->elemset_list))
784  {
785  // Follow standard (see sideset case above) approach for
786  // converting the ids stored in the elemset_list to
787  // libmesh Elem ids.
788  //
789  // TODO: this should be moved to a helper function so we
790  // don't duplicate the code.
791  dof_id_type libmesh_elem_id =
792  cast_int<dof_id_type>(exio_helper->elem_num_map[exio_helper->elemset_list[e] - 1] - 1);
793 
794  // Get a pointer to this Elem
795  Elem * elem = mesh.elem_ptr(libmesh_elem_id);
796 
797  // Debugging:
798  // libMesh::out << "Elem " << elem->id() << " is in elemset " << exio_helper->elemset_id_list[e] << std::endl;
799 
800  // Store elemset id in the map
801  elem_to_elemsets[elem].insert(exio_helper->elemset_id_list[e]);
802  }
803 
804  // Create a set of unique elemsets
805  std::set<MeshBase::elemset_type> unique_elemsets;
806  for (const auto & pr : elem_to_elemsets)
807  unique_elemsets.insert(pr.second);
808 
809  // Debugging: print the unique elemsets
810  // libMesh::out << "The set of unique elemsets which exist on the Mesh:" << std::endl;
811  // for (const auto & s : unique_elemsets)
812  // {
813  // for (const auto & elemset_id : s)
814  // libMesh::out << elemset_id << " ";
815  // libMesh::out << std::endl;
816  // }
817 
818  // Enumerate the unique_elemsets and tell the mesh about them
819  dof_id_type code = 0;
820  for (const auto & s : unique_elemsets)
821  mesh.add_elemset_code(code++, s);
822 
823  // Sanity check: make sure that MeshBase::n_elemsets() reports
824  // the expected value after calling MeshBase::add_elemset_code()
825  // one or more times.
826  libmesh_assert_msg(exio_helper->num_elem_sets == cast_int<int>(mesh.n_elemsets()),
827  "Error: mesh.n_elemsets() is " << mesh.n_elemsets()
828  << ", but mesh should have " << exio_helper->num_elem_sets << " elemsets.");
829 
830  // Create storage for the extra integer on all Elems. Elems which
831  // are not in any set will use the default value of DofObject::invalid_id
832  unsigned int elemset_index =
833  mesh.add_elem_integer("elemset_code",
834  /*allocate_data=*/true);
835 
836  // Store the appropriate extra_integer value on all Elems that need it.
837  for (const auto & [elem, s] : elem_to_elemsets)
838  elem->set_extra_integer(elemset_index, mesh.get_elemset_code(s));
839  }
840  } // done reading elemset info
841 
842  // Read nodeset info
843  {
844  // This fills in the following fields of the helper for later use:
845  // nodeset_ids
846  // num_nodes_per_set
847  // num_node_df_per_set
848  // node_sets_node_index
849  // node_sets_dist_index
850  // node_sets_node_list
851  // node_sets_dist_fact
852  exio_helper->read_all_nodesets();
853 
854  for (int nodeset=0; nodeset<exio_helper->num_node_sets; nodeset++)
855  {
856  boundary_id_type nodeset_id =
857  cast_int<boundary_id_type>(exio_helper->nodeset_ids[nodeset]);
858 
859  std::string nodeset_name = exio_helper->get_node_set_name(nodeset);
860  if (!nodeset_name.empty())
861  mesh.get_boundary_info().nodeset_name(nodeset_id) = nodeset_name;
862 
863  // Get starting index of node ids for current nodeset.
864  unsigned int offset = exio_helper->node_sets_node_index[nodeset];
865 
866  for (int i=0; i<exio_helper->num_nodes_per_set[nodeset]; ++i)
867  {
868  int exodus_id = exio_helper->node_sets_node_list[i + offset];
869 
870  // It's possible for nodesets to have invalid ids in them
871  // by accident. Instead of possibly accessing past the
872  // end of node_num_map, let's make sure we have that many
873  // entries.
874  libmesh_error_msg_if(static_cast<std::size_t>(exodus_id - 1) >= exio_helper->node_num_map.size(),
875  "Invalid Exodus node id " << exodus_id
876  << " found in nodeset " << nodeset_id);
877 
878  // As before, the entries in 'node_list' are 1-based
879  // indices into the node_num_map array, so we have to map
880  // them. See comment above.
881  int libmesh_node_id = exio_helper->node_num_map[exodus_id - 1] - 1;
882  mesh.get_boundary_info().add_node(cast_int<dof_id_type>(libmesh_node_id),
883  nodeset_id);
884  }
885  }
886  }
887 
888 #if LIBMESH_DIM < 3
889  libmesh_error_msg_if(mesh.mesh_dimension() > LIBMESH_DIM,
890  "Cannot open dimension "
891  << mesh.mesh_dimension()
892  << " mesh file when configured without "
893  << mesh.mesh_dimension()
894  << "D support.");
895 #endif
896 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
constraint_rows_type & get_constraint_rows()
Definition: mesh_base.h:1683
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2381
A Node is like a Point, but with more information.
Definition: node.h:52
std::string & nodeset_name(boundary_id_type id)
std::vector< std::string > _extra_integer_vars
An optional list of variables in the EXODUS file that are to be used to set extra integers when loadi...
Definition: exodusII_io.h:626
static const int invalid_id
An invalid_id that can be returned to signal failure in case something goes wrong.
std::vector< bool > elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh...
Definition: mesh_input.h:107
unsigned int add_elem_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each element in the mesh...
Definition: mesh_base.C:512
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set...
Definition: mesh_base.C:350
Defines mapping from libMesh element types to LS-DYNA element types or vice-versa.
Definition: dyna_io.h:121
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
dof_id_type get_elemset_code(const MeshBase::elemset_type &id_set) const
Definition: mesh_base.C:391
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
This is the MeshBase class.
Definition: mesh_base.h:74
static const ElementDefinition & find_elem_definition(dyna_int_type dyna_elem, int dim, int p)
Finds the ElementDefinition corresponding to a particular element type.
Definition: dyna_io.C:754
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
const dof_id_type n_nodes
Definition: tecplot_io.C:67
int8_t boundary_id_type
Definition: id_types.h:51
dof_id_type id() const
Definition: dof_object.h:823
virtual unsigned int n_nodes() const =0
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:273
void set_default_mapping_type(const ElemMappingType type)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
Definition: mesh_base.h:800
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set.
Definition: mesh_base.C:376
void set_extra_datum(const unsigned int index, const T value)
Sets the value on this object of the extra datum associated with index, which should have been obtain...
Definition: dof_object.h:1119
std::string & subdomain_name(subdomain_id_type id)
Definition: mesh_base.C:1619
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:269
bool _disc_bex
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element...
Definition: exodusII_io.h:659
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition: mesh_base.C:862
unsigned int add_node_datum(const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
Register a datum (of type T) to be added to each node in the mesh.
Definition: mesh_base.h:2246
std::string & sideset_name(boundary_id_type id)
std::string enum_to_string(const T e)
virtual const Elem * elem_ptr(const dof_id_type i) const =0
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual unsigned short dim() const =0
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
Add shell face shellface of element number elem with boundary id id to the boundary information data ...
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:618
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
void set_default_mapping_data(const unsigned char data)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
Definition: mesh_base.h:818
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:575
virtual const Node * node_ptr(const dof_id_type i) const =0
std::vector< unsigned int > nodes
Definition: dyna_io.h:138
virtual Order default_order() const =0
virtual ElemType type() const =0
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
void set_extra_integer(const unsigned int index, const dof_id_type value)
Sets the value on this object of the extra integer associated with index, which should have been obta...
Definition: dof_object.h:1079
virtual dof_id_type n_nodes() const =0
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_elemental_variable()

void libMesh::ExodusII_IO::read_elemental_variable ( std::string  elemental_var_name,
unsigned int  timestep,
std::map< unsigned int, Real > &  unique_id_to_value_map 
)

Given an elemental variable and a time step, returns a mapping from the elements (top parent) unique IDs to the value of the elemental variable at the corresponding time step index.

Note that this function MUST only be called before renumbering! This function is essentially a wrapper for read_elemental_var_values from the exodus helper (which is not accessible outside this class).

Parameters
elemental_var_nameName of an elemental variable
timestepThe corresponding time step index
unique_id_to_value_mapThe map to be filled

Definition at line 1287 of file exodusII_io.C.

References exio_helper, libMesh::MeshInput< MT >::mesh(), libMesh::Elem::top_parent(), and libMesh::DofObject::unique_id().

1290 {
1291  LOG_SCOPE("read_elemental_variable()", "ExodusII_IO");
1292 
1293  // Note that this function MUST be called before renumbering
1294  std::map<dof_id_type, Real> elem_var_value_map;
1295 
1296  exio_helper->read_elemental_var_values(elemental_var_name, timestep, elem_var_value_map);
1297  for (auto & pr : elem_var_value_map)
1298  {
1299  const Elem * elem = MeshInput<MeshBase>::mesh().query_elem_ptr(pr.first);
1300  unique_id_to_value_map.emplace(elem->top_parent()->unique_id(), pr.second);
1301  }
1302 }
const Elem * top_parent() const
Definition: elem.h:2893
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
unique_id_type unique_id() const
Definition: dof_object.h:839
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ read_elemset_data()

void libMesh::ExodusII_IO::read_elemset_data ( int  timestep,
std::vector< std::string > &  var_names,
std::vector< std::set< elemset_id_type >> &  elemset_ids_in,
std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real >> &  elemset_vals 
)

Read all the elemset data at a particular timestep.

Definition at line 2127 of file exodusII_io.C.

References exio_helper.

2131 {
2132  libmesh_error_msg_if(!exio_helper->opened_for_reading,
2133  "ERROR, ExodusII file must be opened for reading "
2134  "before calling ExodusII_IO::read_elemset_data()!");
2135 
2136  exio_helper->read_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2137 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ read_global_variable()

void libMesh::ExodusII_IO::read_global_variable ( std::vector< std::string >  global_var_names,
unsigned int  timestep,
std::vector< Real > &  global_values 
)

Given a vector of global variables and a time step, returns the values of the global variable at the corresponding time step index.

Parameters
global_var_namesVector of names of global variables
timestepThe corresponding time step index
global_valuesThe vector to be filled

Definition at line 1304 of file exodusII_io.C.

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

Referenced by copy_scalar_solution().

1307 {
1308  LOG_SCOPE("read_global_variable()", "ExodusII_IO");
1309 
1310  std::size_t size = global_var_names.size();
1311  libmesh_error_msg_if(size == 0, "ERROR, empty list of global variables to read from the Exodus file.");
1312 
1313  // read the values for all global variables
1314  std::vector<Real> values_from_exodus;
1315  exio_helper->read_var_names(ExodusII_IO_Helper::GLOBAL);
1316  exio_helper->read_global_values(values_from_exodus, timestep);
1317  std::vector<std::string> global_var_names_exodus = exio_helper->global_var_names;
1318 
1319  if (values_from_exodus.size() == 0)
1320  return; // This will happen in parallel on procs that are not 0
1321 
1322  global_values.clear();
1323  for (std::size_t i = 0; i != size; ++i)
1324  {
1325  // for each global variable in global_var_names, look the corresponding one in global_var_names_from_exodus
1326  // and fill global_values accordingly
1327  auto it = find(global_var_names_exodus.begin(), global_var_names_exodus.end(), global_var_names[i]);
1328  if (it != global_var_names_exodus.end())
1329  global_values.push_back(values_from_exodus[it - global_var_names_exodus.begin()]);
1330  else
1331  libmesh_error_msg("ERROR, Global variable " << global_var_names[i] << \
1332  " not found in Exodus file.");
1333  }
1334 
1335 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ read_header()

ExodusHeaderInfo libMesh::ExodusII_IO::read_header ( const std::string &  name)

Read only the header information, instead of the entire mesh.

After the header is read, the file is closed and the MeshBase object remains unchanged. This capability is useful if you only need to know the mesh "metadata" and should be faster than reading in all the nodes and elems.

The header information currently includes: .) Title string .) Mesh spatial dimension .) Number of nodes .) Number of elements .) Number of element blocks .) Number of node sets .) Number of side sets .) Number of edge blocks/edges

Definition at line 901 of file exodusII_io.C.

References libMesh::ExodusHeaderInfo::broadcast(), libMesh::ParallelObject::comm(), exio_helper, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), and libMesh::ParallelObject::processor_id().

Referenced by MeshInputTest::testExodusReadHeader().

902 {
903  // We will need the Communicator of the Mesh we were created with.
905 
906  // Eventual return value
907  ExodusHeaderInfo header_info;
908 
909  // File I/O is done on processor 0, then broadcast to other procs
910  if (mesh.processor_id() == 0)
911  {
912  // Open the exodus file in EX_READ mode
913  exio_helper->open(fname.c_str(), /*read_only=*/true);
914 
915  // Get header information from exodus file without updating the
916  // Helper object's internal data structures.
917  header_info = exio_helper->read_header();
918 
919  // Close the file, we are now done with it. The goal is to keep the
920  // exio_helper object unchanged while calling this function,
921  // although it can't quite be marked "const" because we do have to
922  // actually open/close the file. This way, it should be possible to
923  // use the same ExodusII_IO object to read the headers of multiple
924  // different mesh files.
925  exio_helper->close();
926  }
927 
928  // Broadcast header_info to other procs before returning
929  header_info.broadcast(mesh.comm());
930 
931  // Return the information we read back to the user.
932  return header_info;
933 }
This class is used as both an external data structure for passing around Exodus file header informati...
const Parallel::Communicator & comm() const
This is the MeshBase class.
Definition: mesh_base.h:74
void broadcast(const Parallel::Communicator &comm)
Broadcasts data from processor 0 to other procs using the provided Communicator.
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
processor_id_type processor_id() const

◆ read_nodeset_data()

void libMesh::ExodusII_IO::read_nodeset_data ( int  timestep,
std::vector< std::string > &  var_names,
std::vector< std::set< boundary_id_type >> &  node_boundary_ids,
std::vector< std::map< BoundaryInfo::NodeBCTuple, Real >> &  bc_vals 
)

Read all the nodeset data at a particular timestep.

TODO: currently all the nodeset variables are read, but we might want to change this to only read the requested ones.

Definition at line 2097 of file exodusII_io.C.

References exio_helper.

2101 {
2102  libmesh_error_msg_if(!exio_helper->opened_for_reading,
2103  "ERROR, ExodusII file must be opened for reading "
2104  "before calling ExodusII_IO::read_nodeset_data()!");
2105 
2106  exio_helper->read_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2107 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ read_sideset_data()

void libMesh::ExodusII_IO::read_sideset_data ( int  timestep,
std::vector< std::string > &  var_names,
std::vector< std::set< boundary_id_type >> &  side_ids,
std::vector< std::map< BoundaryInfo::BCTuple, Real >> &  bc_vals 
)

Similar to write_sideset_data(), this function is used to read the data at a particular timestep.

TODO: currently all the sideset variables are read, but we might want to change this to only read the requested ones.

Definition at line 2040 of file exodusII_io.C.

References exio_helper, libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshOutput< MT >::mesh().

2044 {
2045  libmesh_error_msg_if(!exio_helper->opened_for_reading,
2046  "ERROR, ExodusII file must be opened for reading "
2047  "before calling ExodusII_IO::read_sideset_data()!");
2048 
2050  exio_helper->read_sideset_data(mesh, timestep, var_names, side_ids, bc_vals);
2051 }
const MT & mesh() const
Definition: mesh_output.h:259
This is the MeshBase class.
Definition: mesh_base.h:74
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ set_coordinate_offset()

void libMesh::ExodusII_IO::set_coordinate_offset ( Point  p)

Allows you to set a vector that is added to the coordinates of all of the nodes.

Effectively, this "moves" the mesh to a particular position.

Definition at line 968 of file exodusII_io.C.

References exio_helper.

969 {
970  libmesh_warning("This method may be deprecated in the future");
971  exio_helper->set_coordinate_offset(p);
972 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ set_discontinuous_bex()

void libMesh::ExodusII_IO::set_discontinuous_bex ( bool  disc_bex)

Set to true (false is the default) to generate independent nodes for every Bezier Extraction element in an input file containing them, causing those elements to be disconnected from each other.

(Their vertices will be multiple distinct nodes at overlapping points.) If this is false, Bezier Extraction elements will be connected where possible, thereby using fewer redundancies and less memory, but the input mesh will need to be conforming.

Definition at line 2381 of file exodusII_io.C.

References _disc_bex.

Referenced by MeshInputTest::testExodusFileMappings().

2382 {
2383  _disc_bex = disc_bex;
2384 }
bool _disc_bex
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element...
Definition: exodusII_io.h:659

◆ set_extra_integer_vars()

void libMesh::ExodusII_IO::set_extra_integer_vars ( const std::vector< std::string > &  extra_integer_vars)

Set the elemental variables in the Exodus file to be read into extra element integers.

The names of these elemental variables will be used to name the extra element integers.

Definition at line 158 of file exodusII_io.C.

References _extra_integer_vars.

Referenced by ExtraIntegersTest::testBadExtraIntegersExodusReading(), and ExtraIntegersTest::testExtraIntegersExodusReading().

159 {
160  _extra_integer_vars = extra_integer_vars;
161 }
std::vector< std::string > _extra_integer_vars
An optional list of variables in the EXODUS file that are to be used to set extra integers when loadi...
Definition: exodusII_io.h:626

◆ set_hdf5_writing()

void libMesh::ExodusII_IO::set_hdf5_writing ( bool  write_hdf5)

Set to true (the default) to write files in an HDF5-based file format (when HDF5 is available), or to false to write files in the old NetCDF3-based format.

If HDF5 is unavailable, this setting does nothing.

Definition at line 2375 of file exodusII_io.C.

References exio_helper.

2376 {
2377  exio_helper->set_hdf5_writing(write_hdf5);
2378 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ set_n_partitions()

void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
inlineprotectedinherited

Sets the number of partitions in the mesh.

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

Definition at line 101 of file mesh_input.h.

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

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

101 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1789

◆ set_output_variables()

void libMesh::ExodusII_IO::set_output_variables ( const std::vector< std::string > &  output_variables,
bool  allow_empty = true 
)

Sets the list of variable names to be included in the output.

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

Definition at line 163 of file exodusII_io.C.

References _allow_empty_variables, and _output_variables.

Referenced by main().

165 {
166  _output_variables = output_variables;
167  _allow_empty_variables = allow_empty;
168 }
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:632
bool _allow_empty_variables
Flag which controls the behavior of _output_variables: .) If true, _output_variables is allowed to re...
Definition: exodusII_io.h:642

◆ skip_comment_lines()

void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
)
protectedinherited

Reads input from in, skipping all the lines that start with the character comment_start.

Definition at line 187 of file mesh_input.h.

Referenced by libMesh::TetGenIO::read(), and libMesh::UCDIO::read_implementation().

189 {
190  char c, line[256];
191 
192  while (in.get(c), c==comment_start)
193  in.getline (line, 255);
194 
195  // put back first character of
196  // first non-comment line
197  in.putback (c);
198 }

◆ use_mesh_dimension_instead_of_spatial_dimension()

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

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

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

Definition at line 954 of file exodusII_io.C.

References exio_helper.

955 {
956  exio_helper->use_mesh_dimension_instead_of_spatial_dimension(val);
957 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ verbose()

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

Set the flag indicating if we should be verbose.

Definition at line 937 of file exodusII_io.C.

References _verbose, and exio_helper.

938 {
939  _verbose = set_verbosity;
940 
941  // Set the verbose flag in the helper object as well.
942  exio_helper->verbose = _verbose;
943 }
bool _verbose
should we be verbose?
Definition: exodusII_io.h:612
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ write()

void libMesh::ExodusII_IO::write ( const std::string &  fname)
overridevirtual

This method implements writing a mesh to a specified file.

Note that writes may be buffered for efficiency, and so may not reach disk until after the file has been closed, which happens when the ExodusII_IO object is destructed.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 2150 of file exodusII_io.C.

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

Referenced by main(), libMesh::ErrorVector::plot_error(), ExodusTest< elem_type >::test_write(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), and libMesh::NameBasedIO::write().

2151 {
2152  LOG_SCOPE("write()", "ExodusII_IO");
2153 
2155 
2156  // We may need to gather a DistributedMesh to output it, making that
2157  // const qualifier in our constructor a dirty lie
2158  // The "true" specifies that we only need the mesh serialized to processor 0
2160 
2161  libmesh_assert( !exio_helper->opened_for_writing );
2162 
2163  // If the user has set the append flag here, it doesn't really make
2164  // sense: the intent of this function is to write a Mesh with no
2165  // data, while "appending" is really intended to add data to an
2166  // existing file. If we're verbose, print a message to this effect.
2167  if (_append && _verbose)
2168  libmesh_warning("Warning: Appending in ExodusII_IO::write() does not make sense.\n"
2169  "Creating a new file instead!");
2170 
2171  exio_helper->create(fname);
2172  exio_helper->initialize(fname,mesh);
2173  exio_helper->write_nodal_coordinates(mesh);
2174  exio_helper->write_elements(mesh);
2175  exio_helper->write_sidesets(mesh);
2176  exio_helper->write_nodesets(mesh);
2177  exio_helper->write_elemsets(mesh);
2178 
2179  if ((mesh.get_boundary_info().n_edge_conds() > 0) && _verbose)
2180  libmesh_warning("Warning: Mesh contains edge boundary IDs, but these "
2181  "are not supported by the ExodusII format.");
2182 }
const MT & mesh() const
Definition: mesh_output.h:259
std::size_t n_edge_conds() const
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
This is the MeshBase class.
Definition: mesh_base.h:74
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:56
bool _verbose
should we be verbose?
Definition: exodusII_io.h:612
bool _append
Default false.
Definition: exodusII_io.h:618
libmesh_assert(ctx)
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.

◆ write_added_sides()

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

By default, we only write out the elements physically stored in the mesh.

If we have any SIDE_DISCONTINUOUS variables, however, we cannot easily output them on elements with sides that share vertices (and in 3D, edges). We can set this flag to instead create extra "side elements" on which to visualize such variables.

By default this flag is set to false.

Definition at line 983 of file exodusII_io.C.

References exio_helper.

984 {
985  exio_helper->set_add_sides(val);
986 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ write_as_dimension()

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

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

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

Definition at line 961 of file exodusII_io.C.

References dim, and exio_helper.

962 {
963  exio_helper->write_as_dimension(dim);
964 }
unsigned int dim
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ write_complex_magnitude()

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

Set the flag indicating whether the complex modulus should be written when complex numbers are enabled.

By default this flag is set to true.

Definition at line 947 of file exodusII_io.C.

References _write_complex_abs.

948 {
949  _write_complex_abs = val;
950 }
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
Definition: exodusII_io.h:653

◆ write_discontinuous_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = nullptr 
)
virtualinherited

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

Definition at line 89 of file mesh_output.C.

References libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.

Referenced by write_timestep_discontinuous().

92 {
93  LOG_SCOPE("write_discontinuous_equation_systems()", "MeshOutput");
94 
95  // We may need to gather and/or renumber a DistributedMesh to output
96  // it, making that const qualifier in our constructor a dirty lie
97  MT & my_mesh = const_cast<MT &>(*_obj);
98 
99  // If we're asked to write data that's associated with a different
100  // mesh, output files full of garbage are the result.
101  libmesh_assert_equal_to(&es.get_mesh(), _obj);
102 
103  // A non-renumbered mesh may not have a contiguous numbering, and
104  // that needs to be fixed before we can build a solution vector.
105  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
106  my_mesh.max_node_id() != my_mesh.n_nodes())
107  {
108  // If we were allowed to renumber then we should have already
109  // been properly renumbered...
110  libmesh_assert(!my_mesh.allow_renumbering());
111 
112  libmesh_do_once(libMesh::out <<
113  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
114  << std::endl;);
115 
116  my_mesh.allow_renumbering(true);
117 
118  my_mesh.renumber_nodes_and_elements();
119 
120  // Not sure what good going back to false will do here, the
121  // renumbering horses have already left the barn...
122  my_mesh.allow_renumbering(false);
123  }
124 
125  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
126 
127  // Build the list of variable names that will be written.
128  std::vector<std::string> names;
129  es.build_variable_names (names, nullptr, system_names);
130 
131  if (!_is_parallel_format)
132  {
133  // Build the nodal solution values & get the variable
134  // names from the EquationSystems object
135  std::vector<Number> soln;
136  es.build_discontinuous_solution_vector (soln, system_names,
137  nullptr, false, /* defaults */
138  this->get_add_sides());
139 
140  this->write_nodal_data_discontinuous (fname, soln, names);
141  }
142  else // _is_parallel_format
143  {
144  libmesh_not_implemented();
145  }
146 }
virtual void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with discontinuous data to a specified file where the nodal dat...
Definition: mesh_output.h:118
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:202
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:184
libmesh_assert(ctx)
OStreamProxy out
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero...
Definition: mesh_output.h:193

◆ write_discontinuous_exodusII()

void libMesh::ExodusII_IO::write_discontinuous_exodusII ( const std::string &  name,
const EquationSystems es,
const std::set< std::string > *  system_names = nullptr 
)

Writes a exodusII file with discontinuous data.

Definition at line 172 of file exodusII_io.C.

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

Referenced by main().

175 {
176  std::vector<std::string> solution_names;
177  std::vector<Number> v;
178 
179  es.build_variable_names (solution_names, nullptr, system_names);
180  es.build_discontinuous_solution_vector (v, system_names,
181  nullptr, false, /* defaults */
182  this->get_add_sides());
183  this->write_nodal_data_discontinuous(name, v, solution_names);
184 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
void build_variable_names(std::vector< std::string > &var_names, const FEType *type=nullptr, const std::set< std::string > *system_names=nullptr) const
Fill the input vector var_names with the names of the variables for each system.
void build_discontinuous_solution_vector(std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr, const std::vector< std::string > *var_names=nullptr, bool vertices_only=false, bool add_sides=false) const
Fill the input vector soln with solution values.
virtual bool get_add_sides() override
Definition: exodusII_io.C:990
void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
Write out a discontinuous nodal solution.
Definition: exodusII_io.C:2186

◆ write_element_data()

void libMesh::ExodusII_IO::write_element_data ( const EquationSystems es)

Write out element solution.

Definition at line 1337 of file exodusII_io.C.

References _output_variables, _timestep, _write_complex_abs, libMesh::EquationSystems::build_elemental_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::CONSTANT, exio_helper, libMesh::EquationSystems::get_vars_active_subdomains(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MONOMIAL, libMesh::MONOMIAL_VEC, and libMesh::ParallelObject::processor_id().

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

1338 {
1339  LOG_SCOPE("write_element_data()", "ExodusII_IO");
1340 
1341  // Be sure the file has been opened for writing!
1342  libmesh_error_msg_if(MeshOutput<MeshBase>::mesh().processor_id() == 0 && !exio_helper->opened_for_writing,
1343  "ERROR, ExodusII file must be initialized before outputting element variables.");
1344 
1345  // This function currently only works on serialized meshes. We rely
1346  // on having a reference to a non-const MeshBase object from our
1347  // MeshInput parent class to construct a MeshSerializer object,
1348  // similar to what is done in ExodusII_IO::write(). Note that
1349  // calling ExodusII_IO::write_timestep() followed by
1350  // ExodusII_IO::write_element_data() when the underlying Mesh is a
1351  // DistributedMesh will result in an unnecessary additional
1352  // serialization/re-parallelization step.
1353  // The "true" specifies that we only need the mesh serialized to processor 0
1355 
1356  // To be (possibly) filled with a filtered list of variable names to output.
1357  std::vector<std::string> names;
1358 
1359  // If _output_variables is populated, only output the monomials which are
1360  // also in the _output_variables vector.
1361  if (_output_variables.size() > 0)
1362  {
1363  // Create a list of CONSTANT MONOMIAL variable names
1364  std::vector<std::string> monomials;
1365  FEType type(CONSTANT, MONOMIAL);
1366  es.build_variable_names(monomials, &type);
1367 
1368  // Now concatenate a list of CONSTANT MONOMIAL_VEC variable names
1369  type = FEType(CONSTANT, MONOMIAL_VEC);
1370  es.build_variable_names(monomials, &type);
1371 
1372  // Filter that list against the _output_variables list. Note: if names is still empty after
1373  // all this filtering, all the monomial variables will be gathered
1374  for (const auto & var : monomials)
1375  if (std::find(_output_variables.begin(), _output_variables.end(), var) != _output_variables.end())
1376  names.push_back(var);
1377  }
1378 
1379  // If we pass in a list of names to "build_elemental_solution_vector()"
1380  // it'll filter the variables coming back.
1381  std::vector<Number> soln;
1382  es.build_elemental_solution_vector(soln, names);
1383 
1384  // Also, store the list of subdomains on which each variable is active
1385  std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1386  es.get_vars_active_subdomains(names, vars_active_subdomains);
1387 
1388  if (soln.empty()) // If there is nothing to write just return
1389  return;
1390 
1391  // The data must ultimately be written block by block. This means that this data
1392  // must be sorted appropriately.
1393  if (MeshOutput<MeshBase>::mesh().processor_id())
1394  return;
1395 
1397 
1398 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1399 
1400  std::vector<std::string> complex_names =
1401  exio_helper->get_complex_names(names, _write_complex_abs);
1402 
1403  std::vector<std::set<subdomain_id_type>>
1404  complex_vars_active_subdomains =
1405  exio_helper->get_complex_vars_active_subdomains(vars_active_subdomains,
1407  exio_helper->initialize_element_variables(complex_names, complex_vars_active_subdomains);
1408 
1409  const std::vector<Real> complex_soln =
1410  complex_soln_components(soln, names.size(), _write_complex_abs);
1411 
1412  exio_helper->write_element_values(mesh, complex_soln, _timestep, complex_vars_active_subdomains);
1413 
1414 #else
1415  exio_helper->initialize_element_variables(names, vars_active_subdomains);
1416  exio_helper->write_element_values(mesh, soln, _timestep, vars_active_subdomains);
1417 #endif
1418 }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:182
const MT & mesh() const
Definition: mesh_output.h:259
void build_variable_names(std::vector< std::string > &var_names, const FEType *type=nullptr, const std::set< std::string > *system_names=nullptr) const
Fill the input vector var_names with the names of the variables for each system.
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
This is the MeshBase class.
Definition: mesh_base.h:74
void get_vars_active_subdomains(const std::vector< std::string > &names, std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) const
Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names...
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:607
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:56
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:632
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
Definition: exodusII_io.h:653
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
processor_id_type processor_id() const
void build_elemental_solution_vector(std::vector< Number > &soln, std::vector< std::string > &names) const
Retrieve the solution data for CONSTANT MONOMIALs and/or components of CONSTANT MONOMIAL_VECs.

◆ write_element_data_from_discontinuous_nodal_data()

void libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data ( const EquationSystems es,
const std::set< std::string > *  system_names = nullptr,
const std::string &  var_suffix = "_elem_node_" 
)

Similar to the function above, but instead of only handling (CONSTANT, MONOMIAL) data, writes out a general discontinuous solution field, e.g.

(FIRST, L2_LAGRANGE) or (SECOND, MONOMIAL) as a number of elemental fields equal to the number of vertices in each element. For example, if you have a (FIRST, L2_LAGRANGE) variable "u" defined on HEX8 elements, calling this function would by default write 8 elemental fields named u_elem_node_0, u_elem_node_1, u_elem_node_2, etc.

This may be useful if you have a viz tool which is capable of interpreting this element data as a discontinuous solution field. Note that (CONSTANT, MONOMIAL) data is still written as a single value per element, as it makes no sense to write n_vertices copies of the same value.

The 'var_suffix' parameter, which defaults to "_elem_node_", is used to generate the elemental variable names, and is inserted between the base variable name and the node id which the variable applies to, e.g. "u_elem_node_0", "u_elem_node_1", etc.

Definition at line 1424 of file exodusII_io.C.

References std::abs(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::CONSTANT, distance(), libMesh::EquationSystems::get_vars_active_subdomains(), libMesh::index_range(), libMesh::MeshOutput< MT >::mesh(), mesh, libMesh::MONOMIAL, and libMesh::Quality::name().

Referenced by MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData().

1427 {
1428  LOG_SCOPE("write_element_data_from_discontinuous_nodal_data()", "ExodusII_IO");
1429 
1430  // Be sure that some other function has already opened the file and prepared it
1431  // for writing. This is the same behavior as the write_element_data() function
1432  // which we are trying to mimic.
1433  libmesh_error_msg_if(MeshOutput<MeshBase>::mesh().processor_id() == 0 && !exio_helper->opened_for_writing,
1434  "ERROR, ExodusII file must be initialized before outputting element variables.");
1435 
1436  // This function currently only works on serialized meshes. The
1437  // "true" flag specifies that we only need the mesh serialized to
1438  // processor 0
1441  true);
1442 
1443  // Note: in general we want to respect the contents of
1444  // _output_variables, only building a solution vector with values
1445  // from the requested variables. First build a list of all variable
1446  // names, then throw out ones that aren't in _output_variables, if
1447  // any.
1448  std::vector<std::string> var_names;
1449  es.build_variable_names (var_names, /*fetype=*/nullptr, system_names);
1450 
1451  // Get a subset of all variable names that are CONSTANT,
1452  // MONOMIALs. We treat those slightly differently since they can
1453  // truly only have a single value per Elem.
1454  //
1455  // Should the same apply here for CONSTANT MONOMIAL_VECs? [CW]
1456  // That is, get rid of 'const' on 'fe_type' and rerun:
1457  // fe_type = FEType(CONSTANT, MONOMIAL_VEC);
1458  // es.build_variable_names(monomial_var_names, &fe_type);
1459  // Then, es.find_variable_numbers() can be used without a type
1460  // (since we know for sure they're monomials) like:
1461  // var_nums = es.find_variable_numbers(monomial_var_names)
1462  // for which the DOF indices for 'var_nums' have to be resolved
1463  // manually like in build_elemental_solution_vector()
1464  std::vector<std::string> monomial_var_names;
1465  const FEType fe_type(CONSTANT, MONOMIAL);
1466  es.build_variable_names(monomial_var_names, &fe_type);
1467 
1468  // Remove all names from var_names that are not in _output_variables.
1469  // Note: This approach avoids errors when the user provides invalid
1470  // variable names in _output_variables, as the code will not try to
1471  // write a variable that doesn't exist.
1472  if (!_output_variables.empty())
1473  {
1474  var_names.erase
1475  (std::remove_if
1476  (var_names.begin(),
1477  var_names.end(),
1478  [this](const std::string & name)
1479  {return !std::count(_output_variables.begin(),
1480  _output_variables.end(),
1481  name);}),
1482  var_names.end());
1483 
1484  // Also filter the monomial variable names.
1485  monomial_var_names.erase
1486  (std::remove_if
1487  (monomial_var_names.begin(),
1488  monomial_var_names.end(),
1489  [this](const std::string & name)
1490  {return !std::count(_output_variables.begin(),
1491  _output_variables.end(),
1492  name);}),
1493  monomial_var_names.end());
1494  }
1495 
1496  // Build a solution vector, limiting the results to the variables in
1497  // var_names and the Systems in system_names, and only computing values
1498  // at the vertices.
1499  std::vector<Number> v;
1501  (v, system_names, &var_names, /*vertices_only=*/true);
1502 
1503  // Get active subdomains for each variable in var_names.
1504  std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1505  es.get_vars_active_subdomains(var_names, vars_active_subdomains);
1506 
1507  // Determine names of variables to write based on the number of
1508  // nodes/vertices the elements in different subdomains have.
1510  std::map<subdomain_id_type, unsigned int> subdomain_id_to_vertices_per_elem;
1511  for (const auto & elem : mesh.active_element_ptr_range())
1512  {
1513  // Try to insert key/value pair into the map. If this returns
1514  // false, check the returned iterator's value to make sure it
1515  // matches. It shouldn't actually be possible for this to fail
1516  // (since if the Mesh was like this it would have already
1517  // failed) but it doesn't hurt to be on the safe side.
1518  auto pr2 = subdomain_id_to_vertices_per_elem.emplace
1519  (elem->subdomain_id(), elem->n_vertices());
1520  libmesh_error_msg_if(!pr2.second && pr2.first->second != elem->n_vertices(),
1521  "Elem with different number of vertices found.");
1522  }
1523 
1524  // Determine "derived" variable names. These names are created by
1525  // starting with the base variable name and appending the user's
1526  // variable_suffix (default: "_elem_node_") followed by a node id.
1527  //
1528  // Not every derived variable will be active on every subdomain,
1529  // even if the original variable _is_ active. Subdomains can have
1530  // different geometric element types (with differing numbers of
1531  // nodes), so some of the derived variable names will be inactive on
1532  // those subdomains.
1533  //
1534  // Since we would otherwise generate the same name once per
1535  // subdomain, we keep the list of names unique as we are creating
1536  // it. We can't use a std::set for this because we don't want the
1537  // variables names to be in a different order from the order
1538  // they were written in the call to: build_discontinuous_solution_vector()
1539  //
1540  // The list of derived variable names includes one for each vertex,
1541  // for higher-order elements we currently only write out vertex
1542  // values, but this could be changed in the future without too much
1543  // trouble.
1544  std::vector<std::string> derived_var_names;
1545 
1546  // Keep track of mapping from derived_name to (orig_name, node_id)
1547  // pair. We will use this later to determine whether a given
1548  // variable is active on a given subdomain.
1549  std::map<std::string, std::pair<std::string, unsigned int>>
1550  derived_name_to_orig_name_and_node_id;
1551 
1552  for (const auto & pr : subdomain_id_to_vertices_per_elem)
1553  {
1554  const subdomain_id_type sbd_id = pr.first;
1555  const unsigned int vertices_per_elem =
1556  subdomain_id_to_vertices_per_elem[sbd_id];
1557 
1558  std::ostringstream oss;
1559  for (unsigned int n=0; n<vertices_per_elem; ++n)
1560  for (const auto & orig_var_name : var_names)
1561  {
1562  oss.str("");
1563  oss.clear();
1564  oss << orig_var_name << var_suffix << n;
1565  std::string derived_name = oss.str();
1566 
1567  // Only add this var name if it's not already in the list.
1568  if (!std::count(derived_var_names.begin(), derived_var_names.end(), derived_name))
1569  {
1570  derived_var_names.push_back(derived_name);
1571  // Add entry for derived_name -> (orig_name, node_id) mapping.
1572  derived_name_to_orig_name_and_node_id[derived_name] =
1573  std::make_pair(orig_var_name, n);
1574  }
1575  }
1576  }
1577 
1578  // For each derived variable name, determine whether it is active
1579  // based on how many nodes/vertices the elements in a given subdomain have,
1580  // and whether they were active on the subdomain to begin with.
1581  std::vector<std::set<subdomain_id_type>>
1582  derived_vars_active_subdomains(derived_var_names.size());
1583 
1584  // A new data structure for keeping track of a list of variable names
1585  // that are in the discontinuous solution vector on each subdomain. Used
1586  // for indexing. Note: if a variable was inactive at the System level,
1587  // an entry for it will still be in the discontinuous solution vector,
1588  // but it will just have a value of zero. On the other hand, when we
1589  // create the derived variable names some of them are "inactive" on
1590  // different subdomains in the sense that they don't exist at all, i.e.
1591  // there is no zero padding for them. We need to be able to distinguish
1592  // between these two types in order to do the indexing into this vector
1593  // correctly.
1594  std::map<subdomain_id_type, std::vector<std::string>>
1595  subdomain_to_var_names;
1596 
1597  for (auto derived_var_id : index_range(derived_var_names))
1598  {
1599  const auto & derived_name = derived_var_names[derived_var_id];
1600  const auto & [orig_name, node_id] =
1601  libmesh_map_find (derived_name_to_orig_name_and_node_id,
1602  derived_name);
1603 
1604  // For each subdomain, determine whether the current variable
1605  // should be active on that subdomain.
1606  for (const auto & pr : subdomain_id_to_vertices_per_elem)
1607  {
1608  // Convenience variables for the current subdomain and the
1609  // number of nodes elements in this subdomain have.
1610  subdomain_id_type sbd_id = pr.first;
1611  unsigned int vertices_per_elem_this_sbd =
1612  subdomain_id_to_vertices_per_elem[sbd_id];
1613 
1614  // Check whether variable orig_name was active on this
1615  // subdomain to begin with by looking in the
1616  // vars_active_subdomains container. We assume that the
1617  // location of orig_name in the var_names vector matches its
1618  // index in the vars_active_subdomains container.
1619  auto var_loc = std::find(var_names.begin(), var_names.end(), orig_name);
1620  libmesh_error_msg_if(var_loc == var_names.end(),
1621  "Variable " << orig_name << " somehow not found in var_names array.");
1622  auto var_id = std::distance(var_names.begin(), var_loc);
1623 
1624  // The derived_var will only be active if this subdomain has
1625  // enough vertices for that to be the case.
1626  if (node_id < vertices_per_elem_this_sbd)
1627  {
1628  // Regardless of whether the original variable was not active on this subdomain,
1629  // the discontinuous solution vector will have zero padding for it, and
1630  // we will need to account for it. Therefore it should still be added to
1631  // the subdomain_to_var_names data structure!
1632  subdomain_to_var_names[sbd_id].push_back(derived_name);
1633 
1634  // If the original variable was not active on the
1635  // current subdomain, it should not be added to the
1636  // derived_vars_active_subdomains data structure, since
1637  // it will not be written to the Exodus file.
1638 
1639  // Determine if the original variable was active on the
1640  // current subdomain.
1641  bool orig_var_active =
1642  (vars_active_subdomains[var_id].empty() ||
1643  vars_active_subdomains[var_id].count(sbd_id));
1644 
1645  // And only if it was, add it to the
1646  // derived_vars_active_subdomains data structure.
1647  if (orig_var_active)
1648  derived_vars_active_subdomains[derived_var_id].insert(sbd_id);
1649  }
1650  } // end loop over subdomain_id_to_vertices_per_elem
1651  } // end loop over derived_var_names
1652 
1653  // At this point we've built the "true" list of derived names, but
1654  // if there are any CONSTANT MONOMIALS in this list, we now want to
1655  // remove all but one copy of them from the derived_var_names list,
1656  // and rename them in (but not remove them from) the
1657  // subdomain_to_var_names list, and then update the
1658  // derived_vars_active_subdomains containers before finally calling
1659  // the Exodus helper functions.
1660  for (auto & derived_var_name : derived_var_names)
1661  {
1662  // Get the original name associated with this derived name.
1663  const auto & name_and_id =
1664  libmesh_map_find (derived_name_to_orig_name_and_node_id,
1665  derived_var_name);
1666 
1667  // Convenience variables for the map entry's contents.
1668  const std::string & orig_name = name_and_id.first;
1669 
1670  // Was the original name a constant monomial?
1671  if (std::count(monomial_var_names.begin(),
1672  monomial_var_names.end(),
1673  orig_name))
1674  {
1675  // Rename this variable in the subdomain_to_var_names vectors.
1676  for (auto & pr : subdomain_to_var_names)
1677  {
1678  // Reference to ordered list of variable names on this subdomain.
1679  auto & name_vec = pr.second;
1680 
1681  auto name_vec_it =
1682  std::find(name_vec.begin(),
1683  name_vec.end(),
1684  derived_var_name);
1685 
1686  if (name_vec_it != name_vec.end())
1687  {
1688  // Actually rename it back to the orig_name, dropping
1689  // the "_elem_corner_" stuff.
1690  *name_vec_it = orig_name;
1691  }
1692  }
1693 
1694  // Finally, rename the variable in the derived_var_names vector itself.
1695  derived_var_name = orig_name;
1696  } // if (monomial)
1697  } // end loop over derived names
1698 
1699  // Now remove duplicate entries from derived_var_names after the first.
1700  // Also update the derived_vars_active_subdomains container in a consistent way.
1701  {
1702  std::vector<std::string> derived_var_names_edited;
1703  std::vector<std::set<subdomain_id_type>> derived_vars_active_subdomains_edited;
1704  std::vector<unsigned int> found_first(monomial_var_names.size());
1705 
1706  for (auto i : index_range(derived_var_names))
1707  {
1708  const auto & derived_var_name = derived_var_names[i];
1709  const auto & active_set = derived_vars_active_subdomains[i];
1710 
1711  // Determine whether we will keep this derived variable name in
1712  // the final container.
1713  bool keep = true;
1714  for (auto j : index_range(monomial_var_names))
1715  if (derived_var_name == monomial_var_names[j])
1716  {
1717  if (!found_first[j])
1718  found_first[j] = 1;
1719 
1720  else
1721  keep = false;
1722  }
1723 
1724  // We also don't keep variables that are not active on any subdomains.
1725  // Contrary to other uses of the var_active_subdomains container where
1726  // the empty set means "all" subdomains, here it really means "none".
1727  if (active_set.empty())
1728  keep = false;
1729 
1730  if (keep)
1731  {
1732  derived_var_names_edited.push_back(derived_var_name);
1733  derived_vars_active_subdomains_edited.push_back(active_set);
1734  }
1735  }
1736 
1737  // We built the filtered ranges, now swap them with the originals.
1738  derived_var_names.swap(derived_var_names_edited);
1739  derived_vars_active_subdomains.swap(derived_vars_active_subdomains_edited);
1740  }
1741 
1742 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1743  // Build complex variable names "r_foo", "i_foo", "a_foo" and the lists of
1744  // subdomains on which they are active.
1745  auto complex_var_names =
1746  exio_helper->get_complex_names(derived_var_names,
1748  auto complex_vars_active_subdomains =
1749  exio_helper->get_complex_vars_active_subdomains(derived_vars_active_subdomains,
1751  auto complex_subdomain_to_var_names =
1752  exio_helper->get_complex_subdomain_to_var_names(subdomain_to_var_names,
1754 
1755  // Make expanded version of vector "v" in which each entry in the
1756  // original expands to an ("r_", "i_", "a_") triple.
1757  // "nco" is the number of complex outputs, which depends on whether
1758  // or not we are writing out the complex magnitudes.
1759  std::vector<Real> complex_v;
1760  int nco = _write_complex_abs ? 3 : 2;
1761  complex_v.reserve(nco * v.size());
1762  for (const auto & val : v)
1763  {
1764  complex_v.push_back(val.real());
1765  complex_v.push_back(val.imag());
1766  if (_write_complex_abs)
1767  complex_v.push_back(std::abs(val));
1768  }
1769 
1770  // Finally, initialize storage for the variables and write them to file.
1771  exio_helper->initialize_element_variables
1772  (complex_var_names, complex_vars_active_subdomains);
1773  exio_helper->write_element_values_element_major
1774  (mesh, complex_v, _timestep,
1775  complex_vars_active_subdomains,
1776  complex_var_names,
1777  complex_subdomain_to_var_names);
1778 #else
1779 
1780  // Call function which writes the derived variable names to the
1781  // Exodus file.
1782  exio_helper->initialize_element_variables(derived_var_names, derived_vars_active_subdomains);
1783 
1784  // ES::build_discontinuous_solution_vector() creates a vector with
1785  // an element-major ordering, so call Helper::write_element_values()
1786  // passing false for the last argument.
1787  exio_helper->write_element_values_element_major
1788  (mesh, v, _timestep,
1789  derived_vars_active_subdomains,
1790  derived_var_names,
1791  subdomain_to_var_names);
1792 #endif
1793 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:182
const MT & mesh() const
Definition: mesh_output.h:259
void build_variable_names(std::vector< std::string > &var_names, const FEType *type=nullptr, const std::set< std::string > *system_names=nullptr) const
Fill the input vector var_names with the names of the variables for each system.
void build_discontinuous_solution_vector(std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr, const std::vector< std::string > *var_names=nullptr, bool vertices_only=false, bool add_sides=false) const
Fill the input vector soln with solution values.
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
Real distance(const Point &p)
This is the MeshBase class.
Definition: mesh_base.h:74
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:57
void get_vars_active_subdomains(const std::vector< std::string > &names, std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) const
Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names...
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:607
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:56
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:632
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
Definition: exodusII_io.h:653
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
processor_id_type processor_id() const
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111

◆ write_elemset_data()

void libMesh::ExodusII_IO::write_elemset_data ( int  timestep,
const std::vector< std::string > &  var_names,
const std::vector< std::set< elemset_id_type >> &  elemset_ids_in,
const std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real >> &  elemset_vals 
)

The Exodus format can also store values on elemsets.

The inputs to the function are: .) var_names[i] is the name of the ith elemset variable to be written to file. .) elemset_ids_in[i] is a set of elemset ids where var_names[i] is active. .) elemset_vals[i] is a map from (elem-id, elemset-id) pairs to the corresponding real-valued data.

Note
You must have already written the mesh by calling e.g. write() (and write_elemsets()) before calling this function, because it uses the ordering of the elemsets that have already been written to the Exodus file.

Definition at line 2111 of file exodusII_io.C.

References exio_helper.

2115 {
2116  libmesh_error_msg_if(!exio_helper->opened_for_writing,
2117  "ERROR, ExodusII file must be opened for writing "
2118  "before calling ExodusII_IO::write_elemset_data()!");
2119 
2120  exio_helper->write_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2121 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ write_elemsets()

void libMesh::ExodusII_IO::write_elemsets ( )

Write elemsets stored on the Mesh to file.

Note
An elemset is a concept which is related to (but distinct from) both elem blocks and sidesets/nodesets. Elements in an elemset can be from multiple different blocks. In addition, one can define an elemset variable, which is like an elemental variable but exists only on the elements defined in the set.

Definition at line 2011 of file exodusII_io.C.

References exio_helper, libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshOutput< MT >::mesh().

2012 {
2013  libmesh_error_msg_if(!exio_helper->opened_for_writing,
2014  "ERROR, ExodusII file must be opened for writing "
2015  "before calling ExodusII_IO::write_elemsets()!");
2016 
2018  exio_helper->write_elemsets(mesh);
2019 }
const MT & mesh() const
Definition: mesh_output.h:259
This is the MeshBase class.
Definition: mesh_base.h:74
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ write_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = nullptr 
)
virtualinherited

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

Reimplemented in libMesh::NameBasedIO.

Definition at line 31 of file mesh_output.C.

References libMesh::EquationSystems::build_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.

Referenced by libMesh::Nemesis_IO::write_timestep(), and write_timestep().

34 {
35  LOG_SCOPE("write_equation_systems()", "MeshOutput");
36 
37  // We may need to gather and/or renumber a DistributedMesh to output
38  // it, making that const qualifier in our constructor a dirty lie
39  MT & my_mesh = const_cast<MT &>(*_obj);
40 
41  // If we're asked to write data that's associated with a different
42  // mesh, output files full of garbage are the result.
43  libmesh_assert_equal_to(&es.get_mesh(), _obj);
44 
45  // A non-parallel format, non-renumbered mesh may not have a contiguous
46  // numbering, and that needs to be fixed before we can build a solution vector.
47  if (!_is_parallel_format &&
48  (my_mesh.max_elem_id() != my_mesh.n_elem() ||
49  my_mesh.max_node_id() != my_mesh.n_nodes()))
50  {
51  // If we were allowed to renumber then we should have already
52  // been properly renumbered...
53  libmesh_assert(!my_mesh.allow_renumbering());
54 
55  libmesh_do_once(libMesh::out <<
56  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
57  << std::endl;);
58 
59  my_mesh.allow_renumbering(true);
60 
61  my_mesh.renumber_nodes_and_elements();
62 
63  // Not sure what good going back to false will do here, the
64  // renumbering horses have already left the barn...
65  my_mesh.allow_renumbering(false);
66  }
67 
69  {
70  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
71 
72  // Build the list of variable names that will be written.
73  std::vector<std::string> names;
74  es.build_variable_names (names, nullptr, system_names);
75 
76  // Build the nodal solution values & get the variable
77  // names from the EquationSystems object
78  std::vector<Number> soln;
79  es.build_solution_vector (soln, system_names,
80  this->get_add_sides());
81 
82  this->write_nodal_data (fname, soln, names);
83  }
84  else // _is_parallel_format
85  this->write_nodal_data (fname, es, system_names);
86 }
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: mesh_output.h:109
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:202
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:184
libmesh_assert(ctx)
OStreamProxy out
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero...
Definition: mesh_output.h:193

◆ write_global_data()

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

Write out global variables.

Definition at line 1963 of file exodusII_io.C.

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

1965 {
1966  LOG_SCOPE("write_global_data()", "ExodusII_IO");
1967 
1969  return;
1970 
1971  libmesh_error_msg_if(!exio_helper->opened_for_writing,
1972  "ERROR, ExodusII file must be initialized before outputting global variables.");
1973 
1974 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1975 
1976  std::vector<std::string> complex_names =
1977  exio_helper->get_complex_names(names,
1979 
1980  exio_helper->initialize_global_variables(complex_names);
1981 
1982  const std::vector<Real> complex_soln =
1983  complex_soln_components(soln, names.size(), _write_complex_abs);
1984 
1985  exio_helper->write_global_values(complex_soln, _timestep);
1986 
1987 #else
1988  exio_helper->initialize_global_variables(names);
1989  exio_helper->write_global_values(soln, _timestep);
1990 #endif
1991 }
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:607
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
Definition: exodusII_io.h:653
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
processor_id_type processor_id() const

◆ write_information_records()

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

Write out information records.

Definition at line 1950 of file exodusII_io.C.

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

1951 {
1953  return;
1954 
1955  libmesh_error_msg_if(!exio_helper->opened_for_writing,
1956  "ERROR, ExodusII file must be initialized before outputting information records.");
1957 
1958  exio_helper->write_information_records(records);
1959 }
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
processor_id_type processor_id() const

◆ write_nodal_data() [1/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const NumericVector< Number > &  parallel_soln,
const std::vector< std::string > &  names 
)
virtualinherited

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

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

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

Reimplemented in libMesh::Nemesis_IO.

Definition at line 149 of file mesh_output.C.

References libMesh::NumericVector< T >::localize().

152 {
153  // This is the fallback implementation for parallel I/O formats that
154  // do not yet implement proper writing in parallel, and instead rely
155  // on the full solution vector being available on all processors.
156  std::vector<Number> soln;
157  parallel_soln.localize(soln);
158  this->write_nodal_data(fname, soln, names);
159 }
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: mesh_output.h:109
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ write_nodal_data() [2/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names 
)
virtualinherited

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

Instead of getting a localized copy of the nodal solution vector, it directly uses EquationSystems current_local_solution vectors to look up nodal values.

If not implemented, reorders the solutions into a nodal-only NumericVector and calls the above version of this function.

Reimplemented in libMesh::Nemesis_IO.

Definition at line 162 of file mesh_output.C.

References libMesh::EquationSystems::build_parallel_solution_vector(), and libMesh::EquationSystems::build_variable_names().

165 {
166  std::vector<std::string> names;
167  es.build_variable_names (names, nullptr, system_names);
168 
169  std::unique_ptr<NumericVector<Number>> parallel_soln =
170  es.build_parallel_solution_vector(system_names);
171 
172  this->write_nodal_data (fname, *parallel_soln, names);
173 }
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: mesh_output.h:109

◆ write_nodal_data() [3/3]

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

Write out a nodal solution.

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 1797 of file exodusII_io.C.

References _allow_empty_variables, _output_variables, _timestep, _write_complex_abs, std::abs(), exio_helper, libMesh::MeshTools::Generation::Private::idx(), std::imag(), libMesh::index_range(), libMesh::libmesh_ignore(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), std::real(), libMesh::EquationSystems::redundant_added_side(), and write_nodal_data_common().

Referenced by libMesh::NameBasedIO::write_nodal_data().

1800 {
1801  LOG_SCOPE("write_nodal_data()", "ExodusII_IO");
1802 
1804 
1805  int num_vars = cast_int<int>(names.size());
1806  dof_id_type num_nodes = mesh.n_nodes();
1807 
1808  // The names of the variables to be output
1809  std::vector<std::string> output_names;
1810 
1811  if (_allow_empty_variables || !_output_variables.empty())
1812  output_names = _output_variables;
1813  else
1814  output_names = names;
1815 
1816 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
1817  std::vector<std::string> complex_names =
1818  exio_helper->get_complex_names(output_names,
1820 
1821  // Call helper function for opening/initializing data, giving it the
1822  // complex variable names
1823  this->write_nodal_data_common(fname, complex_names, /*continuous=*/true);
1824 #else
1825  // Call helper function for opening/initializing data
1826  this->write_nodal_data_common(fname, output_names, /*continuous=*/true);
1827 #endif
1828 
1829  if (mesh.processor_id())
1830  return;
1831 
1832  // This will count the number of variables actually output
1833  for (int c=0; c<num_vars; c++)
1834  {
1835  std::stringstream name_to_find;
1836 
1837  std::vector<std::string>::iterator pos =
1838  std::find(output_names.begin(), output_names.end(), names[c]);
1839  if (pos == output_names.end())
1840  continue;
1841 
1842  unsigned int variable_name_position =
1843  cast_int<unsigned int>(pos - output_names.begin());
1844 
1845  // Set up temporary vectors to be passed to Exodus to write the
1846  // nodal values for a single variable at a time.
1847 #ifdef LIBMESH_USE_REAL_NUMBERS
1848  std::vector<Number> cur_soln;
1849 
1850  // num_nodes is either exactly how much space we will need for
1851  // each vector, or a safe upper bound for the amount of memory
1852  // we will require when there are gaps in the numbering.
1853  cur_soln.reserve(num_nodes);
1854 #else
1855  std::vector<Real> real_parts;
1856  std::vector<Real> imag_parts;
1857  std::vector<Real> magnitudes;
1858  real_parts.reserve(num_nodes);
1859  imag_parts.reserve(num_nodes);
1860  if (_write_complex_abs)
1861  magnitudes.reserve(num_nodes);
1862 #endif
1863 
1864  // There could be gaps in soln based on node numbering, but in
1865  // serial the empty numbers are left empty.
1866  // There could also be offsets in soln based on "fake" nodes
1867  // inserted on each processor (because NumericVector indices
1868  // have to be contiguous); the helper keeps track of those.
1869  // We now copy the proper solution values contiguously into
1870  // "cur_soln", removing the gaps.
1871  for (const auto & node : mesh.node_ptr_range())
1872  {
1873  const dof_id_type idx =
1874  (exio_helper->node_id_to_vec_id(node->id()))
1875  * num_vars + c;
1876 #ifdef LIBMESH_USE_REAL_NUMBERS
1877  cur_soln.push_back(soln[idx]);
1878 #else
1879  real_parts.push_back(soln[idx].real());
1880  imag_parts.push_back(soln[idx].imag());
1881  if (_write_complex_abs)
1882  magnitudes.push_back(std::abs(soln[idx]));
1883 #endif
1884  }
1885 
1886  // If we're adding extra sides, we need to add their data too.
1887  //
1888  // Because soln was created from a parallel NumericVector, its
1889  // numbering was contiguous on each processor; we need to use
1890  // the same offsets here, and we need to loop through elements
1891  // from earlier ranks first.
1892  if (exio_helper->get_add_sides())
1893  {
1894  std::vector<std::vector<const Elem *>>
1895  elems_by_pid(mesh.n_processors());
1896 
1897  for (const auto & elem : mesh.active_element_ptr_range())
1898  elems_by_pid[elem->processor_id()].push_back(elem);
1899 
1900  for (auto p : index_range(elems_by_pid))
1901  {
1902  dof_id_type global_idx =
1903  exio_helper->added_node_offset_on(p) * num_vars + c;
1904  for (const Elem * elem : elems_by_pid[p])
1905  {
1906  for (auto s : elem->side_index_range())
1907  {
1909  continue;
1910 
1911  const std::vector<unsigned int> side_nodes =
1912  elem->nodes_on_side(s);
1913 
1914  for (auto n : index_range(side_nodes))
1915  {
1916  libmesh_ignore(n);
1917  libmesh_assert_less(global_idx, soln.size());
1918 #ifdef LIBMESH_USE_REAL_NUMBERS
1919  cur_soln.push_back(soln[global_idx]);
1920 #else
1921  real_parts.push_back(soln[global_idx].real());
1922  imag_parts.push_back(soln[global_idx].imag());
1923  if (_write_complex_abs)
1924  magnitudes.push_back(std::abs(soln[global_idx]));
1925 #endif
1926  global_idx += num_vars;
1927  }
1928  }
1929  }
1930  }
1931  }
1932 
1933  // Finally, actually call the Exodus API to write to file.
1934 #ifdef LIBMESH_USE_REAL_NUMBERS
1935  exio_helper->write_nodal_values(variable_name_position+1, cur_soln, _timestep);
1936 #else
1937  int nco = _write_complex_abs ? 3 : 2;
1938  exio_helper->write_nodal_values(nco*variable_name_position+1, real_parts, _timestep);
1939  exio_helper->write_nodal_values(nco*variable_name_position+2, imag_parts, _timestep);
1940  if (_write_complex_abs)
1941  exio_helper->write_nodal_values(3*variable_name_position+3, magnitudes, _timestep);
1942 #endif
1943 
1944  }
1945 }
const MT & mesh() const
Definition: mesh_output.h:259
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
This is the MeshBase class.
Definition: mesh_base.h:74
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:57
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:607
processor_id_type n_processors() const
void libmesh_ignore(const Args &...)
std::vector< std::string > _output_variables
The names of the variables to be output.
Definition: exodusII_io.h:632
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_d...
Definition: exodusII_io.C:2264
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
Definition: exodusII_io.h:653
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
bool _allow_empty_variables
Flag which controls the behavior of _output_variables: .) If true, _output_variables is allowed to re...
Definition: exodusII_io.h:642
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
processor_id_type processor_id() const
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
virtual dof_id_type n_nodes() const =0
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:67
static bool redundant_added_side(const Elem &elem, unsigned int side)

◆ write_nodal_data_common()

void libMesh::ExodusII_IO::write_nodal_data_common ( std::string  fname,
const std::vector< std::string > &  names,
bool  continuous = true 
)

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

Definition at line 2264 of file exodusII_io.C.

References _append, exio_helper, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), and libMesh::ParallelObject::processor_id().

Referenced by write_nodal_data(), and write_nodal_data_discontinuous().

2267 {
2269 
2270  // This function can be called multiple times, we only want to open
2271  // the ExodusII file the first time it's called.
2272  if (!exio_helper->opened_for_writing)
2273  {
2274  // If we're appending, open() the file with read_only=false,
2275  // otherwise create() it and write the contents of the mesh to
2276  // it.
2277  if (_append)
2278  {
2279  // We do our writing only from proc 0, to avoid race
2280  // conditions with Exodus 8
2282  {
2283  exio_helper->open(fname.c_str(), /*read_only=*/false);
2284  // If we're appending, it's not valid to call exio_helper->initialize()
2285  // or exio_helper->initialize_nodal_variables(), but we do need to set up
2286  // certain aspects of the Helper object itself, such as the number of nodes
2287  // and elements. We do that by reading the header...
2288  exio_helper->read_and_store_header_info();
2289 
2290  // ...and reading the block info
2291  exio_helper->read_block_info();
2292  }
2293  // Keep other processors aware of what we've done on root
2294  else
2295  {
2296  exio_helper->opened_for_writing = true;
2297  exio_helper->current_filename = fname;
2298  }
2299  }
2300  else
2301  {
2302  exio_helper->create(fname);
2303 
2304  // But some of our write calls are parallel-only, due to
2305  // calls to parallel-only getter functions.
2306  exio_helper->initialize(fname, mesh, !continuous);
2307 
2308  exio_helper->write_nodal_coordinates(mesh, !continuous);
2309  exio_helper->write_elements(mesh, !continuous);
2310 
2311  exio_helper->write_sidesets(mesh);
2312  exio_helper->write_nodesets(mesh);
2313  exio_helper->write_elemsets(mesh);
2314 
2315  exio_helper->initialize_nodal_variables(names);
2316  }
2317  }
2318  else
2319  {
2320  // We are already open for writing, so check that the filename
2321  // passed to this function matches the filename currently in use
2322  // by the helper.
2323  libmesh_error_msg_if(fname != exio_helper->current_filename,
2324  "Error! This ExodusII_IO object is already associated with file: "
2325  << exio_helper->current_filename
2326  << ", cannot use it with requested file: "
2327  << fname);
2328  }
2329 }
const MT & mesh() const
Definition: mesh_output.h:259
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
This is the MeshBase class.
Definition: mesh_base.h:74
bool _append
Default false.
Definition: exodusII_io.h:618
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
processor_id_type processor_id() const

◆ write_nodal_data_discontinuous()

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

Write out a discontinuous nodal solution.

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 2186 of file exodusII_io.C.

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

Referenced by write_discontinuous_exodusII().

2189 {
2190  LOG_SCOPE("write_nodal_data_discontinuous()", "ExodusII_IO");
2191 
2193 
2194 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
2195 
2196  std::vector<std::string> complex_names =
2197  exio_helper->get_complex_names(names,
2199 
2200  // Call helper function for opening/initializing data, giving it the
2201  // complex variable names
2202  this->write_nodal_data_common(fname, complex_names, /*continuous=*/false);
2203 #else
2204  // Call helper function for opening/initializing data
2205  this->write_nodal_data_common(fname, names, /*continuous=*/false);
2206 #endif
2207 
2208  if (mesh.processor_id())
2209  return;
2210 
2211  int num_vars = cast_int<int>(names.size());
2212  libmesh_assert_equal_to(soln.size() % num_vars, 0);
2213  int num_nodes = soln.size() / num_vars;
2214  libmesh_assert_equal_to(exio_helper->num_nodes, num_nodes);
2215 
2216 #ifndef NDEBUG
2217  if (!this->get_add_sides())
2218  {
2219  int num_real_nodes = 0;
2220  for (const auto & elem : mesh.active_element_ptr_range())
2221  num_real_nodes += elem->n_nodes();
2222  libmesh_assert_equal_to(num_real_nodes, num_nodes);
2223  }
2224 #endif
2225 
2226  for (int c=0; c<num_vars; c++)
2227  {
2228 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
2229  std::vector<Real> real_parts(num_nodes);
2230  std::vector<Real> imag_parts(num_nodes);
2231  std::vector<Real> magnitudes;
2232  if (_write_complex_abs)
2233  magnitudes.resize(num_nodes);
2234 
2235  // The number of complex outputs depends on whether or not we are
2236  // writing out the absolute values.
2237  int nco = _write_complex_abs ? 3 : 2;
2238 
2239  for (int i=0; i<num_nodes; ++i)
2240  {
2241  real_parts[i] = soln[i*num_vars + c].real();
2242  imag_parts[i] = soln[i*num_vars + c].imag();
2243  if (_write_complex_abs)
2244  magnitudes[i] = std::abs(soln[i*num_vars + c]);
2245  }
2246  exio_helper->write_nodal_values(nco*c+1, real_parts, _timestep);
2247  exio_helper->write_nodal_values(nco*c+2, imag_parts, _timestep);
2248  if (_write_complex_abs)
2249  exio_helper->write_nodal_values(3*c+3, magnitudes, _timestep);
2250 #else
2251  // Copy out this variable's solution
2252  std::vector<Number> cur_soln(num_nodes);
2253 
2254  for (int i=0; i<num_nodes; i++)
2255  cur_soln[i] = soln[i*num_vars + c];
2256 
2257  exio_helper->write_nodal_values(c+1,cur_soln,_timestep);
2258 #endif
2259  }
2260 }
const MT & mesh() const
Definition: mesh_output.h:259
This is the MeshBase class.
Definition: mesh_base.h:74
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:57
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:607
virtual bool get_add_sides() override
Definition: exodusII_io.C:990
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_d...
Definition: exodusII_io.C:2264
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
Definition: exodusII_io.h:653
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
processor_id_type processor_id() const

◆ write_nodeset_data()

void libMesh::ExodusII_IO::write_nodeset_data ( int  timestep,
const std::vector< std::string > &  var_names,
const std::vector< std::set< boundary_id_type >> &  node_boundary_ids,
const std::vector< std::map< BoundaryInfo::NodeBCTuple, Real >> &  bc_vals 
)

The Exodus format can also store values on nodesets.

This can be thought of as an alternative to defining a nodal variable field on lower-dimensional elements making up a part of the boundary. The inputs to the function are: .) var_names[i] is the name of the ith sideset variable to be written to file. .) node_boundary_ids[i] is a set of node_ids where var_names[i] is active. .) bc_vals[i] is a map from (node-id, boundary-id) NodeBCTuple objects to the corresponding real-valued data.

Note
You must have already written the mesh by calling e.g. write() before calling this function, because it uses the existing ordering of the Exodus nodesets.

Definition at line 2081 of file exodusII_io.C.

References exio_helper.

2085 {
2086  libmesh_error_msg_if(!exio_helper->opened_for_writing,
2087  "ERROR, ExodusII file must be opened for writing "
2088  "before calling ExodusII_IO::write_nodeset_data()!");
2089 
2090  exio_helper->write_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2091 }
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ write_sideset_data()

void libMesh::ExodusII_IO::write_sideset_data ( int  timestep,
const std::vector< std::string > &  var_names,
const std::vector< std::set< boundary_id_type >> &  side_ids,
const std::vector< std::map< BoundaryInfo::BCTuple, Real >> &  bc_vals 
)

The Exodus format can also store values on sidesets.

This can be thought of as an alternative to defining an elemental variable field on lower-dimensional elements making up a part of the boundary. The inputs to the function are: .) var_names[i] is the name of the ith sideset variable to be written to file. .) side_ids[i] is a set of side_ids where var_names[i] is active. .) bc_vals[i] is a map from (elem,side,id) BCTuple objects to the corresponding real-valued data.

Note
You must have already written the mesh by calling e.g. write() before calling this function, because it uses the existing ordering of the Exodus sidesets.

Definition at line 2023 of file exodusII_io.C.

References exio_helper, libMesh::MeshInput< MeshBase >::mesh(), and libMesh::MeshOutput< MT >::mesh().

2027 {
2028  libmesh_error_msg_if(!exio_helper->opened_for_writing,
2029  "ERROR, ExodusII file must be opened for writing "
2030  "before calling ExodusII_IO::write_sideset_data()!");
2031 
2033  exio_helper->write_sideset_data(mesh, timestep, var_names, side_ids, bc_vals);
2034 }
const MT & mesh() const
Definition: mesh_output.h:259
This is the MeshBase class.
Definition: mesh_base.h:74
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601

◆ write_timestep()

void libMesh::ExodusII_IO::write_timestep ( const std::string &  fname,
const EquationSystems es,
const int  timestep,
const Real  time,
const std::set< std::string > *  system_names = nullptr 
)

Writes out the solution at a specific timestep.

Parameters
fnameName of the file to write to
esEquationSystems object which contains the solution vector.
timestepThe timestep to write out, should be 1 indexed.
timeThe current simulation time.
system_namesOptional list of systems to write solutions for.

Definition at line 1995 of file exodusII_io.C.

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

Referenced by main(), and write_output().

2000 {
2001  _timestep = timestep;
2002  write_equation_systems(fname,es,system_names);
2003 
2005  return;
2006 
2007  exio_helper->write_timestep(timestep, time);
2008 }
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition: mesh_output.C:31
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:607
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
processor_id_type processor_id() const

◆ write_timestep_discontinuous()

void libMesh::ExodusII_IO::write_timestep_discontinuous ( const std::string &  fname,
const EquationSystems es,
const int  timestep,
const Real  time,
const std::set< std::string > *  system_names = nullptr 
)

Writes a discontinuous solution at a specific timestep.

Parameters
fnameName of the file to be written
esEquationSystems object which contains the solution vector
timestepThe timestep to write out. (should be 1 indexed)
timeThe current simulation time
system_namesOptional list of systems to write solutions for.

Definition at line 188 of file exodusII_io.C.

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

193 {
194  _timestep = timestep;
195  write_discontinuous_equation_systems (fname,es,system_names);
196 
198  return;
199 
200  exio_helper->write_timestep(timestep, time);
201 }
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
Definition: exodusII_io.h:607
virtual void write_discontinuous_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with discontinuous data to a specified file where the data is t...
Definition: mesh_output.C:89
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
Definition: exodusII_io.h:601
processor_id_type processor_id() const

Member Data Documentation

◆ _allow_empty_variables

bool libMesh::ExodusII_IO::_allow_empty_variables
private

Flag which controls the behavior of _output_variables: .) If true, _output_variables is allowed to remain empty.

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

Definition at line 642 of file exodusII_io.h.

Referenced by set_output_variables(), and write_nodal_data().

◆ _append

bool libMesh::ExodusII_IO::_append
private

Default false.

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

Definition at line 618 of file exodusII_io.h.

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

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _disc_bex

bool libMesh::ExodusII_IO::_disc_bex
private

Set to true (false is the default) to generate independent nodes for every Bezier Extraction element.

Definition at line 659 of file exodusII_io.h.

Referenced by read(), and set_discontinuous_bex().

◆ _extra_integer_vars

std::vector<std::string> libMesh::ExodusII_IO::_extra_integer_vars
private

An optional list of variables in the EXODUS file that are to be used to set extra integers when loading the file into a mesh.

The variable names will be used to name the extra integers.

Definition at line 626 of file exodusII_io.h.

Referenced by read(), and set_extra_integer_vars().

◆ _is_parallel_format

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

Flag specifying whether this format is parallel-capable.

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

Definition at line 184 of file mesh_output.h.

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

◆ _output_variables

std::vector<std::string> libMesh::ExodusII_IO::_output_variables
private

The names of the variables to be output.

If this is empty then all variables are output.

Definition at line 632 of file exodusII_io.h.

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

◆ _serial_only_needed_on_proc_0

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

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

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

Definition at line 193 of file mesh_output.h.

◆ _timestep

int libMesh::ExodusII_IO::_timestep
private

◆ _verbose

bool libMesh::ExodusII_IO::_verbose
private

should we be verbose?

Definition at line 612 of file exodusII_io.h.

Referenced by verbose(), and write().

◆ _write_complex_abs

bool libMesh::ExodusII_IO::_write_complex_abs
private

By default, when complex numbers are enabled, for each variable we write out three values: the real part, "r_u" the imaginary part, "i_u", and the complex modulus, a_u := sqrt(r_u*r_u + i_u*i_u), which is also the value returned by std::abs(std::complex).

Since the modulus is not an independent quantity, we can set this flag to false and save some file space by not writing out.

Definition at line 653 of file exodusII_io.h.

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

◆ elems_of_dimension

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited

◆ exio_helper

std::unique_ptr<ExodusII_IO_Helper> libMesh::ExodusII_IO::exio_helper
private

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