libMesh::Nemesis_IO_Helper Class Reference

#include <nemesis_io_helper.h>

Inheritance diagram for libMesh::Nemesis_IO_Helper:

Public Types

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

Public Member Functions

 Nemesis_IO_Helper (const ParallelObject &parent, bool verbose=false, bool single_precision=false)
 
virtual ~Nemesis_IO_Helper ()
 
void get_init_global ()
 
void get_ss_param_global ()
 
void get_ns_param_global ()
 
void get_eb_info_global ()
 
void get_init_info ()
 
void get_loadbal_param ()
 
void get_elem_map ()
 
void get_node_map ()
 
void get_cmap_params ()
 
void get_node_cmap ()
 
void get_elem_cmap ()
 
void put_init_info (unsigned num_proc, unsigned num_proc_in_file, const char *ftype)
 
void put_init_global (dof_id_type num_nodes_global, dof_id_type num_elems_global, unsigned num_elem_blks_global, unsigned num_node_sets_global, unsigned num_side_sets_global)
 
void put_eb_info_global (std::vector< int > &global_elem_blk_ids, std::vector< int > &global_elem_blk_cnts)
 
void put_ns_param_global (std::vector< int > &global_nodeset_ids, std::vector< int > &num_global_node_counts, std::vector< int > &num_global_node_df_counts)
 
void put_ss_param_global (std::vector< int > &global_sideset_ids, std::vector< int > &num_global_side_counts, std::vector< int > &num_global_side_df_counts)
 
void put_loadbal_param (unsigned num_internal_nodes, unsigned num_border_nodes, unsigned num_external_nodes, unsigned num_internal_elems, unsigned num_border_elems, unsigned num_node_cmaps, unsigned num_elem_cmaps)
 
void put_cmap_params (std::vector< int > &node_cmap_ids, std::vector< int > &node_cmap_node_cnts, std::vector< int > &elem_cmap_ids, std::vector< int > &elem_cmap_elem_cnts)
 
void put_node_cmap (std::vector< std::vector< int >> &node_cmap_node_ids, std::vector< std::vector< int >> &node_cmap_proc_ids)
 
void put_node_map (std::vector< int > &node_mapi, std::vector< int > &node_mapb, std::vector< int > &node_mape)
 
void put_elem_cmap (std::vector< std::vector< int >> &elem_cmap_elem_ids, std::vector< std::vector< int >> &elem_cmap_side_ids, std::vector< std::vector< int >> &elem_cmap_proc_ids)
 
void put_elem_map (std::vector< int > &elem_mapi, std::vector< int > &elem_mapb)
 
void put_n_coord (unsigned start_node_num, unsigned num_nodes, std::vector< Real > &x_coor, std::vector< Real > &y_coor, std::vector< Real > &z_coor)
 
virtual void write_nodal_coordinates (const MeshBase &mesh, bool use_discontinuous=false) override
 
virtual void write_elements (const MeshBase &mesh, bool use_discontinuous=false) override
 
virtual void write_sidesets (const MeshBase &mesh) override
 
virtual void write_nodesets (const MeshBase &mesh) override
 
virtual void create (std::string filename) override
 
virtual void initialize (std::string title, const MeshBase &mesh, bool use_discontinuous=false) override
 
void write_nodal_solution (const NumericVector< Number > &parallel_soln, const std::vector< std::string > &names, int timestep, const std::vector< std::string > &output_names)
 
void write_nodal_solution (const std::vector< Number > &values, const std::vector< std::string > &names, int timestep)
 
virtual void initialize_element_variables (std::vector< std::string > names, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) override
 
void write_element_values (const MeshBase &mesh, const NumericVector< Number > &parallel_soln, const std::vector< std::string > &names, int timestep, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains)
 
std::string construct_nemesis_filename (const std::string &base_filename)
 
const char * get_elem_type () const
 
void open (const char *filename, bool read_only)
 
void read_header ()
 
void read_qa_records ()
 
void print_header ()
 
void read_nodes ()
 
void read_node_num_map ()
 
void print_nodes (std::ostream &out=libMesh::out)
 
void read_block_info ()
 
int get_block_id (int index)
 
std::string get_block_name (int index)
 
int get_side_set_id (int index)
 
std::string get_side_set_name (int index)
 
int get_node_set_id (int index)
 
std::string get_node_set_name (int index)
 
void read_elem_in_block (int block)
 
void read_elem_num_map ()
 
void read_sideset_info ()
 
void read_nodeset_info ()
 
void read_sideset (int id, int offset)
 
void read_nodeset (int id)
 
void close ()
 
int inquire (int req_info, std::string error_msg="")
 
void read_time_steps ()
 
void read_num_time_steps ()
 
void read_nodal_var_values (std::string nodal_var_name, int time_step)
 
void read_elemental_var_values (std::string elemental_var_name, int time_step, std::map< dof_id_type, Real > &elem_var_value_map)
 
void initialize_nodal_variables (std::vector< std::string > names)
 
void initialize_global_variables (std::vector< std::string > names)
 
void write_timestep (int timestep, Real time)
 
void write_element_values (const MeshBase &mesh, const std::vector< Real > &values, int timestep, const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains)
 
void write_nodal_values (int var_id, const std::vector< Real > &values, int timestep)
 
void write_information_records (const std::vector< std::string > &records)
 
void write_global_values (const std::vector< Real > &values, int timestep)
 
void read_global_values (std::vector< Real > &values, int timestep)
 
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
 
void write_as_dimension (unsigned dim)
 
void set_coordinate_offset (Point p)
 
std::vector< std::string > get_complex_names (const std::vector< std::string > &names) const
 
std::vector< std::set< subdomain_id_type > > get_complex_vars_active_subdomains (const std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) const
 
void message (const std::string &msg)
 
void message (const std::string &msg, int i)
 
void read_var_names (ExodusVarType type)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

int nemesis_err_flag
 
int num_nodes_global
 
int num_elems_global
 
int num_elem_blks_global
 
int num_node_sets_global
 
int num_side_sets_global
 
int num_proc
 
int num_proc_in_file
 
char ftype
 
std::vector< int > global_sideset_ids
 
std::vector< int > num_global_side_counts
 
std::vector< int > num_global_side_df_counts
 
std::vector< int > global_nodeset_ids
 
std::vector< int > num_global_node_counts
 
std::vector< int > num_global_node_df_counts
 
std::vector< int > global_elem_blk_ids
 
std::vector< int > global_elem_blk_cnts
 
std::set< int > nodes_attached_to_local_elems
 
std::map< subdomain_id_type, std::vector< dof_id_type > > subdomain_map
 
std::map< int, std::vector< int > > block_id_to_elem_connectivity
 
int num_internal_nodes
 
int num_border_nodes
 
int num_external_nodes
 
int num_internal_elems
 
int num_border_elems
 
int num_node_cmaps
 
int num_elem_cmaps
 
std::vector< int > elem_mapi
 
std::vector< int > elem_mapb
 
std::vector< int > node_mapi
 
std::vector< int > node_mapb
 
std::vector< int > node_mape
 
std::vector< int > node_cmap_ids
 
std::vector< int > node_cmap_node_cnts
 
std::vector< int > elem_cmap_ids
 
std::vector< int > elem_cmap_elem_cnts
 
std::vector< std::vector< int > > node_cmap_node_ids
 
std::vector< std::vector< int > > node_cmap_proc_ids
 
std::vector< std::vector< int > > elem_cmap_elem_ids
 
std::vector< std::vector< int > > elem_cmap_side_ids
 
std::vector< std::vector< int > > elem_cmap_proc_ids
 
int ex_id
 
int ex_err
 
int num_dim
 
int num_global_vars
 
int num_nodes
 
int num_elem
 
int num_elem_blk
 
int num_node_sets
 
int num_side_sets
 
int num_elem_this_blk
 
int num_nodes_per_elem
 
int num_attr
 
int num_elem_all_sidesets
 
std::vector< int > block_ids
 
std::vector< int > connect
 
std::vector< int > ss_ids
 
std::vector< int > nodeset_ids
 
std::vector< int > num_sides_per_set
 
std::vector< int > num_nodes_per_set
 
std::vector< int > num_df_per_set
 
std::vector< int > num_node_df_per_set
 
std::vector< int > elem_list
 
std::vector< int > side_list
 
std::vector< int > node_list
 
std::vector< int > id_list
 
std::vector< int > node_num_map
 
std::vector< int > elem_num_map
 
std::vector< Realx
 
std::vector< Realy
 
std::vector< Realz
 
std::vector< char > title
 
std::vector< char > elem_type
 
std::map< int, int > libmesh_elem_num_to_exodus
 
std::vector< int > exodus_elem_num_to_libmesh
 
std::map< int, int > libmesh_node_num_to_exodus
 
std::vector< int > exodus_node_num_to_libmesh
 
int num_time_steps
 
std::vector< Realtime_steps
 
int num_nodal_vars
 
std::vector< std::string > nodal_var_names
 
std::vector< Realnodal_var_values
 
int num_elem_vars
 
std::vector< std::string > elem_var_names
 
std::vector< Realelem_var_values
 
std::vector< std::string > global_var_names
 
std::map< int, std::string > id_to_block_names
 
std::map< int, std::string > id_to_ss_names
 
std::map< int, std::string > id_to_ns_names
 
bool verbose
 
bool opened_for_writing
 
bool opened_for_reading
 
std::string current_filename
 

Protected Member Functions

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

Protected Attributes

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

Private Types

typedef std::map< unsigned, std::set< unsigned > >::iterator proc_nodes_touched_iterator
 
typedef std::map< unsigned, std::set< std::pair< unsigned, unsigned > > >::iterator proc_border_elem_sets_iterator
 

Private Member Functions

void compute_num_global_elem_blocks (const MeshBase &pmesh)
 
void compute_num_global_nodesets (const MeshBase &pmesh)
 
void compute_num_global_sidesets (const MeshBase &pmesh)
 
void build_element_and_node_maps (const MeshBase &pmesh)
 
void compute_border_node_ids (const MeshBase &pmesh)
 
void compute_internal_and_border_elems_and_internal_nodes (const MeshBase &pmesh)
 
void compute_communication_map_parameters ()
 
void compute_node_communication_maps ()
 
void compute_node_maps ()
 
void compute_elem_communication_maps ()
 
void compute_element_maps ()
 
void write_exodus_initialization_info (const MeshBase &pmesh, const std::string &title)
 

Private Attributes

std::map< subdomain_id_type, unsigned > local_subdomain_counts
 
std::set< unsigned > border_node_ids
 
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
 
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > > proc_border_elem_sets
 
std::set< unsigned > internal_node_ids
 
std::set< unsigned > internal_elem_ids
 
std::set< unsigned > border_elem_ids
 

Detailed Description

This is the Nemesis_IO_Helper class. Think of it as a big struct with storage for all the stuff one might want to pull from a Nemesis file. Derived from ExodusII_IO_Helper object, since Nemesis is based on the same file format.

Author
John W. Peterson
Date
2008

Definition at line 64 of file nemesis_io_helper.h.

Member Typedef Documentation

◆ proc_border_elem_sets_iterator

typedef std::map<unsigned, std::set<std::pair<unsigned,unsigned> > >::iterator libMesh::Nemesis_IO_Helper::proc_border_elem_sets_iterator
private

Typedef for an iterator into the data structure above.

Definition at line 594 of file nemesis_io_helper.h.

◆ proc_nodes_touched_iterator

typedef std::map<unsigned, std::set<unsigned> >::iterator libMesh::Nemesis_IO_Helper::proc_nodes_touched_iterator
private

Typedef for an iterator into the data structure above.

Definition at line 584 of file nemesis_io_helper.h.

Member Enumeration Documentation

◆ ExodusVarType

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

Enumerator
NODAL 
ELEMENTAL 
GLOBAL 

Definition at line 601 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

◆ Nemesis_IO_Helper()

libMesh::Nemesis_IO_Helper::Nemesis_IO_Helper ( const ParallelObject parent,
bool  verbose = false,
bool  single_precision = false 
)
explicit

Constructor.

Definition at line 45 of file nemesis_io_helper.C.

46  :
47  ExodusII_IO_Helper(parent, verbose_in, /*run_only_on_proc0=*/false, /*single_precision=*/single_precision),
54  num_proc(0),
56  ftype('\0'),
62  num_node_cmaps(0),
64 {
65  // Warn about using untested code!
66  libmesh_experimental();
67 }
ExodusII_IO_Helper(const ParallelObject &parent, bool v=false, bool run_only_on_proc0=true, bool single_precision=false)

◆ ~Nemesis_IO_Helper()

libMesh::Nemesis_IO_Helper::~Nemesis_IO_Helper ( )
virtual

Destructor.

Definition at line 70 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::close(), libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, ex_update(), and libMesh::ExodusII_IO_Helper::opened_for_writing.

71 {
72  // Our destructor is called from Nemesis_IO. We close the Exodus file here since we have
73  // responsibility for managing the file's lifetime. Only call ex_update() if the file was
74  // opened for writing!
75  if (this->opened_for_writing)
76  {
77  this->ex_err = exII::ex_update(this->ex_id);
78  EX_EXCEPTIONLESS_CHECK_ERR(ex_err, "Error flushing buffers to file.");
79  }
80  this->close();
81 }
EXODUS_EXPORT int ex_update(int exoid)

Member Function Documentation

◆ build_element_and_node_maps()

void libMesh::Nemesis_IO_Helper::build_element_and_node_maps ( const MeshBase pmesh)
private

This function builds the libmesh -> exodus and exodus -> libmesh node and element maps. These maps allow us to have a consistent numbering scheme within an Exodus file, given an existing globally consistent numbering scheme from LibMesh.

Definition at line 1695 of file nemesis_io_helper.C.

References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), block_id_to_elem_connectivity, libMesh::ExodusII_IO_Helper::block_ids, libMesh::Elem::build(), libMesh::MeshBase::elem_ref(), libMesh::ExodusII_IO_Helper::exodus_elem_num_to_libmesh, libMesh::ExodusII_IO_Helper::exodus_node_num_to_libmesh, libMesh::ExodusII_IO_Helper::Conversion::get_canonical_type(), libMesh::ExodusII_IO_Helper::Conversion::get_node_map(), libMesh::index_range(), libMesh::ExodusII_IO_Helper::libmesh_elem_num_to_exodus, libMesh::ExodusII_IO_Helper::libmesh_node_num_to_exodus, local_subdomain_counts, n_nodes, libMesh::Elem::n_nodes(), nodes_attached_to_local_elems, libMesh::ExodusII_IO_Helper::num_nodes, libMesh::ExodusII_IO_Helper::num_nodes_per_elem, libMesh::out, libMesh::ParallelObject::processor_id(), subdomain_map, libMesh::Elem::type(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1696 {
1697  // If we don't have any local subdomains, it had better be because
1698  // we don't have any local elements
1699 #ifdef DEBUG
1700  if (local_subdomain_counts.empty())
1701  {
1702  libmesh_assert(pmesh.active_local_elements_begin() ==
1703  pmesh.active_local_elements_end());
1704  libmesh_assert(this->nodes_attached_to_local_elems.empty());
1705  }
1706 #endif
1707 
1708  // Elements have to be numbered contiguously based on what block
1709  // number they are in. Therefore we have to do a bit of work to get
1710  // the block (ie subdomain) numbers first and store them off as
1711  // block_ids.
1712 
1713  // Make sure there is no leftover information in the subdomain_map, and reserve
1714  // enough space to store the elements we need.
1715  this->subdomain_map.clear();
1716  for (const auto & pr : local_subdomain_counts)
1717  {
1718  if (verbose)
1719  {
1720  libMesh::out << "[" << this->processor_id() << "] "
1721  << "local_subdomain_counts [" << static_cast<unsigned>(pr.first) << "]= "
1722  << pr.second
1723  << std::endl;
1724  }
1725 
1726  // pr.first is the subdomain ID, pr.second is the number of elements it contains
1727  this->subdomain_map[pr.first].reserve(pr.second);
1728  }
1729 
1730 
1731  // First loop over the elements to figure out which elements are in which subdomain
1732  for (const auto & elem : pmesh.active_local_element_ptr_range())
1733  {
1734  // Grab the nodes while we're here.
1735  for (auto n : elem->node_index_range())
1736  this->nodes_attached_to_local_elems.insert( elem->node_id(n) );
1737 
1738  subdomain_id_type cur_subdomain = elem->subdomain_id();
1739 
1740  this->subdomain_map[cur_subdomain].push_back(elem->id());
1741  }
1742 
1743  // Set num_nodes which is used by exodusII_io_helper
1744  this->num_nodes =
1745  cast_int<int>(this->nodes_attached_to_local_elems.size());
1746 
1747  // Now come up with a 1-based numbering for these nodes
1748  this->exodus_node_num_to_libmesh.clear(); // Make sure it's empty
1749  this->exodus_node_num_to_libmesh.reserve(this->nodes_attached_to_local_elems.size());
1750 
1751  // Also make sure there's no leftover information in the map which goes the
1752  // other direction.
1753  this->libmesh_node_num_to_exodus.clear();
1754 
1755  // Set the map for nodes
1756  for (const auto & id : nodes_attached_to_local_elems)
1757  {
1758  // I.e. given exodus_node_id,
1759  // exodus_node_num_to_libmesh[ exodus_node_id ] returns the libmesh ID for that node.
1760  // Note that even though most of Exodus is 1-based, this code will map an Exodus ID of
1761  // zero to some libmesh node ID. Is that a problem?
1762  this->exodus_node_num_to_libmesh.push_back(id);
1763 
1764  // Likewise, given libmesh_node_id,
1765  // libmesh_node_num_to_exodus[ libmesh_node_id ] returns the *Exodus* ID for that node.
1766  // Unlike the exodus_node_num_to_libmesh vector above, this one is a std::map
1767  this->libmesh_node_num_to_exodus[id] =
1768  cast_int<int>(this->exodus_node_num_to_libmesh.size()); // should never be zero...
1769  }
1770 
1771  // Now we're going to loop over the subdomain map and build a few things right
1772  // now that we'll use later.
1773 
1774  // First make sure our data structures don't have any leftover data...
1775  this->exodus_elem_num_to_libmesh.clear();
1776  this->block_ids.clear();
1777  this->libmesh_elem_num_to_exodus.clear();
1778 
1779  // Now loop over each subdomain and get a unique numbering for the elements
1780  for (auto & pr : subdomain_map)
1781  {
1782  block_ids.push_back(pr.first);
1783 
1784  // Vector of element IDs for this subdomain
1785  std::vector<dof_id_type> & elem_ids_this_subdomain = pr.second;
1786 
1787  // The code below assumes this subdomain block is not empty, make sure that's the case!
1788  if (elem_ids_this_subdomain.size() == 0)
1789  libmesh_error_msg("Error, no element IDs found in subdomain " << pr.first);
1790 
1791  ExodusII_IO_Helper::ElementMaps em;
1792 
1793  // Use the first element in this block to get representative information.
1794  // Note that Exodus assumes all elements in a block are of the same type!
1795  // We are using that same assumption here!
1796  const ExodusII_IO_Helper::Conversion conv = em.assign_conversion
1797  (pmesh.elem_ref(elem_ids_this_subdomain[0]).type());
1798  this->num_nodes_per_elem =
1799  pmesh.elem_ref(elem_ids_this_subdomain[0]).n_nodes();
1800 
1801  // Get a reference to the connectivity vector for this subdomain. This vector
1802  // is most likely empty, we are going to fill it up now.
1803  std::vector<int> & current_block_connectivity = this->block_id_to_elem_connectivity[pr.first];
1804 
1805  // Just in case it's not already empty...
1806  current_block_connectivity.clear();
1807  current_block_connectivity.resize(elem_ids_this_subdomain.size() * this->num_nodes_per_elem);
1808 
1809  for (auto i : index_range(elem_ids_this_subdomain))
1810  {
1811  auto elem_id = elem_ids_this_subdomain[i];
1812 
1813  // Set the number map for elements
1814  this->exodus_elem_num_to_libmesh.push_back(elem_id);
1815  this->libmesh_elem_num_to_exodus[elem_id] =
1816  cast_int<int>(this->exodus_elem_num_to_libmesh.size());
1817 
1818  const Elem & elem = pmesh.elem_ref(elem_id);
1819 
1820  // Exodus/Nemesis want every block to have the same element type
1821  // libmesh_assert_equal_to (elem->type(), conv.get_canonical_type());
1822 
1823  // But we can get away with writing e.g. HEX8 and INFHEX8 in
1824  // the same block...
1825  libmesh_assert_equal_to (elem.n_nodes(), Elem::build(conv.get_canonical_type(), nullptr)->n_nodes());
1826 
1827  for (auto j : IntRange<int>(0, this->num_nodes_per_elem))
1828  {
1829  const unsigned int connect_index = (i*this->num_nodes_per_elem)+j;
1830  const unsigned int elem_node_index = conv.get_node_map(j);
1831 
1832  std::map<int, int>::iterator node_it = libmesh_node_num_to_exodus.find(elem.node_id(elem_node_index));
1833  if (node_it == libmesh_node_num_to_exodus.end())
1834  libmesh_error_msg("Node number " << elem.node_id(elem_node_index) << " not found in libmesh_node_num_to_exodus map.");
1835 
1836  current_block_connectivity[connect_index] = node_it->second;
1837  }
1838  } // End loop over elems in this subdomain
1839  } // end loop over subdomain_map
1840 }
std::map< subdomain_id_type, std::vector< dof_id_type > > subdomain_map
TestClass subdomain_id_type
Definition: id_types.h:43
std::vector< int > exodus_elem_num_to_libmesh
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Definition: int_range.h:104
std::map< int, int > libmesh_elem_num_to_exodus
const dof_id_type n_nodes
Definition: tecplot_io.C:68
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition: elem.C:245
std::set< int > nodes_attached_to_local_elems
std::map< int, int > libmesh_node_num_to_exodus
std::map< subdomain_id_type, unsigned > local_subdomain_counts
std::map< int, std::vector< int > > block_id_to_elem_connectivity
std::vector< int > exodus_node_num_to_libmesh
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ check_existing_vars()

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

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

Definition at line 1814 of file exodusII_io_helper.C.

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

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

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

◆ close()

void libMesh::ExodusII_IO_Helper::close ( )
inherited

Closes the ExodusII mesh file.

Definition at line 795 of file exodusII_io_helper.C.

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

Referenced by ~Nemesis_IO_Helper().

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

◆ comm()

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

Definition at line 89 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::PetscDMWrapper::check_section_n_dofs(), compute_num_global_elem_blocks(), compute_num_global_nodesets(), compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

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

◆ compute_border_node_ids()

void libMesh::Nemesis_IO_Helper::compute_border_node_ids ( const MeshBase pmesh)
private

This function constructs the set of border node IDs present on the current mesh. These are nodes which live on the "border" between elements which live on different processors.

Definition at line 1846 of file nemesis_io_helper.C.

References libMesh::MeshBase::active_element_ptr_range(), border_node_ids, libMesh::ParallelObject::n_processors(), num_border_nodes, num_node_cmaps, libMesh::out, proc_nodes_touched_intersections, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1847 {
1848  // The set which will eventually contain the IDs of "border nodes". These are nodes
1849  // that lie on the boundary between one or more processors.
1850  //std::set<unsigned> border_node_ids;
1851 
1852  // map from processor ID to set of nodes which elements from this processor "touch",
1853  // that is,
1854  // proc_nodes_touched[p] = (set all node IDs found in elements owned by processor p)
1855  std::map<unsigned, std::set<unsigned>> proc_nodes_touched;
1856 
1857 
1858  // We are going to create a lot of intermediate data structures here, so make sure
1859  // as many as possible all cleaned up by creating scope!
1860  {
1861  // Loop over active (not just active local) elements, make sets of node IDs for each
1862  // processor which has an element that "touches" a node.
1863  for (const auto & elem : pmesh.active_element_ptr_range())
1864  {
1865  // Get reference to the set for this processor. If it does not exist
1866  // it will be created.
1867  std::set<unsigned> & set_p = proc_nodes_touched[ elem->processor_id() ];
1868 
1869  // Insert all nodes touched by this element into the set
1870  for (auto node : elem->node_index_range())
1871  set_p.insert(elem->node_id(node));
1872  }
1873 
1874  // The number of node communication maps is the number of other processors
1875  // with which we share nodes. (I think.) This is just the size of the map we just
1876  // created, minus 1 unless this processor has no nodes of its own.
1877  this->num_node_cmaps =
1878  cast_int<int>(proc_nodes_touched.size() -
1879  proc_nodes_touched.count(this->processor_id()));
1880 
1881  // We can't be connecting to more processors than exist outside
1882  // ourselves
1883  libmesh_assert_less (static_cast<unsigned>(this->num_node_cmaps), this->n_processors());
1884 
1885  if (verbose)
1886  {
1887  libMesh::out << "[" << this->processor_id()
1888  << "] proc_nodes_touched contains "
1889  << proc_nodes_touched.size()
1890  << " sets of nodes."
1891  << std::endl;
1892 
1893  for (const auto & pr : proc_nodes_touched)
1894  libMesh::out << "[" << this->processor_id()
1895  << "] proc_nodes_touched[" << pr.first << "] has "
1896  << pr.second.size()
1897  << " entries."
1898  << std::endl;
1899  }
1900 
1901 
1902  // Loop over all the sets we just created and compute intersections with the
1903  // this processor's set. Obviously, don't intersect with ourself.
1904  for (auto & pr : proc_nodes_touched)
1905  {
1906  // Don't compute intersections with ourself
1907  if (pr.first == this->processor_id())
1908  continue;
1909 
1910  // Otherwise, compute intersection with other processor and ourself
1911  std::set<unsigned> & my_set = proc_nodes_touched[this->processor_id()];
1912  std::set<unsigned> & other_set = pr.second;
1913  std::set<unsigned> & result_set = this->proc_nodes_touched_intersections[pr.first]; // created if does not exist
1914 
1915  std::set_intersection(my_set.begin(), my_set.end(),
1916  other_set.begin(), other_set.end(),
1917  std::inserter(result_set, result_set.end()));
1918  }
1919 
1920  if (verbose)
1921  {
1922  for (const auto & pr : proc_nodes_touched_intersections)
1923  libMesh::out << "[" << this->processor_id()
1924  << "] this->proc_nodes_touched_intersections[" << pr.first << "] has "
1925  << pr.second.size()
1926  << " entries."
1927  << std::endl;
1928  }
1929 
1930  // Compute the set_union of all the preceding intersections. This will be the set of
1931  // border node IDs for this processor.
1932  for (auto & pr : proc_nodes_touched_intersections)
1933  {
1934  std::set<unsigned> & other_set = pr.second;
1935  std::set<unsigned> intermediate_result; // Don't think we can insert into one of the sets we're unioning...
1936 
1937  std::set_union(this->border_node_ids.begin(), this->border_node_ids.end(),
1938  other_set.begin(), other_set.end(),
1939  std::inserter(intermediate_result, intermediate_result.end()));
1940 
1941  // Swap our intermediate result into the final set
1942  this->border_node_ids.swap(intermediate_result);
1943  }
1944 
1945  libmesh_assert_less_equal
1946  (this->proc_nodes_touched_intersections.size(),
1947  std::size_t(this->num_node_cmaps));
1948 
1949  if (verbose)
1950  {
1951  libMesh::out << "[" << this->processor_id()
1952  << "] border_node_ids.size()=" << this->border_node_ids.size()
1953  << std::endl;
1954  }
1955  } // end scope for border node ID creation
1956 
1957  // Store the number of border node IDs to be written to Nemesis file
1958  this->num_border_nodes = cast_int<int>(this->border_node_ids.size());
1959 }
processor_id_type n_processors() const
std::set< unsigned > border_node_ids
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ compute_communication_map_parameters()

void libMesh::Nemesis_IO_Helper::compute_communication_map_parameters ( )
private

This function determines the communication map parameters which will eventually be written to file

Definition at line 1171 of file nemesis_io_helper.C.

References elem_cmap_elem_cnts, elem_cmap_ids, end, node_cmap_ids, node_cmap_node_cnts, num_elem_cmaps, num_node_cmaps, libMesh::out, proc_border_elem_sets, proc_nodes_touched_intersections, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1172 {
1173  // For the nodes, these are the number of entries in the sets in proc_nodes_touched_intersections
1174  // map computed above. Note: this map does not contain self-intersections so we can loop over it
1175  // directly.
1176  this->node_cmap_node_cnts.clear(); // Make sure we don't have any leftover information...
1177  this->node_cmap_ids.clear(); // Make sure we don't have any leftover information...
1178  this->node_cmap_node_cnts.resize(this->num_node_cmaps);
1179  this->node_cmap_ids.resize(this->num_node_cmaps);
1180 
1181  {
1182  unsigned cnt=0; // Index into the vector
1184  it = this->proc_nodes_touched_intersections.begin(),
1185  end = this->proc_nodes_touched_intersections.end();
1186 
1187  for (; it != end; ++it)
1188  {
1189  this->node_cmap_ids[cnt] = it->first; // The ID of the proc we communicate with
1190  this->node_cmap_node_cnts[cnt] = cast_int<int>(it->second.size()); // The number of nodes we communicate
1191  cnt++; // increment vector index!
1192  }
1193  }
1194 
1195  // Print the packed vectors we just filled
1196  if (verbose)
1197  {
1198  libMesh::out << "[" << this->processor_id() << "] node_cmap_node_cnts = ";
1199  for (std::size_t i=0; i<node_cmap_node_cnts.size(); ++i)
1200  libMesh::out << node_cmap_node_cnts[i] << ", ";
1201  libMesh::out << std::endl;
1202 
1203  libMesh::out << "[" << this->processor_id() << "] node_cmap_ids = ";
1204  for (std::size_t i=0; i<node_cmap_ids.size(); ++i)
1205  libMesh::out << node_cmap_ids[i] << ", ";
1206  libMesh::out << std::endl;
1207  }
1208 
1209  // For the elements, we have not yet computed all this information..
1210  this->elem_cmap_elem_cnts.clear(); // Make sure we don't have any leftover information...
1211  this->elem_cmap_ids.clear(); // Make sure we don't have any leftover information...
1212  this->elem_cmap_elem_cnts.resize(this->num_elem_cmaps);
1213  this->elem_cmap_ids.resize(this->num_elem_cmaps);
1214 
1215  // Pack the elem_cmap_ids and elem_cmap_elem_cnts vectors
1216  {
1217  unsigned cnt=0; // Index into the vectors we're filling
1219  it = this->proc_border_elem_sets.begin(),
1220  end = this->proc_border_elem_sets.end();
1221 
1222  for (; it != end; ++it)
1223  {
1224  this->elem_cmap_ids[cnt] = it->first; // The ID of the proc we communicate with
1225  this->elem_cmap_elem_cnts[cnt] = cast_int<int>(it->second.size()); // The number of elems we communicate to/from that proc
1226  cnt++; // increment vector index!
1227  }
1228  }
1229 
1230  // Print the packed vectors we just filled
1231  if (verbose)
1232  {
1233  libMesh::out << "[" << this->processor_id() << "] elem_cmap_elem_cnts = ";
1234  for (std::size_t i=0; i<elem_cmap_elem_cnts.size(); ++i)
1235  libMesh::out << elem_cmap_elem_cnts[i] << ", ";
1236  libMesh::out << std::endl;
1237 
1238  libMesh::out << "[" << this->processor_id() << "] elem_cmap_ids = ";
1239  for (std::size_t i=0; i<elem_cmap_ids.size(); ++i)
1240  libMesh::out << elem_cmap_ids[i] << ", ";
1241  libMesh::out << std::endl;
1242  }
1243 }
std::vector< int > node_cmap_ids
IterBase * end
std::map< unsigned, std::set< unsigned > >::iterator proc_nodes_touched_iterator
std::vector< int > elem_cmap_elem_cnts
std::vector< int > elem_cmap_ids
std::vector< int > node_cmap_node_cnts
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
processor_id_type processor_id() const
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > >::iterator proc_border_elem_sets_iterator
OStreamProxy out(std::cout)
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > > proc_border_elem_sets

◆ compute_elem_communication_maps()

void libMesh::Nemesis_IO_Helper::compute_elem_communication_maps ( )
private

This function computes element communication maps (really just packs vectors) in preparation for writing them to file.

Definition at line 1002 of file nemesis_io_helper.C.

References elem_cmap_elem_ids, elem_cmap_ids, elem_cmap_proc_ids, elem_cmap_side_ids, end, libMesh::ExodusII_IO_Helper::libmesh_elem_num_to_exodus, num_elem_cmaps, and proc_border_elem_sets.

Referenced by initialize().

1003 {
1004  // Make sure there is no leftover information
1005  this->elem_cmap_elem_ids.clear();
1006  this->elem_cmap_side_ids.clear();
1007  this->elem_cmap_proc_ids.clear();
1008 
1009  // Allocate enough space for all our element maps
1010  this->elem_cmap_elem_ids.resize(this->num_elem_cmaps);
1011  this->elem_cmap_side_ids.resize(this->num_elem_cmaps);
1012  this->elem_cmap_proc_ids.resize(this->num_elem_cmaps);
1013  {
1014  unsigned cnt=0; // Index into vectors
1016  it = this->proc_border_elem_sets.begin(),
1017  end = this->proc_border_elem_sets.end();
1018 
1019  for (; it != end; ++it)
1020  {
1021  // Make sure the current elem_cmap_id matches the index in our map of node intersections
1022  libmesh_assert_equal_to (static_cast<unsigned>(this->elem_cmap_ids[cnt]), it->first);
1023 
1024  // Get reference to the set of IDs to be packed into the vector
1025  std::set<std::pair<unsigned,unsigned>> & elem_set = it->second;
1026 
1027  // Resize the vectors to receive their payload
1028  this->elem_cmap_elem_ids[cnt].resize(elem_set.size());
1029  this->elem_cmap_side_ids[cnt].resize(elem_set.size());
1030  this->elem_cmap_proc_ids[cnt].resize(elem_set.size());
1031 
1032  std::set<std::pair<unsigned,unsigned>>::iterator elem_set_iter = elem_set.begin();
1033 
1034  // Pack the vectors with elem IDs, side IDs, and processor IDs.
1035  for (std::size_t j=0; j<this->elem_cmap_elem_ids[cnt].size(); ++j, ++elem_set_iter)
1036  {
1037  std::map<int, int>::iterator elem_it = libmesh_elem_num_to_exodus.find((*elem_set_iter).first);
1038 
1039  if (elem_it == libmesh_elem_num_to_exodus.end())
1040  libmesh_error_msg("Elem number " << (*elem_set_iter).first << " not found in libmesh_elem_num_to_exodus map.");
1041 
1042  this->elem_cmap_elem_ids[cnt][j] = elem_it->second;
1043  this->elem_cmap_side_ids[cnt][j] = (*elem_set_iter).second; // Side ID, this has already been converted above
1044  this->elem_cmap_proc_ids[cnt][j] = it->first; // All have the same processor ID
1045  }
1046 
1047  // increment vector index to go to next processor
1048  cnt++;
1049  }
1050  } // end scope for packing
1051 }
IterBase * end
std::vector< std::vector< int > > elem_cmap_side_ids
std::map< int, int > libmesh_elem_num_to_exodus
std::vector< std::vector< int > > elem_cmap_elem_ids
std::vector< std::vector< int > > elem_cmap_proc_ids
std::vector< int > elem_cmap_ids
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > >::iterator proc_border_elem_sets_iterator
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > > proc_border_elem_sets

◆ compute_element_maps()

void libMesh::Nemesis_IO_Helper::compute_element_maps ( )
private

This function computes element maps (really just packs vectors) which map the elements to internal and border elements.

Definition at line 967 of file nemesis_io_helper.C.

References border_elem_ids, elem_mapb, elem_mapi, internal_elem_ids, and libMesh::ExodusII_IO_Helper::libmesh_elem_num_to_exodus.

Referenced by initialize().

968 {
969  // Make sure we don't have any leftover info
970  this->elem_mapi.clear();
971  this->elem_mapb.clear();
972 
973  // Copy set contents into vectors
974  this->elem_mapi.resize(this->internal_elem_ids.size());
975  this->elem_mapb.resize(this->border_elem_ids.size());
976 
977  {
978  unsigned cnt = 0;
979  for (const auto & id : this->internal_elem_ids)
980  {
981  std::map<int, int>::iterator elem_it = libmesh_elem_num_to_exodus.find(id);
982  if (elem_it == libmesh_elem_num_to_exodus.end())
983  libmesh_error_msg("Elem number " << id << " not found in libmesh_elem_num_to_exodus map.");
984  this->elem_mapi[cnt++] = elem_it->second;
985  }
986  }
987 
988  {
989  unsigned cnt = 0;
990  for (const auto & id : this->border_elem_ids)
991  {
992  std::map<int, int>::iterator elem_it = libmesh_elem_num_to_exodus.find(id);
993  if (elem_it == libmesh_elem_num_to_exodus.end())
994  libmesh_error_msg("Elem number " << id << " not found in libmesh_elem_num_to_exodus map.");
995  this->elem_mapb[cnt++] = elem_it->second;
996  }
997  }
998 }
std::map< int, int > libmesh_elem_num_to_exodus
std::set< unsigned > border_elem_ids
std::vector< int > elem_mapb
std::vector< int > elem_mapi
std::set< unsigned > internal_elem_ids

◆ compute_internal_and_border_elems_and_internal_nodes()

void libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes ( const MeshBase pmesh)
private

This function constructs the set of border and internal element IDs and internal node IDs present on the current mesh.

Definition at line 1249 of file nemesis_io_helper.C.

References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), border_elem_ids, border_node_ids, libMesh::ExodusII_IO_Helper::Conversion::get_inverse_side_map(), internal_elem_ids, internal_node_ids, nodes_attached_to_local_elems, num_border_elems, num_border_nodes, num_elem_cmaps, num_internal_elems, num_internal_nodes, libMesh::out, proc_border_elem_sets, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1250 {
1251  // Set of all local, active element IDs. After we have identified border element
1252  // IDs, the set_difference between this set and the border_elem_ids set will give us
1253  // the set of internal_elem_ids.
1254  std::set<unsigned> all_elem_ids;
1255 
1256  // A set of processor IDs which elements on this processor have as
1257  // neighbors. The size of this set will determine the number of
1258  // element communication maps in Exodus.
1259  std::set<unsigned> neighboring_processor_ids;
1260 
1261  // Will be used to create conversion objects capable of mapping libmesh
1262  // element numberings into Nemesis numberings.
1263  ExodusII_IO_Helper::ElementMaps element_mapper;
1264 
1265  for (const auto & elem : pmesh.active_local_element_ptr_range())
1266  {
1267  // Add this Elem's ID to all_elem_ids, later we will take the difference
1268  // between this set and the set of border_elem_ids, to get the set of
1269  // internal_elem_ids.
1270  all_elem_ids.insert(elem->id());
1271 
1272  // Will be set to true if element is determined to be a border element
1273  bool is_border_elem = false;
1274 
1275  // Construct a conversion object for this Element. This will help us map
1276  // Libmesh numberings into Nemesis numberings for sides.
1277  ExodusII_IO_Helper::Conversion conv = element_mapper.assign_conversion(elem->type());
1278 
1279  // Add all this element's node IDs to the set of all node IDs.
1280  // The set of internal_node_ids will be the set difference between
1281  // the set of all nodes and the set of border nodes.
1282  //
1283  // In addition, if any node of a local node is listed in the
1284  // border nodes list, then this element goes into the proc_border_elem_sets.
1285  // Note that there is not a 1:1 correspondence between
1286  // border_elem_ids and the entries which go into proc_border_elem_sets.
1287  // The latter is for communication purposes, ie determining which elements
1288  // should be shared between processors.
1289  for (auto node : elem->node_index_range())
1290  this->nodes_attached_to_local_elems.insert(elem->node_id(node));
1291 
1292  // Loop over element's neighbors, see if it has a neighbor which is off-processor
1293  for (auto n : elem->side_index_range())
1294  {
1295  if (elem->neighbor_ptr(n) != nullptr)
1296  {
1297  unsigned neighbor_proc_id = elem->neighbor_ptr(n)->processor_id();
1298 
1299  // If my neighbor has a different processor ID, I must be a border element.
1300  // Also track the neighboring processor ID if it is are different from our processor ID
1301  if (neighbor_proc_id != this->processor_id())
1302  {
1303  is_border_elem = true;
1304  neighboring_processor_ids.insert(neighbor_proc_id);
1305 
1306  // Convert libmesh side(n) of this element into a side ID for Nemesis
1307  unsigned nemesis_side_id = conv.get_inverse_side_map(n);
1308 
1309  if (verbose)
1310  libMesh::out << "[" << this->processor_id() << "] LibMesh side "
1311  << n
1312  << " mapped to (1-based) Exodus side "
1313  << nemesis_side_id
1314  << std::endl;
1315 
1316  // Add this element's ID and the ID of the side which is on the boundary
1317  // to the set of border elements for this processor.
1318  // Note: if the set does not already exist, this creates it.
1319  this->proc_border_elem_sets[ neighbor_proc_id ].insert( std::make_pair(elem->id(), nemesis_side_id) );
1320  }
1321  }
1322  } // end for loop over neighbors
1323 
1324  // If we're on a border element, add it to the set
1325  if (is_border_elem)
1326  this->border_elem_ids.insert( elem->id() );
1327 
1328  } // end for loop over active local elements
1329 
1330  // Take the set_difference between all elements and border elements to get internal
1331  // element IDs
1332  std::set_difference(all_elem_ids.begin(), all_elem_ids.end(),
1333  this->border_elem_ids.begin(), this->border_elem_ids.end(),
1334  std::inserter(this->internal_elem_ids, this->internal_elem_ids.end()));
1335 
1336  // Take the set_difference between all nodes and border nodes to get internal nodes
1337  std::set_difference(this->nodes_attached_to_local_elems.begin(), this->nodes_attached_to_local_elems.end(),
1338  this->border_node_ids.begin(), this->border_node_ids.end(),
1339  std::inserter(this->internal_node_ids, this->internal_node_ids.end()));
1340 
1341  if (verbose)
1342  {
1343  libMesh::out << "[" << this->processor_id() << "] neighboring_processor_ids = ";
1344  for (const auto & id : neighboring_processor_ids)
1345  libMesh::out << id << " ";
1346  libMesh::out << std::endl;
1347  }
1348 
1349  // The size of the neighboring_processor_ids set should be the number of element communication maps
1350  this->num_elem_cmaps =
1351  cast_int<int>(neighboring_processor_ids.size());
1352 
1353  if (verbose)
1354  libMesh::out << "[" << this->processor_id() << "] "
1355  << "Number of neighboring processor IDs="
1356  << this->num_elem_cmaps
1357  << std::endl;
1358 
1359  if (verbose)
1360  {
1361  // Print out counts of border elements for each processor
1362  for (const auto & pr : proc_border_elem_sets)
1363  {
1364  libMesh::out << "[" << this->processor_id() << "] "
1365  << "Proc "
1366  << pr.first << " communicates "
1367  << pr.second.size() << " elements." << std::endl;
1368  }
1369  }
1370 
1371  // Store the number of internal and border elements, and the number of internal nodes,
1372  // to be written to the Nemesis file.
1373  this->num_internal_elems =
1374  cast_int<int>(this->internal_elem_ids.size());
1375  this->num_border_elems =
1376  cast_int<int>(this->border_elem_ids.size());
1377  this->num_internal_nodes =
1378  cast_int<int>(this->internal_node_ids.size());
1379 
1380  if (verbose)
1381  {
1382  libMesh::out << "[" << this->processor_id() << "] num_internal_nodes=" << this->num_internal_nodes << std::endl;
1383  libMesh::out << "[" << this->processor_id() << "] num_border_nodes=" << this->num_border_nodes << std::endl;
1384  libMesh::out << "[" << this->processor_id() << "] num_border_elems=" << this->num_border_elems << std::endl;
1385  libMesh::out << "[" << this->processor_id() << "] num_internal_elems=" << this->num_internal_elems << std::endl;
1386  }
1387 }
std::set< unsigned > border_elem_ids
std::set< unsigned > internal_node_ids
std::set< unsigned > border_node_ids
std::set< int > nodes_attached_to_local_elems
processor_id_type processor_id() const
OStreamProxy out(std::cout)
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > > proc_border_elem_sets
std::set< unsigned > internal_elem_ids

◆ compute_node_communication_maps()

void libMesh::Nemesis_IO_Helper::compute_node_communication_maps ( )
private

Compute the node communication maps (really just pack vectors) in preparation for writing them to file.

Definition at line 1096 of file nemesis_io_helper.C.

References end, libMesh::ExodusII_IO_Helper::libmesh_node_num_to_exodus, node_cmap_ids, node_cmap_node_ids, node_cmap_proc_ids, node_set, num_node_cmaps, libMesh::out, proc_nodes_touched_intersections, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1097 {
1098  // Make sure there's no left-over information
1099  this->node_cmap_node_ids.clear();
1100  this->node_cmap_proc_ids.clear();
1101 
1102  libmesh_assert_less_equal
1103  (this->proc_nodes_touched_intersections.size(),
1104  std::size_t(this->num_node_cmaps));
1105 
1106  // Allocate enough space for all our node maps
1107  this->node_cmap_node_ids.resize(this->num_node_cmaps);
1108  this->node_cmap_proc_ids.resize(this->num_node_cmaps);
1109  {
1110  unsigned cnt=0; // Index into vectors
1112  it = this->proc_nodes_touched_intersections.begin(),
1113  end = this->proc_nodes_touched_intersections.end();
1114 
1115  for (; it != end; ++it)
1116  {
1117  // Make sure the current node_cmap_id matches the index in our map of node intersections
1118  libmesh_assert_equal_to (static_cast<unsigned>(this->node_cmap_ids[cnt]), it->first);
1119 
1120  // Get reference to the set of IDs to be packed into the vector.
1121  std::set<unsigned> & node_set = it->second;
1122 
1123  // Resize the vectors to receive their payload
1124  this->node_cmap_node_ids[cnt].resize(node_set.size());
1125  this->node_cmap_proc_ids[cnt].resize(node_set.size());
1126 
1127  std::set<unsigned>::iterator node_set_iter = node_set.begin();
1128 
1129  // Pack the vectors with node IDs and processor IDs.
1130  for (std::size_t j=0; j<this->node_cmap_node_ids[cnt].size(); ++j, ++node_set_iter)
1131  {
1132  std::map<int, int>::iterator node_it = libmesh_node_num_to_exodus.find(*node_set_iter);
1133  if (node_it == libmesh_node_num_to_exodus.end())
1134  libmesh_error_msg("Node number " << *node_set_iter << " not found in libmesh_node_num_to_exodus map.");
1135 
1136  this->node_cmap_node_ids[cnt][j] = node_it->second;
1137  this->node_cmap_proc_ids[cnt][j] = it->first;
1138  }
1139 
1140  // increment vector index to go to next processor
1141  cnt++;
1142  }
1143  } // end scope for packing
1144 
1145  // Print out the vectors we just packed
1146  if (verbose)
1147  {
1148  for (std::size_t i=0; i<this->node_cmap_node_ids.size(); ++i)
1149  {
1150  libMesh::out << "[" << this->processor_id() << "] nodes communicated to proc "
1151  << this->node_cmap_ids[i]
1152  << " = ";
1153  for (std::size_t j=0; j<this->node_cmap_node_ids[i].size(); ++j)
1154  libMesh::out << this->node_cmap_node_ids[i][j] << " ";
1155  libMesh::out << std::endl;
1156  }
1157 
1158  for (std::size_t i=0; i<this->node_cmap_node_ids.size(); ++i)
1159  {
1160  libMesh::out << "[" << this->processor_id() << "] processor ID node communicated to = ";
1161  for (std::size_t j=0; j<this->node_cmap_proc_ids[i].size(); ++j)
1162  libMesh::out << this->node_cmap_proc_ids[i][j] << " ";
1163  libMesh::out << std::endl;
1164  }
1165  }
1166 }
std::vector< int > node_cmap_ids
IterBase * end
std::vector< std::vector< int > > node_cmap_proc_ids
std::map< int, int > libmesh_node_num_to_exodus
std::map< unsigned, std::set< unsigned > >::iterator proc_nodes_touched_iterator
std::unordered_set< const Node * > & node_set
Definition: mesh_tools.C:2142
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
std::vector< std::vector< int > > node_cmap_node_ids
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ compute_node_maps()

void libMesh::Nemesis_IO_Helper::compute_node_maps ( )
private

Compute the node maps (really just pack vectors) which map the nodes to internal, border, and external nodes in the file.

Definition at line 1057 of file nemesis_io_helper.C.

References border_node_ids, internal_node_ids, libMesh::ExodusII_IO_Helper::libmesh_node_num_to_exodus, node_mapb, node_mape, and node_mapi.

Referenced by initialize().

1058 {
1059  // Make sure we don't have any leftover information
1060  this->node_mapi.clear();
1061  this->node_mapb.clear();
1062  this->node_mape.clear();
1063 
1064  // Make sure there's enough space to hold all our node IDs
1065  this->node_mapi.resize(this->internal_node_ids.size());
1066  this->node_mapb.resize(this->border_node_ids.size());
1067 
1068  // Copy set contents into vectors
1069  {
1070  unsigned cnt = 0;
1071  for (const auto & id : this->internal_node_ids)
1072  {
1073  std::map<int, int>::iterator node_it = libmesh_node_num_to_exodus.find(id);
1074  if (node_it == libmesh_node_num_to_exodus.end())
1075  libmesh_error_msg("Node number " << id << " not found in libmesh_node_num_to_exodus map.");
1076  this->node_mapi[cnt++] = node_it->second;
1077  }
1078  }
1079 
1080  {
1081  unsigned cnt=0;
1082  for (const auto & id : this->border_node_ids)
1083  {
1084  std::map<int, int>::iterator node_it = libmesh_node_num_to_exodus.find(id);
1085  if (node_it == libmesh_node_num_to_exodus.end())
1086  libmesh_error_msg("Node number " << id << " not found in libmesh_node_num_to_exodus map.");
1087  this->node_mapb[cnt++] = node_it->second;
1088  }
1089  }
1090 }
std::vector< int > node_mape
std::set< unsigned > internal_node_ids
std::vector< int > node_mapi
std::set< unsigned > border_node_ids
std::map< int, int > libmesh_node_num_to_exodus
std::vector< int > node_mapb

◆ compute_num_global_elem_blocks()

void libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks ( const MeshBase pmesh)
private

This function uses global communication routines to determine the number of element blocks across the entire mesh.

Definition at line 1595 of file nemesis_io_helper.C.

References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::Parallel::Communicator::allgather(), libMesh::ParallelObject::comm(), global_elem_blk_cnts, global_elem_blk_ids, local_subdomain_counts, num_elem_blks_global, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::sum(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1596 {
1597  // 1.) Loop over active local elements, build up set of subdomain IDs.
1598  std::set<subdomain_id_type> global_subdomain_ids;
1599 
1600  // This map keeps track of the number of elements in each subdomain over all processors
1601  std::map<subdomain_id_type, unsigned> global_subdomain_counts;
1602 
1603  for (const auto & elem : pmesh.active_local_element_ptr_range())
1604  {
1605  subdomain_id_type cur_subdomain = elem->subdomain_id();
1606 
1607  /*
1608  // We can't have a zero subdomain ID in Exodus (for some reason?)
1609  // so map zero subdomains to a max value...
1610  if (cur_subdomain == 0)
1611  cur_subdomain = std::numeric_limits<subdomain_id_type>::max();
1612  */
1613 
1614  global_subdomain_ids.insert(cur_subdomain);
1615 
1616  // Increment the count of elements in this subdomain
1617  global_subdomain_counts[cur_subdomain]++;
1618  }
1619 
1620  // We're next going to this->comm().sum the subdomain counts, so save the local counts
1621  this->local_subdomain_counts = global_subdomain_counts;
1622 
1623  {
1624  // 2.) Copy local subdomain IDs into a vector for communication
1625  std::vector<subdomain_id_type> global_subdomain_ids_vector(global_subdomain_ids.begin(),
1626  global_subdomain_ids.end());
1627 
1628  // 3.) Gather them into an enlarged vector
1629  this->comm().allgather(global_subdomain_ids_vector);
1630 
1631  // 4.) Insert any new IDs into the set (any duplicates will be dropped)
1632  global_subdomain_ids.insert(global_subdomain_ids_vector.begin(),
1633  global_subdomain_ids_vector.end());
1634  }
1635 
1636  // 5.) Now global_subdomain_ids actually contains a global list of all subdomain IDs
1637  this->num_elem_blks_global =
1638  cast_int<int>(global_subdomain_ids.size());
1639 
1640  // Print the number of elements found locally in each subdomain
1641  if (verbose)
1642  {
1643  libMesh::out << "[" << this->processor_id() << "] ";
1644  for (const auto & pr : global_subdomain_counts)
1645  {
1646  libMesh::out << "ID: "
1647  << static_cast<unsigned>(pr.first)
1648  << ", Count: " << pr.second << ", ";
1649  }
1650  libMesh::out << std::endl;
1651  }
1652 
1653  // 6.) this->comm().sum up the number of elements in each block. We know the global
1654  // subdomain IDs, so pack them into a vector one by one. Use a vector of int since
1655  // that is what Nemesis wants
1656  this->global_elem_blk_cnts.resize(global_subdomain_ids.size());
1657 
1658  unsigned cnt=0;
1659  // Find the entry in the local map, note: if not found, will be created with 0 default value, which is OK...
1660  for (const auto & id : global_subdomain_ids)
1661  this->global_elem_blk_cnts[cnt++] = global_subdomain_counts[id];
1662 
1663  // Sum up subdomain counts from all processors
1664  this->comm().sum(this->global_elem_blk_cnts);
1665 
1666  if (verbose)
1667  {
1668  libMesh::out << "[" << this->processor_id() << "] global_elem_blk_cnts = ";
1669  for (std::size_t i=0; i<this->global_elem_blk_cnts.size(); ++i)
1670  libMesh::out << this->global_elem_blk_cnts[i] << ", ";
1671  libMesh::out << std::endl;
1672  }
1673 
1674  // 7.) Create a vector<int> from the global_subdomain_ids set, for passing to Nemesis
1675  this->global_elem_blk_ids.clear();
1676  this->global_elem_blk_ids.insert(this->global_elem_blk_ids.end(), // pos
1677  global_subdomain_ids.begin(),
1678  global_subdomain_ids.end());
1679 
1680  if (verbose)
1681  {
1682  libMesh::out << "[" << this->processor_id() << "] global_elem_blk_ids = ";
1683  for (std::size_t i=0; i<this->global_elem_blk_ids.size(); ++i)
1684  libMesh::out << this->global_elem_blk_ids[i] << ", ";
1685  libMesh::out << std::endl;
1686  }
1687 
1688 
1689  // 8.) We will call put_eb_info_global later, it must be called after this->put_init_global().
1690 }
TestClass subdomain_id_type
Definition: id_types.h:43
void allgather(const T &send, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
std::vector< int > global_elem_blk_ids
std::map< subdomain_id_type, unsigned > local_subdomain_counts
processor_id_type processor_id() const
OStreamProxy out(std::cout)
std::vector< int > global_elem_blk_cnts

◆ compute_num_global_nodesets()

void libMesh::Nemesis_IO_Helper::compute_num_global_nodesets ( const MeshBase pmesh)
private

This function uses global communication routines to determine the number of nodesets across the entire mesh.

Definition at line 1484 of file nemesis_io_helper.C.

References libMesh::BoundaryInfo::build_node_list(), libMesh::ParallelObject::comm(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_node_boundary_ids(), global_nodeset_ids, libMesh::MeshBase::node_ptr(), num_global_node_counts, num_node_sets_global, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Parallel::Communicator::set_union(), libMesh::Parallel::Communicator::sum(), swap(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1485 {
1486  std::set<boundary_id_type> local_node_boundary_ids;
1487 
1488  // 1.) Get reference to the set of node boundary IDs *for this processor*
1489  std::set<boundary_id_type> global_node_boundary_ids
1490  (pmesh.get_boundary_info().get_node_boundary_ids().begin(),
1491  pmesh.get_boundary_info().get_node_boundary_ids().end());
1492 
1493  // Save a copy of the local_node_boundary_ids...
1494  local_node_boundary_ids = global_node_boundary_ids;
1495 
1496  // 2.) Gather boundary node IDs from other processors
1497  this->comm().set_union(global_node_boundary_ids);
1498 
1499  // 3.) Now global_node_boundary_ids actually contains a global list of all node boundary IDs
1500  this->num_node_sets_global =
1501  cast_int<int>(global_node_boundary_ids.size());
1502 
1503  // 4.) Create a vector<int> from the global_node_boundary_ids set
1504  this->global_nodeset_ids.clear();
1505  this->global_nodeset_ids.insert(this->global_nodeset_ids.end(),
1506  global_node_boundary_ids.begin(),
1507  global_node_boundary_ids.end());
1508 
1509  if (verbose)
1510  {
1511  libMesh::out << "[" << this->processor_id() << "] global_nodeset_ids = ";
1512  for (std::size_t i=0; i<global_nodeset_ids.size(); ++i)
1513  libMesh::out << global_nodeset_ids[i] << ", ";
1514  libMesh::out << std::endl;
1515 
1516  libMesh::out << "[" << this->processor_id() << "] local_node_boundary_ids = ";
1517  for (const auto & id : local_node_boundary_ids)
1518  libMesh::out << id << ", ";
1519  libMesh::out << std::endl;
1520  }
1521 
1522  // 7.) We also need to know the number of nodes which is in each of the nodesets, globally.
1523 
1524  // Build list of (node-id, bc-id) tuples.
1525  typedef std::tuple<dof_id_type, boundary_id_type> Tuple;
1526  std::vector<Tuple> bc_tuples = pmesh.get_boundary_info().build_node_list();
1527 
1528  if (verbose)
1529  {
1530  libMesh::out << "[" << this->processor_id() << "] boundary_node_list.size()="
1531  << bc_tuples.size() << std::endl;
1532  libMesh::out << "[" << this->processor_id() << "] (boundary_node_id, boundary_id) = ";
1533  for (const auto & t : bc_tuples)
1534  libMesh::out << "(" << std::get<0>(t) << ", " << std::get<1>(t) << ") ";
1535  libMesh::out << std::endl;
1536  }
1537 
1538  // Now get the global information. In this case, we only want to count boundary
1539  // information for nodes *owned* by this processor, so there are no duplicates.
1540 
1541  // Make sure we don't have any left over information
1542  this->num_global_node_counts.clear();
1543  this->num_global_node_counts.resize(this->global_nodeset_ids.size());
1544 
1545  // Unfortunately, we can't just count up all occurrences of a given id,
1546  // that would give us duplicate entries when we do the parallel summation.
1547  // So instead, only count entries for nodes owned by this processor.
1548  // Start by getting rid of all non-local node entries from the vectors.
1549  std::vector<Tuple>::iterator
1550  it = bc_tuples.begin(),
1551  new_end = bc_tuples.end();
1552 
1553  while (it != new_end)
1554  {
1555  if (pmesh.node_ptr(std::get<0>(*it))->processor_id() != this->processor_id())
1556  {
1557  // Back up the new end iterators to prepare for swap
1558  --new_end;
1559 
1560  // Swap places, the non-local node will now be "past-the-end"
1561  std::swap(*it, *new_end);
1562  }
1563  else // node is local, go to next
1564  ++it;
1565  }
1566 
1567  // Erase from "new" end to old end.
1568  bc_tuples.erase(new_end, bc_tuples.end());
1569 
1570  // Now we can do the local count for each ID...
1571  for (std::size_t i=0; i<global_nodeset_ids.size(); ++i)
1572  {
1573  int id = this->global_nodeset_ids[i];
1574  this->num_global_node_counts[i] =
1575  cast_int<int>(std::count_if(bc_tuples.begin(),
1576  bc_tuples.end(),
1577  [id](const Tuple & t)->bool { return std::get<1>(t) == id; }));
1578  }
1579 
1580  // And finally we can sum them up
1581  this->comm().sum(this->num_global_node_counts);
1582 
1583  if (verbose)
1584  {
1585  libMesh::out << "[" << this->processor_id() << "] num_global_node_counts = ";
1586  for (std::size_t i=0; i<num_global_node_counts.size(); ++i)
1587  libMesh::out << num_global_node_counts[i] << ", ";
1588  libMesh::out << std::endl;
1589  }
1590 }
void set_union(T &data, const unsigned int root_id) const
std::vector< int > num_global_node_counts
std::vector< int > global_nodeset_ids
const Parallel::Communicator & comm() const
void swap(Iterator &lhs, Iterator &rhs)
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ compute_num_global_sidesets()

void libMesh::Nemesis_IO_Helper::compute_num_global_sidesets ( const MeshBase pmesh)
private

This function uses global communication routines to determine the number of sidesets across the entire mesh.

Definition at line 1391 of file nemesis_io_helper.C.

References libMesh::BoundaryInfo::build_side_list(), libMesh::ParallelObject::comm(), libMesh::MeshBase::elem_ref(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_side_boundary_ids(), global_sideset_ids, num_global_side_counts, num_side_sets_global, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Parallel::Communicator::set_union(), libMesh::Parallel::Communicator::sum(), swap(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1392 {
1393  // 1.) Get reference to the set of side boundary IDs
1394  std::set<boundary_id_type> global_side_boundary_ids
1395  (pmesh.get_boundary_info().get_side_boundary_ids().begin(),
1396  pmesh.get_boundary_info().get_side_boundary_ids().end());
1397 
1398  // 2.) Gather boundary side IDs from other processors
1399  this->comm().set_union(global_side_boundary_ids);
1400 
1401  // 3.) Now global_side_boundary_ids actually contains a global list of all side boundary IDs
1402  this->num_side_sets_global =
1403  cast_int<int>(global_side_boundary_ids.size());
1404 
1405  // 4.) Pack these sidesets into a vector so they can be written by Nemesis
1406  this->global_sideset_ids.clear(); // Make sure there is no leftover information
1407  this->global_sideset_ids.insert(this->global_sideset_ids.end(),
1408  global_side_boundary_ids.begin(),
1409  global_side_boundary_ids.end());
1410 
1411  if (verbose)
1412  {
1413  libMesh::out << "[" << this->processor_id() << "] global_sideset_ids = ";
1414  for (std::size_t i=0; i<this->global_sideset_ids.size(); ++i)
1415  libMesh::out << this->global_sideset_ids[i] << ", ";
1416  libMesh::out << std::endl;
1417  }
1418 
1419  // We also need global counts of sides in each of the sidesets.
1420  // Build a list of (elem, side, bc) tuples.
1421  typedef std::tuple<dof_id_type, unsigned short int, boundary_id_type> Tuple;
1422  std::vector<Tuple> bc_triples = pmesh.get_boundary_info().build_side_list();
1423 
1424  // Iterators to the beginning and end of the current range.
1425  std::vector<Tuple>::iterator
1426  it = bc_triples.begin(),
1427  new_end = bc_triples.end();
1428 
1429  while (it != new_end)
1430  {
1431  if (pmesh.elem_ref(std::get<0>(*it)).processor_id() != this->processor_id())
1432  {
1433  // Back up the new end iterators to prepare for swap
1434  --new_end;
1435 
1436  // Swap places, the non-local elem will now be "past-the-end"
1437  std::swap (*it, *new_end);
1438  }
1439  else // elem is local, go to next
1440  ++it;
1441  }
1442 
1443  // Erase from "new" end to old.
1444  bc_triples.erase(new_end, bc_triples.end());
1445 
1446  this->num_global_side_counts.clear(); // Make sure we don't have any leftover information
1447  this->num_global_side_counts.resize(this->global_sideset_ids.size());
1448 
1449  // Get the count for each global sideset ID
1450  for (std::size_t i=0; i<global_sideset_ids.size(); ++i)
1451  {
1452  int id = global_sideset_ids[i];
1453  this->num_global_side_counts[i] =
1454  cast_int<int>(std::count_if(bc_triples.begin(),
1455  bc_triples.end(),
1456  [id](const Tuple & t)->bool { return std::get<2>(t) == id; }));
1457  }
1458 
1459  if (verbose)
1460  {
1461  libMesh::out << "[" << this->processor_id() << "] num_global_side_counts = ";
1462  for (std::size_t i=0; i<this->num_global_side_counts.size(); ++i)
1463  libMesh::out << this->num_global_side_counts[i] << ", ";
1464  libMesh::out << std::endl;
1465  }
1466 
1467  // Finally sum up the result
1468  this->comm().sum(this->num_global_side_counts);
1469 
1470  if (verbose)
1471  {
1472  libMesh::out << "[" << this->processor_id() << "] num_global_side_counts = ";
1473  for (std::size_t i=0; i<this->num_global_side_counts.size(); ++i)
1474  libMesh::out << this->num_global_side_counts[i] << ", ";
1475  libMesh::out << std::endl;
1476  }
1477 }
void set_union(T &data, const unsigned int root_id) const
std::vector< int > global_sideset_ids
const Parallel::Communicator & comm() const
std::vector< int > num_global_side_counts
void swap(Iterator &lhs, Iterator &rhs)
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ construct_nemesis_filename()

std::string libMesh::Nemesis_IO_Helper::construct_nemesis_filename ( const std::string &  base_filename)

Given base_filename, foo.e, constructs the Nemesis filename foo.e.X.Y, where X=n. CPUs and Y=processor ID

Definition at line 2648 of file nemesis_io_helper.C.

References libMesh::ParallelObject::n_processors(), libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

2649 {
2650  // Build a filename for this processor. This code is cut-n-pasted from the read function
2651  // and should probably be put into a separate function...
2652  std::ostringstream file_oss;
2653 
2654  // We have to be a little careful here: Nemesis left pads its file
2655  // numbers based on the number of processors, so for example on 10
2656  // processors, we'd have:
2657  // mesh.e.10.00
2658  // mesh.e.10.01
2659  // mesh.e.10.02
2660  // ...
2661  // mesh.e.10.09
2662 
2663  // And on 100 you'd have:
2664  // mesh.e.100.000
2665  // mesh.e.100.001
2666  // ...
2667  // mesh.e.128.099
2668 
2669  // Find the length of the highest processor ID
2670  file_oss << (this->n_processors());
2671  unsigned int field_width = cast_int<unsigned int>(file_oss.str().size());
2672 
2673  if (verbose)
2674  libMesh::out << "field_width=" << field_width << std::endl;
2675 
2676  file_oss.str(""); // reset the string stream
2677  file_oss << base_filename
2678  << '.' << this->n_processors()
2679  << '.' << std::setfill('0') << std::setw(field_width) << this->processor_id();
2680 
2681  // Return the resulting string
2682  return file_oss.str();
2683 }
processor_id_type n_processors() const
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ create()

void libMesh::Nemesis_IO_Helper::create ( std::string  filename)
overridevirtual

This function is specialized from ExodusII_IO_Helper to create the nodal coordinates stored on the local piece of the Mesh.

Reimplemented from libMesh::ExodusII_IO_Helper.

Definition at line 727 of file nemesis_io_helper.C.

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

728 {
729  // Fall back on double precision when necessary since ExodusII
730  // doesn't seem to support long double
731  int
732  comp_ws = 0,
733  io_ws = 0;
734 
735  if (_single_precision)
736  {
737  comp_ws = sizeof(float);
738  io_ws = sizeof(float);
739  }
740  else
741  {
742  comp_ws = cast_int<int>(std::min(sizeof(Real), sizeof(double)));
743  io_ws = cast_int<int>(std::min(sizeof(Real), sizeof(double)));
744  }
745 
746  this->ex_id = exII::ex_create(filename.c_str(), EX_CLOBBER, &comp_ws, &io_ws);
747 
748  EX_CHECK_ERR(ex_id, "Error creating Nemesis mesh file.");
749 
750  if (verbose)
751  libMesh::out << "File created successfully." << std::endl;
752 
753  this->opened_for_writing = true;
754 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out(std::cout)
long double min(long double a, double b)

◆ get_block_id()

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

Get the block number for the given block index.

Definition at line 544 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::block_ids.

Referenced by libMesh::ExodusII_IO_Helper::write_element_values().

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

◆ get_block_name()

std::string libMesh::ExodusII_IO_Helper::get_block_name ( int  index)
inherited

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

Definition at line 553 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::block_ids, and libMesh::ExodusII_IO_Helper::id_to_block_names.

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

◆ get_cmap_params()

void libMesh::Nemesis_IO_Helper::get_cmap_params ( )

Definition at line 322 of file nemesis_io_helper.C.

References elem_cmap_elem_cnts, elem_cmap_ids, libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, node_cmap_ids, node_cmap_node_cnts, num_elem_cmaps, num_node_cmaps, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

323 {
328 
330  Nemesis::ne_get_cmap_params(ex_id,
331  node_cmap_ids.empty() ? nullptr : node_cmap_ids.data(),
332  node_cmap_node_cnts.empty() ? nullptr : node_cmap_node_cnts.data(),
333  elem_cmap_ids.empty() ? nullptr : elem_cmap_ids.data(),
334  elem_cmap_elem_cnts.empty() ? nullptr : elem_cmap_elem_cnts.data(),
335  this->processor_id());
336  EX_CHECK_ERR(nemesis_err_flag, "Error reading cmap parameters!");
337 
338 
339  if (verbose)
340  {
341  libMesh::out << "[" << this->processor_id() << "] ";
342  for (std::size_t i=0; i<node_cmap_ids.size(); ++i)
343  libMesh::out << "node_cmap_ids["<<i<<"]=" << node_cmap_ids[i] << " ";
344  libMesh::out << std::endl;
345 
346  libMesh::out << "[" << this->processor_id() << "] ";
347  for (std::size_t i=0; i<node_cmap_node_cnts.size(); ++i)
348  libMesh::out << "node_cmap_node_cnts["<<i<<"]=" << node_cmap_node_cnts[i] << " ";
349  libMesh::out << std::endl;
350 
351  libMesh::out << "[" << this->processor_id() << "] ";
352  for (std::size_t i=0; i<elem_cmap_ids.size(); ++i)
353  libMesh::out << "elem_cmap_ids["<<i<<"]=" << elem_cmap_ids[i] << " ";
354  libMesh::out << std::endl;
355 
356  libMesh::out << "[" << this->processor_id() << "] ";
357  for (std::size_t i=0; i<elem_cmap_elem_cnts.size(); ++i)
358  libMesh::out << "elem_cmap_elem_cnts["<<i<<"]=" << elem_cmap_elem_cnts[i] << " ";
359  libMesh::out << std::endl;
360  }
361 }
std::vector< int > node_cmap_ids
std::vector< int > elem_cmap_elem_cnts
std::vector< int > elem_cmap_ids
std::vector< int > node_cmap_node_cnts
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_complex_names()

std::vector< std::string > libMesh::ExodusII_IO_Helper::get_complex_names ( const std::vector< std::string > &  names) const
inherited
Returns
A vector with three copies of each element in the provided name vector, starting with r_, i_ and a_ respectively.

Definition at line 2064 of file exodusII_io_helper.C.

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

◆ get_complex_vars_active_subdomains()

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

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

Definition at line 2090 of file exodusII_io_helper.C.

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

◆ get_eb_info_global()

void libMesh::Nemesis_IO_Helper::get_eb_info_global ( )

Definition at line 176 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, global_elem_blk_cnts, global_elem_blk_ids, nemesis_err_flag, num_elem_blks_global, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

177 {
180 
181  if (num_elem_blks_global > 0)
182  {
184  Nemesis::ne_get_eb_info_global(ex_id,
185  global_elem_blk_ids.data(),
186  global_elem_blk_cnts.data());
187  EX_CHECK_ERR(nemesis_err_flag, "Error reading global element block info!");
188  }
189 
190  if (verbose)
191  {
192  libMesh::out << "[" << this->processor_id() << "] " << "Global Element Block IDs and Counts:" << std::endl;
193  for (std::size_t bn=0; bn<global_elem_blk_ids.size(); ++bn)
194  {
195  libMesh::out << " [" << this->processor_id() << "] "
196  << "global_elem_blk_ids["<<bn<<"]=" << global_elem_blk_ids[bn]
197  << ", global_elem_blk_cnts["<<bn<<"]=" << global_elem_blk_cnts[bn]
198  << std::endl;
199  }
200  }
201 }
std::vector< int > global_elem_blk_ids
processor_id_type processor_id() const
OStreamProxy out(std::cout)
std::vector< int > global_elem_blk_cnts

◆ get_elem_cmap()

void libMesh::Nemesis_IO_Helper::get_elem_cmap ( )

Definition at line 407 of file nemesis_io_helper.C.

References data, elem_cmap_elem_cnts, elem_cmap_elem_ids, elem_cmap_ids, elem_cmap_proc_ids, elem_cmap_side_ids, libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, num_elem_cmaps, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

408 {
412 
413  for (std::size_t i=0; i<elem_cmap_elem_ids.size(); ++i)
414  {
418 
419  if (elem_cmap_elem_cnts[i] > 0)
420  {
422  Nemesis::ne_get_elem_cmap(ex_id,
423  elem_cmap_ids[i],
427  this->processor_id());
428  EX_CHECK_ERR(nemesis_err_flag, "Error reading elem cmap elem, side, and processor ids!");
429  }
430 
431  if (verbose)
432  {
433  libMesh::out << "[" << this->processor_id() << "] elem_cmap_elem_ids["<<i<<"]=";
434  for (std::size_t j=0; j<elem_cmap_elem_ids[i].size(); ++j)
435  libMesh::out << elem_cmap_elem_ids[i][j] << " ";
436  libMesh::out << std::endl;
437 
438  // These must be the (local) side IDs (in the ExodusII face numbering scheme)
439  // of the sides shared across processors.
440  libMesh::out << "[" << this->processor_id() << "] elem_cmap_side_ids["<<i<<"]=";
441  for (std::size_t j=0; j<elem_cmap_side_ids[i].size(); ++j)
442  libMesh::out << elem_cmap_side_ids[i][j] << " ";
443  libMesh::out << std::endl;
444 
445  // This is basically a vector, all entries of which are = elem_cmap_ids[i]
446  // Not sure if it's always guaranteed to be that or what...
447  libMesh::out << "[" << this->processor_id() << "] elem_cmap_proc_ids["<<i<<"]=";
448  for (std::size_t j=0; j<elem_cmap_proc_ids[i].size(); ++j)
449  libMesh::out << elem_cmap_proc_ids[i][j] << " ";
450  libMesh::out << std::endl;
451  }
452  }
453 }
std::vector< std::vector< int > > elem_cmap_side_ids
std::vector< std::vector< int > > elem_cmap_elem_ids
std::vector< std::vector< int > > elem_cmap_proc_ids
std::vector< int > elem_cmap_elem_cnts
std::vector< int > elem_cmap_ids
IterBase * data
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_elem_map()

void libMesh::Nemesis_IO_Helper::get_elem_map ( )

Definition at line 254 of file nemesis_io_helper.C.

References elem_mapb, elem_mapi, libMesh::ExodusII_IO_Helper::ex_id, std::min(), nemesis_err_flag, num_border_elems, num_internal_elems, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

255 {
257  elem_mapb.resize(num_border_elems);
258 
260  Nemesis::ne_get_elem_map(ex_id,
261  elem_mapi.empty() ? nullptr : elem_mapi.data(),
262  elem_mapb.empty() ? nullptr : elem_mapb.data(),
263  this->processor_id()
264  );
265  EX_CHECK_ERR(nemesis_err_flag, "Error reading element maps!");
266 
267 
268  if (verbose)
269  {
270  libMesh::out << "[" << this->processor_id() << "] elem_mapi[i] = ";
271  for (auto i : IntRange<int>(0, num_internal_elems-1))
272  libMesh::out << elem_mapi[i] << ", ";
273  libMesh::out << "... " << elem_mapi.back() << std::endl;
274 
275  libMesh::out << "[" << this->processor_id() << "] elem_mapb[i] = ";
276  for (auto i : IntRange<int>(0, std::min(10, num_border_elems-1)))
277  libMesh::out << elem_mapb[i] << ", ";
278  libMesh::out << "... " << elem_mapb.back() << std::endl;
279  }
280 }
std::vector< int > elem_mapb
processor_id_type processor_id() const
OStreamProxy out(std::cout)
long double min(long double a, double b)
std::vector< int > elem_mapi

◆ get_elem_type()

const char * libMesh::ExodusII_IO_Helper::get_elem_type ( ) const
inherited
Returns
The current element type.
Note
The default behavior is for this value to be in all capital letters, e.g. HEX27.

Definition at line 314 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::elem_type.

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

◆ get_init_global()

void libMesh::Nemesis_IO_Helper::get_init_global ( )

Reading functions. These just allocate memory for you and call the Nemesis routines of the same name. They also handle error checking for the Nemesis return value. Be careful calling these at random, some depend on others being called first... Fills: num_nodes_global, num_elems_global, num_elem_blks_global, num_node_sets_global, num_side_sets_global Call after: read_header() Call before: Any other get_* function from this class

Definition at line 85 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, num_elem_blks_global, num_elems_global, num_node_sets_global, num_nodes_global, num_side_sets_global, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

86 {
88  Nemesis::ne_get_init_global(ex_id,
94  EX_CHECK_ERR(nemesis_err_flag, "Error reading initial global data!");
95 
96  if (verbose)
97  {
98  libMesh::out << "[" << this->processor_id() << "] " << "num_nodes_global=" << num_nodes_global << std::endl;
99  libMesh::out << "[" << this->processor_id() << "] " << "num_elems_global=" << num_elems_global << std::endl;
100  libMesh::out << "[" << this->processor_id() << "] " << "num_elem_blks_global=" << num_elem_blks_global << std::endl;
101  libMesh::out << "[" << this->processor_id() << "] " << "num_node_sets_global=" << num_node_sets_global << std::endl;
102  libMesh::out << "[" << this->processor_id() << "] " << "num_side_sets_global=" << num_side_sets_global << std::endl;
103  }
104 }
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_init_info()

void libMesh::Nemesis_IO_Helper::get_init_info ( )

Definition at line 205 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, ftype, nemesis_err_flag, num_proc, num_proc_in_file, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

206 {
208  Nemesis::ne_get_init_info(ex_id,
209  &num_proc,
211  &ftype);
212  EX_CHECK_ERR(nemesis_err_flag, "Error reading initial info!");
213 
214  if (verbose)
215  {
216  libMesh::out << "[" << this->processor_id() << "] " << "num_proc=" << num_proc << std::endl;
217  libMesh::out << "[" << this->processor_id() << "] " << "num_proc_in_file=" << num_proc_in_file << std::endl;
218  libMesh::out << "[" << this->processor_id() << "] " << "ftype=" << ftype << std::endl;
219  }
220 }
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_loadbal_param()

void libMesh::Nemesis_IO_Helper::get_loadbal_param ( )

Definition at line 224 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, num_border_elems, num_border_nodes, num_elem_cmaps, num_external_nodes, num_internal_elems, num_internal_nodes, num_node_cmaps, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

225 {
227  Nemesis::ne_get_loadbal_param(ex_id,
235  this->processor_id() // The ID of the processor for which info is to be read
236  );
237  EX_CHECK_ERR(nemesis_err_flag, "Error reading load balance parameters!");
238 
239 
240  if (verbose)
241  {
242  libMesh::out << "[" << this->processor_id() << "] " << "num_internal_nodes=" << num_internal_nodes << std::endl;
243  libMesh::out << "[" << this->processor_id() << "] " << "num_border_nodes=" << num_border_nodes << std::endl;
244  libMesh::out << "[" << this->processor_id() << "] " << "num_external_nodes=" << num_external_nodes << std::endl;
245  libMesh::out << "[" << this->processor_id() << "] " << "num_internal_elems=" << num_internal_elems << std::endl;
246  libMesh::out << "[" << this->processor_id() << "] " << "num_border_elems=" << num_border_elems << std::endl;
247  libMesh::out << "[" << this->processor_id() << "] " << "num_node_cmaps=" << num_node_cmaps << std::endl;
248  libMesh::out << "[" << this->processor_id() << "] " << "num_elem_cmaps=" << num_elem_cmaps << std::endl;
249  }
250 }
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_node_cmap()

void libMesh::Nemesis_IO_Helper::get_node_cmap ( )

Definition at line 365 of file nemesis_io_helper.C.

References data, libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, node_cmap_ids, node_cmap_node_cnts, node_cmap_node_ids, node_cmap_proc_ids, num_node_cmaps, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

366 {
369 
370  for (std::size_t i=0; i<node_cmap_node_ids.size(); ++i)
371  {
374 
375  // Don't call ne_get_node_cmap() if there is nothing there to
376  // get, Nemesis throws an error in this case.
377  if (node_cmap_node_cnts[i] > 0)
378  {
380  Nemesis::ne_get_node_cmap(ex_id,
381  node_cmap_ids[i],
384  this->processor_id());
385  EX_CHECK_ERR(nemesis_err_flag, "Error reading node cmap node and processor ids!");
386  }
387 
388  if (verbose)
389  {
390  libMesh::out << "[" << this->processor_id() << "] node_cmap_node_ids["<<i<<"]=";
391  for (std::size_t j=0; j<node_cmap_node_ids[i].size(); ++j)
392  libMesh::out << node_cmap_node_ids[i][j] << " ";
393  libMesh::out << std::endl;
394 
395  // This is basically a vector, all entries of which are = node_cmap_ids[i]
396  // Not sure if it's always guaranteed to be that or what...
397  libMesh::out << "[" << this->processor_id() << "] node_cmap_proc_ids["<<i<<"]=";
398  for (std::size_t j=0; j<node_cmap_proc_ids[i].size(); ++j)
399  libMesh::out << node_cmap_proc_ids[i][j] << " ";
400  libMesh::out << std::endl;
401  }
402  }
403 }
std::vector< int > node_cmap_ids
std::vector< std::vector< int > > node_cmap_proc_ids
std::vector< int > node_cmap_node_cnts
IterBase * data
std::vector< std::vector< int > > node_cmap_node_ids
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_node_map()

void libMesh::Nemesis_IO_Helper::get_node_map ( )

Definition at line 285 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, node_mapb, node_mape, node_mapi, num_border_nodes, num_external_nodes, num_internal_nodes, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

286 {
288  node_mapb.resize(num_border_nodes);
290 
292  Nemesis::ne_get_node_map(ex_id,
293  node_mapi.empty() ? nullptr : node_mapi.data(),
294  node_mapb.empty() ? nullptr : node_mapb.data(),
295  node_mape.empty() ? nullptr : node_mape.data(),
296  this->processor_id()
297  );
298  EX_CHECK_ERR(nemesis_err_flag, "Error reading node maps!");
299 
300  if (verbose)
301  {
302  // Remark: The Exodus/Nemesis node numbering is always (?) 1-based! This means the first interior node id will
303  // always be == 1.
304  libMesh::out << "[" << this->processor_id() << "] " << "first interior node id=" << node_mapi[0] << std::endl;
305  libMesh::out << "[" << this->processor_id() << "] " << "last interior node id=" << node_mapi.back() << std::endl;
306 
307  libMesh::out << "[" << this->processor_id() << "] " << "first boundary node id=" << node_mapb[0] << std::endl;
308  libMesh::out << "[" << this->processor_id() << "] " << "last boundary node id=" << node_mapb.back() << std::endl;
309 
310  // The number of external nodes is sometimes zero, don't try to access
311  // node_mape.back() in this case!
312  if (num_external_nodes > 0)
313  {
314  libMesh::out << "[" << this->processor_id() << "] " << "first external node id=" << node_mape[0] << std::endl;
315  libMesh::out << "[" << this->processor_id() << "] " << "last external node id=" << node_mape.back() << std::endl;
316  }
317  }
318 }
std::vector< int > node_mape
std::vector< int > node_mapi
std::vector< int > node_mapb
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_node_set_id()

int libMesh::ExodusII_IO_Helper::get_node_set_id ( int  index)
inherited

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

Definition at line 580 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::nodeset_ids.

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

◆ get_node_set_name()

std::string libMesh::ExodusII_IO_Helper::get_node_set_name ( int  index)
inherited

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

Definition at line 589 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::id_to_ns_names, and libMesh::ExodusII_IO_Helper::nodeset_ids.

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

◆ get_ns_param_global()

void libMesh::Nemesis_IO_Helper::get_ns_param_global ( )

Definition at line 144 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, global_nodeset_ids, nemesis_err_flag, num_global_node_counts, num_global_node_df_counts, num_node_sets_global, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

145 {
146  if (num_node_sets_global > 0)
147  {
151 
153  Nemesis::ne_get_ns_param_global(ex_id,
154  global_nodeset_ids.data(),
155  num_global_node_counts.data(),
157  EX_CHECK_ERR(nemesis_err_flag, "Error reading global nodeset parameters!");
158 
159  if (verbose)
160  {
161  libMesh::out << "[" << this->processor_id() << "] " << "Global Nodeset IDs, Node Counts, and DF counts:" << std::endl;
162  for (std::size_t bn=0; bn<global_nodeset_ids.size(); ++bn)
163  {
164  libMesh::out << " [" << this->processor_id() << "] "
165  << "global_nodeset_ids["<<bn<<"]=" << global_nodeset_ids[bn]
166  << ", num_global_node_counts["<<bn<<"]=" << num_global_node_counts[bn]
167  << ", num_global_node_df_counts["<<bn<<"]=" << num_global_node_df_counts[bn]
168  << std::endl;
169  }
170  }
171  }
172 }
std::vector< int > num_global_node_counts
std::vector< int > global_nodeset_ids
std::vector< int > num_global_node_df_counts
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ get_side_set_id()

int libMesh::ExodusII_IO_Helper::get_side_set_id ( int  index)
inherited

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

Definition at line 562 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::ss_ids.

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

◆ get_side_set_name()

std::string libMesh::ExodusII_IO_Helper::get_side_set_name ( int  index)
inherited

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

Definition at line 571 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::id_to_ss_names, and libMesh::ExodusII_IO_Helper::ss_ids.

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

◆ get_ss_param_global()

void libMesh::Nemesis_IO_Helper::get_ss_param_global ( )

Fills: global_sideset_ids, num_global_side_counts, num_global_side_df_counts Call after: get_init_global()

Definition at line 108 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, global_sideset_ids, nemesis_err_flag, num_global_side_counts, num_global_side_df_counts, num_side_sets_global, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

109 {
110  if (num_side_sets_global > 0)
111  {
114 
115  // df = "distribution factor", not really sure what that is. I don't yet have a file
116  // which has distribution factors so I guess we'll worry about it later...
118 
120  Nemesis::ne_get_ss_param_global(ex_id,
121  global_sideset_ids.data(),
122  num_global_side_counts.data(),
124  EX_CHECK_ERR(nemesis_err_flag, "Error reading global sideset parameters!");
125 
126  if (verbose)
127  {
128  libMesh::out << "[" << this->processor_id() << "] " << "Global Sideset IDs, Side Counts, and DF counts:" << std::endl;
129  for (std::size_t bn=0; bn<global_sideset_ids.size(); ++bn)
130  {
131  libMesh::out << " [" << this->processor_id() << "] "
132  << "global_sideset_ids["<<bn<<"]=" << global_sideset_ids[bn]
133  << ", num_global_side_counts["<<bn<<"]=" << num_global_side_counts[bn]
134  << ", num_global_side_df_counts["<<bn<<"]=" << num_global_side_df_counts[bn]
135  << std::endl;
136  }
137  }
138  }
139 }
std::vector< int > global_sideset_ids
std::vector< int > num_global_side_df_counts
std::vector< int > num_global_side_counts
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ initialize()

void libMesh::Nemesis_IO_Helper::initialize ( std::string  title,
const MeshBase mesh,
bool  use_discontinuous = false 
)
overridevirtual

Specialization of the initialize function from ExodusII_IO_Helper that also writes global initial data to file.

Reimplemented from libMesh::ExodusII_IO_Helper.

Definition at line 763 of file nemesis_io_helper.C.

References build_element_and_node_maps(), compute_border_node_ids(), compute_communication_map_parameters(), compute_elem_communication_maps(), compute_element_maps(), compute_internal_and_border_elems_and_internal_nodes(), compute_node_communication_maps(), compute_node_maps(), compute_num_global_elem_blocks(), compute_num_global_nodesets(), compute_num_global_sidesets(), elem_cmap_elem_cnts, elem_cmap_elem_ids, elem_cmap_ids, elem_cmap_proc_ids, elem_cmap_side_ids, elem_mapb, elem_mapi, global_elem_blk_cnts, global_elem_blk_ids, global_nodeset_ids, global_sideset_ids, mesh, libMesh::ParallelObject::n_processors(), node_cmap_ids, node_cmap_node_cnts, node_cmap_node_ids, node_cmap_proc_ids, node_mapb, node_mape, node_mapi, num_border_elems, num_border_nodes, num_elem_blks_global, num_elem_cmaps, num_external_nodes, num_global_node_counts, num_global_node_df_counts, num_global_side_counts, num_global_side_df_counts, num_internal_elems, num_internal_nodes, num_node_cmaps, num_node_sets_global, num_side_sets_global, libMesh::MeshBase::parallel_n_elem(), libMesh::MeshBase::parallel_n_nodes(), put_cmap_params(), put_eb_info_global(), put_elem_cmap(), put_elem_map(), put_init_global(), put_init_info(), put_loadbal_param(), put_node_cmap(), put_node_map(), put_ns_param_global(), put_ss_param_global(), and write_exodus_initialization_info().

764 {
765  // Make sure that the reference passed in is really a DistributedMesh
766  // const DistributedMesh & pmesh = cast_ref<const DistributedMesh &>(mesh);
767  const MeshBase & pmesh = mesh;
768 
769  // According to Nemesis documentation, first call when writing should be to
770  // ne_put_init_info(). Our reader doesn't actually call this, but we should
771  // strive to be as close to a normal nemesis file as possible...
772  this->put_init_info(this->n_processors(), 1, "p");
773 
774 
775  // Gather global "initial" information for Nemesis. This consists of
776  // three parts labeled I, II, and III below...
777 
778  //
779  // I.) Need to compute the number of global element blocks. To be consistent with
780  // Exodus, we also incorrectly associate the number of element blocks with the
781  // number of libmesh subdomains...
782  //
783  this->compute_num_global_elem_blocks(pmesh);
784 
785  //
786  // II.) Determine the global number of nodesets by communication.
787  // This code relies on BoundaryInfo storing side and node
788  // boundary IDs separately at the time they are added to the
789  // BoundaryInfo object.
790  //
791  this->compute_num_global_nodesets(pmesh);
792 
793  //
794  // III.) Need to compute the global number of sidesets by communication:
795  // This code relies on BoundaryInfo storing side and node
796  // boundary IDs separately at the time they are added to the
797  // BoundaryInfo object.
798  //
799  this->compute_num_global_sidesets(pmesh);
800 
801  // Now write the global data obtained in steps I, II, and III to the Nemesis file
802  this->put_init_global(pmesh.parallel_n_nodes(),
803  pmesh.parallel_n_elem(),
804  this->num_elem_blks_global, /* I. */
805  this->num_node_sets_global, /* II. */
806  this->num_side_sets_global /* III. */
807  );
808 
809  // Next, we'll write global element block information to the file. This was already
810  // gathered in step I. above
812  this->global_elem_blk_cnts);
813 
814 
815  // Next, write global nodeset information to the file. This was already gathered in
816  // step II. above.
817  this->num_global_node_df_counts.clear();
818  this->num_global_node_df_counts.resize(this->global_nodeset_ids.size()); // distribution factors all zero...
822 
823 
824  // Next, write global sideset information to the file. This was already gathered in
825  // step III. above.
826  this->num_global_side_df_counts.clear();
827  this->num_global_side_df_counts.resize(this->global_sideset_ids.size()); // distribution factors all zero...
831 
832 
833  // Before we go any further we need to derive consistent node and
834  // element numbering schemes for all local elems and nodes connected
835  // to local elements.
836  //
837  // Must be called *after* the local_subdomain_counts map has been constructed
838  // by the compute_num_global_elem_blocks() function!
839  this->build_element_and_node_maps(pmesh);
840 
841  // Next step is to write "load balance" parameters. Several things need to
842  // be computed first though...
843 
844  // First we'll collect IDs of border nodes.
845  this->compute_border_node_ids(pmesh);
846 
847  // Next we'll collect numbers of internal and border elements, and internal nodes.
848  // Note: "A border node does not a border element make...", that is, just because one
849  // of an element's nodes has been identified as a border node, the element is not
850  // necessarily a border element. It must have a side on the boundary between processors,
851  // i.e. have a face neighbor with a different processor id...
853 
854  // Finally we are ready to write the loadbal information to the file
856  this->num_border_nodes,
857  this->num_external_nodes,
858  this->num_internal_elems,
859  this->num_border_elems,
860  this->num_node_cmaps,
861  this->num_elem_cmaps);
862 
863 
864  // Now we need to compute the "communication map" parameters. These are basically
865  // lists of nodes and elements which need to be communicated between different processors
866  // when the mesh file is read back in.
868 
869  // Do we have communication maps to write? Note that
870  // ne_put_cmap_params expects us to have either *both* node and elem
871  // cmaps or *neither*
872  if (!this->node_cmap_ids.empty() &&
873  !this->node_cmap_node_cnts.empty() &&
874  !this->elem_cmap_ids.empty() &&
875  !this->elem_cmap_elem_cnts.empty())
876  {
877  // Write communication map parameters to file.
878  this->put_cmap_params(this->node_cmap_ids,
879  this->node_cmap_node_cnts,
880  this->elem_cmap_ids,
881  this->elem_cmap_elem_cnts);
882 
883  // Ready the node communication maps. The node IDs which
884  // are communicated are the ones currently stored in
885  // proc_nodes_touched_intersections.
887 
888  // Write the packed node communication vectors to file.
889  this->put_node_cmap(this->node_cmap_node_ids,
890  this->node_cmap_proc_ids);
891 
892  // Ready the node maps. These have nothing to do with communication, they map
893  // the nodes to internal, border, and external nodes in the file.
894  this->compute_node_maps();
895 
896  // Call the Nemesis API to write the node maps to file.
897  this->put_node_map(this->node_mapi,
898  this->node_mapb,
899  this->node_mape);
900 
901  // Ready the element communication maps. This includes border
902  // element IDs, sides which are on the border, and the processors to which
903  // they are to be communicated...
905 
906  // Call the Nemesis API to write the packed element communication maps vectors to file
907  this->put_elem_cmap(this->elem_cmap_elem_ids,
908  this->elem_cmap_side_ids,
909  this->elem_cmap_proc_ids);
910  }
911 
912 
913  // Ready the Nemesis element maps (internal and border) for writing to file.
914  this->compute_element_maps();
915 
916  // Call the Nemesis API to write the internal and border element IDs.
917  this->put_elem_map(this->elem_mapi,
918  this->elem_mapb);
919 
920  // Now write Exodus-specific initialization information, some of which is
921  // different when you are using Nemesis.
922  this->write_exodus_initialization_info(pmesh, title_in);
923 } // end initialize()
std::vector< int > num_global_node_counts
std::vector< int > global_nodeset_ids
std::vector< int > global_sideset_ids
void compute_num_global_nodesets(const MeshBase &pmesh)
std::vector< int > node_cmap_ids
std::vector< int > node_mape
void compute_num_global_elem_blocks(const MeshBase &pmesh)
MeshBase & mesh
void put_elem_map(std::vector< int > &elem_mapi, std::vector< int > &elem_mapb)
std::vector< int > num_global_node_df_counts
std::vector< std::vector< int > > elem_cmap_side_ids
std::vector< std::vector< int > > node_cmap_proc_ids
void put_ns_param_global(std::vector< int > &global_nodeset_ids, std::vector< int > &num_global_node_counts, std::vector< int > &num_global_node_df_counts)
void put_eb_info_global(std::vector< int > &global_elem_blk_ids, std::vector< int > &global_elem_blk_cnts)
void compute_border_node_ids(const MeshBase &pmesh)
std::vector< int > num_global_side_df_counts
void build_element_and_node_maps(const MeshBase &pmesh)
void put_init_global(dof_id_type num_nodes_global, dof_id_type num_elems_global, unsigned num_elem_blks_global, unsigned num_node_sets_global, unsigned num_side_sets_global)
processor_id_type n_processors() const
std::vector< int > num_global_side_counts
std::vector< int > global_elem_blk_ids
std::vector< std::vector< int > > elem_cmap_elem_ids
std::vector< int > node_mapi
std::vector< std::vector< int > > elem_cmap_proc_ids
void put_cmap_params(std::vector< int > &node_cmap_ids, std::vector< int > &node_cmap_node_cnts, std::vector< int > &elem_cmap_ids, std::vector< int > &elem_cmap_elem_cnts)
void compute_num_global_sidesets(const MeshBase &pmesh)
void compute_internal_and_border_elems_and_internal_nodes(const MeshBase &pmesh)
void put_elem_cmap(std::vector< std::vector< int >> &elem_cmap_elem_ids, std::vector< std::vector< int >> &elem_cmap_side_ids, std::vector< std::vector< int >> &elem_cmap_proc_ids)
void put_node_map(std::vector< int > &node_mapi, std::vector< int > &node_mapb, std::vector< int > &node_mape)
std::vector< int > elem_cmap_elem_cnts
std::vector< int > elem_cmap_ids
void put_ss_param_global(std::vector< int > &global_sideset_ids, std::vector< int > &num_global_side_counts, std::vector< int > &num_global_side_df_counts)
std::vector< int > node_cmap_node_cnts
void write_exodus_initialization_info(const MeshBase &pmesh, const std::string &title)
void put_init_info(unsigned num_proc, unsigned num_proc_in_file, const char *ftype)
void put_node_cmap(std::vector< std::vector< int >> &node_cmap_node_ids, std::vector< std::vector< int >> &node_cmap_proc_ids)
std::vector< int > elem_mapb
std::vector< int > node_mapb
std::vector< std::vector< int > > node_cmap_node_ids
std::vector< int > global_elem_blk_cnts
void put_loadbal_param(unsigned num_internal_nodes, unsigned num_border_nodes, unsigned num_external_nodes, unsigned num_internal_elems, unsigned num_border_elems, unsigned num_node_cmaps, unsigned num_elem_cmaps)
std::vector< int > elem_mapi

◆ initialize_element_variables()

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

Override the Exodus Helper's implementation of this function so that it works correctly in parallel.

Reimplemented from libMesh::ExodusII_IO_Helper.

Definition at line 2531 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::_elem_vars_initialized, libMesh::ExodusII_IO_Helper::check_existing_vars(), libMesh::ExodusII_IO_Helper::elem_var_names, libMesh::ExodusII_IO_Helper::ELEMENTAL, libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, ex_put_elem_var_tab(), global_elem_blk_ids, libMesh::ExodusII_IO_Helper::num_elem_vars, and libMesh::ExodusII_IO_Helper::write_var_names().

2533 {
2534  // Quick return if there are no element variables to write
2535  if (names.size() == 0)
2536  return;
2537 
2538  // Quick return if we have already called this function
2540  return;
2541 
2542  // Be sure that variables in the file match what we are asking for
2543  if (num_elem_vars > 0)
2544  {
2545  this->check_existing_vars(ELEMENTAL, names, this->elem_var_names);
2546  return;
2547  }
2548 
2549  // Set the flag so we can skip this stuff on subsequent calls to
2550  // initialize_element_variables()
2551  _elem_vars_initialized = true;
2552 
2553  this->write_var_names(ELEMENTAL, names);
2554 
2555  // Create a truth table from global_elem_blk_ids and the information
2556  // in vars_active_subdomains. Create a truth table of
2557  // size global_elem_blk_ids.size() * names.size().
2558  std::vector<int> truth_tab(global_elem_blk_ids.size() * names.size());
2559  for (unsigned int blk=0; blk<global_elem_blk_ids.size(); ++blk)
2560  for (unsigned int var=0; var<names.size(); ++var)
2561  if (vars_active_subdomains[var].empty() ||
2562  vars_active_subdomains[var].count
2563  (cast_int<subdomain_id_type>(global_elem_blk_ids[blk])))
2564  truth_tab[names.size()*blk + var] = 1;
2565 
2566  // Write truth table to file.
2567  if (truth_tab.size())
2568  {
2570  cast_int<int>(global_elem_blk_ids.size()),
2571  cast_int<int>(names.size()),
2572  truth_tab.data());
2573  EX_CHECK_ERR(ex_err, "Error writing element truth table.");
2574  }
2575 }
std::vector< std::string > elem_var_names
void write_var_names(ExodusVarType type, std::vector< std::string > &names)
void check_existing_vars(ExodusVarType type, std::vector< std::string > &names, std::vector< std::string > &names_from_file)
std::vector< int > global_elem_blk_ids
EXODUS_EXPORT int ex_put_elem_var_tab(int exoid, int num_elem_blk, int num_elem_var, int *elem_var_tab)

◆ initialize_global_variables()

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

Sets up the global variables

Definition at line 1788 of file exodusII_io_helper.C.

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

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

◆ initialize_nodal_variables()

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

Sets up the nodal variables

Definition at line 1760 of file exodusII_io_helper.C.

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

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

◆ inquire()

int libMesh::ExodusII_IO_Helper::inquire ( int  req_info,
std::string  error_msg = "" 
)
inherited
Returns
The value obtained from a generic exII::ex_inquire() call.

Definition at line 814 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, and ex_inquire().

Referenced by libMesh::ExodusII_IO_Helper::read_num_time_steps(), libMesh::ExodusII_IO_Helper::read_qa_records(), libMesh::ExodusII_IO_Helper::read_sideset_info(), and libMesh::ExodusII_IO_Helper::write_information_records().

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

◆ message() [1/2]

◆ message() [2/2]

void libMesh::ExodusII_IO_Helper::message ( const std::string &  msg,
int  i 
)
inherited

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

Definition at line 328 of file exodusII_io_helper.C.

References libMesh::out, and libMesh::ExodusII_IO_Helper::verbose.

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

◆ n_processors()

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

Definition at line 95 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), compute_border_node_ids(), construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::MeshBase::partition(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

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

◆ open()

void libMesh::ExodusII_IO_Helper::open ( const char *  filename,
bool  read_only 
)
inherited

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

Definition at line 335 of file exodusII_io_helper.C.

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

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

◆ print_header()

void libMesh::ExodusII_IO_Helper::print_header ( )
inherited

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

Definition at line 455 of file exodusII_io_helper.C.

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

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

◆ print_nodes()

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

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

Definition at line 509 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::num_nodes, libMesh::ExodusII_IO_Helper::x, libMesh::ExodusII_IO_Helper::y, and libMesh::ExodusII_IO_Helper::z.

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

◆ processor_id()

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

Definition at line 101 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::EquationSystems::build_discontinuous_solution_vector(), build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), compute_border_node_ids(), compute_communication_map_parameters(), compute_internal_and_border_elems_and_internal_nodes(), compute_node_communication_maps(), compute_num_global_elem_blocks(), compute_num_global_nodesets(), compute_num_global_sidesets(), 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::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), get_cmap_params(), get_eb_info_global(), get_elem_cmap(), get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), get_init_global(), get_init_info(), get_loadbal_param(), get_node_cmap(), get_node_map(), get_ns_param_global(), get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), 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::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), put_cmap_params(), put_elem_cmap(), put_elem_map(), put_loadbal_param(), put_node_cmap(), put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< T >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

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

◆ put_cmap_params()

void libMesh::Nemesis_IO_Helper::put_cmap_params ( std::vector< int > &  node_cmap_ids,
std::vector< int > &  node_cmap_node_cnts,
std::vector< int > &  elem_cmap_ids,
std::vector< int > &  elem_cmap_elem_cnts 
)

Outputs initial information for communication maps.

Note
The order of the arguments specified in the Nemesis User's Manual is wrong. The correct order is (ids, counts, ids, counts). Must be called after put_loadbal_param().

Definition at line 573 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, and libMesh::ParallelObject::processor_id().

Referenced by initialize().

577 {
578  libmesh_assert(!node_cmap_ids_in.empty());
579  libmesh_assert(!node_cmap_node_cnts_in.empty());
580  libmesh_assert(!elem_cmap_ids_in.empty());
581  libmesh_assert(!elem_cmap_elem_cnts_in.empty());
582 
584  Nemesis::ne_put_cmap_params(ex_id,
585  node_cmap_ids_in.data(),
586  node_cmap_node_cnts_in.data(),
587  elem_cmap_ids_in.data(),
588  elem_cmap_elem_cnts_in.data(),
589  this->processor_id());
590 
591  EX_CHECK_ERR(nemesis_err_flag, "Error writing cmap parameters!");
592 }
processor_id_type processor_id() const

◆ put_eb_info_global()

void libMesh::Nemesis_IO_Helper::put_eb_info_global ( std::vector< int > &  global_elem_blk_ids,
std::vector< int > &  global_elem_blk_cnts 
)

Writes global block information to the file .) global_elem_blk_ids - list of block IDs for all blocks present in the mesh .) global_elem_blk_cnts - number of elements in each block for the global mesh

Must be called after put_init_global().

Definition at line 493 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, and nemesis_err_flag.

Referenced by initialize().

495 {
497  Nemesis::ne_put_eb_info_global(ex_id,
498  global_elem_blk_ids_in.data(),
499  global_elem_blk_cnts_in.data());
500 
501  EX_CHECK_ERR(nemesis_err_flag, "Error writing global element block information!");
502 }

◆ put_elem_cmap()

void libMesh::Nemesis_IO_Helper::put_elem_cmap ( std::vector< std::vector< int >> &  elem_cmap_elem_ids,
std::vector< std::vector< int >> &  elem_cmap_side_ids,
std::vector< std::vector< int >> &  elem_cmap_proc_ids 
)

Writes information about elemental communication map.

Note
This class contains elem_cmap_elem_ids, elem_cmap_side_ids, abd elem_cmap_proc_ids which can be used when calling this function.

Must be called after put_cmap_params().

Definition at line 659 of file nemesis_io_helper.C.

References data, elem_cmap_ids, libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, and libMesh::ParallelObject::processor_id().

Referenced by initialize().

662 {
663  for (std::size_t i=0; i<elem_cmap_ids.size(); ++i)
664  {
666  Nemesis::ne_put_elem_cmap(ex_id,
667  this->elem_cmap_ids[i],
668  elem_cmap_elem_ids_in[i].data(),
669  elem_cmap_side_ids_in[i].data(),
670  elem_cmap_proc_ids_in[i].data(),
671  this->processor_id());
672 
673  EX_CHECK_ERR(nemesis_err_flag, "Error writing elem communication map to file!");
674  }
675 }
std::vector< int > elem_cmap_ids
IterBase * data
processor_id_type processor_id() const

◆ put_elem_map()

void libMesh::Nemesis_IO_Helper::put_elem_map ( std::vector< int > &  elem_mapi,
std::vector< int > &  elem_mapb 
)

Outputs IDs of internal and border elements.

Must be called after ne_put_loadbal_param().

Definition at line 680 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, and libMesh::ParallelObject::processor_id().

Referenced by initialize().

682 {
684  Nemesis::ne_put_elem_map(ex_id,
685  elem_mapi_in.empty() ? nullptr : elem_mapi_in.data(),
686  elem_mapb_in.empty() ? nullptr : elem_mapb_in.data(),
687  this->processor_id());
688 
689  EX_CHECK_ERR(nemesis_err_flag, "Error writing Nemesis internal and border element maps to file!");
690 }
processor_id_type processor_id() const

◆ put_init_global()

void libMesh::Nemesis_IO_Helper::put_init_global ( dof_id_type  num_nodes_global,
dof_id_type  num_elems_global,
unsigned  num_elem_blks_global,
unsigned  num_node_sets_global,
unsigned  num_side_sets_global 
)

Writes global information including: .) global number of nodes .) global number of elems .) global number of element blocks .) global number of node sets .) global number of side sets

Definition at line 474 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, and nemesis_err_flag.

Referenced by initialize().

479 {
481  Nemesis::ne_put_init_global(ex_id,
482  num_nodes_global_in,
483  num_elems_global_in,
484  num_elem_blks_global_in,
485  num_node_sets_global_in,
486  num_side_sets_global_in);
487 
488  EX_CHECK_ERR(nemesis_err_flag, "Error writing initial global data!");
489 }

◆ put_init_info()

void libMesh::Nemesis_IO_Helper::put_init_info ( unsigned  num_proc,
unsigned  num_proc_in_file,
const char *  ftype 
)

Writing functions. Writes basic info about the partitioning to file .) num_proc - number of processors .) num_proc_in_file - number of processors in the current file - generally equal to 1 .) ftype = "s" for scalar load-balance file, "p" for parallel file

Definition at line 458 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, and nemesis_err_flag.

Referenced by initialize().

461 {
463  Nemesis::ne_put_init_info(ex_id,
464  num_proc_in,
465  num_proc_in_file_in,
466  const_cast<char *>(ftype_in));
467 
468  EX_CHECK_ERR(nemesis_err_flag, "Error writing initial information!");
469 }

◆ put_loadbal_param()

void libMesh::Nemesis_IO_Helper::put_loadbal_param ( unsigned  num_internal_nodes,
unsigned  num_border_nodes,
unsigned  num_external_nodes,
unsigned  num_internal_elems,
unsigned  num_border_elems,
unsigned  num_node_cmaps,
unsigned  num_elem_cmaps 
)

Writes load balance parameters, some of which are described below: .) num_internal_nodes - nodes "wholly" owned by the current processor .) num_border_nodes - nodes local to a processor but residing in an element which also has nodes on other processors .) num_external_nodes - nodes that reside on other processors but whose element "partially" resides on the current processor – we assert this should be zero on reading! .) num_border_elems - elements local to this processor but whose nodes reside on other processors as well. .) processor - ID of the processor for which information is to be written

Definition at line 547 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, and libMesh::ParallelObject::processor_id().

Referenced by initialize().

554 {
556  Nemesis::ne_put_loadbal_param(ex_id,
557  num_internal_nodes_in,
558  num_border_nodes_in,
559  num_external_nodes_in,
560  num_internal_elems_in,
561  num_border_elems_in,
562  num_node_cmaps_in,
563  num_elem_cmaps_in,
564  this->processor_id());
565 
566  EX_CHECK_ERR(nemesis_err_flag, "Error writing loadbal parameters!");
567 }
processor_id_type processor_id() const

◆ put_n_coord()

void libMesh::Nemesis_IO_Helper::put_n_coord ( unsigned  start_node_num,
unsigned  num_nodes,
std::vector< Real > &  x_coor,
std::vector< Real > &  y_coor,
std::vector< Real > &  z_coor 
)

Writes the specified number of coordinate values starting at the specified index.

Definition at line 697 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, and nemesis_err_flag.

702 {
703  if (num_nodes_in)
704  {
706  Nemesis::ne_put_n_coord(ex_id,
707  start_node_num,
708  num_nodes_in,
709  x_coor.empty() ? nullptr : x_coor.data(),
710  y_coor.empty() ? nullptr : y_coor.data(),
711  z_coor.empty() ? nullptr : z_coor.data());
712 
713  EX_CHECK_ERR(nemesis_err_flag, "Error writing coords to file!");
714  }
715 }

◆ put_node_cmap()

void libMesh::Nemesis_IO_Helper::put_node_cmap ( std::vector< std::vector< int >> &  node_cmap_node_ids,
std::vector< std::vector< int >> &  node_cmap_proc_ids 
)

Outputs all of the nodal communication maps for this processor. Internally, this function loops over all communication maps and calls Nemesis::ne_put_node_cmap() for each one.

.) node_cmap_node_ids = Nodal IDs of the FEM nodes in this communication map .) node_cmap_proc_ids = processor IDs associated with each of the nodes in node_ids

In the Nemesis file, these all appear to be written to the same chunks of data: n_comm_nids and n_comm_proc, but don't rely on these names...

Note
This class contains node_cmap_node_ids and node_cmap_proc_ids which can be used when calling this function.

Must be called after put_cmap_params().

Definition at line 597 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, node_cmap_ids, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

599 {
600 
601  // Print to screen what we are about to print to Nemesis file
602  if (verbose)
603  {
604  for (std::size_t i=0; i<node_cmap_node_ids_in.size(); ++i)
605  {
606  libMesh::out << "[" << this->processor_id() << "] put_node_cmap() : nodes communicated to proc "
607  << this->node_cmap_ids[i]
608  << " = ";
609  for (std::size_t j=0; j<node_cmap_node_ids_in[i].size(); ++j)
610  libMesh::out << node_cmap_node_ids_in[i][j] << " ";
611  libMesh::out << std::endl;
612  }
613 
614  for (std::size_t i=0; i<node_cmap_node_ids_in.size(); ++i)
615  {
616  libMesh::out << "[" << this->processor_id() << "] put_node_cmap() : processor IDs = ";
617  for (std::size_t j=0; j<node_cmap_proc_ids_in[i].size(); ++j)
618  libMesh::out << node_cmap_proc_ids_in[i][j] << " ";
619  libMesh::out << std::endl;
620  }
621  }
622 
623  for (std::size_t i=0; i<node_cmap_node_ids_in.size(); ++i)
624  {
625  int * node_ids_ptr = node_cmap_node_ids_in[i].empty() ?
626  nullptr : node_cmap_node_ids_in[i].data();
627  int * proc_ids_ptr = node_cmap_proc_ids_in[i].empty() ?
628  nullptr : node_cmap_proc_ids_in[i].data();
629 
631  Nemesis::ne_put_node_cmap(ex_id, this->node_cmap_ids[i],
632  node_ids_ptr, proc_ids_ptr,
633  this->processor_id());
634 
635  EX_CHECK_ERR(nemesis_err_flag, "Error writing node communication map to file!");
636  }
637 }
std::vector< int > node_cmap_ids
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ put_node_map()

void libMesh::Nemesis_IO_Helper::put_node_map ( std::vector< int > &  node_mapi,
std::vector< int > &  node_mapb,
std::vector< int > &  node_mape 
)

Outputs IDs of internal, border, and external nodes. LibMesh asserts that the number of external nodes is zero in the Nemesis files it reads

Definition at line 642 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, nemesis_err_flag, and libMesh::ParallelObject::processor_id().

Referenced by initialize().

645 {
647  Nemesis::ne_put_node_map(ex_id,
648  node_mapi_in.empty() ? nullptr : node_mapi_in.data(),
649  node_mapb_in.empty() ? nullptr : node_mapb_in.data(),
650  node_mape_in.empty() ? nullptr : node_mape_in.data(),
651  this->processor_id());
652 
653  EX_CHECK_ERR(nemesis_err_flag, "Error writing Nemesis internal and border node maps to file!");
654 }
processor_id_type processor_id() const

◆ put_ns_param_global()

void libMesh::Nemesis_IO_Helper::put_ns_param_global ( std::vector< int > &  global_nodeset_ids,
std::vector< int > &  num_global_node_counts,
std::vector< int > &  num_global_node_df_counts 
)

This function writes information about global node sets. .) global_nodeset_ids - vector of global node set IDs .) num_global_node_counts - vector of global node counts contained in each global node set .) num_global_df_count - vector of global distribution factors in each global node set

Must be called after put_init_global()

Definition at line 507 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, global_nodeset_ids, and nemesis_err_flag.

Referenced by initialize().

510 {
511  // Only add nodesets if there are some
512  if (global_nodeset_ids.size())
513  {
515  Nemesis::ne_put_ns_param_global(ex_id,
516  global_nodeset_ids_in.data(),
517  num_global_node_counts_in.data(),
518  num_global_node_df_counts_in.data());
519  }
520 
521  EX_CHECK_ERR(nemesis_err_flag, "Error writing global nodeset parameters!");
522 }
std::vector< int > global_nodeset_ids

◆ put_ss_param_global()

void libMesh::Nemesis_IO_Helper::put_ss_param_global ( std::vector< int > &  global_sideset_ids,
std::vector< int > &  num_global_side_counts,
std::vector< int > &  num_global_side_df_counts 
)

This function writes information about global side sets. .) global_sideset_ids - vector of global side set IDs .) num_global_side_counts - vector of global side counts contained in each global side set .) num_global_df_count - vector of global distribution factors in each global side set

Must be called after put_init_global()

Definition at line 527 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, global_sideset_ids, and nemesis_err_flag.

Referenced by initialize().

530 {
531  // Only add sidesets if there are some
532  if (global_sideset_ids.size())
533  {
535  Nemesis::ne_put_ss_param_global(ex_id,
536  global_sideset_ids_in.data(),
537  num_global_side_counts_in.data(),
538  num_global_side_df_counts_in.data());
539  }
540 
541  EX_CHECK_ERR(nemesis_err_flag, "Error writing global sideset parameters!");
542 }
std::vector< int > global_sideset_ids

◆ read_block_info()

void libMesh::ExodusII_IO_Helper::read_block_info ( )
inherited

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

Definition at line 517 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::block_ids, EX_ELEM_BLOCK, libMesh::ExodusII_IO_Helper::ex_err, ex_get_elem_blk_ids(), ex_get_name(), libMesh::ExodusII_IO_Helper::ex_id, libMesh::ExodusII_IO_Helper::id_to_block_names, libMesh::ExodusII_IO_Helper::message(), and libMesh::ExodusII_IO_Helper::num_elem_blk.

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

◆ read_elem_in_block()

void libMesh::ExodusII_IO_Helper::read_elem_in_block ( int  block)
inherited

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

Definition at line 599 of file exodusII_io_helper.C.

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

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

◆ read_elem_num_map()

void libMesh::ExodusII_IO_Helper::read_elem_num_map ( )
inherited

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 639 of file exodusII_io_helper.C.

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

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

◆ read_elemental_var_values()

void libMesh::ExodusII_IO_Helper::read_elemental_var_values ( std::string  elemental_var_name,
int  time_step,
std::map< dof_id_type, Real > &  elem_var_value_map 
)
inherited

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

Definition at line 1012 of file exodusII_io_helper.C.

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

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

◆ read_global_values()

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

Reads the vector of global variables.

Definition at line 2031 of file exodusII_io_helper.C.

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

2032 {
2033  if ((_run_only_on_proc0) && (this->processor_id() != 0))
2034  return;
2035 
2036  values.clear();
2037  values.resize(num_global_vars);
2038  ex_err = exII::ex_get_glob_vars(ex_id, timestep, num_global_vars, values.data());
2039  EX_CHECK_ERR(ex_err, "Error reading global values.");
2040 }
EXODUS_EXPORT int ex_get_glob_vars(int exoid, int time_step, int num_glob_vars, void *glob_var_vals)
processor_id_type processor_id() const

◆ read_header()

void libMesh::ExodusII_IO_Helper::read_header ( )
inherited

Reads an ExodusII mesh file header.

Definition at line 375 of file exodusII_io_helper.C.

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

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

◆ read_nodal_var_values()

void libMesh::ExodusII_IO_Helper::read_nodal_var_values ( std::string  nodal_var_name,
int  time_step 
)
inherited

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

Definition at line 856 of file exodusII_io_helper.C.

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

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

◆ read_node_num_map()

void libMesh::ExodusII_IO_Helper::read_node_num_map ( )
inherited

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 489 of file exodusII_io_helper.C.

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

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

◆ read_nodes()

void libMesh::ExodusII_IO_Helper::read_nodes ( )
inherited

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

Definition at line 469 of file exodusII_io_helper.C.

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

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

◆ read_nodeset()

void libMesh::ExodusII_IO_Helper::read_nodeset ( int  id)
inherited

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

Definition at line 765 of file exodusII_io_helper.C.

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

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

◆ read_nodeset_info()

void libMesh::ExodusII_IO_Helper::read_nodeset_info ( )
inherited

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

Definition at line 694 of file exodusII_io_helper.C.

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

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

◆ read_num_time_steps()

void libMesh::ExodusII_IO_Helper::read_num_time_steps ( )
inherited

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

Definition at line 848 of file exodusII_io_helper.C.

References EX_INQ_TIME, libMesh::ExodusII_IO_Helper::inquire(), and libMesh::ExodusII_IO_Helper::num_time_steps.

Referenced by libMesh::ExodusII_IO_Helper::read_header(), and libMesh::ExodusII_IO_Helper::read_time_steps().

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

◆ read_qa_records()

void libMesh::ExodusII_IO_Helper::read_qa_records ( )
inherited

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

Definition at line 405 of file exodusII_io_helper.C.

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

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

◆ read_sideset()

void libMesh::ExodusII_IO_Helper::read_sideset ( int  id,
int  offset 
)
inherited

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

Definition at line 722 of file exodusII_io_helper.C.

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

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

◆ read_sideset_info()

void libMesh::ExodusII_IO_Helper::read_sideset_info ( )
inherited

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

Definition at line 661 of file exodusII_io_helper.C.

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

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

◆ read_time_steps()

void libMesh::ExodusII_IO_Helper::read_time_steps ( )
inherited

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

Definition at line 833 of file exodusII_io_helper.C.

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

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

◆ read_var_names()

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

Definition at line 896 of file exodusII_io_helper.C.

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

Referenced by libMesh::ExodusII_IO_Helper::check_existing_vars(), libMesh::ExodusII_IO_Helper::read_elemental_var_values(), and libMesh::ExodusII_IO_Helper::read_nodal_var_values().

897 {
898  switch (type)
899  {
900  case NODAL:
902  break;
903  case ELEMENTAL:
905  break;
906  case GLOBAL:
908  break;
909  default:
910  libmesh_error_msg("Unrecognized ExodusVarType " << type);
911  }
912 }
std::vector< std::string > elem_var_names
void read_var_names_impl(const char *var_type, int &count, std::vector< std::string > &result)
std::vector< std::string > global_var_names
std::vector< std::string > nodal_var_names

◆ set_coordinate_offset()

void libMesh::ExodusII_IO_Helper::set_coordinate_offset ( Point  p)
inherited

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

Definition at line 2058 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::_coordinate_offset.

2059 {
2060  _coordinate_offset = p;
2061 }

◆ use_mesh_dimension_instead_of_spatial_dimension()

void libMesh::ExodusII_IO_Helper::use_mesh_dimension_instead_of_spatial_dimension ( bool  val)
inherited

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

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

Definition at line 2044 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::_use_mesh_dimension_instead_of_spatial_dimension.

◆ write_as_dimension()

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

Sets the value of _write_as_dimension.

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

Definition at line 2051 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::_write_as_dimension.

2052 {
2053  _write_as_dimension = dim;
2054 }

◆ write_element_values() [1/2]

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

Writes the vector of values to the element variables.

Definition at line 1865 of file exodusII_io_helper.C.

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

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

◆ write_element_values() [2/2]

void libMesh::Nemesis_IO_Helper::write_element_values ( const MeshBase mesh,
const NumericVector< Number > &  parallel_soln,
const std::vector< std::string > &  names,
int  timestep,
const std::vector< std::set< subdomain_id_type >> &  vars_active_subdomains 
)

Writes the vector of elemental variable values, one variable and one subdomain at a time.

Definition at line 2580 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, ex_put_elem_var(), ex_update(), global_elem_blk_ids, if(), libMesh::NumericVector< T >::localize(), mesh, and subdomain_map.

2585 {
2586  // The total number of elements in the mesh. We need this for
2587  // indexing into parallel_soln.
2588  dof_id_type parallel_n_elem = mesh.parallel_n_elem();
2589 
2590  // For each variable in names,
2591  // For each subdomain in subdomain_map,
2592  // If this (subdomain, variable) combination is active
2593  // Extract our values into local_soln (localize is a collective)
2594  // Write local_soln to file
2595  for (unsigned int v=0; v<names.size(); ++v)
2596  {
2597  // Get list of active subdomains for variable v
2598  const auto & active_subdomains = vars_active_subdomains[v];
2599 
2600  // Loop over all subdomain blocks, even ones for which we have
2601  // no elements, so we localize in sync
2602  for (const int sbd_id_int : global_elem_blk_ids)
2603  {
2604  const subdomain_id_type sbd_id =
2605  cast_int<subdomain_id_type>(sbd_id_int);
2606  auto it = subdomain_map.find(sbd_id);
2607  const std::vector<dof_id_type> empty_vec;
2608  const std::vector<dof_id_type> & elem_ids =
2609  (it == subdomain_map.end()) ? empty_vec : it->second;
2610 
2611  // Possibly skip this (variable, subdomain) combination
2612  if (active_subdomains.empty() || active_subdomains.count(sbd_id))
2613  {
2614  std::vector<numeric_index_type> required_indices;
2615  required_indices.reserve(elem_ids.size());
2616 
2617  for (const auto & id : elem_ids)
2618  required_indices.push_back(v * parallel_n_elem + id);
2619 
2620  std::vector<Number> local_soln;
2621  parallel_soln.localize(local_soln, required_indices);
2622 
2623  // It's possible that there's nothing for us to write:
2624  // we may not be responsible for any elements on the
2625  // current subdomain. We did still have to participate
2626  // in the localize() call above, however, since it is a
2627  // collective.
2628  if (local_soln.size())
2629  {
2631  timestep,
2632  static_cast<int>(v+1),
2633  static_cast<int>(sbd_id),
2634  static_cast<int>(local_soln.size()),
2635  local_soln.data());
2636  EX_CHECK_ERR(ex_err, "Error writing element values.");
2637  }
2638  }
2639  }
2640  } // end loop over vars
2641 
2643  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
2644 }
std::map< subdomain_id_type, std::vector< dof_id_type > > subdomain_map
TestClass subdomain_id_type
Definition: id_types.h:43
if(!eq) SETERRQ2(((PetscObject) dm) -> comm, PETSC_ERR_ARG_WRONG, "DM of type %s, not of type %s",((PetscObject) dm) ->type, DMLIBMESH)
MeshBase & mesh
EXODUS_EXPORT int ex_put_elem_var(int exoid, int time_step, int elem_var_index, ex_entity_id elem_blk_id, int64_t num_elem_this_blk, const void *elem_var_vals)
std::vector< int > global_elem_blk_ids
EXODUS_EXPORT int ex_update(int exoid)
uint8_t dof_id_type
Definition: id_types.h:64
virtual void localize(std::vector< T > &v_local) const =0

◆ write_elements()

void libMesh::Nemesis_IO_Helper::write_elements ( const MeshBase mesh,
bool  use_discontinuous = false 
)
overridevirtual

This function is specialized to write the connectivity.

Reimplemented from libMesh::ExodusII_IO_Helper.

Definition at line 2344 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), block_id_to_elem_connectivity, libMesh::MeshBase::elem_ref(), EX_ELEM_BLOCK, libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, ex_put_elem_block(), ex_put_elem_conn(), ex_put_elem_num_map(), ex_put_names(), libMesh::ExodusII_IO_Helper::exodus_elem_num_to_libmesh, libMesh::ExodusII_IO_Helper::Conversion::exodus_elem_type(), libMesh::ExodusII_IO_Helper::NamesData::get_char_star_star(), global_elem_blk_ids, mesh, libMesh::Elem::n_nodes(), num_elem_blks_global, libMesh::ExodusII_IO_Helper::num_nodes_per_elem, libMesh::ExodusII_IO_Helper::NamesData::push_back_entry(), and subdomain_map.

2345 {
2346  // Only write elements if there are elements blocks available.
2347  if (this->num_elem_blks_global > 0)
2348  {
2349  // Data structure to store element block names that will be used to
2350  // write the element block names to file.
2351  NamesData names_table(this->num_elem_blks_global, MAX_STR_LENGTH);
2352 
2353  // Loop over all blocks, even if we don't have elements in each block.
2354  // If we don't have elements we need to write out a 0 for that block...
2355  for (auto i : IntRange<int>(0, this->num_elem_blks_global))
2356  {
2357  // Even if there are no elements for this block on the current
2358  // processor, we still want to write its name to file, if
2359  // possible. MeshBase::subdomain_name() will just return an
2360  // empty string if there is no name associated with the current
2361  // block.
2362  names_table.push_back_entry
2363  (mesh.subdomain_name(cast_int<subdomain_id_type>(this->global_elem_blk_ids[i])));
2364 
2365  // Search for the current global block ID in the map
2366  std::map<int, std::vector<int>>::iterator it =
2367  this->block_id_to_elem_connectivity.find( this->global_elem_blk_ids[i] );
2368 
2369  // If not found, write a zero to file....
2370  if (it == this->block_id_to_elem_connectivity.end())
2371  {
2372  this->ex_err = exII::ex_put_elem_block(this->ex_id,
2373  this->global_elem_blk_ids[i],
2374  "Empty",
2375  0, /* n. elements in this block */
2376  0, /* n. nodes per element */
2377  0); /* number of attributes per element */
2378 
2379  EX_CHECK_ERR(this->ex_err, "Error writing element block from Nemesis.");
2380  }
2381 
2382  // Otherwise, write the actual block information and connectivity to file
2383  else
2384  {
2385  subdomain_id_type block =
2386  cast_int<subdomain_id_type>(it->first);
2387  std::vector<int> & this_block_connectivity = it->second;
2388  std::vector<dof_id_type> & elements_in_this_block = subdomain_map[block];
2389 
2390  ExodusII_IO_Helper::ElementMaps em;
2391 
2392  //Use the first element in this block to get representative information.
2393  //Note that Exodus assumes all elements in a block are of the same type!
2394  //We are using that same assumption here!
2395  const ExodusII_IO_Helper::Conversion conv =
2396  em.assign_conversion(mesh.elem_ref(elements_in_this_block[0]).type());
2397 
2398  this->num_nodes_per_elem =
2399  mesh.elem_ref(elements_in_this_block[0]).n_nodes();
2400 
2402  block,
2403  conv.exodus_elem_type().c_str(),
2404  elements_in_this_block.size(),
2406  0);
2407  EX_CHECK_ERR(ex_err, "Error writing element block from Nemesis.");
2408 
2410  block,
2411  this_block_connectivity.data());
2412  EX_CHECK_ERR(ex_err, "Error writing element connectivities from Nemesis.");
2413  }
2414  } // end loop over global block IDs
2415 
2416  // Only call this once, not in the loop above!
2418  exodus_elem_num_to_libmesh.empty() ? nullptr : exodus_elem_num_to_libmesh.data());
2419  EX_CHECK_ERR(ex_err, "Error writing element map");
2420 
2421  // Write the element block names to file.
2422  ex_err = exII::ex_put_names(ex_id, exII::EX_ELEM_BLOCK, names_table.get_char_star_star());
2423  EX_CHECK_ERR(ex_err, "Error writing element block names");
2424  } // end if (this->num_elem_blks_global > 0)
2425 }
std::map< subdomain_id_type, std::vector< dof_id_type > > subdomain_map
TestClass subdomain_id_type
Definition: id_types.h:43
std::vector< int > exodus_elem_num_to_libmesh
MeshBase & mesh
EXODUS_EXPORT int ex_put_elem_block(int exoid, ex_entity_id elem_blk_id, const char *elem_type, int64_t num_elem_this_blk, int64_t num_nodes_per_elem, int64_t num_attr)
std::vector< int > global_elem_blk_ids
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
std::map< int, std::vector< int > > block_id_to_elem_connectivity
EXODUS_EXPORT int ex_put_elem_conn(int exoid, ex_entity_id elem_blk_id, const void_int *connect)
EXODUS_EXPORT int ex_put_elem_num_map(int exoid, const void_int *elem_map)

◆ write_exodus_initialization_info()

void libMesh::Nemesis_IO_Helper::write_exodus_initialization_info ( const MeshBase pmesh,
const std::string &  title 
)
private

This function writes exodus-specific initialization information. This information is slightly different when you are working with Nemesis, as it depends on some global information being known.

Definition at line 930 of file nemesis_io_helper.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, ex_put_init(), global_nodeset_ids, global_sideset_ids, libMesh::ExodusII_IO_Helper::num_dim, libMesh::ExodusII_IO_Helper::num_elem, libMesh::ExodusII_IO_Helper::num_elem_blk, num_elem_blks_global, libMesh::ExodusII_IO_Helper::num_node_sets, libMesh::ExodusII_IO_Helper::num_nodes, and libMesh::ExodusII_IO_Helper::num_side_sets.

Referenced by initialize().

932 {
933  // This follows the convention of Exodus: we always write out the mesh as LIBMESH_DIM-dimensional,
934  // even if it is 2D...
935  this->num_dim = LIBMESH_DIM;
936 
937  this->num_elem = static_cast<unsigned int>(std::distance (pmesh.active_local_elements_begin(),
938  pmesh.active_local_elements_end()));
939 
940  // Exodus will also use *global* number of side and node sets,
941  // though it will not write out entries for all of them...
942  this->num_side_sets =
943  cast_int<int>(this->global_sideset_ids.size());
944  this->num_node_sets =
945  cast_int<int>(this->global_nodeset_ids.size());
946 
947  // We need to write the global number of blocks, even though this processor might not have
948  // elements in some of them!
949  this->num_elem_blk = this->num_elem_blks_global;
950 
952  title_in.c_str(),
953  this->num_dim,
954  this->num_nodes,
955  this->num_elem,
956  this->num_elem_blk,
957  this->num_node_sets,
958  this->num_side_sets);
959 
960  EX_CHECK_ERR(ex_err, "Error initializing new Nemesis file.");
961 }
std::vector< int > global_nodeset_ids
std::vector< int > global_sideset_ids
EXODUS_EXPORT int ex_put_init(int exoid, const char *title, int64_t num_dim, int64_t num_nodes, int64_t num_elem, int64_t num_elem_blk, int64_t num_node_sets, int64_t num_side_sets)

◆ write_global_values()

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

Writes the vector of global variables.

Definition at line 2009 of file exodusII_io_helper.C.

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

2010 {
2011  if ((_run_only_on_proc0) && (this->processor_id() != 0))
2012  return;
2013 
2014  if (_single_precision)
2015  {
2016  std::vector<float> cast_values(values.begin(), values.end());
2017  ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_global_vars, cast_values.data());
2018  }
2019  else
2020  {
2021  ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_global_vars, values.data());
2022  }
2023  EX_CHECK_ERR(ex_err, "Error writing global values.");
2024 
2026  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
2027 }
EXODUS_EXPORT int ex_put_glob_vars(int exoid, int time_step, int num_glob_vars, const void *glob_var_vals)
EXODUS_EXPORT int ex_update(int exoid)
processor_id_type processor_id() const

◆ write_information_records()

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

Writes the vector of information records.

Definition at line 1970 of file exodusII_io_helper.C.

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

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

◆ write_nodal_coordinates()

void libMesh::Nemesis_IO_Helper::write_nodal_coordinates ( const MeshBase mesh,
bool  use_discontinuous = false 
)
overridevirtual

This function is specialized from ExodusII_IO_Helper to write only the nodal coordinates stored on the local piece of the Mesh.

Reimplemented from libMesh::ExodusII_IO_Helper.

Definition at line 2285 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::_single_precision, libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, ex_put_coord(), ex_put_node_num_map(), libMesh::ExodusII_IO_Helper::exodus_node_num_to_libmesh, mesh, libMesh::ExodusII_IO_Helper::x, libMesh::ExodusII_IO_Helper::y, and libMesh::ExodusII_IO_Helper::z.

2286 {
2287  auto local_num_nodes = this->exodus_node_num_to_libmesh.size();
2288 
2289  x.resize(local_num_nodes);
2290  y.resize(local_num_nodes);
2291  z.resize(local_num_nodes);
2292 
2293  // Just loop over our list outputting the nodes the way we built the map
2294  for (auto i : IntRange<int>(0, local_num_nodes))
2295  {
2296  const Point & pt = mesh.point(this->exodus_node_num_to_libmesh[i]);
2297  x[i]=pt(0);
2298  y[i]=pt(1);
2299  z[i]=pt(2);
2300  }
2301 
2302  if (local_num_nodes)
2303  {
2304  if (_single_precision)
2305  {
2306  std::vector<float>
2307  x_single(x.begin(), x.end()),
2308  y_single(y.begin(), y.end()),
2309  z_single(z.begin(), z.end());
2310 
2312  x_single.data(),
2313  y_single.data(),
2314  z_single.data());
2315  }
2316  else
2317  {
2318  // Call Exodus API to write nodal coordinates...
2320  x.data(),
2321  y.data(),
2322  z.data());
2323  }
2324  EX_CHECK_ERR(ex_err, "Error writing node coordinates");
2325 
2326  // And write the nodal map we created for them
2328  EX_CHECK_ERR(ex_err, "Error writing node num map");
2329  }
2330  else // Does the Exodus API want us to write empty nodal coordinates?
2331  {
2332  ex_err = exII::ex_put_coord(ex_id, nullptr, nullptr, nullptr);
2333  EX_CHECK_ERR(ex_err, "Error writing empty node coordinates");
2334 
2336  EX_CHECK_ERR(ex_err, "Error writing empty node num map");
2337  }
2338 }
MeshBase & mesh
EXODUS_EXPORT int ex_put_coord(int exoid, const void *x_coor, const void *y_coor, const void *z_coor)
EXODUS_EXPORT int ex_put_node_num_map(int exoid, const void_int *node_map)
std::vector< int > exodus_node_num_to_libmesh

◆ write_nodal_solution() [1/2]

void libMesh::Nemesis_IO_Helper::write_nodal_solution ( const NumericVector< Number > &  parallel_soln,
const std::vector< std::string > &  names,
int  timestep,
const std::vector< std::string > &  output_names 
)

Takes a parallel solution vector containing the node-major solution vector for all variables and outputs it to the files.

Parameters
parallel_soln
namesA vector containing the names of all variables in parallel_soln.
timestepTo be passed to the ExodusII_IO_Helper::write_nodal_values() function.
output_namesA vector containing the names of variables in parallel_soln that should actually be written (whitelist).
Note
This version of write_nodal_solution() is called by the parallel version of Nemesis_IO::write_nodal_data(), which is called by MeshOutput::write_equation_systems() for parallel I/O formats like Nemesis. The other version is still available to continue supporting things like NamebasedIO::write_nodal_data(), but this version should be preferred when running in parallel.

Definition at line 2469 of file nemesis_io_helper.C.

References std::abs(), libMesh::ExodusII_IO_Helper::exodus_node_num_to_libmesh, libMesh::NumericVector< T >::localize(), libMesh::ExodusII_IO_Helper::num_nodes, and libMesh::ExodusII_IO_Helper::write_nodal_values().

2473 {
2474  int num_vars = cast_int<int>(names.size());
2475 
2476  for (int c=0; c<num_vars; c++)
2477  {
2478  // Find the position of names[c] in the output_names vector, if it exists.
2479  auto pos = std::find(output_names.begin(), output_names.end(), names[c]);
2480 
2481  // Skip names[c] if it's not supposed to be output.
2482  if (pos == output_names.end())
2483  continue;
2484 
2485  // Compute the (zero-based) index which determines which
2486  // variable this will be as far as Nemesis is concerned. This
2487  // will be used below in the write_nodal_values() call.
2488  int variable_name_position =
2489  cast_int<int>(std::distance(output_names.begin(), pos));
2490 
2491  // Fill up a std::vector with the dofs for the current variable
2492  std::vector<numeric_index_type> required_indices(num_nodes);
2493 
2494  for (int i=0; i<num_nodes; i++)
2495  required_indices[i] = static_cast<dof_id_type>(this->exodus_node_num_to_libmesh[i]) * num_vars + c;
2496 
2497  // Get the dof values required to write just our local part of
2498  // the solution vector.
2499  std::vector<Number> local_soln;
2500  parallel_soln.localize(local_soln, required_indices);
2501 
2502 #ifndef LIBMESH_USE_COMPLEX_NUMBERS
2503  // Call the ExodusII_IO_Helper function to write the data.
2504  write_nodal_values(variable_name_position + 1, local_soln, timestep);
2505 #else
2506  // We have the local (complex) values. Now extract the real,
2507  // imaginary, and magnitude values from them.
2508  std::vector<Real> real_parts(num_nodes);
2509  std::vector<Real> imag_parts(num_nodes);
2510  std::vector<Real> magnitudes(num_nodes);
2511 
2512  for (int i=0; i<num_nodes; ++i)
2513  {
2514  real_parts[i] = local_soln[i].real();
2515  imag_parts[i] = local_soln[i].imag();
2516  magnitudes[i] = std::abs(local_soln[i]);
2517  }
2518 
2519  // Write the real, imaginary, and magnitude values to file.
2520  write_nodal_values(3 * variable_name_position + 1, real_parts, timestep);
2521  write_nodal_values(3 * variable_name_position + 2, imag_parts, timestep);
2522  write_nodal_values(3 * variable_name_position + 3, magnitudes, timestep);
2523 #endif
2524  }
2525 }
double abs(double a)
void write_nodal_values(int var_id, const std::vector< Real > &values, int timestep)
std::vector< int > exodus_node_num_to_libmesh
virtual void localize(std::vector< T > &v_local) const =0

◆ write_nodal_solution() [2/2]

void libMesh::Nemesis_IO_Helper::write_nodal_solution ( const std::vector< Number > &  values,
const std::vector< std::string > &  names,
int  timestep 
)

Takes a solution vector containing the solution for all variables and outputs it to the files

Definition at line 2431 of file nemesis_io_helper.C.

References std::abs(), libMesh::ExodusII_IO_Helper::exodus_node_num_to_libmesh, libMesh::ExodusII_IO_Helper::num_nodes, value, and libMesh::ExodusII_IO_Helper::write_nodal_values().

2434 {
2435  int num_vars = cast_int<int>(names.size());
2436  //int num_values = values.size(); // Not used?
2437 
2438  for (int c=0; c<num_vars; c++)
2439  {
2440 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
2441  std::vector<Real> real_parts(num_nodes);
2442  std::vector<Real> imag_parts(num_nodes);
2443  std::vector<Real> magnitudes(num_nodes);
2444 
2445  for (int i=0; i<num_nodes; ++i)
2446  {
2447  Number value = values[this->exodus_node_num_to_libmesh[i]*num_vars + c];
2448  real_parts[i] = value.real();
2449  imag_parts[i] = value.imag();
2450  magnitudes[i] = std::abs(value);
2451  }
2452  write_nodal_values(3*c+1,real_parts,timestep);
2453  write_nodal_values(3*c+2,imag_parts,timestep);
2454  write_nodal_values(3*c+3,magnitudes,timestep);
2455 #else
2456  std::vector<Number> cur_soln(num_nodes);
2457 
2458  // Copy out this variable's solution
2459  for (int i=0; i<num_nodes; i++)
2460  cur_soln[i] = values[this->exodus_node_num_to_libmesh[i]*num_vars + c];
2461 
2462  write_nodal_values(c+1,cur_soln,timestep);
2463 #endif
2464  }
2465 }
double abs(double a)
void write_nodal_values(int var_id, const std::vector< Real > &values, int timestep)
static const bool value
Definition: xdr_io.C:109
std::vector< int > exodus_node_num_to_libmesh

◆ write_nodal_values()

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

Writes the vector of values to a nodal variable.

Definition at line 1948 of file exodusII_io_helper.C.

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

Referenced by write_nodal_solution().

1949 {
1950  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1951  return;
1952 
1953  if (_single_precision)
1954  {
1955  std::vector<float> cast_values(values.begin(), values.end());
1956  ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, cast_values.data());
1957  }
1958  else
1959  {
1960  ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, values.data());
1961  }
1962  EX_CHECK_ERR(ex_err, "Error writing nodal values.");
1963 
1965  EX_CHECK_ERR(ex_err, "Error flushing buffers to file.");
1966 }
EXODUS_EXPORT int ex_update(int exoid)
processor_id_type processor_id() const
EXODUS_EXPORT int ex_put_nodal_var(int exoid, int time_step, int nodal_var_index, int64_t num_nodes, const void *nodal_var_vals)

◆ write_nodesets()

void libMesh::Nemesis_IO_Helper::write_nodesets ( const MeshBase mesh)
overridevirtual

Writes the nodesets for this processor.

Reimplemented from libMesh::ExodusII_IO_Helper.

Definition at line 1965 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, EX_NODE_SET, ex_put_names(), ex_put_node_set(), ex_put_node_set_param(), global_nodeset_ids, libMesh::ExodusII_IO_Helper::libmesh_node_num_to_exodus, mesh, libMesh::out, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

1966 {
1967  // Write the nodesets. In Nemesis, the idea is to "create space" for the global
1968  // set of boundary nodesets, but to only write node IDs which are local to the current
1969  // processor. This is what is done in Nemesis files created by the "loadbal" script.
1970 
1971  // Store a map of vectors for boundary node IDs on this processor.
1972  // Use a vector of int here so it can be passed directly to Exodus.
1973  std::map<boundary_id_type, std::vector<int>> local_node_boundary_id_lists;
1974 
1975  // FIXME: We should build this list only one time!! We already built it above, but we
1976  // did not have the libmesh to exodus node mapping at that time... for now we'll just
1977  // build it here again, hopefully it's small relative to the size of the entire mesh.
1978 
1979  // Build list of (node-id, bc-id) tuples.
1980  typedef std::tuple<dof_id_type, boundary_id_type> Tuple;
1981  std::vector<Tuple> bc_tuples = mesh.get_boundary_info().build_node_list();
1982 
1983  if (verbose)
1984  {
1985  libMesh::out << "[" << this->processor_id() << "] boundary_node_list.size()="
1986  << bc_tuples.size() << std::endl;
1987  libMesh::out << "[" << this->processor_id() << "] (boundary_node_id, boundary_id) = ";
1988  for (const auto & t : bc_tuples)
1989  libMesh::out << "(" << std::get<0>(t) << ", " << std::get<1>(t) << ") ";
1990  libMesh::out << std::endl;
1991  }
1992 
1993  // For each node in the node list, add it to the vector of node IDs for that
1994  // set for the local processor. This will be used later when writing Exodus
1995  // nodesets.
1996  for (const auto & t : bc_tuples)
1997  {
1998  // Don't try to grab a reference to the vector unless the current node is attached
1999  // to a local element. Otherwise, another processor will be responsible for writing it in its nodeset.
2000  std::map<int, int>::iterator it = this->libmesh_node_num_to_exodus.find(std::get<0>(t));
2001 
2002  if (it != this->libmesh_node_num_to_exodus.end())
2003  {
2004  // Get reference to the vector where this node ID will be inserted. If it
2005  // doesn't yet exist, this will create it.
2006  std::vector<int> & current_id_set = local_node_boundary_id_lists[std::get<1>(t)];
2007 
2008  // Push back Exodus-mapped node ID for this set
2009  // TODO: reserve space in these vectors somehow.
2010  current_id_set.push_back( it->second );
2011  }
2012  }
2013 
2014  // See what we got
2015  if (verbose)
2016  {
2017  for (const auto & pr : local_node_boundary_id_lists)
2018  {
2019  libMesh::out << "[" << this->processor_id() << "] ID: " << pr.first << ", ";
2020 
2021  // Libmesh node ID (Exodus Node ID)
2022  for (const auto & id : pr.second)
2023  libMesh::out << id << ", ";
2024  libMesh::out << std::endl;
2025  }
2026  }
2027 
2028  // Loop over *global* nodeset IDs, call the Exodus API. Note that some nodesets may be empty
2029  // for a given processor.
2030  if (global_nodeset_ids.size() > 0)
2031  {
2032  NamesData names_table(global_nodeset_ids.size(), MAX_STR_LENGTH);
2033 
2034  for (std::size_t i=0; i<this->global_nodeset_ids.size(); ++i)
2035  {
2036  const std::string & current_ns_name =
2037  mesh.get_boundary_info().get_nodeset_name
2038  (cast_int<boundary_id_type>(global_nodeset_ids[i]));
2039 
2040  // Store this name in a data structure that will be used to
2041  // write sideset names to file.
2042  names_table.push_back_entry(current_ns_name);
2043 
2044  if (verbose)
2045  {
2046  libMesh::out << "[" << this->processor_id()
2047  << "] Writing out Exodus nodeset info for ID: " << global_nodeset_ids[i]
2048  << ", Name: " << current_ns_name
2049  << std::endl;
2050  }
2051 
2052  // Convert current global_nodeset_id into an exodus ID, which can't be zero...
2053  int exodus_id = global_nodeset_ids[i];
2054 
2055  /*
2056  // Exodus can't handle zero nodeset IDs (?) Use max short here since
2057  // when libmesh reads it back in, it will want to store it as a short...
2058  if (exodus_id==0)
2059  exodus_id = std::numeric_limits<short>::max();
2060  */
2061 
2062  // Try to find this boundary ID in the local list we created
2063  auto it =
2064  local_node_boundary_id_lists.find (cast_int<boundary_id_type>(this->global_nodeset_ids[i]));
2065 
2066  // No nodes found for this boundary ID on this processor
2067  if (it == local_node_boundary_id_lists.end())
2068  {
2069  if (verbose)
2070  libMesh::out << "[" << this->processor_id()
2071  << "] No nodeset data for ID: " << global_nodeset_ids[i]
2072  << " on this processor." << std::endl;
2073 
2074  // Call the Exodus interface to write the parameters of this node set
2076  exodus_id,
2077  0, /* No nodes for this ID */
2078  0 /* No distribution factors */);
2079  EX_CHECK_ERR(this->ex_err, "Error writing nodeset parameters in Nemesis");
2080 
2081  }
2082  else // Boundary ID *was* found in list
2083  {
2084  // Get reference to the vector of node IDs
2085  std::vector<int> & current_nodeset_ids = it->second;
2086 
2087  // Call the Exodus interface to write the parameters of this node set
2089  exodus_id,
2090  current_nodeset_ids.size(),
2091  0 /* No distribution factors */);
2092 
2093  EX_CHECK_ERR(this->ex_err, "Error writing nodeset parameters in Nemesis");
2094 
2095  // Call Exodus interface to write the actual node IDs for this boundary ID
2096  this->ex_err = exII::ex_put_node_set(this->ex_id,
2097  exodus_id,
2098  current_nodeset_ids.data());
2099 
2100  EX_CHECK_ERR(this->ex_err, "Error writing nodesets in Nemesis");
2101 
2102  }
2103  } // end loop over global nodeset IDs
2104 
2105  // Write out the nodeset names
2108  names_table.get_char_star_star());
2109  EX_CHECK_ERR(ex_err, "Error writing nodeset names");
2110  } // end for loop over global nodeset IDs
2111 }
std::vector< int > global_nodeset_ids
EXODUS_EXPORT int ex_put_node_set_param(int exoid, ex_entity_id node_set_id, int64_t num_nodes_in_set, int64_t num_dist_in_set)
MeshBase & mesh
EXODUS_EXPORT int ex_put_node_set(int exoid, ex_entity_id node_set_id, const void_int *node_set_node_list)
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
std::map< int, int > libmesh_node_num_to_exodus
processor_id_type processor_id() const
OStreamProxy out(std::cout)

◆ write_sidesets()

void libMesh::Nemesis_IO_Helper::write_sidesets ( const MeshBase mesh)
overridevirtual

Writes the sidesets for this processor.

Reimplemented from libMesh::ExodusII_IO_Helper.

Definition at line 2116 of file nemesis_io_helper.C.

References libMesh::Elem::active_family_tree_by_side(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), libMesh::ExodusII_IO_Helper::ex_err, libMesh::ExodusII_IO_Helper::ex_id, ex_put_names(), ex_put_side_set(), ex_put_side_set_param(), EX_SIDE_SET, libMesh::ExodusII_IO_Helper::Conversion::get_inverse_side_map(), global_sideset_ids, libMesh::ExodusII_IO_Helper::libmesh_elem_num_to_exodus, mesh, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Elem::type(), and libMesh::ExodusII_IO_Helper::verbose.

2117 {
2118  // Write the sidesets. In Nemesis, the idea is to "create space" for the global
2119  // set of boundary sidesets, but to only write sideset IDs which are local to the current
2120  // processor. This is what is done in Nemesis files created by the "loadbal" script.
2121  // See also: ExodusII_IO_Helper::write_sidesets()...
2122 
2123 
2124  // Store a map of vectors for boundary side IDs on this processor.
2125  // Use a vector of int here so it can be passed directly to Exodus.
2126  std::map<boundary_id_type, std::vector<int>> local_elem_boundary_id_lists;
2127  std::map<boundary_id_type, std::vector<int>> local_elem_boundary_id_side_lists;
2128 
2129  ExodusII_IO_Helper::ElementMaps em;
2130 
2131  // FIXME: We already built this list once, we should reuse that information!
2132  std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type>> bndry_elem_side_id_list =
2133  mesh.get_boundary_info().build_side_list();
2134 
2135  // Integer looping, skipping non-local elements
2136  for (std::size_t i=0; i<bndry_elem_side_id_list.size(); ++i)
2137  {
2138  // Get pointer to current Elem
2139  const Elem * elem = mesh.elem_ptr(std::get<0>(bndry_elem_side_id_list[i]));
2140 
2141  std::vector<const Elem *> family;
2142 #ifdef LIBMESH_ENABLE_AMR
2143  // We need to build up active elements if AMR is enabled and add
2144  // them to the exodus sidesets instead of the potentially inactive "parent" elements
2145  // Technically we don't need to "reset" the tree since the vector was just created.
2146  elem->active_family_tree_by_side(family, std::get<1>(bndry_elem_side_id_list[i]), /*reset tree=*/false);
2147 #else
2148  // If AMR is not even enabled, just push back the element itself
2149  family.push_back( elem );
2150 #endif
2151 
2152  // Loop over all the elements in the family tree, store their converted IDs
2153  // and side IDs to the map's vectors. TODO: Somehow reserve enough space for these
2154  // push_back's...
2155  for (std::size_t j=0; j<family.size(); ++j)
2156  {
2157  const dof_id_type f_id = family[j]->id();
2158  const Elem & f = mesh.elem_ref(f_id);
2159 
2160  // If element is local, process it
2161  if (f.processor_id() == this->processor_id())
2162  {
2163  const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(f.type());
2164 
2165  // Use the libmesh to exodus data structure map to get the proper sideset IDs
2166  // The data structure contains the "collapsed" contiguous ids.
2167  //
2168  // We know the parent element is local, but let's be absolutely sure that all the children have been
2169  // actually mapped to Exodus IDs before we blindly try to add them...
2170  std::map<int,int>::iterator it = this->libmesh_elem_num_to_exodus.find( f_id );
2171  if (it != this->libmesh_elem_num_to_exodus.end())
2172  {
2173  local_elem_boundary_id_lists[ std::get<2>(bndry_elem_side_id_list[i]) ].push_back( it->second );
2174  local_elem_boundary_id_side_lists[ std::get<2>(bndry_elem_side_id_list[i]) ].push_back(conv.get_inverse_side_map( std::get<1>(bndry_elem_side_id_list[i]) ));
2175  }
2176  else
2177  libmesh_error_msg("Error, no Exodus mapping for Elem " \
2178  << f_id \
2179  << " on processor " \
2180  << this->processor_id());
2181  }
2182  }
2183  }
2184 
2185 
2186  // Loop over *global* sideset IDs, call the Exodus API. Note that some sidesets may be empty
2187  // for a given processor.
2188  if (global_sideset_ids.size() > 0)
2189  {
2190  NamesData names_table(global_sideset_ids.size(), MAX_STR_LENGTH);
2191 
2192  for (std::size_t i=0; i<this->global_sideset_ids.size(); ++i)
2193  {
2194  const std::string & current_ss_name =
2195  mesh.get_boundary_info().get_sideset_name
2196  (cast_int<boundary_id_type>(global_sideset_ids[i]));
2197 
2198  // Store this name in a data structure that will be used to
2199  // write sideset names to file.
2200  names_table.push_back_entry(current_ss_name);
2201 
2202  if (verbose)
2203  {
2204  libMesh::out << "[" << this->processor_id()
2205  << "] Writing out Exodus sideset info for ID: " << global_sideset_ids[i]
2206  << ", Name: " << current_ss_name
2207  << std::endl;
2208  }
2209 
2210  // Convert current global_sideset_id into an exodus ID, which can't be zero...
2211  int exodus_id = global_sideset_ids[i];
2212 
2213  /*
2214  // Exodus can't handle zero sideset IDs (?) Use max short here since
2215  // when libmesh reads it back in, it will want to store it as a short...
2216  if (exodus_id==0)
2217  exodus_id = std::numeric_limits<short>::max();
2218  */
2219 
2220  // Try to find this boundary ID in the local list we created
2221  auto it =
2222  local_elem_boundary_id_lists.find (cast_int<boundary_id_type>(this->global_sideset_ids[i]));
2223 
2224  // No sides found for this boundary ID on this processor
2225  if (it == local_elem_boundary_id_lists.end())
2226  {
2227  if (verbose)
2228  libMesh::out << "[" << this->processor_id()
2229  << "] No sideset data for ID: " << global_sideset_ids[i]
2230  << " on this processor." << std::endl;
2231 
2232  // Call the Exodus interface to write the parameters of this side set
2234  exodus_id,
2235  0, /* No sides for this ID */
2236  0 /* No distribution factors */);
2237  EX_CHECK_ERR(this->ex_err, "Error writing sideset parameters in Nemesis");
2238 
2239  }
2240  else // Boundary ID *was* found in list
2241  {
2242  // Get iterator to sides vector as well
2243  auto it_sides =
2244  local_elem_boundary_id_side_lists.find (cast_int<boundary_id_type>(this->global_sideset_ids[i]));
2245 
2246  libmesh_assert (it_sides != local_elem_boundary_id_side_lists.end());
2247 
2248  // Get reference to the vector of elem IDs
2249  std::vector<int> & current_sideset_elem_ids = it->second;
2250 
2251  // Get reference to the vector of side IDs
2252  std::vector<int> & current_sideset_side_ids = (*it_sides).second;
2253 
2254  // Call the Exodus interface to write the parameters of this side set
2256  exodus_id,
2257  current_sideset_elem_ids.size(),
2258  0 /* No distribution factors */);
2259 
2260  EX_CHECK_ERR(this->ex_err, "Error writing sideset parameters in Nemesis");
2261 
2262  // Call Exodus interface to write the actual side IDs for this boundary ID
2263  this->ex_err = exII::ex_put_side_set(this->ex_id,
2264  exodus_id,
2265  current_sideset_elem_ids.data(),
2266  current_sideset_side_ids.data());
2267 
2268  EX_CHECK_ERR(this->ex_err, "Error writing sidesets in Nemesis");
2269  }
2270  } // end for loop over global sideset IDs
2271 
2272  // Write sideset names to file. Some of these may be blank strings
2273  // if the current processor didn't have all the sideset names for
2274  // any reason...
2277  names_table.get_char_star_star());
2278  EX_CHECK_ERR(ex_err, "Error writing sideset names");
2279 
2280  } // end if (global_sideset_ids.size() > 0)
2281 }
std::vector< int > global_sideset_ids
MeshBase & mesh
std::map< int, int > libmesh_elem_num_to_exodus
EXODUS_EXPORT int ex_put_side_set(int exoid, ex_entity_id side_set_id, const void_int *side_set_elem_list, const void_int *side_set_side_list)
EXODUS_EXPORT int ex_put_names(int exoid, ex_entity_type obj_type, char *names[])
EXODUS_EXPORT int ex_put_side_set_param(int exoid, ex_entity_id side_set_id, int64_t num_side_in_set, int64_t num_dist_fact_in_set)
processor_id_type processor_id() const
OStreamProxy out(std::cout)
uint8_t dof_id_type
Definition: id_types.h:64

◆ write_timestep()

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

Writes the time for the timestep

Definition at line 1843 of file exodusII_io_helper.C.

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

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

◆ write_var_names()

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

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

Definition at line 956 of file exodusII_io_helper.C.

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

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

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

Member Data Documentation

◆ _communicator

◆ _coordinate_offset

Point libMesh::ExodusII_IO_Helper::_coordinate_offset
protectedinherited

◆ _elem_vars_initialized

bool libMesh::ExodusII_IO_Helper::_elem_vars_initialized
protectedinherited

◆ _global_vars_initialized

bool libMesh::ExodusII_IO_Helper::_global_vars_initialized
protectedinherited

◆ _nodal_vars_initialized

bool libMesh::ExodusII_IO_Helper::_nodal_vars_initialized
protectedinherited

◆ _run_only_on_proc0

◆ _single_precision

◆ _use_mesh_dimension_instead_of_spatial_dimension

bool libMesh::ExodusII_IO_Helper::_use_mesh_dimension_instead_of_spatial_dimension
protectedinherited

◆ _write_as_dimension

unsigned libMesh::ExodusII_IO_Helper::_write_as_dimension
protectedinherited

◆ block_id_to_elem_connectivity

std::map<int, std::vector<int> > libMesh::Nemesis_IO_Helper::block_id_to_elem_connectivity

This is the block connectivity, i.e. for each subdomain (block) there is an element connectivity list. This map associates the block ID to that vector.

Definition at line 434 of file nemesis_io_helper.h.

Referenced by build_element_and_node_maps(), and write_elements().

◆ block_ids

◆ border_elem_ids

std::set<unsigned> libMesh::Nemesis_IO_Helper::border_elem_ids
private

A set of border elem IDs for this processor.

Definition at line 609 of file nemesis_io_helper.h.

Referenced by compute_element_maps(), and compute_internal_and_border_elems_and_internal_nodes().

◆ border_node_ids

std::set<unsigned> libMesh::Nemesis_IO_Helper::border_node_ids
private

The set which will eventually contain the IDs of "border nodes". These are nodes that lie on the boundary between one or more processors.

Definition at line 572 of file nemesis_io_helper.h.

Referenced by compute_border_node_ids(), compute_internal_and_border_elems_and_internal_nodes(), and compute_node_maps().

◆ connect

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

◆ current_filename

std::string libMesh::ExodusII_IO_Helper::current_filename
inherited

◆ elem_cmap_elem_cnts

std::vector<int> libMesh::Nemesis_IO_Helper::elem_cmap_elem_cnts

◆ elem_cmap_elem_ids

std::vector<std::vector<int> > libMesh::Nemesis_IO_Helper::elem_cmap_elem_ids

3 vectors of vectors for storing element communication IDs for this processor. There will be num_elem_cmaps rows, row i will have elem_cmap_elem_cnts[i] entries. To be used with Nemesis::ne_get_elem_cmap().

Definition at line 556 of file nemesis_io_helper.h.

Referenced by compute_elem_communication_maps(), get_elem_cmap(), and initialize().

◆ elem_cmap_ids

std::vector<int> libMesh::Nemesis_IO_Helper::elem_cmap_ids

◆ elem_cmap_proc_ids

std::vector<std::vector<int> > libMesh::Nemesis_IO_Helper::elem_cmap_proc_ids

Definition at line 558 of file nemesis_io_helper.h.

Referenced by compute_elem_communication_maps(), get_elem_cmap(), and initialize().

◆ elem_cmap_side_ids

std::vector<std::vector<int> > libMesh::Nemesis_IO_Helper::elem_cmap_side_ids

Definition at line 557 of file nemesis_io_helper.h.

Referenced by compute_elem_communication_maps(), get_elem_cmap(), and initialize().

◆ elem_list

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

◆ elem_mapb

std::vector<int> libMesh::Nemesis_IO_Helper::elem_mapb

Vector which stores border element IDs. Will have length num_border_elems. To be used with Nemesis::ne_get_elem_map().

Definition at line 501 of file nemesis_io_helper.h.

Referenced by compute_element_maps(), get_elem_map(), and initialize().

◆ elem_mapi

std::vector<int> libMesh::Nemesis_IO_Helper::elem_mapi

Vector which stores internal element IDs. Will have length num_internal_elems. To be used with Nemesis::ne_get_elem_map().

Definition at line 494 of file nemesis_io_helper.h.

Referenced by compute_element_maps(), get_elem_map(), and initialize().

◆ elem_num_map

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

◆ elem_type

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

◆ elem_var_names

◆ elem_var_values

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

Definition at line 562 of file exodusII_io_helper.h.

◆ ex_err

int libMesh::ExodusII_IO_Helper::ex_err
inherited

Definition at line 438 of file exodusII_io_helper.h.

Referenced by libMesh::ExodusII_IO_Helper::close(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), initialize_element_variables(), libMesh::ExodusII_IO_Helper::inquire(), libMesh::ExodusII_IO_Helper::read_block_info(), libMesh::ExodusII_IO_Helper::read_elem_in_block(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_elemental_var_values(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO_Helper::read_header(), libMesh::ExodusII_IO_Helper::read_nodal_var_values(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::ExodusII_IO_Helper::read_nodes(), libMesh::ExodusII_IO_Helper::read_nodeset(), libMesh::ExodusII_IO_Helper::read_nodeset_info(), libMesh::ExodusII_IO_Helper::read_qa_records(), libMesh::ExodusII_IO_Helper::read_sideset(), libMesh::ExodusII_IO_Helper::read_sideset_info(), libMesh::ExodusII_IO_Helper::read_time_steps(), libMesh::ExodusII_IO_Helper::read_var_names_impl(), libMesh::ExodusII_IO_Helper::write_element_values(), write_element_values(), write_elements(), libMesh::ExodusII_IO_Helper::write_elements(), write_exodus_initialization_info(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::ExodusII_IO_Helper::write_information_records(), write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_values(), write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_timestep(), libMesh::ExodusII_IO_Helper::write_var_names_impl(), and ~Nemesis_IO_Helper().

◆ ex_id

int libMesh::ExodusII_IO_Helper::ex_id
inherited

Definition at line 435 of file exodusII_io_helper.h.

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

◆ exodus_elem_num_to_libmesh

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

Definition at line 533 of file exodusII_io_helper.h.

Referenced by build_element_and_node_maps(), and write_elements().

◆ exodus_node_num_to_libmesh

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

◆ ftype

char libMesh::Nemesis_IO_Helper::ftype

The type of file to be written. Either 's', for a scalar load-balance file, or 'p' for a parallel file. To be used with Nemesis::ne_get_init_info().

Definition at line 386 of file nemesis_io_helper.h.

Referenced by get_init_info().

◆ global_elem_blk_cnts

std::vector<int> libMesh::Nemesis_IO_Helper::global_elem_blk_cnts

◆ global_elem_blk_ids

std::vector<int> libMesh::Nemesis_IO_Helper::global_elem_blk_ids

Read the global element block IDs and counts. These vectors will eventually have num_elem_blks_global entries. To be used with Nemesis::ne_get_eb_info_global().

Definition at line 417 of file nemesis_io_helper.h.

Referenced by compute_num_global_elem_blocks(), get_eb_info_global(), initialize(), initialize_element_variables(), write_element_values(), and write_elements().

◆ global_nodeset_ids

std::vector<int> libMesh::Nemesis_IO_Helper::global_nodeset_ids

Containers for reading global nodeset information. One vector entry per nodeset. Each vector will eventually have num_node_sets_global entries, and will be used in calls to Nemesis::ne_get_ns_param_global().

It's an error to call ne_get_ns_param_global when num_node_sets_global==0

Definition at line 407 of file nemesis_io_helper.h.

Referenced by compute_num_global_nodesets(), get_ns_param_global(), initialize(), put_ns_param_global(), write_exodus_initialization_info(), and write_nodesets().

◆ global_sideset_ids

std::vector<int> libMesh::Nemesis_IO_Helper::global_sideset_ids

Containers for reading global sideset (boundary conditions) information. Each vector will eventually have num_side_sets_global entries, and be used in calls to Nemesis::ne_get_ss_param_global().

It's an error to call ne_get_ss_param_global when num_side_sets_global==0

Definition at line 395 of file nemesis_io_helper.h.

Referenced by compute_num_global_sidesets(), get_ss_param_global(), initialize(), put_ss_param_global(), write_exodus_initialization_info(), and write_sidesets().

◆ global_var_names

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

◆ id_list

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

◆ id_to_block_names

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

◆ id_to_ns_names

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

◆ id_to_ss_names

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

◆ internal_elem_ids

std::set<unsigned> libMesh::Nemesis_IO_Helper::internal_elem_ids
private

A set of internal elem IDs for this processor.

Definition at line 604 of file nemesis_io_helper.h.

Referenced by compute_element_maps(), and compute_internal_and_border_elems_and_internal_nodes().

◆ internal_node_ids

std::set<unsigned> libMesh::Nemesis_IO_Helper::internal_node_ids
private

A set of internal node IDs for this processor.

Definition at line 599 of file nemesis_io_helper.h.

Referenced by compute_internal_and_border_elems_and_internal_nodes(), and compute_node_maps().

◆ libmesh_elem_num_to_exodus

std::map<int, int> libMesh::ExodusII_IO_Helper::libmesh_elem_num_to_exodus
inherited

◆ libmesh_node_num_to_exodus

std::map<int, int> libMesh::ExodusII_IO_Helper::libmesh_node_num_to_exodus
inherited

◆ local_subdomain_counts

std::map<subdomain_id_type, unsigned> libMesh::Nemesis_IO_Helper::local_subdomain_counts
private

This map keeps track of the number of elements in each subdomain (block) for this processor.

Definition at line 566 of file nemesis_io_helper.h.

Referenced by build_element_and_node_maps(), and compute_num_global_elem_blocks().

◆ nemesis_err_flag

int libMesh::Nemesis_IO_Helper::nemesis_err_flag

◆ nodal_var_names

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

◆ nodal_var_values

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

◆ node_cmap_ids

std::vector<int> libMesh::Nemesis_IO_Helper::node_cmap_ids

Vectors for storing the communication map parameters. Each will eventually have length num_node_cmaps OR num_elem_cmaps as appropriate. For use with Nemesis::ne_get_cmap_params().

Definition at line 533 of file nemesis_io_helper.h.

Referenced by compute_communication_map_parameters(), compute_node_communication_maps(), get_cmap_params(), get_node_cmap(), initialize(), and put_node_cmap().

◆ node_cmap_node_cnts

std::vector<int> libMesh::Nemesis_IO_Helper::node_cmap_node_cnts

◆ node_cmap_node_ids

std::vector<std::vector<int> > libMesh::Nemesis_IO_Helper::node_cmap_node_ids

2 vectors of vectors for storing the node communication IDs for this processor. There will be num_node_cmaps rows, row i will have node_cmap_node_cnts[i] entries. To be used with Nemesis::ne_get_node_cmap().

Remark: node_cmap_proc_ids is a vector, all entries of which are = node_cmap_ids[i] Not sure what the point of that is...

Definition at line 547 of file nemesis_io_helper.h.

Referenced by compute_node_communication_maps(), get_node_cmap(), and initialize().

◆ node_cmap_proc_ids

std::vector<std::vector<int> > libMesh::Nemesis_IO_Helper::node_cmap_proc_ids

Definition at line 548 of file nemesis_io_helper.h.

Referenced by compute_node_communication_maps(), get_node_cmap(), and initialize().

◆ node_list

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

Definition at line 504 of file exodusII_io_helper.h.

Referenced by libMesh::ExodusII_IO_Helper::read_nodeset().

◆ node_mapb

std::vector<int> libMesh::Nemesis_IO_Helper::node_mapb

Vector which stores border node IDs. Will have length num_border_nodes. To be used with Nemesis::ne_get_node_map().

Definition at line 517 of file nemesis_io_helper.h.

Referenced by compute_node_maps(), get_node_map(), and initialize().

◆ node_mape

std::vector<int> libMesh::Nemesis_IO_Helper::node_mape

Vector which stores external node IDs. Will have length num_external_nodes. To be used with Nemesis::ne_get_node_map().

Definition at line 524 of file nemesis_io_helper.h.

Referenced by compute_node_maps(), get_node_map(), and initialize().

◆ node_mapi

std::vector<int> libMesh::Nemesis_IO_Helper::node_mapi

Vector which stores internal node IDs. Will have length num_internal_nodes. To be used with Nemesis::ne_get_node_map().

Definition at line 510 of file nemesis_io_helper.h.

Referenced by compute_node_maps(), get_node_map(), and initialize().

◆ node_num_map

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

◆ nodes_attached_to_local_elems

std::set<int> libMesh::Nemesis_IO_Helper::nodes_attached_to_local_elems

libMesh numbered node ids attached to local elems.

Definition at line 423 of file nemesis_io_helper.h.

Referenced by build_element_and_node_maps(), and compute_internal_and_border_elems_and_internal_nodes().

◆ nodeset_ids

◆ num_attr

int libMesh::ExodusII_IO_Helper::num_attr
inherited

◆ num_border_elems

int libMesh::Nemesis_IO_Helper::num_border_elems

The number of border FEM elements. Elements local to this processor but whose FEM nodes reside on other processors as well. To be used with the Nemesis::ne_get_loadbal_param() routine.

Definition at line 471 of file nemesis_io_helper.h.

Referenced by compute_internal_and_border_elems_and_internal_nodes(), get_elem_map(), get_loadbal_param(), and initialize().

◆ num_border_nodes

int libMesh::Nemesis_IO_Helper::num_border_nodes

The number of FEM nodes local to a processor but residing in an element which also has FEM nodes on other processors. To be used with the Nemesis::ne_get_loadbal_param() routine.

Definition at line 451 of file nemesis_io_helper.h.

Referenced by compute_border_node_ids(), compute_internal_and_border_elems_and_internal_nodes(), get_loadbal_param(), get_node_map(), and initialize().

◆ num_df_per_set

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

◆ num_dim

◆ num_elem

◆ num_elem_all_sidesets

int libMesh::ExodusII_IO_Helper::num_elem_all_sidesets
inherited

◆ num_elem_blk

◆ num_elem_blks_global

int libMesh::Nemesis_IO_Helper::num_elem_blks_global

◆ num_elem_cmaps

int libMesh::Nemesis_IO_Helper::num_elem_cmaps

The number of elemental communication maps for this processor. (One per neighboring proc?) To be used with the Nemesis::ne_get_loadbal_param() routine.

Definition at line 485 of file nemesis_io_helper.h.

Referenced by compute_communication_map_parameters(), compute_elem_communication_maps(), compute_internal_and_border_elems_and_internal_nodes(), get_cmap_params(), get_elem_cmap(), get_loadbal_param(), and initialize().

◆ num_elem_this_blk

int libMesh::ExodusII_IO_Helper::num_elem_this_blk
inherited

◆ num_elem_vars

◆ num_elems_global

int libMesh::Nemesis_IO_Helper::num_elems_global

Definition at line 363 of file nemesis_io_helper.h.

Referenced by get_init_global().

◆ num_external_nodes

int libMesh::Nemesis_IO_Helper::num_external_nodes

The number of FEM nodes that reside on another processor but whose element partially resides on the current processor. To be used with the Nemesis::ne_get_loadbal_param() routine.

Definition at line 458 of file nemesis_io_helper.h.

Referenced by get_loadbal_param(), get_node_map(), and initialize().

◆ num_global_node_counts

std::vector<int> libMesh::Nemesis_IO_Helper::num_global_node_counts

◆ num_global_node_df_counts

std::vector<int> libMesh::Nemesis_IO_Helper::num_global_node_df_counts

Definition at line 409 of file nemesis_io_helper.h.

Referenced by get_ns_param_global(), and initialize().

◆ num_global_side_counts

std::vector<int> libMesh::Nemesis_IO_Helper::num_global_side_counts

◆ num_global_side_df_counts

std::vector<int> libMesh::Nemesis_IO_Helper::num_global_side_df_counts

Definition at line 397 of file nemesis_io_helper.h.

Referenced by get_ss_param_global(), and initialize().

◆ num_global_vars

◆ num_internal_elems

int libMesh::Nemesis_IO_Helper::num_internal_elems

The number of internal FEM elements. Elements local to this processor. To be used with the Nemesis::ne_get_loadbal_param() routine.

Definition at line 464 of file nemesis_io_helper.h.

Referenced by compute_internal_and_border_elems_and_internal_nodes(), get_elem_map(), get_loadbal_param(), and initialize().

◆ num_internal_nodes

int libMesh::Nemesis_IO_Helper::num_internal_nodes

To be used with the Nemesis::ne_get_loadbal_param() routine. The number of FEM nodes contained in FEM elements wholly owned by the current processor. To be used with the Nemesis::ne_get_loadbal_param() routine.

Definition at line 444 of file nemesis_io_helper.h.

Referenced by compute_internal_and_border_elems_and_internal_nodes(), get_loadbal_param(), get_node_map(), and initialize().

◆ num_nodal_vars

◆ num_node_cmaps

int libMesh::Nemesis_IO_Helper::num_node_cmaps

The number of nodal communication maps for this processor. (One per neighboring proc?) To be used with the Nemesis::ne_get_loadbal_param() routine.

Definition at line 478 of file nemesis_io_helper.h.

Referenced by compute_border_node_ids(), compute_communication_map_parameters(), compute_node_communication_maps(), get_cmap_params(), get_loadbal_param(), get_node_cmap(), and initialize().

◆ num_node_df_per_set

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

◆ num_node_sets

◆ num_node_sets_global

int libMesh::Nemesis_IO_Helper::num_node_sets_global

◆ num_nodes

◆ num_nodes_global

int libMesh::Nemesis_IO_Helper::num_nodes_global

Global initial information. The names are self-explanatory for the most part. Used with Nemesis::ne_get_init_global().

Definition at line 362 of file nemesis_io_helper.h.

Referenced by get_init_global().

◆ num_nodes_per_elem

int libMesh::ExodusII_IO_Helper::num_nodes_per_elem
inherited

◆ num_nodes_per_set

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

◆ num_proc

int libMesh::Nemesis_IO_Helper::num_proc

The number of processors for which the NEMESIS I file was created. To be used with Nemesis::ne_get_init_info().

Definition at line 372 of file nemesis_io_helper.h.

Referenced by get_init_info().

◆ num_proc_in_file

int libMesh::Nemesis_IO_Helper::num_proc_in_file

The number of processors for which the NEMESIS I file stores information. This is generally equal to 1 (1 CPU/file) at least for the splitting Derek gave us. To be used with Nemesis::ne_get_init_info().

Definition at line 379 of file nemesis_io_helper.h.

Referenced by get_init_info().

◆ num_side_sets

◆ num_side_sets_global

int libMesh::Nemesis_IO_Helper::num_side_sets_global

◆ num_sides_per_set

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

◆ num_time_steps

int libMesh::ExodusII_IO_Helper::num_time_steps
inherited

◆ opened_for_reading

bool libMesh::ExodusII_IO_Helper::opened_for_reading
inherited

◆ opened_for_writing

bool libMesh::ExodusII_IO_Helper::opened_for_writing
inherited

◆ proc_border_elem_sets

std::map<unsigned, std::set<std::pair<unsigned,unsigned> > > libMesh::Nemesis_IO_Helper::proc_border_elem_sets
private

Map between processor ID and (element,side) pairs bordering that processor ID.

Definition at line 589 of file nemesis_io_helper.h.

Referenced by compute_communication_map_parameters(), compute_elem_communication_maps(), and compute_internal_and_border_elems_and_internal_nodes().

◆ proc_nodes_touched_intersections

std::map<unsigned, std::set<unsigned> > libMesh::Nemesis_IO_Helper::proc_nodes_touched_intersections
private

Another map to store sets of intersections with each other processor (other than ourself, of course). A node which appears in one of these vectors belongs to element owned by at least this processor and one other.

Definition at line 579 of file nemesis_io_helper.h.

Referenced by compute_border_node_ids(), compute_communication_map_parameters(), and compute_node_communication_maps().

◆ side_list

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

◆ ss_ids

◆ subdomain_map

std::map<subdomain_id_type, std::vector<dof_id_type> > libMesh::Nemesis_IO_Helper::subdomain_map

Map of subdomains to element numbers.

Definition at line 428 of file nemesis_io_helper.h.

Referenced by build_element_and_node_maps(), write_element_values(), and write_elements().

◆ time_steps

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

Definition at line 544 of file exodusII_io_helper.h.

Referenced by libMesh::ExodusII_IO_Helper::read_time_steps().

◆ title

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

◆ verbose

◆ x

◆ y

◆ z


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