libMesh::ExodusII_IO Class Reference

Handles reading and writing of Exodus binary files. More...

#include <exodusII_io.h>

Inheritance diagram for libMesh::ExodusII_IO:

Public Member Functions

 ExodusII_IO (MeshBase &mesh, bool single_precision=false)
 
virtual ~ExodusII_IO ()
 
virtual void read (const std::string &name) libmesh_override
 
virtual void write (const std::string &fname) libmesh_override
 
void verbose (bool set_verbosity)
 
const std::vector< Real > & get_time_steps ()
 
int get_num_time_steps ()
 
void copy_nodal_solution (System &system, std::string var_name, unsigned int timestep=1)
 
void copy_nodal_solution (System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
 
void copy_elemental_solution (System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
 
void write_discontinuous_exodusII (const std::string &name, const EquationSystems &es, const std::set< std::string > *system_names=libmesh_nullptr)
 
void write_element_data (const EquationSystems &es)
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) libmesh_override
 
void write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 
void write_global_data (const std::vector< Number > &, const std::vector< std::string > &)
 
void write_information_records (const std::vector< std::string > &)
 
void write_timestep (const std::string &fname, const EquationSystems &es, const int timestep, const Real time)
 
void set_output_variables (const std::vector< std::string > &output_variables, bool allow_empty=true)
 
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
 
void write_as_dimension (unsigned dim)
 
void set_coordinate_offset (Point p)
 
void append (bool val)
 
const std::vector< std::string > & get_elem_var_names ()
 
const std::vector< std::string > & get_nodal_var_names ()
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 
unsigned int & ascii_precision ()
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

MeshBasemesh ()
 
void set_n_partitions (unsigned int n_parts)
 
void skip_comment_lines (std::istream &in, const char comment_start)
 
const MeshBasemesh () const
 

Protected Attributes

std::vector< bool > elems_of_dimension
 
const bool _is_parallel_format
 
const bool _serial_only_needed_on_proc_0
 
const Parallel::Communicator_communicator
 

Private Member Functions

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

Private Attributes

UniquePtr< ExodusII_IO_Helperexio_helper
 
int _timestep
 
bool _verbose
 
std::vector< std::string > _output_variables
 
bool _append
 
bool _allow_empty_variables
 

Detailed Description

Handles reading and writing of Exodus binary files.

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

Definition at line 52 of file exodusII_io.h.

Constructor & Destructor Documentation

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

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

Definition at line 45 of file exodusII_io.C.

51  :
52  MeshInput<MeshBase> (mesh),
53  MeshOutput<MeshBase> (mesh,
54  /* is_parallel_format = */ false,
55  /* serial_only_needed_on_proc_0 = */ true),
57 #ifdef LIBMESH_HAVE_EXODUS_API
58  exio_helper(new ExodusII_IO_Helper(*this, false, true, single_precision)),
59 #endif
60  _timestep(1),
61  _verbose(false),
62  _append(false),
64 {
65 }
ParallelObject(const Parallel::Communicator &comm_in)
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
libMesh::ExodusII_IO::~ExodusII_IO ( )
virtual

Destructor.

Definition at line 107 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

108 {
109  exio_helper->close();
110 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249

Member Function Documentation

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

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

Definition at line 428 of file exodusII_io.C.

References _append.

Referenced by get_elem_var_names().

429 {
430  _append = val;
431 }
unsigned int& libMesh::MeshOutput< MeshBase >::ascii_precision ( )
inherited

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

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

Referenced by libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

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

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

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

88  { return _communicator; }
const Parallel::Communicator & _communicator
void libMesh::ExodusII_IO::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 489 of file exodusII_io.C.

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

Referenced by get_elem_var_names().

493 {
494  if (!exio_helper->opened_for_reading)
495  libmesh_error_msg("ERROR, ExodusII file must be opened for reading before copying an elemental solution!");
496 
497  // Map from element ID to elemental variable value. We need to use
498  // a map here rather than a vector (e.g. elem_var_values) since the
499  // libmesh element numbering can contain "holes". This is the case
500  // if we are reading elemental var values from an adaptively refined
501  // mesh that has not been sequentially renumbered.
502  std::map<dof_id_type, Real> elem_var_value_map;
503  exio_helper->read_elemental_var_values(exodus_var_name, timestep, elem_var_value_map);
504 
505  const unsigned int var_num = system.variable_number(system_var_name);
506  if (system.variable_type(var_num) != FEType(CONSTANT, MONOMIAL))
507  libmesh_error_msg("Error! Trying to copy elemental solution into a variable that is not of CONSTANT MONOMIAL type.");
508 
509  std::map<dof_id_type, Real>::iterator
510  it = elem_var_value_map.begin(),
511  end = elem_var_value_map.end();
512 
513  for (; it!=end; ++it)
514  {
515  const Elem * elem = MeshInput<MeshBase>::mesh().query_elem_ptr(it->first);
516 
517  if (!elem)
518  libmesh_error_msg("Error! Mesh returned NULL pointer for elem " << it->first);
519 
520  if (elem->n_comp(system.number(), var_num) > 0)
521  {
522  dof_id_type dof_index = elem->dof_number(system.number(), var_num, 0);
523 
524  // If the dof_index is local to this processor, set the value
525  if ((dof_index >= system.solution->first_local_index()) && (dof_index < system.solution->last_local_index()))
526  system.solution->set (dof_index, it->second);
527  }
528  }
529 
530  system.solution->close();
531  system.update();
532 }
IterBase * end
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::ExodusII_IO::copy_nodal_solution ( System system,
std::string  var_name,
unsigned int  timestep = 1 
)

Backward compatibility version of function that takes a single variable name

Definition at line 77 of file exodusII_io.C.

Referenced by get_elem_var_names().

80 {
81  libmesh_deprecated();
82  copy_nodal_solution(system, var_name, var_name, timestep);
83 }
void copy_nodal_solution(System &system, std::string var_name, unsigned int timestep=1)
Definition: exodusII_io.C:77
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 457 of file exodusII_io.C.

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

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

Return list of the nodal variable names

Definition at line 948 of file exodusII_io.C.

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

Referenced by get_elem_var_names().

949 {
950  exio_helper->read_var_names(ExodusII_IO_Helper::NODAL);
951  return exio_helper->nodal_var_names;
952 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
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 446 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

447 {
448  if (!exio_helper->opened_for_reading && !exio_helper->opened_for_writing)
449  libmesh_error_msg("ERROR, ExodusII file must be opened for reading or writing before calling ExodusII_IO::get_num_time_steps()!");
450 
451  exio_helper->read_num_time_steps();
452  return exio_helper->num_time_steps;
453 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
const std::vector< Real > & libMesh::ExodusII_IO::get_time_steps ( )

Returns an array containing the timesteps in the file

Definition at line 435 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

436 {
437  if (!exio_helper->opened_for_reading)
438  libmesh_error_msg("ERROR, ExodusII file must be opened for reading before calling ExodusII_IO::get_time_steps()!");
439 
440  exio_helper->read_time_steps();
441  return exio_helper->time_steps;
442 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited

Returns the object as a writeable reference.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::CheckpointIO::build_elem_list(), libMesh::CheckpointIO::build_node_list(), libMesh::CheckpointIO::current_n_processors(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::UNVIO::elements_out(), libMesh::UNVIO::groups_in(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::UNVIO::nodes_out(), libMesh::GMVIO::read(), read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::UCDIO::UCDIO(), libMesh::VTKIO::VTKIO(), libMesh::TetGenIO::write(), write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::CheckpointIO::write_bcs(), libMesh::GMVIO::write_binary(), libMesh::CheckpointIO::write_connectivity(), libMesh::GMVIO::write_discontinuous_gmv(), write_element_data(), libMesh::UCDIO::write_implementation(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), write_nodal_data(), write_nodal_data_common(), write_nodal_data_discontinuous(), libMesh::CheckpointIO::write_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(), and libMesh::CheckpointIO::write_subdomain_names().

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

Definition at line 93 of file parallel_object.h.

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

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

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

Definition at line 99 of file parallel_object.h.

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

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

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:677
void libMesh::ExodusII_IO::read ( const std::string &  name)
virtual

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

Implements libMesh::MeshInput< MeshBase >.

Definition at line 114 of file exodusII_io.C.

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

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

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

Allows you to set a vector that is added to the coordinates of all of the nodes. Effectively, this "moves" the mesh to a particular position

Definition at line 420 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

421 {
422  libmesh_deprecated();
423  exio_helper->set_coordinate_offset(p);
424 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
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 91 of file mesh_input.h.

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

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

91 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1264
void libMesh::ExodusII_IO::set_output_variables ( const std::vector< std::string > &  output_variables,
bool  allow_empty = true 
)

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

Definition at line 68 of file exodusII_io.C.

References _allow_empty_variables, and _output_variables.

70 {
71  _output_variables = output_variables;
72  _allow_empty_variables = allow_empty;
73 }
std::vector< std::string > _output_variables
Definition: exodusII_io.h:267
void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
)
protectedinherited

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

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

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

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

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

Definition at line 406 of file exodusII_io.C.

References exio_helper.

Referenced by get_elem_var_names().

407 {
408  exio_helper->use_mesh_dimension_instead_of_spatial_dimension(val);
409 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
void libMesh::ExodusII_IO::verbose ( bool  set_verbosity)

Set the flag indicating if we should be verbose.

Definition at line 396 of file exodusII_io.C.

References _verbose, and exio_helper.

Referenced by get_elem_var_names(), and read().

397 {
398  _verbose = set_verbosity;
399 
400  // Set the verbose flag in the helper object as well.
401  exio_helper->verbose = _verbose;
402 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
void libMesh::ExodusII_IO::write ( const std::string &  fname)
virtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 790 of file exodusII_io.C.

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

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

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

References exio_helper.

Referenced by get_elem_var_names().

414 {
415  exio_helper->write_as_dimension(dim);
416 }
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
void libMesh::ExodusII_IO::write_discontinuous_exodusII ( const std::string &  name,
const EquationSystems es,
const std::set< std::string > *  system_names = libmesh_nullptr 
)

Writes a exodusII file with discontinuous data

Definition at line 87 of file exodusII_io.C.

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

90 {
91  std::vector<std::string> solution_names;
92  std::vector<Number> v;
93 
94  es.build_variable_names (solution_names, libmesh_nullptr, system_names);
95  es.build_discontinuous_solution_vector (v, system_names);
96 
97  this->write_nodal_data_discontinuous(name, v, solution_names);
98 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
const class libmesh_nullptr_t libmesh_nullptr
void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
Definition: exodusII_io.C:828
void libMesh::ExodusII_IO::write_element_data ( const EquationSystems es)

Write out element solution.

Definition at line 536 of file exodusII_io.C.

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

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

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

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

Reimplemented in libMesh::NameBasedIO.

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

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

Write out global variables.

Definition at line 721 of file exodusII_io.C.

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

Referenced by get_elem_var_names().

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

Write out information records.

Definition at line 708 of file exodusII_io.C.

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

Referenced by get_elem_var_names().

709 {
711  return;
712 
713  if (!exio_helper->opened_for_writing)
714  libmesh_error_msg("ERROR, ExodusII file must be initialized before outputting information records.");
715 
716  exio_helper->write_information_records(records);
717 }
const MeshBase & mesh() const
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
processor_id_type processor_id() const
virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const NumericVector< Number > &  ,
const std::vector< std::string > &   
)
virtualinherited

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

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

Reimplemented in libMesh::Nemesis_IO.

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

Write out a nodal solution.

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 632 of file exodusII_io.C.

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

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

635 {
636  LOG_SCOPE("write_nodal_data()", "ExodusII_IO");
637 
638  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
639 
640  int num_vars = cast_int<int>(names.size());
641  dof_id_type num_nodes = mesh.n_nodes();
642 
643  // The names of the variables to be output
644  std::vector<std::string> output_names;
645 
647  output_names = _output_variables;
648  else
649  output_names = names;
650 
651 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
652 
653  std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
654 
655  // Call helper function for opening/initializing data, giving it the
656  // complex variable names
657  this->write_nodal_data_common(fname, complex_names, /*continuous=*/true);
658 #else
659  // Call helper function for opening/initializing data
660  this->write_nodal_data_common(fname, output_names, /*continuous=*/true);
661 #endif
662 
663  if (mesh.processor_id())
664  return;
665 
666  // This will count the number of variables actually output
667  for (int c=0; c<num_vars; c++)
668  {
669  std::stringstream name_to_find;
670 
671  std::vector<std::string>::iterator pos =
672  std::find(output_names.begin(), output_names.end(), names[c]);
673  if (pos == output_names.end())
674  continue;
675 
676  unsigned int variable_name_position =
677  cast_int<unsigned int>(pos - output_names.begin());
678 
679 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
680  std::vector<Real> real_parts(num_nodes);
681  std::vector<Real> imag_parts(num_nodes);
682  std::vector<Real> magnitudes(num_nodes);
683 
684  for (unsigned int i=0; i<num_nodes; ++i)
685  {
686  real_parts[i] = soln[i*num_vars + c].real();
687  imag_parts[i] = soln[i*num_vars + c].imag();
688  magnitudes[i] = std::abs(soln[i*num_vars + c]);
689  }
690  exio_helper->write_nodal_values(3*variable_name_position+1,real_parts,_timestep);
691  exio_helper->write_nodal_values(3*variable_name_position+2,imag_parts,_timestep);
692  exio_helper->write_nodal_values(3*variable_name_position+3,magnitudes,_timestep);
693 #else
694  std::vector<Number> cur_soln(num_nodes);
695 
696  // Copy out this variable's solution
697  for (dof_id_type i=0; i<num_nodes; i++)
698  cur_soln[i] = soln[i*num_vars + c];
699  exio_helper->write_nodal_values(variable_name_position+1,cur_soln,_timestep);
700 #endif
701 
702  }
703 }
double abs(double a)
const MT & mesh() const
Definition: mesh_output.h:216
std::vector< std::string > _output_variables
Definition: exodusII_io.h:267
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
Definition: exodusII_io.C:888
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
uint8_t dof_id_type
Definition: id_types.h:64
void libMesh::ExodusII_IO::write_nodal_data_common ( std::string  fname,
const std::vector< std::string > &  names,
bool  continuous = true 
)
private

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

Definition at line 888 of file exodusII_io.C.

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

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

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

Write out a discontinuous nodal solution.

Definition at line 828 of file exodusII_io.C.

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

Referenced by get_elem_var_names(), and write_discontinuous_exodusII().

831 {
832  LOG_SCOPE("write_nodal_data_discontinuous()", "ExodusII_IO");
833 
834  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
835 
836  int num_vars = cast_int<int>(names.size());
837  int num_nodes = 0;
838  MeshBase::const_element_iterator it = mesh.active_elements_begin();
839  const MeshBase::const_element_iterator end = mesh.active_elements_end();
840  for ( ; it != end; ++it)
841  num_nodes += (*it)->n_nodes();
842 
843 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
844 
845  std::vector<std::string> complex_names = exio_helper->get_complex_names(names);
846 
847  // Call helper function for opening/initializing data, giving it the
848  // complex variable names
849  this->write_nodal_data_common(fname, complex_names, /*continuous=*/false);
850 #else
851  // Call helper function for opening/initializing data
852  this->write_nodal_data_common(fname, names, /*continuous=*/false);
853 #endif
854 
855  if (mesh.processor_id())
856  return;
857 
858  for (int c=0; c<num_vars; c++)
859  {
860 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
861  std::vector<Real> real_parts(num_nodes);
862  std::vector<Real> imag_parts(num_nodes);
863  std::vector<Real> magnitudes(num_nodes);
864 
865  for (int i=0; i<num_nodes; ++i)
866  {
867  real_parts[i] = soln[i*num_vars + c].real();
868  imag_parts[i] = soln[i*num_vars + c].imag();
869  magnitudes[i] = std::abs(soln[i*num_vars + c]);
870  }
871  exio_helper->write_nodal_values(3*c+1,real_parts,_timestep);
872  exio_helper->write_nodal_values(3*c+2,imag_parts,_timestep);
873  exio_helper->write_nodal_values(3*c+3,magnitudes,_timestep);
874 #else
875  // Copy out this variable's solution
876  std::vector<Number> cur_soln(num_nodes);
877 
878  for (int i=0; i<num_nodes; i++)
879  cur_soln[i] = soln[i*num_vars + c];
880 
881  exio_helper->write_nodal_values(c+1,cur_soln,_timestep);
882 #endif
883  }
884 }
double abs(double a)
IterBase * end
const MT & mesh() const
Definition: mesh_output.h:216
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
Definition: exodusII_io.C:888
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
void libMesh::ExodusII_IO::write_timestep ( const std::string &  fname,
const EquationSystems es,
const int  timestep,
const Real  time 
)

Writes out the solution at a specific timestep.

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

Definition at line 774 of file exodusII_io.C.

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

Referenced by get_elem_var_names().

778 {
779  _timestep = timestep;
780  write_equation_systems(fname,es);
781 
783  return;
784 
785  exio_helper->write_timestep(timestep, time);
786 }
const MeshBase & mesh() const
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
UniquePtr< ExodusII_IO_Helper > exio_helper
Definition: exodusII_io.h:249
processor_id_type processor_id() const

Member Data Documentation

bool libMesh::ExodusII_IO::_allow_empty_variables
private

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

Definition at line 288 of file exodusII_io.h.

Referenced by set_output_variables(), and write_nodal_data().

bool libMesh::ExodusII_IO::_append
private

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

Definition at line 273 of file exodusII_io.h.

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

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

Flag specifying whether this format is parallel-capable. If this is false (default) I/O is only permitted when the mesh has been serialized.

Definition at line 141 of file mesh_output.h.

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

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

The names of the variables to be output. If this is empty then all variables are output.

Definition at line 267 of file exodusII_io.h.

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

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

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

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

Definition at line 150 of file mesh_output.h.

int libMesh::ExodusII_IO::_timestep
private

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

Definition at line 256 of file exodusII_io.h.

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

bool libMesh::ExodusII_IO::_verbose
private

should we be verbose?

Definition at line 261 of file exodusII_io.h.

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


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