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)
 
virtual void write_elements (const MeshBase &mesh, bool use_discontinuous=false)
 
virtual void write_sidesets (const MeshBase &mesh)
 
virtual void write_nodesets (const MeshBase &mesh)
 
virtual void create (std::string filename)
 
virtual void initialize (std::string title, const MeshBase &mesh, bool use_discontinuous=false)
 
void write_nodal_solution (const NumericVector< Number > &parallel_soln, const std::vector< std::string > &names, int timestep)
 
void write_nodal_solution (const std::vector< Number > &values, const std::vector< std::string > &names, int timestep)
 
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_element_variables (std::vector< std::string > names)
 
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)
 
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 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
 
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< unsigned int > > 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 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

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 572 of file nemesis_io_helper.h.

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 562 of file nemesis_io_helper.h.

Member Enumeration Documentation

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

Enumerator
NODAL 
ELEMENTAL 
GLOBAL 

Definition at line 572 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 44 of file nemesis_io_helper.C.

45  :
46  ExodusII_IO_Helper(parent, verbose_in, /*run_only_on_proc0=*/false, /*single_precision=*/single_precision),
53  num_proc(0),
55  ftype('\0'),
61  num_node_cmaps(0),
63 {
64  // Warn about using untested code!
65  libmesh_experimental();
66 }
ExodusII_IO_Helper(const ParallelObject &parent, bool v=false, bool run_only_on_proc0=true, bool single_precision=false)
libMesh::Nemesis_IO_Helper::~Nemesis_IO_Helper ( )
virtual

Destructor.

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

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

Member Function Documentation

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 1752 of file nemesis_io_helper.C.

References 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::DofObject::id(), libMesh::libmesh_assert(), libMesh::ExodusII_IO_Helper::libmesh_elem_num_to_exodus, libMesh::ExodusII_IO_Helper::libmesh_node_num_to_exodus, libmesh_nullptr, local_subdomain_counts, n_nodes, libMesh::Elem::n_nodes(), libMesh::Elem::node_id(), 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(), libMesh::Elem::subdomain_id(), subdomain_map, libMesh::Elem::type(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1753 {
1754  // If we don't have any local subdomains, it had better be because
1755  // we don't have any local elements
1756 #ifdef DEBUG
1757  if (local_subdomain_counts.empty())
1758  {
1759  libmesh_assert(pmesh.active_local_elements_begin() ==
1760  pmesh.active_local_elements_end());
1762  }
1763 #endif
1764 
1765  // Elements have to be numbered contiguously based on what block
1766  // number they are in. Therefore we have to do a bit of work to get
1767  // the block (ie subdomain) numbers first and store them off as
1768  // block_ids.
1769 
1770  // Make sure there is no leftover information in the subdomain_map, and reserve
1771  // enough space to store the elements we need.
1772  this->subdomain_map.clear();
1773  for (std::map<subdomain_id_type, unsigned>::iterator it=this->local_subdomain_counts.begin();
1774  it != this->local_subdomain_counts.end();
1775  ++it)
1776  {
1777  subdomain_id_type cur_subdomain = it->first;
1778 
1779  /*
1780  // We can't have a zero subdomain ID in Exodus (for some reason?)
1781  // so map zero subdomains to a max value...
1782  if (cur_subdomain == 0)
1783  cur_subdomain = std::numeric_limits<subdomain_id_type>::max();
1784  */
1785 
1786  if (verbose)
1787  {
1788  libMesh::out << "[" << this->processor_id() << "] "
1789  << "local_subdomain_counts [" << static_cast<unsigned>(cur_subdomain) << "]= "
1790  << it->second
1791  << std::endl;
1792  }
1793 
1794  // *it.first is the subodmain ID, *it.second is the number of elements it contains
1795  this->subdomain_map[ cur_subdomain ].reserve( it->second );
1796  }
1797 
1798 
1799  // First loop over the elements to figure out which elements are in which subdomain
1800  MeshBase::const_element_iterator elem_it = pmesh.active_local_elements_begin();
1801  MeshBase::const_element_iterator elem_end = pmesh.active_local_elements_end();
1802 
1803  for (; elem_it != elem_end; ++elem_it)
1804  {
1805  const Elem * elem = *elem_it;
1806 
1807  // Grab the nodes while we're here.
1808  for (unsigned int n=0; n<elem->n_nodes(); ++n)
1809  this->nodes_attached_to_local_elems.insert( elem->node_id(n) );
1810 
1811  subdomain_id_type cur_subdomain = elem->subdomain_id();
1812 
1813  this->subdomain_map[cur_subdomain].push_back
1814  (cast_int<unsigned>(elem->id()));
1815  }
1816 
1817  // Set num_nodes which is used by exodusII_io_helper
1818  this->num_nodes =
1819  cast_int<int>(this->nodes_attached_to_local_elems.size());
1820 
1821  // Now come up with a 1-based numbering for these nodes
1822  this->exodus_node_num_to_libmesh.clear(); // Make sure it's empty
1823  this->exodus_node_num_to_libmesh.reserve(this->nodes_attached_to_local_elems.size());
1824 
1825  // Also make sure there's no leftover information in the map which goes the
1826  // other direction.
1827  this->libmesh_node_num_to_exodus.clear();
1828 
1829  // Set the map for nodes
1830  for (std::set<int>::iterator it = this->nodes_attached_to_local_elems.begin();
1831  it != this->nodes_attached_to_local_elems.end();
1832  ++it)
1833  {
1834  // I.e. given exodus_node_id,
1835  // exodus_node_num_to_libmesh[ exodus_node_id ] returns the libmesh ID for that node.
1836  // Note that even though most of Exodus is 1-based, this code will map an Exodus ID of
1837  // zero to some libmesh node ID. Is that a problem?
1838  this->exodus_node_num_to_libmesh.push_back(*it);
1839 
1840  // Likewise, given libmesh_node_id,
1841  // libmesh_node_num_to_exodus[ libmesh_node_id ] returns the *Exodus* ID for that node.
1842  // Unlike the exodus_node_num_to_libmesh vector above, this one is a std::map
1843  this->libmesh_node_num_to_exodus[*it] =
1844  cast_int<int>(this->exodus_node_num_to_libmesh.size()); // should never be zero...
1845  }
1846 
1847  // Now we're going to loop over the subdomain map and build a few things right
1848  // now that we'll use later.
1849 
1850  // First make sure our data structures don't have any leftover data...
1851  this->exodus_elem_num_to_libmesh.clear();
1852  this->block_ids.clear();
1853  this->libmesh_elem_num_to_exodus.clear();
1854 
1855  // Now loop over each subdomain and get a unique numbering for the elements
1856  for (std::map<subdomain_id_type, std::vector<unsigned int> >::iterator it = this->subdomain_map.begin();
1857  it != this->subdomain_map.end();
1858  ++it)
1859  {
1860  block_ids.push_back(it->first);
1861 
1862  // Vector of element IDs for this subdomain
1863  std::vector<unsigned int> & elem_ids_this_subdomain = it->second;
1864 
1865  // The code below assumes this subdomain block is not empty, make sure that's the case!
1866  if (elem_ids_this_subdomain.size() == 0)
1867  libmesh_error_msg("Error, no element IDs found in subdomain " << it->first);
1868 
1869  ExodusII_IO_Helper::ElementMaps em;
1870 
1871  // Use the first element in this block to get representative information.
1872  // Note that Exodus assumes all elements in a block are of the same type!
1873  // We are using that same assumption here!
1874  const ExodusII_IO_Helper::Conversion conv = em.assign_conversion
1875  (pmesh.elem_ref(elem_ids_this_subdomain[0]).type());
1876  this->num_nodes_per_elem =
1877  pmesh.elem_ref(elem_ids_this_subdomain[0]).n_nodes();
1878 
1879  // Get a reference to the connectivity vector for this subdomain. This vector
1880  // is most likely empty, we are going to fill it up now.
1881  std::vector<int> & current_block_connectivity = this->block_id_to_elem_connectivity[it->first];
1882 
1883  // Just in case it's not already empty...
1884  current_block_connectivity.clear();
1885  current_block_connectivity.resize(elem_ids_this_subdomain.size() * this->num_nodes_per_elem);
1886 
1887  for (std::size_t i=0; i<elem_ids_this_subdomain.size(); i++)
1888  {
1889  unsigned int elem_id = elem_ids_this_subdomain[i];
1890 
1891  // Set the number map for elements
1892  this->exodus_elem_num_to_libmesh.push_back(elem_id);
1893  this->libmesh_elem_num_to_exodus[elem_id] =
1894  cast_int<int>(this->exodus_elem_num_to_libmesh.size());
1895 
1896  const Elem & elem = pmesh.elem_ref(elem_id);
1897 
1898  // Exodus/Nemesis want every block to have the same element type
1899  // libmesh_assert_equal_to (elem->type(), conv.get_canonical_type());
1900 
1901  // But we can get away with writing e.g. HEX8 and INFHEX8 in
1902  // the same block...
1903  libmesh_assert_equal_to (elem.n_nodes(), Elem::build(conv.get_canonical_type(), libmesh_nullptr)->n_nodes());
1904 
1905  for (unsigned int j=0; j < static_cast<unsigned int>(this->num_nodes_per_elem); j++)
1906  {
1907  const unsigned int connect_index = (i*this->num_nodes_per_elem)+j;
1908  const unsigned int elem_node_index = conv.get_node_map(j);
1909 
1910  std::map<int, int>::iterator node_it = libmesh_node_num_to_exodus.find(elem.node_id(elem_node_index));
1911  if (node_it == libmesh_node_num_to_exodus.end())
1912  libmesh_error_msg("Node number " << elem.node_id(elem_node_index) << " not found in libmesh_node_num_to_exodus map.");
1913 
1914  current_block_connectivity[connect_index] = node_it->second;
1915  }
1916  } // End loop over elems in this subdomain
1917  } // end loop over subdomain_map
1918 }
static UniquePtr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:234
TestClass subdomain_id_type
Definition: id_types.h:43
std::vector< int > exodus_elem_num_to_libmesh
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
std::map< int, int > libmesh_elem_num_to_exodus
const dof_id_type n_nodes
Definition: tecplot_io.C:67
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
OStreamProxy out(std::cout)
std::map< subdomain_id_type, std::vector< unsigned int > > subdomain_map
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::close ( )
inherited

Closes the ExodusII mesh file.

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

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

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

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

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

References libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), border_node_ids, libMesh::libmesh_assert(), libMesh::Elem::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::Elem::node_id(), num_border_nodes, num_node_cmaps, libMesh::out, proc_nodes_touched_intersections, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::Parallel::set_union(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1925 {
1926  // The set which will eventually contain the IDs of "border nodes". These are nodes
1927  // that lie on the boundary between one or more processors.
1928  //std::set<unsigned> border_node_ids;
1929 
1930  // map from processor ID to set of nodes which elements from this processor "touch",
1931  // that is,
1932  // proc_nodes_touched[p] = (set all node IDs found in elements owned by processor p)
1933  std::map<unsigned, std::set<unsigned> > proc_nodes_touched;
1934 
1935 
1936  // We are going to create a lot of intermediate data structures here, so make sure
1937  // as many as possible all cleaned up by creating scope!
1938  {
1939  // Loop over active (not just active local) elements, make sets of node IDs for each
1940  // processor which has an element that "touches" a node.
1941  {
1942  MeshBase::const_element_iterator elem_it = pmesh.active_elements_begin();
1943  MeshBase::const_element_iterator elem_end = pmesh.active_elements_end();
1944 
1945  for (; elem_it != elem_end; ++elem_it)
1946  {
1947  const Elem * elem = *elem_it;
1948 
1949  // Get reference to the set for this processor. If it does not exist
1950  // it will be created.
1951  std::set<unsigned> & set_p = proc_nodes_touched[ elem->processor_id() ];
1952 
1953  // Insert all nodes touched by this element into the set
1954  for (unsigned int node=0; node<elem->n_nodes(); ++node)
1955  set_p.insert(elem->node_id(node));
1956  }
1957  }
1958 
1959  // The number of node communication maps is the number of other processors
1960  // with which we share nodes. (I think.) This is just the size of the map we just
1961  // created, minus 1.
1962  this->num_node_cmaps =
1963  cast_int<int>(proc_nodes_touched.size() - 1);
1964 
1965  // If we've got no elements on this processor and haven't touched
1966  // any nodes, however, then that's 0 other processors with which
1967  // we share nodes, not -1.
1968  if (this->num_node_cmaps == -1)
1969  {
1970  libmesh_assert (pmesh.active_elements_begin() == pmesh.active_elements_end());
1971  this->num_node_cmaps = 0;
1972  }
1973 
1974  // We can't be connecting to more processors than exist outside
1975  // ourselves
1976  libmesh_assert_less (static_cast<unsigned>(this->num_node_cmaps), this->n_processors());
1977 
1978  if (verbose)
1979  {
1980  libMesh::out << "[" << this->processor_id()
1981  << "] proc_nodes_touched contains "
1982  << proc_nodes_touched.size()
1983  << " sets of nodes."
1984  << std::endl;
1985 
1986  for (proc_nodes_touched_iterator it = proc_nodes_touched.begin();
1987  it != proc_nodes_touched.end();
1988  ++it)
1989  {
1990  libMesh::out << "[" << this->processor_id()
1991  << "] proc_nodes_touched[" << it->first << "] has "
1992  << it->second.size()
1993  << " entries."
1994  << std::endl;
1995  }
1996  }
1997 
1998 
1999  // Loop over all the sets we just created and compute intersections with the
2000  // this processor's set. Obviously, don't intersect with ourself.
2001  for (proc_nodes_touched_iterator it = proc_nodes_touched.begin();
2002  it != proc_nodes_touched.end();
2003  ++it)
2004  {
2005  // Don't compute intersections with ourself
2006  if (it->first == this->processor_id())
2007  continue;
2008 
2009  // Otherwise, compute intersection with other processor and ourself
2010  std::set<unsigned> & my_set = proc_nodes_touched[this->processor_id()];
2011  std::set<unsigned> & other_set = it->second;
2012  std::set<unsigned> & result_set = this->proc_nodes_touched_intersections[ it->first ]; // created if does not exist
2013 
2014  std::set_intersection(my_set.begin(), my_set.end(),
2015  other_set.begin(), other_set.end(),
2016  std::inserter(result_set, result_set.end()));
2017  }
2018 
2019  if (verbose)
2020  {
2022  it != this->proc_nodes_touched_intersections.end();
2023  ++it)
2024  {
2025  libMesh::out << "[" << this->processor_id()
2026  << "] this->proc_nodes_touched_intersections[" << it->first << "] has "
2027  << it->second.size()
2028  << " entries."
2029  << std::endl;
2030  }
2031  }
2032 
2033  // Compute the set_union of all the preceding intersections. This will be the set of
2034  // border node IDs for this processor.
2036  it != this->proc_nodes_touched_intersections.end();
2037  ++it)
2038  {
2039  std::set<unsigned> & other_set = it->second;
2040  std::set<unsigned> intermediate_result; // Don't think we can insert into one of the sets we're unioning...
2041 
2042  std::set_union(this->border_node_ids.begin(), this->border_node_ids.end(),
2043  other_set.begin(), other_set.end(),
2044  std::inserter(intermediate_result, intermediate_result.end()));
2045 
2046  // Swap our intermediate result into the final set
2047  this->border_node_ids.swap(intermediate_result);
2048  }
2049 
2050  if (verbose)
2051  {
2052  libMesh::out << "[" << this->processor_id()
2053  << "] border_node_ids.size()=" << this->border_node_ids.size()
2054  << std::endl;
2055  }
2056  } // end scope for border node ID creation
2057 
2058  // Store the number of border node IDs to be written to Nemesis file
2059  this->num_border_nodes = cast_int<int>(this->border_node_ids.size());
2060 }
processor_id_type n_processors() const
libmesh_assert(j)
std::set< unsigned > border_node_ids
std::map< unsigned, std::set< unsigned > >::iterator proc_nodes_touched_iterator
void set_union(T &data, const unsigned int root_id, const Communicator &comm=Communicator_World)
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
OStreamProxy out(std::cout)
processor_id_type processor_id() const
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 1178 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().

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

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

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

Referenced by initialize().

963 {
964  // Make sure we don't have any leftover info
965  this->elem_mapi.clear();
966  this->elem_mapb.clear();
967 
968  // Copy set contents into vectors
969  this->elem_mapi.resize(this->internal_elem_ids.size());
970  this->elem_mapb.resize(this->border_elem_ids.size());
971 
972  {
973  unsigned cnt = 0;
974  std::set<unsigned>::iterator
975  it = this->internal_elem_ids.begin(),
976  end = this->internal_elem_ids.end();
977 
978  for (; it != end; ++it, ++cnt)
979  {
980  std::map<int, int>::iterator elem_it = libmesh_elem_num_to_exodus.find(*it);
981  if (elem_it == libmesh_elem_num_to_exodus.end())
982  libmesh_error_msg("Elem number " << *it << " not found in libmesh_elem_num_to_exodus map.");
983  this->elem_mapi[cnt] = elem_it->second;
984  }
985  }
986 
987  {
988  unsigned cnt = 0;
989  std::set<unsigned>::iterator
990  it = this->border_elem_ids.begin(),
991  end = this->border_elem_ids.end();
992 
993  for (; it != end; ++it, ++cnt)
994  {
995  std::map<int, int>::iterator elem_it = libmesh_elem_num_to_exodus.find(*it);
996  if (elem_it == libmesh_elem_num_to_exodus.end())
997  libmesh_error_msg("Elem number " << *it << " not found in libmesh_elem_num_to_exodus map.");
998  this->elem_mapb[cnt] = elem_it->second;
999  }
1000  }
1001 }
IterBase * end
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
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 1256 of file nemesis_io_helper.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), border_elem_ids, border_node_ids, libMesh::ExodusII_IO_Helper::Conversion::get_inverse_side_map(), libMesh::DofObject::id(), internal_elem_ids, internal_node_ids, libmesh_nullptr, libMesh::Elem::n_neighbors(), libMesh::Elem::n_nodes(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::node_id(), 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(), libMesh::DofObject::processor_id(), libMesh::Elem::type(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

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

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

Definition at line 1107 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, num_node_cmaps, libMesh::out, proc_nodes_touched_intersections, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

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

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

Referenced by initialize().

1061 {
1062  // Make sure we don't have any leftover information
1063  this->node_mapi.clear();
1064  this->node_mapb.clear();
1065  this->node_mape.clear();
1066 
1067  // Make sure there's enough space to hold all our node IDs
1068  this->node_mapi.resize(this->internal_node_ids.size());
1069  this->node_mapb.resize(this->border_node_ids.size());
1070 
1071  // Copy set contents into vectors
1072  {
1073  unsigned cnt = 0;
1074  std::set<unsigned>::iterator
1075  it = this->internal_node_ids.begin(),
1076  end = this->internal_node_ids.end();
1077 
1078  for (; it != end; ++it, ++cnt)
1079  {
1080  std::map<int, int>::iterator node_it = libmesh_node_num_to_exodus.find(*it);
1081  if (node_it == libmesh_node_num_to_exodus.end())
1082  libmesh_error_msg("Node number " << *it << " not found in libmesh_node_num_to_exodus map.");
1083  this->node_mapi[cnt] = node_it->second;
1084  }
1085  }
1086 
1087  {
1088  unsigned cnt=0;
1089  std::set<unsigned>::iterator
1090  it = this->border_node_ids.begin(),
1091  end = this->border_node_ids.end();
1092 
1093  for (; it != end; ++it, ++cnt)
1094  {
1095  std::map<int, int>::iterator node_it = libmesh_node_num_to_exodus.find(*it);
1096  if (node_it == libmesh_node_num_to_exodus.end())
1097  libmesh_error_msg("Node number " << *it << " not found in libmesh_node_num_to_exodus map.");
1098  this->node_mapb[cnt] = node_it->second;
1099  }
1100  }
1101 }
std::vector< int > node_mape
IterBase * end
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
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 1642 of file nemesis_io_helper.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), 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::Elem::subdomain_id(), libMesh::Parallel::Communicator::sum(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

1643 {
1644  // 1.) Loop over active local elements, build up set of subdomain IDs.
1645  std::set<subdomain_id_type> global_subdomain_ids;
1646 
1647  // This map keeps track of the number of elements in each subdomain over all processors
1648  std::map<subdomain_id_type, unsigned> global_subdomain_counts;
1649 
1650  MeshBase::const_element_iterator elem_it = pmesh.active_local_elements_begin();
1651  MeshBase::const_element_iterator elem_end = pmesh.active_local_elements_end();
1652 
1653  for (; elem_it != elem_end; ++elem_it)
1654  {
1655  const Elem * elem = *elem_it;
1656 
1657  subdomain_id_type cur_subdomain = elem->subdomain_id();
1658 
1659  /*
1660  // We can't have a zero subdomain ID in Exodus (for some reason?)
1661  // so map zero subdomains to a max value...
1662  if (cur_subdomain == 0)
1663  cur_subdomain = std::numeric_limits<subdomain_id_type>::max();
1664  */
1665 
1666  global_subdomain_ids.insert(cur_subdomain);
1667 
1668  // Increment the count of elements in this subdomain
1669  global_subdomain_counts[cur_subdomain]++;
1670  }
1671 
1672  // We're next going to this->comm().sum the subdomain counts, so save the local counts
1673  this->local_subdomain_counts = global_subdomain_counts;
1674 
1675  {
1676  // 2.) Copy local subdomain IDs into a vector for communication
1677  std::vector<subdomain_id_type> global_subdomain_ids_vector(global_subdomain_ids.begin(),
1678  global_subdomain_ids.end());
1679 
1680  // 3.) Gather them into an enlarged vector
1681  this->comm().allgather(global_subdomain_ids_vector);
1682 
1683  // 4.) Insert any new IDs into the set (any duplicates will be dropped)
1684  global_subdomain_ids.insert(global_subdomain_ids_vector.begin(),
1685  global_subdomain_ids_vector.end());
1686  }
1687 
1688  // 5.) Now global_subdomain_ids actually contains a global list of all subdomain IDs
1689  this->num_elem_blks_global =
1690  cast_int<int>(global_subdomain_ids.size());
1691 
1692  // Print the number of elements found locally in each subdomain
1693  if (verbose)
1694  {
1695  libMesh::out << "[" << this->processor_id() << "] ";
1696  for (std::map<subdomain_id_type, unsigned>::iterator it=global_subdomain_counts.begin();
1697  it != global_subdomain_counts.end();
1698  ++it)
1699  {
1700  libMesh::out << "ID: "
1701  << static_cast<unsigned>(it->first)
1702  << ", Count: " << it->second << ", ";
1703  }
1704  libMesh::out << std::endl;
1705  }
1706 
1707  // 6.) this->comm().sum up the number of elements in each block. We know the global
1708  // subdomain IDs, so pack them into a vector one by one. Use a vector of int since
1709  // that is what Nemesis wants
1710  this->global_elem_blk_cnts.resize(global_subdomain_ids.size());
1711 
1712  unsigned cnt=0;
1713  for (std::set<subdomain_id_type>::iterator it=global_subdomain_ids.begin();
1714  it != global_subdomain_ids.end(); ++it)
1715  {
1716  // Find the entry in the local map, note: if not found, will be created with 0 default value, which is OK...
1717  this->global_elem_blk_cnts[cnt++] = global_subdomain_counts[*it];
1718  }
1719 
1720  // Sum up subdomain counts from all processors
1721  this->comm().sum(this->global_elem_blk_cnts);
1722 
1723  if (verbose)
1724  {
1725  libMesh::out << "[" << this->processor_id() << "] global_elem_blk_cnts = ";
1726  for (std::size_t i=0; i<this->global_elem_blk_cnts.size(); ++i)
1727  libMesh::out << this->global_elem_blk_cnts[i] << ", ";
1728  libMesh::out << std::endl;
1729  }
1730 
1731  // 7.) Create a vector<int> from the global_subdomain_ids set, for passing to Nemesis
1732  this->global_elem_blk_ids.clear();
1733  this->global_elem_blk_ids.insert(this->global_elem_blk_ids.end(), // pos
1734  global_subdomain_ids.begin(),
1735  global_subdomain_ids.end());
1736 
1737  if (verbose)
1738  {
1739  libMesh::out << "[" << this->processor_id() << "] global_elem_blk_ids = ";
1740  for (std::size_t i=0; i<this->global_elem_blk_ids.size(); ++i)
1741  libMesh::out << this->global_elem_blk_ids[i] << ", ";
1742  libMesh::out << std::endl;
1743  }
1744 
1745 
1746  // 8.) We will call put_eb_info_global later, it must be called after this->put_init_global().
1747 }
TestClass subdomain_id_type
Definition: id_types.h:43
std::vector< int > global_elem_blk_ids
std::map< subdomain_id_type, unsigned > local_subdomain_counts
const Parallel::Communicator & comm() const
OStreamProxy out(std::cout)
std::vector< int > global_elem_blk_cnts
processor_id_type processor_id() const
void allgather(const T &send, std::vector< T > &recv) const
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 1519 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().

1520 {
1521  std::set<boundary_id_type> local_node_boundary_ids;
1522 
1523  // 1.) Get reference to the set of node boundary IDs *for this processor*
1524  std::set<boundary_id_type> global_node_boundary_ids
1525  (pmesh.get_boundary_info().get_node_boundary_ids().begin(),
1526  pmesh.get_boundary_info().get_node_boundary_ids().end());
1527 
1528  // Save a copy of the local_node_boundary_ids...
1529  local_node_boundary_ids = global_node_boundary_ids;
1530 
1531  // 2.) Gather boundary node IDs from other processors
1532  this->comm().set_union(global_node_boundary_ids);
1533 
1534  // 3.) Now global_node_boundary_ids actually contains a global list of all node boundary IDs
1535  this->num_node_sets_global =
1536  cast_int<int>(global_node_boundary_ids.size());
1537 
1538  // 4.) Create a vector<int> from the global_node_boundary_ids set
1539  this->global_nodeset_ids.clear();
1540  this->global_nodeset_ids.insert(this->global_nodeset_ids.end(),
1541  global_node_boundary_ids.begin(),
1542  global_node_boundary_ids.end());
1543 
1544  if (verbose)
1545  {
1546  libMesh::out << "[" << this->processor_id() << "] global_nodeset_ids = ";
1547  for (std::size_t i=0; i<global_nodeset_ids.size(); ++i)
1548  libMesh::out << global_nodeset_ids[i] << ", ";
1549  libMesh::out << std::endl;
1550 
1551  libMesh::out << "[" << this->processor_id() << "] local_node_boundary_ids = ";
1552  for (std::set<boundary_id_type>::iterator it = local_node_boundary_ids.begin();
1553  it != local_node_boundary_ids.end();
1554  ++it)
1555  libMesh::out << *it << ", ";
1556  libMesh::out << std::endl;
1557  }
1558 
1559  // 7.) We also need to know the number of nodes which is in each of the nodesets, globally.
1560  // There is probably a better way to do this...
1561  std::vector<dof_id_type> boundary_node_list;
1562  std::vector<boundary_id_type> boundary_node_boundary_id_list;
1563  pmesh.get_boundary_info().build_node_list
1564  (boundary_node_list, boundary_node_boundary_id_list);
1565 
1566  if (verbose)
1567  {
1568  libMesh::out << "[" << this->processor_id() << "] boundary_node_list.size()="
1569  << boundary_node_list.size() << std::endl;
1570  libMesh::out << "[" << this->processor_id() << "] (boundary_node_id, boundary_id) = ";
1571  for (std::size_t i=0; i<boundary_node_list.size(); ++i)
1572  {
1573  libMesh::out << "(" << boundary_node_list[i] << ", " << boundary_node_boundary_id_list[i] << ") ";
1574  }
1575  libMesh::out << std::endl;
1576  }
1577 
1578  // Now get the global information. In this case, we only want to count boundary
1579  // information for nodes *owned* by this processor, so there are no duplicates.
1580 
1581  // Make sure we don't have any left over information
1582  this->num_global_node_counts.clear();
1583  this->num_global_node_counts.resize(this->global_nodeset_ids.size());
1584 
1585  // Unfortunately, we can't just count up all occurrences of a given id,
1586  // that would give us duplicate entries when we do the parallel summation.
1587  // So instead, only count entries for nodes owned by this processor.
1588  // Start by getting rid of all non-local node entries from the vectors.
1589  std::vector<dof_id_type>::iterator it_node=boundary_node_list.begin();
1590  std::vector<boundary_id_type>::iterator it_id=boundary_node_boundary_id_list.begin();
1591 
1592  // New end iterators, to be updated as we find non-local IDs
1593  std::vector<dof_id_type>::iterator new_node_list_end = boundary_node_list.end();
1594  std::vector<boundary_id_type>::iterator new_boundary_id_list_end = boundary_node_boundary_id_list.end();
1595  for ( ; it_node != new_node_list_end; )
1596  {
1597  if (pmesh.node_ptr( *it_node )->processor_id() != this->processor_id())
1598  {
1599  // Back up the new end iterators to prepare for swap
1600  --new_node_list_end;
1601  --new_boundary_id_list_end;
1602 
1603  // Swap places, the non-local node will now be "past-the-end"
1604  std::swap (*it_node, *new_node_list_end);
1605  std::swap (*it_id, *new_boundary_id_list_end);
1606  }
1607  else // node is local, go to next
1608  {
1609  ++it_node;
1610  ++it_id;
1611  }
1612  }
1613 
1614  // Erase from "new" end to old end on each vector.
1615  boundary_node_list.erase(new_node_list_end, boundary_node_list.end());
1616  boundary_node_boundary_id_list.erase(new_boundary_id_list_end, boundary_node_boundary_id_list.end());
1617 
1618  // Now we can do the local count for each ID...
1619  for (std::size_t i=0; i<global_nodeset_ids.size(); ++i)
1620  {
1621  this->num_global_node_counts[i] = cast_int<int>
1622  (std::count(boundary_node_boundary_id_list.begin(),
1623  boundary_node_boundary_id_list.end(),
1624  cast_int<boundary_id_type>(this->global_nodeset_ids[i])));
1625  }
1626 
1627  // And finally we can sum them up
1628  this->comm().sum(this->num_global_node_counts);
1629 
1630  if (verbose)
1631  {
1632  libMesh::out << "[" << this->processor_id() << "] num_global_node_counts = ";
1633  for (std::size_t i=0; i<num_global_node_counts.size(); ++i)
1634  libMesh::out << num_global_node_counts[i] << ", ";
1635  libMesh::out << std::endl;
1636  }
1637 }
std::vector< int > num_global_node_counts
std::vector< int > global_nodeset_ids
const Parallel::Communicator & comm() const
void swap(Iterator &lhs, Iterator &rhs)
OStreamProxy out(std::cout)
processor_id_type processor_id() const
void set_union(T &data, const unsigned int root_id) const
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 1410 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().

1411 {
1412  // 1.) Get reference to the set of side boundary IDs
1413  std::set<boundary_id_type> global_side_boundary_ids
1414  (pmesh.get_boundary_info().get_side_boundary_ids().begin(),
1415  pmesh.get_boundary_info().get_side_boundary_ids().end());
1416 
1417  // 2.) Gather boundary side IDs from other processors
1418  this->comm().set_union(global_side_boundary_ids);
1419 
1420  // 3.) Now global_side_boundary_ids actually contains a global list of all side boundary IDs
1421  this->num_side_sets_global =
1422  cast_int<int>(global_side_boundary_ids.size());
1423 
1424  // 4.) Pack these sidesets into a vector so they can be written by Nemesis
1425  this->global_sideset_ids.clear(); // Make sure there is no leftover information
1426  this->global_sideset_ids.insert(this->global_sideset_ids.end(),
1427  global_side_boundary_ids.begin(),
1428  global_side_boundary_ids.end());
1429 
1430  if (verbose)
1431  {
1432  libMesh::out << "[" << this->processor_id() << "] global_sideset_ids = ";
1433  for (std::size_t i=0; i<this->global_sideset_ids.size(); ++i)
1434  libMesh::out << this->global_sideset_ids[i] << ", ";
1435  libMesh::out << std::endl;
1436  }
1437 
1438  // We also need global counts of sides in each of the sidesets. Again, there may be a
1439  // better way to do this...
1440  std::vector<dof_id_type> bndry_elem_list;
1441  std::vector<unsigned short int> bndry_side_list;
1442  std::vector<boundary_id_type> bndry_id_list;
1443  pmesh.get_boundary_info().build_side_list(bndry_elem_list, bndry_side_list, bndry_id_list);
1444 
1445  // Similarly to the nodes, we can't count any sides for elements which aren't local
1446  std::vector<dof_id_type>::iterator it_elem=bndry_elem_list.begin();
1447  std::vector<unsigned short>::iterator it_side=bndry_side_list.begin();
1448  std::vector<boundary_id_type>::iterator it_id=bndry_id_list.begin();
1449 
1450  // New end iterators, to be updated as we find non-local IDs
1451  std::vector<dof_id_type>::iterator new_bndry_elem_list_end = bndry_elem_list.end();
1452  std::vector<unsigned short>::iterator new_bndry_side_list_end = bndry_side_list.end();
1453  std::vector<boundary_id_type>::iterator new_bndry_id_list_end = bndry_id_list.end();
1454 
1455  for ( ; it_elem != new_bndry_elem_list_end; )
1456  {
1457  if (pmesh.elem_ref(*it_elem).processor_id() != this->processor_id())
1458  {
1459  // Back up the new end iterators to prepare for swap
1460  --new_bndry_elem_list_end;
1461  --new_bndry_side_list_end;
1462  --new_bndry_id_list_end;
1463 
1464  // Swap places, the non-local elem will now be "past-the-end"
1465  std::swap (*it_elem, *new_bndry_elem_list_end);
1466  std::swap (*it_side, *new_bndry_side_list_end);
1467  std::swap (*it_id, *new_bndry_id_list_end);
1468  }
1469  else // elem is local, go to next
1470  {
1471  ++it_elem;
1472  ++it_side;
1473  ++it_id;
1474  }
1475  }
1476 
1477  // Erase from "new" end to old end on each vector.
1478  bndry_elem_list.erase(new_bndry_elem_list_end, bndry_elem_list.end());
1479  bndry_side_list.erase(new_bndry_side_list_end, bndry_side_list.end());
1480  bndry_id_list.erase(new_bndry_id_list_end, bndry_id_list.end());
1481 
1482  this->num_global_side_counts.clear(); // Make sure we don't have any leftover information
1483  this->num_global_side_counts.resize(this->global_sideset_ids.size());
1484 
1485  // Get the count for each global sideset ID
1486  for (std::size_t i=0; i<global_sideset_ids.size(); ++i)
1487  {
1488  this->num_global_side_counts[i] = cast_int<int>
1489  (std::count(bndry_id_list.begin(),
1490  bndry_id_list.end(),
1491  cast_int<boundary_id_type>(this->global_sideset_ids[i])));
1492  }
1493 
1494  if (verbose)
1495  {
1496  libMesh::out << "[" << this->processor_id() << "] num_global_side_counts = ";
1497  for (std::size_t i=0; i<this->num_global_side_counts.size(); ++i)
1498  libMesh::out << this->num_global_side_counts[i] << ", ";
1499  libMesh::out << std::endl;
1500  }
1501 
1502  // Finally sum up the result
1503  this->comm().sum(this->num_global_side_counts);
1504 
1505  if (verbose)
1506  {
1507  libMesh::out << "[" << this->processor_id() << "] num_global_side_counts = ";
1508  for (std::size_t i=0; i<this->num_global_side_counts.size(); ++i)
1509  libMesh::out << this->num_global_side_counts[i] << ", ";
1510  libMesh::out << std::endl;
1511  }
1512 }
std::vector< int > global_sideset_ids
std::vector< int > num_global_side_counts
const Parallel::Communicator & comm() const
void swap(Iterator &lhs, Iterator &rhs)
OStreamProxy out(std::cout)
processor_id_type processor_id() const
void set_union(T &data, const unsigned int root_id) const
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 2646 of file nemesis_io_helper.C.

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

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

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

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

Get the block number for the given block index.

Definition at line 536 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::block_ids.

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

537 {
538  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
539 
540  return block_ids[index];
541 }
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 545 of file exodusII_io_helper.C.

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

546 {
547  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
548 
549  return id_to_block_names[block_ids[index]];
550 }
std::map< int, std::string > id_to_block_names
void libMesh::Nemesis_IO_Helper::get_cmap_params ( )

Definition at line 321 of file nemesis_io_helper.C.

References elem_cmap_elem_cnts, elem_cmap_ids, libMesh::ExodusII_IO_Helper::ex_id, libmesh_nullptr, 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.

322 {
327 
329  Nemesis::ne_get_cmap_params(ex_id,
334  this->processor_id());
335  EX_CHECK_ERR(nemesis_err_flag, "Error reading cmap parameters!");
336 
337 
338  if (verbose)
339  {
340  libMesh::out << "[" << this->processor_id() << "] ";
341  for (std::size_t i=0; i<node_cmap_ids.size(); ++i)
342  libMesh::out << "node_cmap_ids["<<i<<"]=" << node_cmap_ids[i] << " ";
343  libMesh::out << std::endl;
344 
345  libMesh::out << "[" << this->processor_id() << "] ";
346  for (std::size_t i=0; i<node_cmap_node_cnts.size(); ++i)
347  libMesh::out << "node_cmap_node_cnts["<<i<<"]=" << node_cmap_node_cnts[i] << " ";
348  libMesh::out << std::endl;
349 
350  libMesh::out << "[" << this->processor_id() << "] ";
351  for (std::size_t i=0; i<elem_cmap_ids.size(); ++i)
352  libMesh::out << "elem_cmap_ids["<<i<<"]=" << elem_cmap_ids[i] << " ";
353  libMesh::out << std::endl;
354 
355  libMesh::out << "[" << this->processor_id() << "] ";
356  for (std::size_t i=0; i<elem_cmap_elem_cnts.size(); ++i)
357  libMesh::out << "elem_cmap_elem_cnts["<<i<<"]=" << elem_cmap_elem_cnts[i] << " ";
358  libMesh::out << std::endl;
359  }
360 }
std::vector< int > node_cmap_ids
const class libmesh_nullptr_t libmesh_nullptr
std::vector< int > elem_cmap_elem_cnts
std::vector< int > elem_cmap_ids
std::vector< int > node_cmap_node_cnts
OStreamProxy out(std::cout)
processor_id_type processor_id() const
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 2050 of file exodusII_io_helper.C.

2051 {
2052  std::vector<std::string>::const_iterator names_it = names.begin();
2053  std::vector<std::string>::const_iterator names_end = names.end();
2054 
2055  std::vector<std::string> complex_names;
2056 
2057  // This will loop over all names and create new "complex" names
2058  // (i.e. names that start with r_, i_ or a_
2059  for (; names_it != names_end; ++names_it)
2060  {
2061  std::stringstream name_real, name_imag, name_abs;
2062  name_real << "r_" << *names_it;
2063  name_imag << "i_" << *names_it;
2064  name_abs << "a_" << *names_it;
2065 
2066  complex_names.push_back(name_real.str());
2067  complex_names.push_back(name_imag.str());
2068  complex_names.push_back(name_abs.str());
2069  }
2070 
2071  return complex_names;
2072 }
void libMesh::Nemesis_IO_Helper::get_eb_info_global ( )

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

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

Definition at line 406 of file nemesis_io_helper.C.

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

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

Definition at line 253 of file nemesis_io_helper.C.

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

254 {
256  elem_mapb.resize(num_border_elems);
257 
259  Nemesis::ne_get_elem_map(ex_id,
260  elem_mapi.empty() ? libmesh_nullptr : &elem_mapi[0],
261  elem_mapb.empty() ? libmesh_nullptr : &elem_mapb[0],
262  this->processor_id()
263  );
264  EX_CHECK_ERR(nemesis_err_flag, "Error reading element maps!");
265 
266 
267  if (verbose)
268  {
269  libMesh::out << "[" << this->processor_id() << "] elem_mapi[i] = ";
270  for (unsigned int i=0; i< static_cast<unsigned int>(num_internal_elems-1); ++i)
271  libMesh::out << elem_mapi[i] << ", ";
272  libMesh::out << "... " << elem_mapi.back() << std::endl;
273 
274  libMesh::out << "[" << this->processor_id() << "] elem_mapb[i] = ";
275  for (unsigned int i=0; i< static_cast<unsigned int>(std::min(10, num_border_elems-1)); ++i)
276  libMesh::out << elem_mapb[i] << ", ";
277  libMesh::out << "... " << elem_mapb.back() << std::endl;
278  }
279 }
const class libmesh_nullptr_t libmesh_nullptr
std::vector< int > elem_mapb
OStreamProxy out(std::cout)
long double min(long double a, double b)
std::vector< int > elem_mapi
processor_id_type processor_id() const
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 309 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::elem_type.

310 {
311  return &elem_type[0];
312 }
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 84 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.

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

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

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

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

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

Definition at line 364 of file nemesis_io_helper.C.

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

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

Definition at line 284 of file nemesis_io_helper.C.

References libMesh::ExodusII_IO_Helper::ex_id, libmesh_nullptr, 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.

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

References libMesh::ExodusII_IO_Helper::nodeset_ids.

573 {
574  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
575 
576  return nodeset_ids[index];
577 }
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 581 of file exodusII_io_helper.C.

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

582 {
583  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
584 
585  return id_to_ns_names[nodeset_ids[index]];
586 }
std::map< int, std::string > id_to_ns_names
void libMesh::Nemesis_IO_Helper::get_ns_param_global ( )

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

144 {
145  if (num_node_sets_global > 0)
146  {
150 
152  Nemesis::ne_get_ns_param_global(ex_id,
153  &global_nodeset_ids[0],
156  EX_CHECK_ERR(nemesis_err_flag, "Error reading global nodeset parameters!");
157 
158  if (verbose)
159  {
160  libMesh::out << "[" << this->processor_id() << "] " << "Global Nodeset IDs, Node Counts, and DF counts:" << std::endl;
161  for (std::size_t bn=0; bn<global_nodeset_ids.size(); ++bn)
162  {
163  libMesh::out << " [" << this->processor_id() << "] "
164  << "global_nodeset_ids["<<bn<<"]=" << global_nodeset_ids[bn]
165  << ", num_global_node_counts["<<bn<<"]=" << num_global_node_counts[bn]
166  << ", num_global_node_df_counts["<<bn<<"]=" << num_global_node_df_counts[bn]
167  << std::endl;
168  }
169  }
170  }
171 }
std::vector< int > num_global_node_counts
std::vector< int > global_nodeset_ids
std::vector< int > num_global_node_df_counts
OStreamProxy out(std::cout)
processor_id_type processor_id() const
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 554 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::ss_ids.

555 {
556  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
557 
558  return ss_ids[index];
559 }
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 563 of file exodusII_io_helper.C.

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

564 {
565  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
566 
567  return id_to_ss_names[ss_ids[index]];
568 }
std::map< int, std::string > id_to_ss_names
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 107 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.

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

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

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

Sets up the nodal variables

Definition at line 1720 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::_elem_vars_initialized, libMesh::ExodusII_IO_Helper::_run_only_on_proc0, 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(), libMesh::ExodusII_IO_Helper::num_elem_blk, libMesh::ExodusII_IO_Helper::num_elem_vars, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::write_var_names().

1721 {
1722  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1723  return;
1724 
1725  // Quick return if there are no element variables to write
1726  if (names.size() == 0)
1727  return;
1728 
1729  // Quick return if we have already called this function
1731  return;
1732 
1733  // Be sure that variables in the file match what we are asking for
1734  if (num_elem_vars > 0)
1735  {
1736  this->check_existing_vars(ELEMENTAL, names, this->elem_var_names);
1737  return;
1738  }
1739 
1740  // Set the flag so we can skip this stuff on subsequent calls to
1741  // initialize_element_variables()
1742  _elem_vars_initialized = true;
1743 
1744  this->write_var_names(ELEMENTAL, names);
1745 
1746  // Form the element variable truth table and send to Exodus.
1747  // This tells which variables are written to which blocks,
1748  // and can dramatically speed up writing element variables
1749  //
1750  // We really should initialize all entries in the truth table to 0
1751  // and then loop over all subdomains, setting their entries to 1
1752  // if a given variable exists on that subdomain. However,
1753  // we don't have that information, and the element variables
1754  // passed to us are padded with zeroes for the blocks where
1755  // they aren't defined. To be consistent with that, fill
1756  // the truth table with ones.
1757  std::vector<int> truth_tab(num_elem_blk*num_elem_vars, 1);
1759  num_elem_blk,
1760  num_elem_vars,
1761  &truth_tab[0]);
1762  EX_CHECK_ERR(ex_err, "Error writing element truth table.");
1763 }
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)
EXODUS_EXPORT int ex_put_elem_var_tab(int exoid, int num_elem_blk, int num_elem_var, int *elem_var_tab)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::initialize_global_variables ( std::vector< std::string >  names)
inherited

Sets up the global variables

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

1796 {
1797  if ((_run_only_on_proc0) && (this->processor_id() != 0))
1798  return;
1799 
1800  // Quick return if there are no global variables to write
1801  if (names.size() == 0)
1802  return;
1803 
1805  return;
1806 
1807  // Be sure that variables in the file match what we are asking for
1808  if (num_global_vars > 0)
1809  {
1810  this->check_existing_vars(GLOBAL, names, this->global_var_names);
1811  return;
1812  }
1813 
1814  _global_vars_initialized = true;
1815 
1816  this->write_var_names(GLOBAL, names);
1817 }
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
void libMesh::ExodusII_IO_Helper::initialize_nodal_variables ( std::vector< std::string >  names)
inherited

Sets up the nodal variables

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

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

807 {
808  int ret_int = 0;
809  char ret_char = 0;
810  float ret_float = 0.;
811 
813  req_info_in,
814  &ret_int,
815  &ret_float,
816  &ret_char);
817 
818  EX_CHECK_ERR(ex_err, error_msg);
819 
820  return ret_int;
821 }
EXODUS_EXPORT int ex_inquire(int exoid, int inquiry, void_int *, float *, char *)
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 323 of file exodusII_io_helper.C.

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

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

Definition at line 93 of file parallel_object.h.

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

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

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:722
const Parallel::Communicator & _communicator
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 330 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.

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

451 {
452  if (verbose)
453  libMesh::out << "Title: \t" << &title[0] << std::endl
454  << "Mesh Dimension: \t" << num_dim << std::endl
455  << "Number of Nodes: \t" << num_nodes << std::endl
456  << "Number of elements: \t" << num_elem << std::endl
457  << "Number of elt blocks: \t" << num_elem_blk << std::endl
458  << "Number of node sets: \t" << num_node_sets << std::endl
459  << "Number of side sets: \t" << num_side_sets << std::endl;
460 }
OStreamProxy out(std::cout)
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 501 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.

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

Definition at line 99 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), 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::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), 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(), libMesh::EquationSystems::get_solution(), get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), 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::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), 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::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::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:720
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 Nemsis User's Manual is wrong. The correct order is (ids, counts, ids, counts). Must be called after put_loadbal_param().

Definition at line 572 of file nemesis_io_helper.C.

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

Referenced by initialize().

576 {
577  // We might not have cmaps on every processor in some corner
578  // cases
579  if (node_cmap_ids.size())
580  {
582  Nemesis::ne_put_cmap_params(ex_id,
583  &node_cmap_ids_in[0],
584  &node_cmap_node_cnts_in[0],
585  &elem_cmap_ids_in[0],
586  &elem_cmap_elem_cnts_in[0],
587  this->processor_id());
588  }
589 
590  EX_CHECK_ERR(nemesis_err_flag, "Error writing cmap parameters!");
591 }
std::vector< int > node_cmap_ids
processor_id_type processor_id() const
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 492 of file nemesis_io_helper.C.

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

Referenced by initialize().

494 {
496  Nemesis::ne_put_eb_info_global(ex_id,
497  &global_elem_blk_ids_in[0],
498  &global_elem_blk_cnts_in[0]);
499 
500  EX_CHECK_ERR(nemesis_err_flag, "Error writing global element block information!");
501 }
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 655 of file nemesis_io_helper.C.

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

Referenced by initialize().

658 {
659  for (std::size_t i=0; i<elem_cmap_ids.size(); ++i)
660  {
662  Nemesis::ne_put_elem_cmap(ex_id,
663  this->elem_cmap_ids[i],
664  &elem_cmap_elem_ids_in[i][0],
665  &elem_cmap_side_ids_in[i][0],
666  &elem_cmap_proc_ids_in[i][0],
667  this->processor_id());
668 
669  EX_CHECK_ERR(nemesis_err_flag, "Error writing elem communication map to file!");
670  }
671 }
std::vector< int > elem_cmap_ids
processor_id_type processor_id() const
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 676 of file nemesis_io_helper.C.

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

Referenced by initialize().

678 {
680  Nemesis::ne_put_elem_map(ex_id,
681  elem_mapi_in.empty() ? libmesh_nullptr : &elem_mapi_in[0],
682  elem_mapb_in.empty() ? libmesh_nullptr : &elem_mapb_in[0],
683  this->processor_id());
684 
685  EX_CHECK_ERR(nemesis_err_flag, "Error writing Nemesis internal and border element maps to file!");
686 }
const class libmesh_nullptr_t libmesh_nullptr
processor_id_type processor_id() const
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 473 of file nemesis_io_helper.C.

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

Referenced by initialize().

478 {
480  Nemesis::ne_put_init_global(ex_id,
481  num_nodes_global_in,
482  num_elems_global_in,
483  num_elem_blks_global_in,
484  num_node_sets_global_in,
485  num_side_sets_global_in);
486 
487  EX_CHECK_ERR(nemesis_err_flag, "Error writing initial global data!");
488 }
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 457 of file nemesis_io_helper.C.

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

Referenced by initialize().

460 {
462  Nemesis::ne_put_init_info(ex_id,
463  num_proc_in,
464  num_proc_in_file_in,
465  const_cast<char *>(ftype_in));
466 
467  EX_CHECK_ERR(nemesis_err_flag, "Error writing initial information!");
468 }
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 546 of file nemesis_io_helper.C.

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

Referenced by initialize().

553 {
555  Nemesis::ne_put_loadbal_param(ex_id,
556  num_internal_nodes_in,
557  num_border_nodes_in,
558  num_external_nodes_in,
559  num_internal_elems_in,
560  num_border_elems_in,
561  num_node_cmaps_in,
562  num_elem_cmaps_in,
563  this->processor_id());
564 
565  EX_CHECK_ERR(nemesis_err_flag, "Error writing loadbal parameters!");
566 }
processor_id_type processor_id() const
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 693 of file nemesis_io_helper.C.

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

698 {
700  Nemesis::ne_put_n_coord(ex_id,
701  start_node_num,
702  num_nodes_in,
703  &x_coor[0],
704  &y_coor[0],
705  &z_coor[0]);
706 
707  EX_CHECK_ERR(nemesis_err_flag, "Error writing coords to file!");
708 }
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 appeart 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 596 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().

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

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

Referenced by initialize().

641 {
643  Nemesis::ne_put_node_map(ex_id,
644  node_mapi_in.empty() ? libmesh_nullptr : &node_mapi_in[0],
645  node_mapb_in.empty() ? libmesh_nullptr : &node_mapb_in[0],
646  node_mape_in.empty() ? libmesh_nullptr : &node_mape_in[0], // Don't take address of empty vector...
647  this->processor_id());
648 
649  EX_CHECK_ERR(nemesis_err_flag, "Error writing Nemesis internal and border node maps to file!");
650 }
const class libmesh_nullptr_t libmesh_nullptr
processor_id_type processor_id() const
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 506 of file nemesis_io_helper.C.

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

Referenced by initialize().

509 {
510  // Only add nodesets if there are some
511  if (global_nodeset_ids.size())
512  {
514  Nemesis::ne_put_ns_param_global(ex_id,
515  &global_nodeset_ids_in[0],
516  &num_global_node_counts_in[0],
517  &num_global_node_df_counts_in[0]);
518  }
519 
520  EX_CHECK_ERR(nemesis_err_flag, "Error writing global nodeset parameters!");
521 }
std::vector< int > global_nodeset_ids
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 526 of file nemesis_io_helper.C.

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

Referenced by initialize().

529 {
530  // Only add sidesets if there are some
531  if (global_sideset_ids.size())
532  {
534  Nemesis::ne_put_ss_param_global(ex_id,
535  &global_sideset_ids_in[0],
536  &num_global_side_counts_in[0],
537  &num_global_side_df_counts_in[0]);
538  }
539 
540  EX_CHECK_ERR(nemesis_err_flag, "Error writing global sideset parameters!");
541 }
std::vector< int > global_sideset_ids
void libMesh::ExodusII_IO_Helper::read_block_info ( )
inherited

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

Definition at line 509 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_nullptr, libMesh::ExodusII_IO_Helper::message(), and libMesh::ExodusII_IO_Helper::num_elem_blk.

510 {
511  block_ids.resize(num_elem_blk);
512  // Get all element block IDs.
514  block_ids.empty() ? libmesh_nullptr : &block_ids[0]);
515  // Usually, there is only one
516  // block since there is only
517  // one type of element.
518  // However, there could be more.
519 
520  EX_CHECK_ERR(ex_err, "Error getting block IDs.");
521  message("All block IDs retrieved successfully.");
522 
523  char name_buffer[MAX_STR_LENGTH+1];
524  for (int i=0; i<num_elem_blk; ++i)
525  {
527  block_ids[i], name_buffer);
528  EX_CHECK_ERR(ex_err, "Error getting block name.");
529  id_to_block_names[block_ids[i]] = name_buffer;
530  }
531  message("All block names retrieved successfully.");
532 }
EXODUS_EXPORT int ex_get_name(int exoid, ex_entity_type obj_type, ex_entity_id entity_id, char *name)
const class libmesh_nullptr_t libmesh_nullptr
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
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 591 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.

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

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 631 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_nullptr, 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.

632 {
633  elem_num_map.resize(num_elem);
634 
636  elem_num_map.empty() ? libmesh_nullptr : &elem_num_map[0]);
637 
638  EX_CHECK_ERR(ex_err, "Error retrieving element number map.");
639  message("Element numbering map retrieved successfully.");
640 
641 
642  if (verbose)
643  {
644  libMesh::out << "[" << this->processor_id() << "] elem_num_map[i] = ";
645  for (unsigned int i=0; i<static_cast<unsigned int>(std::min(10, num_elem-1)); ++i)
646  libMesh::out << elem_num_map[i] << ", ";
647  libMesh::out << "... " << elem_num_map.back() << std::endl;
648  }
649 }
const class libmesh_nullptr_t libmesh_nullptr
EXODUS_EXPORT int ex_get_elem_num_map(int exoid, void_int *elem_map)
void message(const std::string &msg)
OStreamProxy out(std::cout)
long double min(long double a, double b)
processor_id_type processor_id() const
void libMesh::ExodusII_IO_Helper::read_elemental_var_values ( std::string  elemental_var_name,
int  time_step,
std::map< dof_id_type, Real > &  elem_var_value_map 
)
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 1004 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_nullptr, 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().

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

Reads an ExodusII mesh file header.

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

371 {
373  &title[0],
374  &num_dim,
375  &num_nodes,
376  &num_elem,
377  &num_elem_blk,
378  &num_node_sets,
379  &num_side_sets);
380 
381  EX_CHECK_ERR(ex_err, "Error retrieving header info.");
382 
383  this->read_num_time_steps();
384 
386  EX_CHECK_ERR(ex_err, "Error reading number of nodal variables.");
387 
389  EX_CHECK_ERR(ex_err, "Error reading number of elemental variables.");
390 
392  EX_CHECK_ERR(ex_err, "Error reading number of global variables.");
393 
394  message("Exodus header info retrieved successfully.");
395 }
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)
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 848 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().

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

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 481 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_nullptr, 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.

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

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

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

465 {
466  x.resize(num_nodes);
467  y.resize(num_nodes);
468  z.resize(num_nodes);
469 
471  static_cast<void *>(&x[0]),
472  static_cast<void *>(&y[0]),
473  static_cast<void *>(&z[0]));
474 
475  EX_CHECK_ERR(ex_err, "Error retrieving nodal data.");
476  message("Nodal data retrieved successfully.");
477 }
EXODUS_EXPORT int ex_get_coord(int exoid, void *x_coor, void *y_coor, void *z_coor)
void message(const std::string &msg)
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 757 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.

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

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

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

687 {
688  nodeset_ids.resize(num_node_sets);
689  if (num_node_sets > 0)
690  {
692  &nodeset_ids[0]);
693  EX_CHECK_ERR(ex_err, "Error retrieving nodeset information.");
694  message("All nodeset information retrieved successfully.");
695 
696  // Resize appropriate data structures -- only do this once outnode the loop
699  }
700 
701  char name_buffer[MAX_STR_LENGTH+1];
702  for (int i=0; i<num_node_sets; ++i)
703  {
705  nodeset_ids[i], name_buffer);
706  EX_CHECK_ERR(ex_err, "Error getting node set name.");
707  id_to_ns_names[nodeset_ids[i]] = name_buffer;
708  }
709  message("All node set names retrieved successfully.");
710 }
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
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 840 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().

841 {
843  this->inquire(exII::EX_INQ_TIME, "Error retrieving number of time steps");
844 }
int inquire(int req_info, std::string error_msg="")
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 400 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.

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

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

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

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

654 {
655  ss_ids.resize(num_side_sets);
656  if (num_side_sets > 0)
657  {
659  &ss_ids[0]);
660  EX_CHECK_ERR(ex_err, "Error retrieving sideset information.");
661  message("All sideset information retrieved successfully.");
662 
663  // Resize appropriate data structures -- only do this once outside the loop
666 
667  // Inquire about the length of the concatenated side sets element list
668  num_elem_all_sidesets = inquire(exII::EX_INQ_SS_ELEM_LEN, "Error retrieving length of the concatenated side sets element list!");
669 
673  }
674 
675  char name_buffer[MAX_STR_LENGTH+1];
676  for (int i=0; i<num_side_sets; ++i)
677  {
679  ss_ids[i], name_buffer);
680  EX_CHECK_ERR(ex_err, "Error getting side set name.");
681  id_to_ss_names[ss_ids[i]] = name_buffer;
682  }
683  message("All side set names retrieved successfully.");
684 }
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
void libMesh::ExodusII_IO_Helper::read_time_steps ( )
inherited

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

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

826 {
827  // Make sure we have an up-to-date count of the number of time steps in the file.
828  this->read_num_time_steps();
829 
830  if (num_time_steps > 0)
831  {
832  time_steps.resize(num_time_steps);
834  EX_CHECK_ERR(ex_err, "Error reading timesteps!");
835  }
836 }
std::vector< Real > time_steps
EXODUS_EXPORT int ex_get_all_times(int exoid, void *time_values)
void libMesh::ExodusII_IO_Helper::read_var_names ( ExodusVarType  type)
inherited

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

889 {
890  switch (type)
891  {
892  case NODAL:
894  break;
895  case ELEMENTAL:
897  break;
898  case GLOBAL:
900  break;
901  default:
902  libmesh_error_msg("Unrecognized ExodusVarType " << type);
903  }
904 }
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
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 2044 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::_coordinate_offset.

2045 {
2046  _coordinate_offset = p;
2047 }
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 2030 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::_use_mesh_dimension_instead_of_spatial_dimension.