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

This is the Nemesis_IO_Helper class. More...

#include <nemesis_io_helper.h>

Inheritance diagram for libMesh::Nemesis_IO_Helper:
[legend]

Public Types

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

Public Member Functions

 Nemesis_IO_Helper (const ParallelObject &parent, bool verbose=false, bool single_precision=false)
 Constructor. More...
 
virtual ~Nemesis_IO_Helper ()
 Destructor. More...
 
void get_init_global ()
 Reading functions. More...
 
void get_ss_param_global ()
 Fills: global_sideset_ids, num_global_side_counts, num_global_side_df_counts Call after: get_init_global() More...
 
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)
 Writing functions. More...
 
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)
 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. More...
 
void 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. More...
 
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)
 This function writes information about global node sets. More...
 
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)
 This function writes information about global side sets. More...
 
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)
 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. More...
 
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)
 Outputs initial information for communication maps. More...
 
void 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. More...
 
void 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. More...
 
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)
 Writes information about elemental communication map. More...
 
void put_elem_map (std::vector< int > &elem_mapi, std::vector< int > &elem_mapb)
 Outputs IDs of internal and border elements. More...
 
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)
 Writes the specified number of coordinate values starting at the specified index. More...
 
virtual void write_nodal_coordinates (const MeshBase &mesh, bool use_discontinuous=false)
 This function is specialized from ExodusII_IO_Helper to write only the nodal coordinates stored on the local piece of the Mesh. More...
 
virtual void write_elements (const MeshBase &mesh, bool use_discontinuous=false)
 This function is specialized to write the connectivity. More...
 
virtual void write_sidesets (const MeshBase &mesh)
 Writes the sidesets for this processor. More...
 
virtual void write_nodesets (const MeshBase &mesh)
 Writes the nodesets for this processor. More...
 
virtual void create (std::string filename)
 This function is specialized from ExodusII_IO_Helper to create the nodal coordinates stored on the local piece of the Mesh. More...
 
virtual void initialize (std::string title, const MeshBase &mesh, bool use_discontinuous=false)
 Specialization of the initialize function from ExodusII_IO_Helper that also writes global initial data to file. More...
 
void write_nodal_solution (const NumericVector< Number > &parallel_soln, const std::vector< std::string > &names, int timestep)
 Takes a parallel solution vector containing the node-major solution vector for all variables and outputs it to the files. More...
 
void write_nodal_solution (const std::vector< Number > &values, const std::vector< std::string > &names, int timestep)
 Takes a solution vector containing the solution for all variables and outputs it to the files. More...
 
std::string construct_nemesis_filename (const std::string &base_filename)
 Given base_filename, foo.e, constructs the Nemesis filename foo.e.X.Y, where X=n. More...
 
const char * get_elem_type () const
 
void open (const char *filename, bool read_only)
 Opens an ExodusII mesh file named filename. More...
 
void read_header ()
 Reads an ExodusII mesh file header. More...
 
void read_qa_records ()
 Reads the QA records from an ExodusII file. More...
 
void print_header ()
 Prints the ExodusII mesh file header, which includes the mesh title, the number of nodes, number of elements, mesh dimension, number of sidesets, and number of nodesets. More...
 
void read_nodes ()
 Reads the nodal data (x,y,z coordinates) from the ExodusII mesh file. More...
 
void read_node_num_map ()
 Reads the optional node_num_map from the ExodusII mesh file. More...
 
void print_nodes (std::ostream &out=libMesh::out)
 Prints the nodal information, by default to libMesh::out. More...
 
void read_block_info ()
 Reads information for all of the blocks in the ExodusII mesh file. More...
 
int get_block_id (int index)
 Get the block number for the given block index. More...
 
std::string get_block_name (int index)
 Get the block name for the given block index if supplied in the mesh file. More...
 
int get_side_set_id (int index)
 Get the side set id for the given side set index. More...
 
std::string get_side_set_name (int index)
 Get the side set name for the given side set index if supplied in the mesh file. More...
 
int get_node_set_id (int index)
 Get the node set id for the given node set index. More...
 
std::string get_node_set_name (int index)
 Get the node set name for the given node set index if supplied in the mesh file. More...
 
void read_elem_in_block (int block)
 Reads all of the element connectivity for block block in the ExodusII mesh file. More...
 
void read_elem_num_map ()
 Reads the optional node_num_map from the ExodusII mesh file. More...
 
void read_sideset_info ()
 Reads information about all of the sidesets in the ExodusII mesh file. More...
 
void read_nodeset_info ()
 Reads information about all of the nodesets in the ExodusII mesh file. More...
 
void read_sideset (int id, int offset)
 Reads information about sideset id and inserts it into the global sideset array at the position offset. More...
 
void read_nodeset (int id)
 Reads information about nodeset id and inserts it into the global nodeset array at the position offset. More...
 
void close ()
 Closes the ExodusII mesh file. More...
 
int inquire (int req_info, std::string error_msg="")
 
void read_time_steps ()
 Reads and stores the timesteps in the 'time_steps' array. More...
 
void read_num_time_steps ()
 Reads the number of timesteps currently stored in the Exodus file and stores it in the num_time_steps variable. More...
 
void read_nodal_var_values (std::string nodal_var_name, int time_step)
 Reads the nodal values for the variable 'nodal_var_name' at the specified time into the 'nodal_var_values' array. More...
 
void read_elemental_var_values (std::string elemental_var_name, int time_step, std::map< dof_id_type, Real > &elem_var_value_map)
 Reads elemental values for the variable 'elemental_var_name' at the specified timestep into the 'elem_var_value_map' which is passed in. More...
 
void initialize_element_variables (std::vector< std::string > names)
 Sets up the nodal variables. More...
 
void initialize_nodal_variables (std::vector< std::string > names)
 Sets up the nodal variables. More...
 
void initialize_global_variables (std::vector< std::string > names)
 Sets up the global variables. More...
 
void write_timestep (int timestep, Real time)
 Writes the time for the timestep. More...
 
void write_element_values (const MeshBase &mesh, const std::vector< Real > &values, int timestep)
 Writes the vector of values to the element variables. More...
 
void write_nodal_values (int var_id, const std::vector< Real > &values, int timestep)
 Writes the vector of values to a nodal variable. More...
 
void write_information_records (const std::vector< std::string > &records)
 Writes the vector of information records. More...
 
void write_global_values (const std::vector< Real > &values, int timestep)
 Writes the vector of global variables. More...
 
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
 Sets the underlying value of the boolean flag _use_mesh_dimension_instead_of_spatial_dimension. More...
 
void write_as_dimension (unsigned dim)
 Sets the value of _write_as_dimension. More...
 
void set_coordinate_offset (Point p)
 Allows you to set a vector that is added to the coordinates of all of the nodes. More...
 
std::vector< std::string > get_complex_names (const std::vector< std::string > &names) const
 
void message (const std::string &msg)
 Prints the message defined in msg. More...
 
void message (const std::string &msg, int i)
 Prints the message defined in msg, and appends the number i to the end of the message. More...
 
void read_var_names (ExodusVarType type)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

int nemesis_err_flag
 Member data. More...
 
int num_nodes_global
 Global initial information. More...
 
int num_elems_global
 
int num_elem_blks_global
 
int num_node_sets_global
 
int num_side_sets_global
 
int num_proc
 The number of processors for which the NEMESIS I file was created. More...
 
int num_proc_in_file
 The number of processors for which the NEMESIS I file stores information. More...
 
char ftype
 The type of file to be written. More...
 
std::vector< intglobal_sideset_ids
 Containers for reading global sideset (boundary conditions) information. More...
 
std::vector< intnum_global_side_counts
 
std::vector< intnum_global_side_df_counts
 
std::vector< intglobal_nodeset_ids
 Containers for reading global nodeset information. More...
 
std::vector< intnum_global_node_counts
 
std::vector< intnum_global_node_df_counts
 
std::vector< intglobal_elem_blk_ids
 Read the global element block IDs and counts. More...
 
std::vector< intglobal_elem_blk_cnts
 
std::set< intnodes_attached_to_local_elems
 libMesh numbered node ids attached to local elems. More...
 
std::map< subdomain_id_type, std::vector< unsigned int > > subdomain_map
 Map of subdomains to element numbers. More...
 
std::map< int, std::vector< int > > block_id_to_elem_connectivity
 This is the block connectivity, i.e. More...
 
int num_internal_nodes
 To be used with the Nemesis::ne_get_loadbal_param() routine. More...
 
int num_border_nodes
 The number of FEM nodes local to a processor but residing in an element which also has FEM nodes on other processors. More...
 
int num_external_nodes
 The number of FEM nodes that reside on another processor but whose element partially resides on the current processor. More...
 
int num_internal_elems
 The number of internal FEM elements. More...
 
int num_border_elems
 The number of border FEM elements. More...
 
int num_node_cmaps
 The number of nodal communication maps for this processor. More...
 
int num_elem_cmaps
 The number of elemental communication maps for this processor. More...
 
std::vector< intelem_mapi
 Vector which stores internal element IDs. More...
 
std::vector< intelem_mapb
 Vector which stores border element IDs. More...
 
std::vector< intnode_mapi
 Vector which stores internal node IDs. More...
 
std::vector< intnode_mapb
 Vector which stores border node IDs. More...
 
std::vector< intnode_mape
 Vector which stores external node IDs. More...
 
std::vector< intnode_cmap_ids
 Vectors for storing the communication map parameters. More...
 
std::vector< intnode_cmap_node_cnts
 
std::vector< intelem_cmap_ids
 
std::vector< intelem_cmap_elem_cnts
 
std::vector< std::vector< int > > node_cmap_node_ids
 2 vectors of vectors for storing the node communication IDs for this processor. More...
 
std::vector< std::vector< int > > node_cmap_proc_ids
 
std::vector< std::vector< int > > elem_cmap_elem_ids
 3 vectors of vectors for storing element communication IDs for this processor. More...
 
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< intblock_ids
 
std::vector< intconnect
 
std::vector< intss_ids
 
std::vector< intnodeset_ids
 
std::vector< intnum_sides_per_set
 
std::vector< intnum_nodes_per_set
 
std::vector< intnum_df_per_set
 
std::vector< intnum_node_df_per_set
 
std::vector< intelem_list
 
std::vector< intside_list
 
std::vector< intnode_list
 
std::vector< intid_list
 
std::vector< intnode_num_map
 
std::vector< intelem_num_map
 
std::vector< Realx
 
std::vector< Realy
 
std::vector< Realz
 
std::vector< char > title
 
std::vector< char > elem_type
 
std::map< int, intlibmesh_elem_num_to_exodus
 
std::vector< intexodus_elem_num_to_libmesh
 
std::map< int, intlibmesh_node_num_to_exodus
 
std::vector< intexodus_node_num_to_libmesh
 
int num_time_steps
 
std::vector< Realtime_steps
 
int num_nodal_vars
 
std::vector< std::string > nodal_var_names
 
std::vector< Realnodal_var_values
 
int num_elem_vars
 
std::vector< std::string > elem_var_names
 
std::vector< Realelem_var_values
 
std::vector< std::string > global_var_names
 
std::map< int, std::string > id_to_block_names
 
std::map< int, std::string > id_to_ss_names
 
std::map< int, std::string > id_to_ns_names
 
bool verbose
 
bool opened_for_writing
 
bool opened_for_reading
 
std::string current_filename
 

Protected Attributes

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

Private Types

typedef std::map< unsigned, std::set< unsigned > >::iterator proc_nodes_touched_iterator
 Typedef for an iterator into the data structure above. More...
 
typedef std::map< unsigned, std::set< std::pair< unsigned, unsigned > > >::iterator proc_border_elem_sets_iterator
 Typedef for an iterator into the data structure above. More...
 

Private Member Functions

void compute_num_global_elem_blocks (const MeshBase &pmesh)
 This function uses global communication routines to determine the number of element blocks across the entire mesh. More...
 
void compute_num_global_nodesets (const MeshBase &pmesh)
 This function uses global communication routines to determine the number of nodesets across the entire mesh. More...
 
void compute_num_global_sidesets (const MeshBase &pmesh)
 This function uses global communication routines to determine the number of sidesets across the entire mesh. More...
 
void build_element_and_node_maps (const MeshBase &pmesh)
 This function builds the libmesh -> exodus and exodus -> libmesh node and element maps. More...
 
void compute_border_node_ids (const MeshBase &pmesh)
 This function constructs the set of border node IDs present on the current mesh. More...
 
void compute_internal_and_border_elems_and_internal_nodes (const MeshBase &pmesh)
 This function constructs the set of border and internal element IDs and internal node IDs present on the current mesh. More...
 
void compute_communication_map_parameters ()
 This function determines the communication map parameters which will eventually be written to file. More...
 
void compute_node_communication_maps ()
 Compute the node communication maps (really just pack vectors) in preparation for writing them to file. More...
 
void compute_node_maps ()
 Compute the node maps (really just pack vectors) which map the nodes to internal, border, and external nodes in the file. More...
 
void compute_elem_communication_maps ()
 This function computes element communication maps (really just packs vectors) in preparation for writing them to file. More...
 
void compute_element_maps ()
 This function computes element maps (really just packs vectors) which map the elements to internal and border elements. More...
 
void write_exodus_initialization_info (const MeshBase &pmesh, const std::string &title)
 This function writes exodus-specific initialization information. More...
 

Private Attributes

std::map< subdomain_id_type, unsigned > local_subdomain_counts
 This map keeps track of the number of elements in each subdomain (block) for this processor. More...
 
std::set< unsigned > border_node_ids
 The set which will eventually contain the IDs of "border nodes". More...
 
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
 Another map to store sets of intersections with each other processor (other than ourself, of course). More...
 
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > > proc_border_elem_sets
 Map between processor ID and (element,side) pairs bordering that processor ID. More...
 
std::set< unsigned > internal_node_ids
 A set of internal node IDs for this processor. More...
 
std::set< unsigned > internal_elem_ids
 A set of internal elem IDs for this processor. More...
 
std::set< unsigned > border_elem_ids
 A set of border elem IDs for this processor. More...
 

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 575 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 }
char ftype
The type of file to be written.
ExodusII_IO_Helper(const ParallelObject &parent, bool v=false, bool run_only_on_proc0=true, bool single_precision=false)
Constructor.
int num_external_nodes
The number of FEM nodes that reside on another processor but whose element partially resides on the c...
int nemesis_err_flag
Member data.
int num_node_cmaps
The number of nodal communication maps for this processor.
int num_nodes_global
Global initial information.
int num_proc
The number of processors for which the NEMESIS I file was created.
int num_internal_elems
The number of internal FEM elements.
int num_elem_cmaps
The number of elemental communication maps for this processor.
int num_proc_in_file
The number of processors for which the NEMESIS I file stores information.
int num_border_nodes
The number of FEM nodes local to a processor but residing in an element which also has FEM nodes on o...
int num_internal_nodes
To be used with the Nemesis::ne_get_loadbal_param() routine.
int num_border_elems
The number of border FEM elements.
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, 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 }
void close()
Closes the ExodusII mesh file.

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

References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), block_id_to_elem_connectivity, libMesh::ExodusII_IO_Helper::block_ids, libMesh::Elem::build(), libMesh::MeshBase::elem_ref(), libMesh::ExodusII_IO_Helper::exodus_elem_num_to_libmesh, libMesh::ExodusII_IO_Helper::exodus_node_num_to_libmesh, libMesh::ExodusII_IO_Helper::Conversion::get_canonical_type(), libMesh::ExodusII_IO_Helper::Conversion::get_node_map(), libMesh::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(), nodes_attached_to_local_elems, libMesh::ExodusII_IO_Helper::num_nodes, libMesh::ExodusII_IO_Helper::num_nodes_per_elem, libMesh::out, libMesh::ParallelObject::processor_id(), subdomain_map, libMesh::Elem::type(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

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

Closes the ExodusII mesh file.

Definition at line 789 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::_run_only_on_proc0, 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().

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

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

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

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

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

Referenced by initialize().

1910 {
1911  // The set which will eventually contain the IDs of "border nodes". These are nodes
1912  // that lie on the boundary between one or more processors.
1913  //std::set<unsigned> border_node_ids;
1914 
1915  // map from processor ID to set of nodes which elements from this processor "touch",
1916  // that is,
1917  // proc_nodes_touched[p] = (set all node IDs found in elements owned by processor p)
1918  std::map<unsigned, std::set<unsigned>> proc_nodes_touched;
1919 
1920 
1921  // We are going to create a lot of intermediate data structures here, so make sure
1922  // as many as possible all cleaned up by creating scope!
1923  {
1924  // Loop over active (not just active local) elements, make sets of node IDs for each
1925  // processor which has an element that "touches" a node.
1926  for (const auto & elem : pmesh.active_element_ptr_range())
1927  {
1928  // Get reference to the set for this processor. If it does not exist
1929  // it will be created.
1930  std::set<unsigned> & set_p = proc_nodes_touched[ elem->processor_id() ];
1931 
1932  // Insert all nodes touched by this element into the set
1933  for (unsigned int node=0; node<elem->n_nodes(); ++node)
1934  set_p.insert(elem->node_id(node));
1935  }
1936 
1937  // The number of node communication maps is the number of other processors
1938  // with which we share nodes. (I think.) This is just the size of the map we just
1939  // created, minus 1.
1940  this->num_node_cmaps =
1941  cast_int<int>(proc_nodes_touched.size() - 1);
1942 
1943  // If we've got no elements on this processor and haven't touched
1944  // any nodes, however, then that's 0 other processors with which
1945  // we share nodes, not -1.
1946  if (this->num_node_cmaps == -1)
1947  {
1948  libmesh_assert (pmesh.active_elements_begin() == pmesh.active_elements_end());
1949  this->num_node_cmaps = 0;
1950  }
1951 
1952  // We can't be connecting to more processors than exist outside
1953  // ourselves
1954  libmesh_assert_less (static_cast<unsigned>(this->num_node_cmaps), this->n_processors());
1955 
1956  if (verbose)
1957  {
1958  libMesh::out << "[" << this->processor_id()
1959  << "] proc_nodes_touched contains "
1960  << proc_nodes_touched.size()
1961  << " sets of nodes."
1962  << std::endl;
1963 
1964  for (proc_nodes_touched_iterator it = proc_nodes_touched.begin();
1965  it != proc_nodes_touched.end();
1966  ++it)
1967  {
1968  libMesh::out << "[" << this->processor_id()
1969  << "] proc_nodes_touched[" << it->first << "] has "
1970  << it->second.size()
1971  << " entries."
1972  << std::endl;
1973  }
1974  }
1975 
1976 
1977  // Loop over all the sets we just created and compute intersections with the
1978  // this processor's set. Obviously, don't intersect with ourself.
1979  for (proc_nodes_touched_iterator it = proc_nodes_touched.begin();
1980  it != proc_nodes_touched.end();
1981  ++it)
1982  {
1983  // Don't compute intersections with ourself
1984  if (it->first == this->processor_id())
1985  continue;
1986 
1987  // Otherwise, compute intersection with other processor and ourself
1988  std::set<unsigned> & my_set = proc_nodes_touched[this->processor_id()];
1989  std::set<unsigned> & other_set = it->second;
1990  std::set<unsigned> & result_set = this->proc_nodes_touched_intersections[ it->first ]; // created if does not exist
1991 
1992  std::set_intersection(my_set.begin(), my_set.end(),
1993  other_set.begin(), other_set.end(),
1994  std::inserter(result_set, result_set.end()));
1995  }
1996 
1997  if (verbose)
1998  {
2000  it != this->proc_nodes_touched_intersections.end();
2001  ++it)
2002  {
2003  libMesh::out << "[" << this->processor_id()
2004  << "] this->proc_nodes_touched_intersections[" << it->first << "] has "
2005  << it->second.size()
2006  << " entries."
2007  << std::endl;
2008  }
2009  }
2010 
2011  // Compute the set_union of all the preceding intersections. This will be the set of
2012  // border node IDs for this processor.
2014  it != this->proc_nodes_touched_intersections.end();
2015  ++it)
2016  {
2017  std::set<unsigned> & other_set = it->second;
2018  std::set<unsigned> intermediate_result; // Don't think we can insert into one of the sets we're unioning...
2019 
2020  std::set_union(this->border_node_ids.begin(), this->border_node_ids.end(),
2021  other_set.begin(), other_set.end(),
2022  std::inserter(intermediate_result, intermediate_result.end()));
2023 
2024  // Swap our intermediate result into the final set
2025  this->border_node_ids.swap(intermediate_result);
2026  }
2027 
2028  if (verbose)
2029  {
2030  libMesh::out << "[" << this->processor_id()
2031  << "] border_node_ids.size()=" << this->border_node_ids.size()
2032  << std::endl;
2033  }
2034  } // end scope for border node ID creation
2035 
2036  // Store the number of border node IDs to be written to Nemesis file
2037  this->num_border_nodes = cast_int<int>(this->border_node_ids.size());
2038 }
processor_id_type n_processors() const
int num_node_cmaps
The number of nodal communication maps for this processor.
libmesh_assert(j)
std::set< unsigned > border_node_ids
The set which will eventually contain the IDs of "border nodes".
std::map< unsigned, std::set< unsigned > >::iterator proc_nodes_touched_iterator
Typedef for an iterator into the data structure above.
OStreamProxy out
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
Another map to store sets of intersections with each other processor (other than ourself, of course).
int num_border_nodes
The number of FEM nodes local to a processor but residing in an element which also has FEM nodes on o...
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
Vectors for storing the communication map parameters.
int num_node_cmaps
The number of nodal communication maps for this processor.
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< unsigned, std::set< unsigned > >::iterator proc_nodes_touched_iterator
Typedef for an iterator into the data structure above.
std::vector< int > elem_cmap_elem_cnts
int num_elem_cmaps
The number of elemental communication maps for this processor.
OStreamProxy out
std::vector< int > elem_cmap_ids
std::vector< int > node_cmap_node_cnts
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
Another map to store sets of intersections with each other processor (other than ourself, of course).
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > >::iterator proc_border_elem_sets_iterator
Typedef for an iterator into the data structure above.
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > > proc_border_elem_sets
Map between processor ID and (element,side) pairs bordering that processor ID.
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
Also have a polymorphic pointer to the end object, this prevents iterating past the 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
3 vectors of vectors for storing element communication IDs for this processor.
std::vector< std::vector< int > > elem_cmap_proc_ids
int num_elem_cmaps
The number of elemental communication maps for this processor.
std::vector< int > elem_cmap_ids
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > >::iterator proc_border_elem_sets_iterator
Typedef for an iterator into the data structure above.
std::map< unsigned, std::set< std::pair< unsigned, unsigned > > > proc_border_elem_sets
Map between processor ID and (element,side) pairs bordering that processor ID.
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
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::map< int, int > libmesh_elem_num_to_exodus
std::set< unsigned > border_elem_ids
A set of border elem IDs for this processor.
std::vector< int > elem_mapb
Vector which stores border element IDs.
std::vector< int > elem_mapi
Vector which stores internal element IDs.
std::set< unsigned > internal_elem_ids
A set of internal elem IDs for this processor.
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_element_ptr_range(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), border_elem_ids, border_node_ids, libMesh::ExodusII_IO_Helper::Conversion::get_inverse_side_map(), internal_elem_ids, internal_node_ids, libmesh_nullptr, nodes_attached_to_local_elems, num_border_elems, num_border_nodes, num_elem_cmaps, num_internal_elems, num_internal_nodes, libMesh::out, proc_border_elem_sets, libMesh::ParallelObject::processor_id(), and libMesh::ExodusII_IO_Helper::verbose.

Referenced by initialize().

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

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

Definition at line 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
Vectors for storing the communication map parameters.
int num_node_cmaps
The number of nodal communication maps for this processor.
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the 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
Typedef for an iterator into the data structure above.
OStreamProxy out
std::map< unsigned, std::set< unsigned > > proc_nodes_touched_intersections
Another map to store sets of intersections with each other processor (other than ourself, of course).
std::vector< std::vector< int > > node_cmap_node_ids
2 vectors of vectors for storing the node communication IDs for this processor.
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
Vector which stores external node IDs.
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
std::set< unsigned > internal_node_ids
A set of internal node IDs for this processor.
std::vector< int > node_mapi
Vector which stores internal node IDs.
std::set< unsigned > border_node_ids
The set which will eventually contain the IDs of "border nodes".
std::map< int, int > libmesh_node_num_to_exodus
std::vector< int > node_mapb
Vector which stores border node IDs.
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 1637 of file nemesis_io_helper.C.

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

Referenced by initialize().

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

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

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

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

2625 {
2626  // Build a filename for this processor. This code is cut-n-pasted from the read function
2627  // and should probably be put into a separate function...
2628  std::ostringstream file_oss;
2629 
2630  // We have to be a little careful here: Nemesis left pads its file
2631  // numbers based on the number of processors, so for example on 10
2632  // processors, we'd have:
2633  // mesh.e.10.00
2634  // mesh.e.10.01
2635  // mesh.e.10.02
2636  // ...
2637  // mesh.e.10.09
2638 
2639  // And on 100 you'd have:
2640  // mesh.e.100.000
2641  // mesh.e.100.001
2642  // ...
2643  // mesh.e.128.099
2644 
2645  // Find the length of the highest processor ID
2646  file_oss << (this->n_processors());
2647  unsigned int field_width = cast_int<unsigned int>(file_oss.str().size());
2648 
2649  if (verbose)
2650  libMesh::out << "field_width=" << field_width << std::endl;
2651 
2652  file_oss.str(""); // reset the string stream
2653  file_oss << base_filename
2654  << '.' << this->n_processors()
2655  << '.' << std::setfill('0') << std::setw(field_width) << this->processor_id();
2656 
2657  // Return the resulting string
2658  return file_oss.str();
2659 }
processor_id_type n_processors() const
OStreamProxy out
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
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 538 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::block_ids.

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

539 {
540  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
541 
542  return block_ids[index];
543 }
std::string libMesh::ExodusII_IO_Helper::get_block_name ( int  index)
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 547 of file exodusII_io_helper.C.

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

548 {
549  libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
550 
551  return id_to_block_names[block_ids[index]];
552 }
std::map< int, std::string > id_to_block_names
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
Vectors for storing the communication map parameters.
int nemesis_err_flag
Member data.
int num_node_cmaps
The number of nodal communication maps for this processor.
const class libmesh_nullptr_t libmesh_nullptr
std::vector< int > elem_cmap_elem_cnts
int num_elem_cmaps
The number of elemental communication maps for this processor.
OStreamProxy out
std::vector< int > elem_cmap_ids
std::vector< int > node_cmap_node_cnts
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 2014 of file exodusII_io_helper.C.

2015 {
2016  std::vector<std::string>::const_iterator names_it = names.begin();
2017  std::vector<std::string>::const_iterator names_end = names.end();
2018 
2019  std::vector<std::string> complex_names;
2020 
2021  // This will loop over all names and create new "complex" names
2022  // (i.e. names that start with r_, i_ or a_
2023  for (; names_it != names_end; ++names_it)
2024  {
2025  std::stringstream name_real, name_imag, name_abs;
2026  name_real << "r_" << *names_it;
2027  name_imag << "i_" << *names_it;
2028  name_abs << "a_" << *names_it;
2029 
2030  complex_names.push_back(name_real.str());
2031  complex_names.push_back(name_imag.str());
2032  complex_names.push_back(name_abs.str());
2033  }
2034 
2035  return complex_names;
2036 }
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 }
int nemesis_err_flag
Member data.
std::vector< int > global_elem_blk_ids
Read the global element block IDs and counts.
OStreamProxy out
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 }
int nemesis_err_flag
Member data.
std::vector< std::vector< int > > elem_cmap_side_ids
std::vector< std::vector< int > > elem_cmap_elem_ids
3 vectors of vectors for storing element communication IDs for this processor.
std::vector< std::vector< int > > elem_cmap_proc_ids
std::vector< int > elem_cmap_elem_cnts
int num_elem_cmaps
The number of elemental communication maps for this processor.
OStreamProxy out
std::vector< int > elem_cmap_ids
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 }
int nemesis_err_flag
Member data.
const class libmesh_nullptr_t libmesh_nullptr
int num_internal_elems
The number of internal FEM elements.
OStreamProxy out
std::vector< int > elem_mapb
Vector which stores border element IDs.
long double min(long double a, double b)
std::vector< int > elem_mapi
Vector which stores internal element IDs.
processor_id_type processor_id() const
int num_border_elems
The number of border FEM elements.
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 311 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::elem_type.

312 {
313  return &elem_type[0];
314 }
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 }
int nemesis_err_flag
Member data.
int num_nodes_global
Global initial information.
OStreamProxy out
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 }
char ftype
The type of file to be written.
int nemesis_err_flag
Member data.
int num_proc
The number of processors for which the NEMESIS I file was created.
OStreamProxy out
int num_proc_in_file
The number of processors for which the NEMESIS I file stores information.
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 }
int num_external_nodes
The number of FEM nodes that reside on another processor but whose element partially resides on the c...
int nemesis_err_flag
Member data.
int num_node_cmaps
The number of nodal communication maps for this processor.
int num_internal_elems
The number of internal FEM elements.
int num_elem_cmaps
The number of elemental communication maps for this processor.
OStreamProxy out
int num_border_nodes
The number of FEM nodes local to a processor but residing in an element which also has FEM nodes on o...
int num_internal_nodes
To be used with the Nemesis::ne_get_loadbal_param() routine.
processor_id_type processor_id() const
int num_border_elems
The number of border FEM elements.
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
Vectors for storing the communication map parameters.
int nemesis_err_flag
Member data.
int num_node_cmaps
The number of nodal communication maps for this processor.
std::vector< std::vector< int > > node_cmap_proc_ids
OStreamProxy out
std::vector< int > node_cmap_node_cnts
std::vector< std::vector< int > > node_cmap_node_ids
2 vectors of vectors for storing the node communication IDs for this processor.
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 numbering 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 }
int num_external_nodes
The number of FEM nodes that reside on another processor but whose element partially resides on the c...
int nemesis_err_flag
Member data.
std::vector< int > node_mape
Vector which stores external node IDs.
const class libmesh_nullptr_t libmesh_nullptr
std::vector< int > node_mapi
Vector which stores internal node IDs.
OStreamProxy out
std::vector< int > node_mapb
Vector which stores border node IDs.
int num_border_nodes
The number of FEM nodes local to a processor but residing in an element which also has FEM nodes on o...
int num_internal_nodes
To be used with the Nemesis::ne_get_loadbal_param() routine.
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 574 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::nodeset_ids.

575 {
576  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
577 
578  return nodeset_ids[index];
579 }
std::string libMesh::ExodusII_IO_Helper::get_node_set_name ( int  index)
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 583 of file exodusII_io_helper.C.

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

584 {
585  libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
586 
587  return id_to_ns_names[nodeset_ids[index]];
588 }
std::map< int, std::string > id_to_ns_names
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
Containers for reading global nodeset information.
int nemesis_err_flag
Member data.
std::vector< int > num_global_node_df_counts
OStreamProxy out
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 556 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::ss_ids.

557 {
558  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
559 
560  return ss_ids[index];
561 }
std::string libMesh::ExodusII_IO_Helper::get_side_set_name ( int  index)
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 565 of file exodusII_io_helper.C.

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

566 {
567  libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
568 
569  return id_to_ss_names[ss_ids[index]];
570 }
std::map< int, std::string > id_to_ss_names
void libMesh::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
Containers for reading global sideset (boundary conditions) information.
int nemesis_err_flag
Member data.
std::vector< int > num_global_side_df_counts
std::vector< int > num_global_side_counts
OStreamProxy out
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 labeled 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 communication, 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
void compute_element_maps()
This function computes element maps (really just packs vectors) which map the elements to internal an...
std::vector< int > global_nodeset_ids
Containers for reading global nodeset information.
std::vector< int > global_sideset_ids
Containers for reading global sideset (boundary conditions) information.
void compute_num_global_nodesets(const MeshBase &pmesh)
This function uses global communication routines to determine the number of nodesets across the entir...
std::vector< int > node_cmap_ids
Vectors for storing the communication map parameters.
int num_external_nodes
The number of FEM nodes that reside on another processor but whose element partially resides on the c...
std::vector< int > node_mape
Vector which stores external node IDs.
void compute_elem_communication_maps()
This function computes element communication maps (really just packs vectors) in preparation for writ...
void compute_num_global_elem_blocks(const MeshBase &pmesh)
This function uses global communication routines to determine the number of element blocks across the...
processor_id_type n_processors() const
MeshBase & mesh
int num_node_cmaps
The number of nodal communication maps for this processor.
void put_elem_map(std::vector< int > &elem_mapi, std::vector< int > &elem_mapb)
Outputs IDs of internal and border elements.
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)
This function writes information about global node sets.
void 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...
void compute_border_node_ids(const MeshBase &pmesh)
This function constructs the set of border node IDs present on the current mesh.
void compute_communication_map_parameters()
This function determines the communication map parameters which will eventually be written to file...
void compute_node_communication_maps()
Compute the node communication maps (really just pack vectors) in preparation for writing them to fil...
std::vector< int > num_global_side_df_counts
void build_element_and_node_maps(const MeshBase &pmesh)
This function builds the libmesh -> exodus and exodus -> libmesh node and element maps...
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)
Writes global information including: .) global number of nodes .) global number of elems ...
std::vector< int > num_global_side_counts
std::vector< int > global_elem_blk_ids
Read the global element block IDs and counts.
std::vector< std::vector< int > > elem_cmap_elem_ids
3 vectors of vectors for storing element communication IDs for this processor.
std::vector< int > node_mapi
Vector which stores internal node IDs.
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)
Outputs initial information for communication maps.
void compute_num_global_sidesets(const MeshBase &pmesh)
This function uses global communication routines to determine the number of sidesets across the entir...
int num_internal_elems
The number of internal FEM elements.
void compute_internal_and_border_elems_and_internal_nodes(const MeshBase &pmesh)
This function constructs the set of border and internal element IDs and internal node IDs present on ...
void compute_node_maps()
Compute the node maps (really just pack vectors) which map the nodes to internal, border...
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)
Writes information about elemental communication map.
void 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.
std::vector< int > elem_cmap_elem_cnts
int num_elem_cmaps
The number of elemental communication maps for this processor.
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)
This function writes information about global side sets.
std::vector< int > node_cmap_node_cnts
void write_exodus_initialization_info(const MeshBase &pmesh, const std::string &title)
This function writes exodus-specific initialization information.
void put_init_info(unsigned num_proc, unsigned num_proc_in_file, const char *ftype)
Writing functions.
void 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.
std::vector< int > elem_mapb
Vector which stores border element IDs.
std::vector< int > node_mapb
Vector which stores border node IDs.
std::vector< std::vector< int > > node_cmap_node_ids
2 vectors of vectors for storing the node communication IDs for this processor.
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)
Writes load balance parameters, some of which are described below: .) num_internal_nodes - nodes "who...
std::vector< int > elem_mapi
Vector which stores internal element IDs.
int num_border_nodes
The number of FEM nodes local to a processor but residing in an element which also has FEM nodes on o...
int num_internal_nodes
To be used with the Nemesis::ne_get_loadbal_param() routine.
int num_border_elems
The number of border FEM elements.
void libMesh::ExodusII_IO_Helper::initialize_element_variables ( std::vector< std::string >  names)
inherited

Sets up the nodal variables.

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

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

Sets up the global variables.

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

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

Sets up the nodal variables.

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

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

Definition at line 808 of file exodusII_io_helper.C.

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

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

809 {
810  int ret_int = 0;
811  char ret_char = 0;
812  float ret_float = 0.;
813 
814  ex_err = exII::ex_inquire(ex_id,
815  req_info_in,
816  &ret_int,
817  &ret_float,
818  &ret_char);
819 
820  EX_CHECK_ERR(ex_err, error_msg);
821 
822  return ret_int;
823 }
void libMesh::ExodusII_IO_Helper::message ( const std::string &  msg)
inherited
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 325 of file exodusII_io_helper.C.

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

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

Definition at line 93 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), 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::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::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

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

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

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

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

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

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

Definition at line 99 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), 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(), libMesh::RBConstruction::compute_max_error_bound(), 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::RBEIMConstruction::evaluate_mesh_function(), 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::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), 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::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), 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::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), BoundaryInfoTest::testShellFaceConstraints(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), 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::RBEvaluation::write_out_vectors(), write_output_solvedata(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), 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:724
void libMesh::Nemesis_IO_Helper::put_cmap_params ( std::vector< int > &  node_cmap_ids,
std::vector< int > &  node_cmap_node_cnts,
std::vector< int > &  elem_cmap_ids,
std::vector< int > &  elem_cmap_elem_cnts 
)

Outputs initial information for communication maps.

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

Definition at line 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
Vectors for storing the communication map parameters.
int nemesis_err_flag
Member data.
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 }
int nemesis_err_flag
Member data.
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 }
int nemesis_err_flag
Member data.
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 }
int nemesis_err_flag
Member data.
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 }
int nemesis_err_flag
Member data.
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 }
int nemesis_err_flag
Member data.
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 }
int nemesis_err_flag
Member data.
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 }
int nemesis_err_flag
Member data.
void libMesh::Nemesis_IO_Helper::put_node_cmap ( std::vector< std::vector< int >> &  node_cmap_node_ids,
std::vector< std::vector< int >> &  node_cmap_proc_ids 
)

Outputs all of the nodal communication maps for this processor.

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

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

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

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

Must be called after put_cmap_params().

Definition at line 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
Vectors for storing the communication map parameters.
int nemesis_err_flag
Member data.
OStreamProxy out
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 }
int nemesis_err_flag
Member data.
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
Containers for reading global nodeset information.
int nemesis_err_flag
Member data.
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
Containers for reading global sideset (boundary conditions) information.
int nemesis_err_flag
Member data.
void libMesh::ExodusII_IO_Helper::read_block_info ( )
inherited

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

Definition at line 511 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::block_ids, libMesh::ExodusII_IO_Helper::ex_err, 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.

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

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

Definition at line 593 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::block_ids, libMesh::ExodusII_IO_Helper::connect, libMesh::ExodusII_IO_Helper::elem_type, libMesh::ExodusII_IO_Helper::ex_err, 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.

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

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 633 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::elem_num_map, libMesh::ExodusII_IO_Helper::ex_err, 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.

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

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

Reads an ExodusII mesh file header.

Definition at line 372 of file exodusII_io_helper.C.

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

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

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

Definition at line 850 of file exodusII_io_helper.C.

References libMesh::err, libMesh::ExodusII_IO_Helper::ex_err, 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().

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

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 483 of file exodusII_io_helper.C.

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

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

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

Definition at line 466 of file exodusII_io_helper.C.

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

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

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

Definition at line 759 of file exodusII_io_helper.C.

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

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

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

Definition at line 688 of file exodusII_io_helper.C.

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

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

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

Definition at line 842 of file exodusII_io_helper.C.

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

843 {
845  this->inquire(exII::EX_INQ_TIME, "Error retrieving number of time steps");
846 }
int inquire(int req_info, std::string error_msg="")
void libMesh::ExodusII_IO_Helper::read_qa_records ( )
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 402 of file exodusII_io_helper.C.

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

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

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

Definition at line 716 of file exodusII_io_helper.C.

References libMesh::ExodusII_IO_Helper::elem_list, libMesh::ExodusII_IO_Helper::ex_err, 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.

717 {
718  libmesh_assert_less (static_cast<unsigned int>(id), ss_ids.size());
719  libmesh_assert_less (static_cast<unsigned int>(id), num_sides_per_set.size());
720  libmesh_assert_less (static_cast<unsigned int>(id), num_df_per_set.size());
721  libmesh_assert_less_equal (static_cast<unsigned int>(offset), elem_list.size());
722  libmesh_assert_less_equal (static_cast<unsigned int>(offset), side_list.size());
723 
724  ex_err = exII::ex_get_side_set_param(ex_id,
725  ss_ids[id],
726  &num_sides_per_set[id],
727  &num_df_per_set[id]);
728  EX_CHECK_ERR(ex_err, "Error retrieving sideset parameters.");
729  message("Parameters retrieved successfully for sideset: ", id);
730 
731