libMesh::ExodusII_IO_Helper Class Reference

#include <exodusII_io_helper.h>

Inheritance diagram for libMesh::ExodusII_IO_Helper:

List of all members.

Classes

class  Conversion
class  ElementMaps
class  NamesData

Public Member Functions

 ExodusII_IO_Helper (bool v=false, bool run_only_on_proc0=true)
virtual ~ExodusII_IO_Helper ()
bool created ()
void verbose (bool set_verbosity)
int get_num_dim () const
int get_num_globals () const
int get_num_nodes () const
int get_num_elem () const
int get_num_elem_blk () const
int get_num_elem_this_blk () const
int get_num_nodes_per_elem () const
int get_num_side_sets () const
int get_num_node_sets () const
int get_connect (int i) const
int get_num_sides_per_set (int i) const
int get_num_nodes_per_set (int i) const
const std::vector< int > & get_elem_list () const
const std::vector< int > & get_side_list () const
const std::vector< int > & get_node_list () const
int get_nodeset_id (unsigned int i) const
const std::vector< int > & get_id_list () const
const char * get_elem_type () const
Real get_x (int i) const
Real get_y (int i) const
Real get_z (int i) const
void open (const char *filename)
void read_header ()
void print_header ()
void read_nodes ()
void read_node_num_map ()
void print_nodes (std::ostream &out=libMesh::out)
void read_block_info ()
int get_block_id (int index)
std::string get_block_name (int index)
int get_side_set_id (int index)
std::string get_side_set_name (int index)
int get_node_set_id (int index)
std::string get_node_set_name (int index)
void read_elem_in_block (int block)
void read_elem_num_map ()
void read_sideset_info ()
void read_nodeset_info ()
void read_sideset (int id, int offset)
void read_nodeset (int id)
void print_sideset_info ()
void print_nodeset_info ()
void close ()
int inquire (int req_info, std::string error_msg="")
const std::vector< Real > & get_time_steps ()
int get_num_nodal_vars ()
const std::vector< std::string > & get_nodal_var_names ()
const std::vector< Real > & get_nodal_var_values (std::string nodal_var_name, int time_step)
virtual void create (std::string filename)
virtual void initialize (std::string title, const MeshBase &mesh)
void initialize_discontinuous (std::string title, const MeshBase &mesh)
virtual void write_nodal_coordinates (const MeshBase &mesh)
void write_nodal_coordinates_discontinuous (const MeshBase &mesh)
virtual void write_elements (const MeshBase &mesh)
void write_elements_discontinuous (const MeshBase &mesh)
virtual void write_sidesets (const MeshBase &mesh)
virtual void write_nodesets (const MeshBase &mesh)
void initialize_element_variables (const MeshBase &mesh, std::vector< std::string > names)
void initialize_nodal_variables (std::vector< std::string > names)
void initialize_global_variables (const std::vector< std::string > &names)
void write_timestep (int timestep, Real time)
void write_element_values (const MeshBase &mesh, const std::vector< Number > &values, int timestep)
void write_nodal_values (int var_id, const std::vector< Number > &values, int timestep)
void write_information_records (const std::vector< std::string > &records)
void write_global_values (const std::vector< Number > &values, int timestep)
void use_mesh_dimension_instead_of_spatial_dimension (bool val)
void check_err (const int error, const std::string msg)
void message (const std::string msg)
void message (const std::string msg, int i)

Public Attributes

int comp_ws
int io_ws
int ex_id
int ex_err
int num_dim
int num_globals
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 req_info
int ret_int
int num_elem_all_sidesets
std::vector< int > block_ids
std::vector< int > connect
std::vector< int > ss_ids
std::vector< int > nodeset_ids
std::vector< int > num_sides_per_set
std::vector< int > num_nodes_per_set
std::vector< int > num_df_per_set
std::vector< int > num_node_df_per_set
std::vector< int > elem_list
std::vector< int > side_list
std::vector< int > node_list
std::vector< int > id_list
std::vector< int > node_num_map
std::vector< int > elem_num_map
float ex_version
float ret_float
std::vector< Realx
std::vector< Realy
std::vector< Realz
char ret_char
std::vector< char > title
std::vector< char > elem_type
std::map< int, int > libmesh_elem_num_to_exodus
std::vector< int > exodus_elem_num_to_libmesh
std::map< int, int > libmesh_node_num_to_exodus
std::vector< int > exodus_node_num_to_libmesh
int num_time_steps
std::vector< Realtime_steps
int num_nodal_vars
std::vector< std::string > nodal_var_names
std::vector< Realnodal_var_values
int num_elem_vars
std::vector< std::vector< char > > vvc
std::vector< char * > strings
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

Protected Attributes

bool _created
bool _verbose
bool _run_only_on_proc0
bool _elem_vars_initialized
bool _global_vars_initialized
bool _use_mesh_dimension_instead_of_spatial_dimension

Detailed Description

This is the ExodusII_IO_Helper class. This class hides the implementation details of interfacing with the Exodus binary format.

Author:
Johw W. Peterson, 2002.

Definition at line 51 of file exodusII_io_helper.h.


Constructor & Destructor Documentation

libMesh::ExodusII_IO_Helper::ExodusII_IO_Helper ( bool  v = false,
bool  run_only_on_proc0 = true 
) [inline]

Constructor. Automatically initializes all the private members of the class. Also allows you to set the verbosity level to v=true (on) or v=false (off). The second argument, if true, tells the class to only perform its actions if running on processor zero. If you initialize this to false, the writing methods will run on all processors instead.

Definition at line 62 of file exodusII_io_helper.h.

References elem_type, and title.

00062                                                                 :
00063     comp_ws(sizeof(Real)),
00064     io_ws(0),
00065     ex_id(0),
00066     ex_err(0),
00067     num_dim(0),
00068     num_globals(0),
00069     num_nodes(0),
00070     num_elem(0),
00071     num_elem_blk(0),
00072     num_node_sets(0),
00073     num_side_sets(0),
00074     num_elem_this_blk(0),
00075     num_nodes_per_elem(0),
00076     num_attr(0),
00077     req_info(0),
00078     ret_int(0),
00079     num_elem_all_sidesets(0),
00080     ex_version(0.0),
00081     ret_float(0.0),
00082     ret_char(0),
00083     num_time_steps(0),
00084     _created(false),
00085     _verbose(v),
00086     _run_only_on_proc0(run_only_on_proc0),
00087     _elem_vars_initialized(false),
00088     _global_vars_initialized(false),
00089     _use_mesh_dimension_instead_of_spatial_dimension(false)
00090   {
00091     title.resize(MAX_LINE_LENGTH+1);
00092     elem_type.resize(MAX_STR_LENGTH);
00093   }

libMesh::ExodusII_IO_Helper::~ExodusII_IO_Helper (  )  [virtual]

Destructor. The only memory allocated is for title and elem_type. This memory is freed in the destructor.

Definition at line 219 of file exodusII_io_helper.C.

00220 {
00221 }


Member Function Documentation

void libMesh::ExodusII_IO_Helper::check_err ( const int  error,
const std::string  msg 
)

All of the ExodusII API functions return an int error value. This function checks to see if the error has been set, and if it has, prints the error message contained in msg.

Definition at line 230 of file exodusII_io_helper.C.

References libMesh::err.

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

00231 {
00232   if (err_in < 0)
00233     {
00234       libMesh::err << msg << std::endl;
00235       libmesh_error();
00236     }
00237 }

void libMesh::ExodusII_IO_Helper::close (  ) 

Closes the ExodusII mesh file.

Definition at line 649 of file exodusII_io_helper.C.

References _run_only_on_proc0, check_err(), ex_close(), ex_err, ex_id, message(), and libMesh::processor_id().

Referenced by libMesh::ExodusII_IO::~ExodusII_IO(), and libMesh::Nemesis_IO_Helper::~Nemesis_IO_Helper().

00650 {
00651   // Always call close on processor 0.
00652   // If we're running on multiple processors, i.e. as one of several Nemesis files,
00653   // we call close on all processors...
00654   if ((libMesh::processor_id() == 0) || (!_run_only_on_proc0))
00655     {
00656       ex_err = exII::ex_close(ex_id);
00657       check_err(ex_err, "Error closing Exodus file.");
00658       message("Exodus file closed successfully.");
00659     }
00660 }

void libMesh::ExodusII_IO_Helper::create ( std::string  filename  )  [virtual]

Opens an ExodusII mesh file named filename for writing.

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 766 of file exodusII_io_helper.C.

References _created, _run_only_on_proc0, _verbose, check_err(), comp_ws, ex_id, io_ws, std::min(), libMesh::out, libMesh::processor_id(), and libMesh::Real.

Referenced by libMesh::ExodusII_IO::write_nodal_data_discontinuous().

00767 {
00768   // If we're processor 0, always create the file.
00769   // If we running on all procs, e.g. as one of several Nemesis files, also
00770   // call create there.
00771   if ((libMesh::processor_id() == 0) || (!_run_only_on_proc0))
00772     {
00773       //Fall back on double precision when necessary since ExodusII
00774       //doesn't seem to support long double
00775       comp_ws = std::min(sizeof(Real),sizeof(double));
00776       io_ws = std::min(sizeof(Real),sizeof(double));
00777 
00778       ex_id = exII::ex_create(filename.c_str(), EX_CLOBBER, &comp_ws, &io_ws);
00779 
00780       check_err(ex_id, "Error creating ExodusII mesh file.");
00781 
00782       if (_verbose)
00783         libMesh::out << "File created successfully." << std::endl;
00784     }
00785 
00786   _created = true;
00787 }

bool libMesh::ExodusII_IO_Helper::created (  ) 

Returns true once create() has been successfully called, and false otherwise.

Definition at line 1604 of file exodusII_io_helper.C.

References _created.

Referenced by libMesh::Nemesis_IO::write_global_data(), libMesh::Nemesis_IO::write_information_records(), libMesh::Nemesis_IO::write_nodal_data(), and libMesh::ExodusII_IO::write_nodal_data_discontinuous().

01605 {
01606   return _created;
01607 }

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

Get the block number for the given block index.

Definition at line 379 of file exodusII_io_helper.C.

References block_ids.

Referenced by libMesh::ExodusII_IO::read(), and write_element_values().

00380 {
00381   libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
00382 
00383   return block_ids[index];
00384 }

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

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

Definition at line 388 of file exodusII_io_helper.C.

References block_ids, and id_to_block_names.

Referenced by libMesh::ExodusII_IO::read().

00389 {
00390   libmesh_assert_less (static_cast<unsigned int>(index), block_ids.size());
00391 
00392   return id_to_block_names[block_ids[index]];
00393 }

int libMesh::ExodusII_IO_Helper::get_connect ( int  i  )  const [inline]
Returns:
the number of elements in all the sidesets. Effectively returns the total number of elements on the ExodusII mesh boundary.
the $ i^{th} $ node number in the element connectivity list for a given element.

Definition at line 191 of file exodusII_io_helper.h.

References connect.

Referenced by libMesh::ExodusII_IO::read().

00191 { return connect[i]; }

const std::vector<int>& libMesh::ExodusII_IO_Helper::get_elem_list (  )  const [inline]
Returns:
the $ i^{th} $ entry in the element list. The element list contains the numbers of all elements on the boundary.
a constant reference to the elem_list.

Definition at line 219 of file exodusII_io_helper.h.

References elem_list.

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

00219 { return elem_list; }

const char* libMesh::ExodusII_IO_Helper::get_elem_type (  )  const [inline]
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 266 of file exodusII_io_helper.h.

References elem_type.

Referenced by libMesh::ExodusII_IO::read().

00266 { return &elem_type[0]; }

const std::vector<int>& libMesh::ExodusII_IO_Helper::get_id_list (  )  const [inline]
Returns:
the $ i^{th} $ entry in the id list. This is the id for the ith face on the boundary.
a constant reference to the id_list.

Definition at line 256 of file exodusII_io_helper.h.

References id_list.

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

00256 { return id_list; }

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

Definition at line 688 of file exodusII_io_helper.C.

References _verbose, ex_get_var_names(), ex_id, nodal_var_names, num_nodal_vars, libMesh::out, strings, and vvc.

Referenced by get_nodal_var_values().

00689 {
00690   // Allocate enough space for our variable name strings.
00691   nodal_var_names.resize(num_nodal_vars);
00692 
00693   // Use the vvc and strings objects to emulate the behavior of
00694   // a char** object.
00695   vvc.resize(num_nodal_vars);
00696   strings.resize(num_nodal_vars);
00697   for (int i=0;i<num_nodal_vars;i++)
00698     vvc[i].resize(MAX_STR_LENGTH+1);
00699 
00700   for (int i=0;i<num_nodal_vars;i++)
00701     strings[i]=&(vvc[i][0]); // set pointer into vvc only *after* all resizing is complete
00702 
00703   exII::ex_get_var_names(ex_id,
00704                          "n",
00705                          num_nodal_vars,
00706                          &strings[0]//var_names
00707                          );
00708 
00709   if (_verbose)
00710     {
00711       libMesh::out << "Read the variable(s) from the file:" << std::endl;
00712       for (int i=0; i<num_nodal_vars; i++)
00713         libMesh::out << "strings[" << i << "]=" << strings[i] << std::endl;
00714     }
00715 
00716 
00717   // Copy the char buffers into strings.
00718   for (int i=0;i<num_nodal_vars;i++)
00719     nodal_var_names[i]=strings[i]; // calls string::op=(const char*)
00720 
00721 
00722   return nodal_var_names;
00723 }

const std::vector< Real > & libMesh::ExodusII_IO_Helper::get_nodal_var_values ( std::string  nodal_var_name,
int  time_step 
)

Definition at line 728 of file exodusII_io_helper.C.

References libMesh::err, ex_get_nodal_var(), ex_id, get_nodal_var_names(), nodal_var_names, nodal_var_values, and num_nodes.

00729 {
00730   nodal_var_values.resize(num_nodes);
00731 
00732   this->get_nodal_var_names();
00733 
00734   // See if we can find the variable we are looking for
00735   unsigned int var_index = 0;
00736   bool found = false;
00737 
00738   // Do a linear search for nodal_var_name in nodal_var_names
00739   for (; var_index<nodal_var_names.size(); ++var_index)
00740     {
00741       found = (nodal_var_names[var_index] == nodal_var_name);
00742       if (found)
00743         break;
00744     }
00745 
00746   if (!found)
00747     {
00748       libMesh::err << "Unable to locate variable named: " << nodal_var_name << std::endl;
00749       libMesh::err << "Available variables: " << std::endl;
00750       for (unsigned int i=0; i<nodal_var_names.size(); ++i)
00751         libMesh::err << nodal_var_names[i] << std::endl;
00752 
00753       libmesh_error();
00754     }
00755 
00756   exII::ex_get_nodal_var(ex_id, time_step, var_index+1, num_nodes, &nodal_var_values[0]);
00757 
00758   return nodal_var_values;
00759 }

const std::vector<int>& libMesh::ExodusII_IO_Helper::get_node_list (  )  const [inline]
Returns:
a constant reference to the node_list.

Definition at line 239 of file exodusII_io_helper.h.

References node_list.

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

00239 { return node_list; }

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

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

Definition at line 415 of file exodusII_io_helper.C.

References nodeset_ids.

00416 {
00417   libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
00418 
00419   return nodeset_ids[index];
00420 }

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

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 424 of file exodusII_io_helper.C.

References id_to_ns_names, and nodeset_ids.

Referenced by libMesh::ExodusII_IO::read().

00425 {
00426   libmesh_assert_less (static_cast<unsigned int>(index), nodeset_ids.size());
00427 
00428   return id_to_ns_names[nodeset_ids[index]];
00429 }

int libMesh::ExodusII_IO_Helper::get_nodeset_id ( unsigned int  i  )  const [inline]
Returns:
the nodeset id corresponding to the ith nodeset.

Definition at line 244 of file exodusII_io_helper.h.

References nodeset_ids.

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

00244 { return nodeset_ids[i]; }

int libMesh::ExodusII_IO_Helper::get_num_dim (  )  const [inline]
Returns:
the ExodusII mesh dimension.

Definition at line 118 of file exodusII_io_helper.h.

References num_dim.

00118 { return num_dim; }

int libMesh::ExodusII_IO_Helper::get_num_elem (  )  const [inline]
Returns:
the total number of elements in the ExodusII mesh.

Definition at line 137 of file exodusII_io_helper.h.

References num_elem.

Referenced by libMesh::ExodusII_IO::read().

00137 { return num_elem; }

int libMesh::ExodusII_IO_Helper::get_num_elem_blk (  )  const [inline]
Returns:
the total number of element blocks in the ExodusII mesh.

Definition at line 144 of file exodusII_io_helper.h.

References num_elem_blk.

Referenced by libMesh::ExodusII_IO::read().

00144 { return num_elem_blk; }

int libMesh::ExodusII_IO_Helper::get_num_elem_this_blk (  )  const [inline]

For a given block, returns the total number of elements.

Definition at line 151 of file exodusII_io_helper.h.

References num_elem_this_blk.

Referenced by libMesh::ExodusII_IO::read().

00151 { return num_elem_this_blk; }

int libMesh::ExodusII_IO_Helper::get_num_globals (  )  const [inline]
Returns:
the total number of global variables.

Definition at line 124 of file exodusII_io_helper.h.

References num_globals.

00124 { return num_globals; }

int libMesh::ExodusII_IO_Helper::get_num_nodal_vars (  )  [inline]

Definition at line 454 of file exodusII_io_helper.h.

References num_nodal_vars.

00454 { return num_nodal_vars; }

int libMesh::ExodusII_IO_Helper::get_num_node_sets (  )  const [inline]
Returns:
the total number of nodesets in the ExodusII mesh.

Definition at line 174 of file exodusII_io_helper.h.

References num_node_sets.

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

00174 { return num_node_sets; }

int libMesh::ExodusII_IO_Helper::get_num_nodes (  )  const [inline]
Returns:
the total number of nodes in the ExodusII mesh.

Definition at line 130 of file exodusII_io_helper.h.

References num_nodes.

Referenced by libMesh::ExodusII_IO::read().

00130 { return num_nodes; }

int libMesh::ExodusII_IO_Helper::get_num_nodes_per_elem (  )  const [inline]
Returns:
the number of nodes per element in a given block. e.g. for HEX27 it returns 27.

Definition at line 159 of file exodusII_io_helper.h.

References num_nodes_per_elem.

Referenced by libMesh::ExodusII_IO::read().

00159 { return num_nodes_per_elem; }

int libMesh::ExodusII_IO_Helper::get_num_nodes_per_set ( int  i  )  const [inline]

For a single nodeset, returns the total number of nodes in the nodeset.

Definition at line 205 of file exodusII_io_helper.h.

References num_nodes_per_set.

00205 { return num_nodes_per_set[i]; }

int libMesh::ExodusII_IO_Helper::get_num_side_sets (  )  const [inline]
Returns:
the total number of sidesets in the ExodusII mesh. Each sideset contains only one type of element.

Definition at line 167 of file exodusII_io_helper.h.

References num_side_sets.

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

00167 { return num_side_sets; }

int libMesh::ExodusII_IO_Helper::get_num_sides_per_set ( int  i  )  const [inline]

For a single sideset, returns the total number of elements in the sideset.

Definition at line 198 of file exodusII_io_helper.h.

References num_sides_per_set.

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

00198 { return num_sides_per_set[i]; }

const std::vector<int>& libMesh::ExodusII_IO_Helper::get_side_list (  )  const [inline]
Returns:
the $ i^{th} $ entry in the side list. This is effectively the "side" (face in 3D or edge in 2D) number which lies on the boundary.
a constant reference to the side_list.

Definition at line 234 of file exodusII_io_helper.h.

References side_list.

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

00234 { return side_list; }

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

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

Definition at line 397 of file exodusII_io_helper.C.

References ss_ids.

Referenced by libMesh::ExodusII_IO::read().

00398 {
00399   libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
00400 
00401   return ss_ids[index];
00402 }

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

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 406 of file exodusII_io_helper.C.

References id_to_ss_names, and ss_ids.

Referenced by libMesh::ExodusII_IO::read().

00407 {
00408   libmesh_assert_less (static_cast<unsigned int>(index), ss_ids.size());
00409 
00410   return id_to_ss_names[ss_ids[index]];
00411 }

const std::vector< Real > & libMesh::ExodusII_IO_Helper::get_time_steps (  ) 

Definition at line 679 of file exodusII_io_helper.C.

References ex_get_all_times(), ex_id, num_time_steps, and time_steps.

00680 {
00681   time_steps.resize(num_time_steps);
00682   exII::ex_get_all_times(ex_id, time_steps.empty() ? NULL : &time_steps[0]);
00683   return time_steps;
00684 }

Real libMesh::ExodusII_IO_Helper::get_x ( int  i  )  const [inline]
Returns:
the $ i^{th} $ node's x-coordinate.

Definition at line 272 of file exodusII_io_helper.h.

References x.

Referenced by libMesh::ExodusII_IO::read().

00272 { return x[i]; }

Real libMesh::ExodusII_IO_Helper::get_y ( int  i  )  const [inline]
Returns:
the $ i^{th} $ node's y-coordinate.

Definition at line 278 of file exodusII_io_helper.h.

References y.

Referenced by libMesh::ExodusII_IO::read().

00278 { return y[i]; }

Real libMesh::ExodusII_IO_Helper::get_z ( int  i  )  const [inline]
Returns:
the $ i^{th} $ node's z-coordinate.

Definition at line 284 of file exodusII_io_helper.h.

References z.

Referenced by libMesh::ExodusII_IO::read().

00284 { return z[i]; }

void libMesh::ExodusII_IO_Helper::initialize ( std::string  title,
const MeshBase mesh 
) [virtual]

Initializes the Exodus file

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 853 of file exodusII_io_helper.C.

References _run_only_on_proc0, _use_mesh_dimension_instead_of_spatial_dimension, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::MeshBase::boundary_info, check_err(), end, libMesh::err, ex_err, ex_id, ex_put_init(), libMesh::DofObject::id(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_active_elem(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), num_dim, num_elem, num_elem_blk, num_node_sets, num_nodes, num_side_sets, libMesh::processor_id(), libMesh::MeshBase::spatial_dimension(), and libMesh::Elem::subdomain_id().

00854 {
00855   // n_active_elem() is a parallel_only function
00856   unsigned int n_active_elem = mesh.n_active_elem();
00857 
00858   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
00859     return;
00860 
00861   if (_use_mesh_dimension_instead_of_spatial_dimension)
00862     num_dim = mesh.mesh_dimension();
00863   else
00864     num_dim = mesh.spatial_dimension();
00865 
00866   num_nodes = mesh.n_nodes();
00867   num_elem = mesh.n_elem();
00868 
00869   std::vector<boundary_id_type> unique_side_boundaries;
00870   std::vector<boundary_id_type> unique_node_boundaries;
00871 
00872   mesh.boundary_info->build_side_boundary_ids(unique_side_boundaries);
00873   mesh.boundary_info->build_node_boundary_ids(unique_node_boundaries);
00874 
00875   num_side_sets = unique_side_boundaries.size();
00876   num_node_sets = unique_node_boundaries.size();
00877 
00878   //loop through element and map between block and element vector
00879   std::map<subdomain_id_type, std::vector<unsigned int>  > subdomain_map;
00880 
00881   MeshBase::const_element_iterator it = mesh.active_elements_begin();
00882   const MeshBase::const_element_iterator end = mesh.active_elements_end();
00883   for (; it != end; ++it)
00884   {
00885     const Elem * elem = *it;
00886     subdomain_id_type cur_subdomain = elem->subdomain_id();
00887 
00888     subdomain_map[cur_subdomain].push_back(elem->id());
00889   }
00890   num_elem_blk = subdomain_map.size();
00891 
00892   if (str_title.size() > MAX_LINE_LENGTH)
00893     {
00894       libMesh::err << "Warning, Exodus files cannot have titles longer than "
00895                    << MAX_LINE_LENGTH
00896                    << " characters.  Your title will be truncated."
00897                    << std::endl;
00898       str_title.resize(MAX_LINE_LENGTH);
00899     }
00900 
00901   ex_err = exII::ex_put_init(ex_id,
00902                              str_title.c_str(),
00903                              num_dim,
00904                              num_nodes,
00905                              n_active_elem,
00906                              num_elem_blk,
00907                              num_node_sets,
00908                              num_side_sets);
00909 
00910   check_err(ex_err, "Error initializing new Exodus file.");
00911 }

void libMesh::ExodusII_IO_Helper::initialize_discontinuous ( std::string  title,
const MeshBase mesh 
)

Initializes the Exodus file

Definition at line 792 of file exodusII_io_helper.C.

References _run_only_on_proc0, _use_mesh_dimension_instead_of_spatial_dimension, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::MeshBase::boundary_info, check_err(), end, libMesh::err, ex_err, ex_id, ex_put_init(), libMesh::DofObject::id(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem(), num_dim, num_elem, num_elem_blk, num_node_sets, num_nodes, num_side_sets, libMesh::processor_id(), libMesh::MeshBase::spatial_dimension(), and libMesh::Elem::subdomain_id().

Referenced by libMesh::ExodusII_IO::write_nodal_data_discontinuous().

00793 {
00794   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
00795     return;
00796 
00797   if (_use_mesh_dimension_instead_of_spatial_dimension)
00798     num_dim = mesh.mesh_dimension();
00799   else
00800     num_dim = mesh.spatial_dimension();
00801 
00802   MeshBase::const_element_iterator       it  = mesh.active_elements_begin();
00803   const MeshBase::const_element_iterator end = mesh.active_elements_end();
00804   for ( ; it != end; ++it)
00805         num_nodes += (*it)->n_nodes();
00806 
00807   num_elem = mesh.n_elem();
00808 
00809   std::vector<boundary_id_type> unique_side_boundaries;
00810   std::vector<boundary_id_type> unique_node_boundaries;
00811 
00812   mesh.boundary_info->build_side_boundary_ids(unique_side_boundaries);
00813   mesh.boundary_info->build_node_boundary_ids(unique_node_boundaries);
00814 
00815   num_side_sets = unique_side_boundaries.size();
00816   num_node_sets = unique_node_boundaries.size();
00817 
00818   //loop through element and map between block and element vector
00819   std::map<subdomain_id_type, std::vector<unsigned int>  > subdomain_map;
00820 
00821   for(it = mesh.active_elements_begin(); it != end; ++it)
00822     {
00823       const Elem * elem = *it;
00824       subdomain_id_type cur_subdomain = elem->subdomain_id();
00825 
00826       subdomain_map[cur_subdomain].push_back(elem->id());
00827     }
00828   num_elem_blk = subdomain_map.size();
00829 
00830   if (str_title.size() > MAX_LINE_LENGTH)
00831     {
00832       libMesh::err << "Warning, Exodus files cannot have titles longer than "
00833                    << MAX_LINE_LENGTH
00834                    << " characters.  Your title will be truncated."
00835                    << std::endl;
00836       str_title.resize(MAX_LINE_LENGTH);
00837     }
00838 
00839   ex_err = exII::ex_put_init(ex_id,
00840                              str_title.c_str(),
00841                              num_dim,
00842                              num_nodes,
00843                              num_elem,
00844                              num_elem_blk,
00845                              num_node_sets,
00846                              num_side_sets);
00847 
00848   check_err(ex_err, "Error initializing new Exodus file.");
00849 }

void libMesh::ExodusII_IO_Helper::initialize_element_variables ( const MeshBase mesh,
std::vector< std::string >  names 
)

Sets up the nodal variables

Definition at line 1304 of file exodusII_io_helper.C.

References _elem_vars_initialized, _run_only_on_proc0, _verbose, check_err(), ex_err, ex_id, ex_put_elem_var_tab(), ex_put_var_names(), ex_put_var_param(), num_elem_blk, num_elem_vars, libMesh::out, libMesh::processor_id(), strings, and vvc.

01306 {
01307   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01308     return;
01309 
01310   num_elem_vars = names.size();
01311 
01312   if ( num_elem_vars == 0 )
01313     return;
01314 
01315   if (_elem_vars_initialized)
01316     return;
01317   _elem_vars_initialized = true;
01318 
01319   ex_err = exII::ex_put_var_param(ex_id, "e", num_elem_vars);
01320   check_err(ex_err, "Error setting number of element vars.");
01321 
01322   // Form the element variable truth table and send to Exodus.
01323   // This tells which variables are written to which blocks,
01324   // and can dramatically speed up writing element variables
01325 
01326   // We really should initialize all entries in the truth table to 0
01327   // and then loop over all subdomains, setting their entries to 1
01328   // if a given variable exists on that subdomain.  However,
01329   // we don't have that information, and the element variables
01330   // passed to us are padded with zeroes for the blocks where
01331   // they aren't defined.  To be consistent with that, fill
01332   // the truth table with ones.
01333 
01334   std::vector<int> truth_tab(num_elem_blk*num_elem_vars,1);
01335   ex_err = exII::ex_put_elem_var_tab(ex_id, num_elem_blk, num_elem_vars, &truth_tab[0]);
01336   check_err(ex_err, "Error writing element truth table.");
01337 
01338   // Use the vvc and strings objects to emulate the behavior of
01339   // a char** object.
01340   vvc.resize(num_elem_vars);
01341   strings.resize(num_elem_vars);
01342 
01343   // For each string in names, allocate enough space in vvc and copy from
01344   // the C++ string into vvc for passing to the C interface.
01345   for (int i=0; i<num_elem_vars; ++i)
01346     {
01347       // Note: the one additional character is to hold the trailing '\0'
01348       vvc[i].resize(names[i].size() + 1);
01349       //std::strcpy(&(vvc[i][0]), names[i].c_str());
01350       vvc[i][ names[i].copy(&vvc[i][0], vvc[i].size()-1) ] = '\0';
01351     }
01352 
01353   for (int i=0; i<num_elem_vars; ++i)
01354     strings[i] = &(vvc[i][0]); // set pointer into vvc only *after* all resizing is complete
01355 
01356   if (_verbose)
01357     {
01358       libMesh::out << "Writing variable name(s) to file: " << std::endl;
01359       for (int i=0; i < num_elem_vars; ++i)
01360         libMesh::out << "strings[" << i << "]=" << strings[i] << std::endl;
01361     }
01362 
01363   ex_err = exII::ex_put_var_names(ex_id,
01364                                   "e",
01365                                   num_elem_vars,
01366                                   &strings[0]//var_names
01367                                   );
01368 
01369   check_err(ex_err, "Error setting element variable names.");
01370 }

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

Sets up the global variables

Definition at line 1419 of file exodusII_io_helper.C.

References _global_vars_initialized, _run_only_on_proc0, _verbose, check_err(), ex_err, ex_id, ex_put_var_names(), ex_put_var_param(), num_globals, libMesh::out, libMesh::processor_id(), strings, and vvc.

Referenced by libMesh::Nemesis_IO::write_global_data().

01420 {
01421   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01422     return;
01423 
01424   if (_global_vars_initialized)
01425   {
01426     return;
01427   }
01428   _global_vars_initialized = true;
01429 
01430   num_globals = names.size();
01431 
01432   ex_err = exII::ex_put_var_param(ex_id, "g", num_globals);
01433   check_err(ex_err, "Error setting number of global vars.");
01434 
01435   // Use the vvc and strings objects to emulate the behavior of
01436   // a char** object.
01437   vvc.resize(num_globals);
01438   strings.resize(num_globals);
01439 
01440   // For each string in names, allocate enough space in vvc and copy from
01441   // the C++ string into vvc for passing to the C interface.
01442   for (int i=0; i<num_globals; i++)
01443     {
01444       vvc[i].resize(names[i].size()+1);
01445       // std::strcpy(&(vvc[i][0]), names[i].c_str());
01446       vvc[i][ names[i].copy(&vvc[i][0], vvc[i].size()-1) ] = '\0';
01447     }
01448 
01449   for (int i=0; i<num_globals; i++)
01450     strings[i] = &(vvc[i][0]); // set pointer into vvc only *after* all resizing is complete
01451 
01452   if (_verbose)
01453     {
01454       libMesh::out << "Writing variable name(s) to file: " << std::endl;
01455       for (int i=0; i < num_globals; ++i)
01456         libMesh::out << "strings[" << i << "]=" << strings[i] << std::endl;
01457     }
01458 
01459   ex_err = exII::ex_put_var_names(ex_id,
01460                                   "g",
01461                                   num_globals,
01462                                   &strings[0]
01463                                   );
01464 
01465   check_err(ex_err, "Error setting global variable names.");
01466 }

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

Sets up the nodal variables

Definition at line 1374 of file exodusII_io_helper.C.

References _run_only_on_proc0, _verbose, check_err(), ex_err, ex_id, ex_put_var_names(), ex_put_var_param(), num_nodal_vars, libMesh::out, libMesh::processor_id(), strings, and vvc.

Referenced by libMesh::Nemesis_IO::write_nodal_data(), and libMesh::ExodusII_IO::write_nodal_data_discontinuous().

01375 {
01376   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01377     return;
01378 
01379   num_nodal_vars = names.size();
01380 
01381   ex_err = exII::ex_put_var_param(ex_id, "n", num_nodal_vars);
01382   check_err(ex_err, "Error setting number of nodal vars.");
01383 
01384   // Use the vvc and strings objects to emulate the behavior of
01385   // a char** object.
01386   vvc.resize(num_nodal_vars);
01387   strings.resize(num_nodal_vars);
01388 
01389   // For each string in names, allocate enough space in vvc and copy from
01390   // the C++ string into vvc for passing to the C interface.
01391   for (int i=0; i<num_nodal_vars; i++)
01392     {
01393       vvc[i].resize(names[i].size()+1);
01394       //std::strcpy(&(vvc[i][0]), names[i].c_str());
01395       vvc[i][ names[i].copy(&vvc[i][0], vvc[i].size()-1) ] = '\0';
01396     }
01397 
01398   for (int i=0; i<num_nodal_vars; i++)
01399     strings[i] = &(vvc[i][0]); // set pointer into vvc only *after* all resizing is complete
01400 
01401   if (_verbose)
01402     {
01403       libMesh::out << "Writing variable name(s) to file: " << std::endl;
01404       for (int i=0;i<num_nodal_vars;i++)
01405         libMesh::out << "strings[" << i << "]=" << strings[i] << std::endl;
01406     }
01407 
01408   ex_err = exII::ex_put_var_names(ex_id,
01409                                   "n",
01410                                   num_nodal_vars,
01411                                   strings.empty() ? NULL : &strings[0]//var_names
01412                                   );
01413 
01414   check_err(ex_err, "Error setting nodal variable names.");
01415 }

int libMesh::ExodusII_IO_Helper::inquire ( int  req_info,
std::string  error_msg = "" 
)

Generic inquiry, returns the value

Definition at line 664 of file exodusII_io_helper.C.

References check_err(), ex_err, ex_id, ex_inquire(), ret_char, ret_float, and ret_int.

Referenced by read_header().

00665 {
00666   ex_err = exII::ex_inquire(ex_id,
00667                             req_info_in,
00668                             &ret_int,
00669                             &ret_float,
00670                             &ret_char);
00671 
00672   check_err(ex_err, error_msg);
00673 
00674   return ret_int;
00675 }

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

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 248 of file exodusII_io_helper.C.

References _verbose, and libMesh::out.

00249 {
00250   if (_verbose) libMesh::out << msg << i << "." << std::endl;
00251 }

void libMesh::ExodusII_IO_Helper::message ( const std::string  msg  ) 

Prints the message defined in msg. Can be turned off if verbosity is set to 0.

Definition at line 241 of file exodusII_io_helper.C.

References _verbose, and libMesh::out.

Referenced by close(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_header(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_sideset(), and read_sideset_info().

00242 {
00243   if (_verbose) libMesh::out << msg << std::endl;
00244 }

void libMesh::ExodusII_IO_Helper::open ( const char *  filename  ) 

Opens an ExodusII mesh file named filename for reading.

Definition at line 255 of file exodusII_io_helper.C.

References _verbose, check_err(), comp_ws, ex_id, ex_version, io_ws, and libMesh::out.

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

00256 {
00257   ex_id = exII::ex_open(filename,
00258                         EX_READ,
00259                         &comp_ws,
00260                         &io_ws,
00261                         &ex_version);
00262 
00263   std::string err_msg = std::string("Error opening ExodusII mesh file: ") + std::string(filename);
00264   check_err(ex_id, err_msg);
00265   if (_verbose) libMesh::out << "File opened successfully." << std::endl;
00266 }

void libMesh::ExodusII_IO_Helper::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

Definition at line 293 of file exodusII_io_helper.C.

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

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

00294 {
00295   if (_verbose)
00296     libMesh::out << "Title: \t" << &title[0] << std::endl
00297                   << "Mesh Dimension: \t"   << num_dim << std::endl
00298                   << "Number of Nodes: \t" << num_nodes << std::endl
00299                   << "Number of elements: \t" << num_elem << std::endl
00300                   << "Number of elt blocks: \t" << num_elem_blk << std::endl
00301                   << "Number of node sets: \t" << num_node_sets << std::endl
00302                   << "Number of side sets: \t" << num_side_sets << std::endl;
00303 }

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

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

Definition at line 344 of file exodusII_io_helper.C.

References num_nodes, x, y, and z.

00345 {
00346   for (int i=0; i<num_nodes; i++)
00347     out_stream << "(" << x[i] << ", " << y[i] << ", " << z[i] << ")" << std::endl;
00348 }

void libMesh::ExodusII_IO_Helper::print_nodeset_info (  ) 

Prints information about all the nodesets.

void libMesh::ExodusII_IO_Helper::print_sideset_info (  ) 

Prints information about all the sidesets.

Definition at line 639 of file exodusII_io_helper.C.

References elem_list, num_elem_all_sidesets, libMesh::out, and side_list.

00640 {
00641   for (int i=0; i<num_elem_all_sidesets; i++)
00642     {
00643       libMesh::out << elem_list[i] << " " << side_list[i] << std::endl;
00644     }
00645 }

void libMesh::ExodusII_IO_Helper::read_block_info (  ) 

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

Definition at line 352 of file exodusII_io_helper.C.

References block_ids, check_err(), EX_ELEM_BLOCK, ex_err, ex_get_elem_blk_ids(), ex_get_name(), ex_id, id_to_block_names, message(), and num_elem_blk.

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

00353 {
00354   block_ids.resize(num_elem_blk);
00355   // Get all element block IDs.
00356   ex_err = exII::ex_get_elem_blk_ids(ex_id,
00357                                      block_ids.empty() ? NULL : &block_ids[0]);
00358   // Usually, there is only one
00359   // block since there is only
00360   // one type of element.
00361   // However, there could be more.
00362 
00363   check_err(ex_err, "Error getting block IDs.");
00364   message("All block IDs retrieved successfully.");
00365 
00366   char name_buffer[MAX_STR_LENGTH+1];
00367   for (int i=0; i<num_elem_blk; ++i)
00368   {
00369     ex_err = exII::ex_get_name(ex_id, exII::EX_ELEM_BLOCK,
00370                                block_ids[i], name_buffer);
00371     check_err(ex_err, "Error getting block name.");
00372     id_to_block_names[block_ids[i]] = name_buffer;
00373   }
00374   message("All block mames retrieved successfully.");
00375 }

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

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

Definition at line 434 of file exodusII_io_helper.C.

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

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

00435 {
00436   libmesh_assert_less (static_cast<unsigned int>(block), block_ids.size());
00437 
00438   ex_err = exII::ex_get_elem_block(ex_id,
00439                                    block_ids[block],
00440                                    &elem_type[0],
00441                                    &num_elem_this_blk,
00442                                    &num_nodes_per_elem,
00443                                    &num_attr);
00444   if (_verbose)
00445     libMesh::out << "Reading a block of " << num_elem_this_blk
00446               << " " << &elem_type[0] << "(s)"
00447               << " having " << num_nodes_per_elem
00448               << " nodes per element." << std::endl;
00449 
00450   check_err(ex_err, "Error getting block info.");
00451   message("Info retrieved successfully for block: ", block);
00452 
00453 
00454 
00455   // Read in the connectivity of the elements of this block,
00456   // watching out for the case where we actually have no
00457   // elements in this block (possible with parallel files)
00458   connect.resize(num_nodes_per_elem*num_elem_this_blk);
00459 
00460   if (!connect.empty())
00461     {
00462       ex_err = exII::ex_get_elem_conn(ex_id,
00463                                       block_ids[block],
00464                                       &connect[0]);
00465 
00466       check_err(ex_err, "Error reading block connectivity.");
00467       message("Connectivity retrieved successfully for block: ", block);
00468     }
00469 }

void libMesh::ExodusII_IO_Helper::read_elem_num_map (  ) 

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 474 of file exodusII_io_helper.C.

References _verbose, check_err(), elem_num_map, ex_err, ex_get_elem_num_map(), ex_id, message(), std::min(), num_elem, libMesh::out, and libMesh::processor_id().

Referenced by libMesh::Nemesis_IO::read().

00475 {
00476   elem_num_map.resize(num_elem);
00477 
00478   ex_err = exII::ex_get_elem_num_map (ex_id,
00479                                       elem_num_map.empty() ? NULL : &elem_num_map[0]);
00480 
00481   check_err(ex_err, "Error retrieving element number map.");
00482   message("Element numbering map retrieved successfully.");
00483 
00484 
00485   if (_verbose)
00486     {
00487       libMesh::out << "[" << libMesh::processor_id() << "] elem_num_map[i] = ";
00488       for (unsigned int i=0; i< static_cast<unsigned int>(std::min(10, num_elem-1)); ++i)
00489         libMesh::out << elem_num_map[i] << ", ";
00490       libMesh::out << "... " << elem_num_map.back() << std::endl;
00491     }
00492 }

void libMesh::ExodusII_IO_Helper::read_header (  ) 

Reads an ExodusII mesh file header.

Definition at line 270 of file exodusII_io_helper.C.

References check_err(), ex_err, ex_get_init(), ex_get_var_param(), ex_id, EX_INQ_TIME, inquire(), message(), num_dim, num_elem, num_elem_blk, num_nodal_vars, num_node_sets, num_nodes, num_side_sets, num_time_steps, and title.

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

00271 {
00272   ex_err = exII::ex_get_init(ex_id,
00273                              title.empty() ? NULL : &title[0],
00274                              &num_dim,
00275                              &num_nodes,
00276                              &num_elem,
00277                              &num_elem_blk,
00278                              &num_node_sets,
00279                              &num_side_sets);
00280 
00281   check_err(ex_err, "Error retrieving header info.");
00282 
00283   num_time_steps = inquire(exII::EX_INQ_TIME, "Error retrieving time steps");
00284 
00285   exII::ex_get_var_param(ex_id, "n", &num_nodal_vars);
00286 
00287   message("Exodus header info retrieved successfully.");
00288 }

void libMesh::ExodusII_IO_Helper::read_node_num_map (  ) 

Reads the optional node_num_map from the ExodusII mesh file.

Definition at line 324 of file exodusII_io_helper.C.

References _verbose, check_err(), ex_err, ex_get_node_num_map(), ex_id, message(), std::min(), node_num_map, num_nodes, libMesh::out, and libMesh::processor_id().

Referenced by libMesh::Nemesis_IO::read().

00325 {
00326   node_num_map.resize(num_nodes);
00327 
00328   ex_err = exII::ex_get_node_num_map (ex_id,
00329                                       node_num_map.empty() ? NULL : &node_num_map[0]);
00330 
00331   check_err(ex_err, "Error retrieving nodal number map.");
00332   message("Nodal numbering map retrieved successfully.");
00333 
00334   if (_verbose)
00335     {
00336       libMesh::out << "[" << libMesh::processor_id() << "] node_num_map[i] = ";
00337       for (unsigned int i=0; i< static_cast<unsigned int>(std::min(10, num_nodes-1)); ++i)
00338         libMesh::out << node_num_map[i] << ", ";
00339       libMesh::out << "... " << node_num_map.back() << std::endl;
00340     }
00341 }

void libMesh::ExodusII_IO_Helper::read_nodes (  ) 

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

Definition at line 307 of file exodusII_io_helper.C.

References check_err(), ex_err, ex_get_coord(), ex_id, message(), num_nodes, x, y, and z.

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

00308 {
00309   x.resize(num_nodes);
00310   y.resize(num_nodes);
00311   z.resize(num_nodes);
00312 
00313   ex_err = exII::ex_get_coord(ex_id,
00314                               static_cast<void*>(&x[0]),
00315                               static_cast<void*>(&y[0]),
00316                               static_cast<void*>(&z[0]));
00317 
00318   check_err(ex_err, "Error retrieving nodal data.");
00319   message("Nodal data retrieved successfully.");
00320 }

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

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

Definition at line 609 of file exodusII_io_helper.C.

References check_err(), ex_err, ex_get_node_set(), ex_get_node_set_param(), ex_id, message(), node_list, nodeset_ids, num_node_df_per_set, and num_nodes_per_set.

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

00610 {
00611   libmesh_assert_less (static_cast<unsigned int>(id), nodeset_ids.size());
00612   libmesh_assert_less (static_cast<unsigned int>(id), num_nodes_per_set.size());
00613   libmesh_assert_less (static_cast<unsigned int>(id), num_node_df_per_set.size());
00614 
00615   ex_err = exII::ex_get_node_set_param(ex_id,
00616                                        nodeset_ids[id],
00617                                        &num_nodes_per_set[id],
00618                                        &num_node_df_per_set[id]);
00619   check_err(ex_err, "Error retrieving nodeset parameters.");
00620   message("Parameters retrieved successfully for nodeset: ", id);
00621 
00622   node_list.resize(num_nodes_per_set[id]);
00623 
00624   // Don't call ex_get_node_set unless there are actually nodes there to get.
00625   // Exodus prints an annoying warning message in DEBUG mode otherwise...
00626   if (num_nodes_per_set[id] > 0)
00627     {
00628       ex_err = exII::ex_get_node_set(ex_id,
00629                                      nodeset_ids[id],
00630                                      &node_list[0]);
00631 
00632       check_err(ex_err, "Error retrieving nodeset data.");
00633       message("Data retrieved successfully for nodeset: ", id);
00634     }
00635 }

void libMesh::ExodusII_IO_Helper::read_nodeset_info (  ) 

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

Definition at line 538 of file exodusII_io_helper.C.

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

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

00539 {
00540   nodeset_ids.resize(num_node_sets);
00541   if (num_node_sets > 0)
00542     {
00543       ex_err = exII::ex_get_node_set_ids(ex_id,
00544                                          &nodeset_ids[0]);
00545       check_err(ex_err, "Error retrieving nodeset information.");
00546       message("All nodeset information retrieved successfully.");
00547 
00548       // Resize appropriate data structures -- only do this once outnode the loop
00549       num_nodes_per_set.resize(num_node_sets);
00550       num_node_df_per_set.resize(num_node_sets);
00551     }
00552 
00553   char name_buffer[MAX_STR_LENGTH+1];
00554   for (int i=0; i<num_node_sets; ++i)
00555   {
00556     ex_err = exII::ex_get_name(ex_id, exII::EX_NODE_SET,
00557                                nodeset_ids[i], name_buffer);
00558     check_err(ex_err, "Error getting node set name.");
00559     id_to_ns_names[nodeset_ids[i]] = name_buffer;
00560   }
00561   message("All node set mames retrieved successfully.");
00562 }

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

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

Definition at line 566 of file exodusII_io_helper.C.

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

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

00567 {
00568   libmesh_assert_less (static_cast<unsigned int>(id), ss_ids.size());
00569   libmesh_assert_less (static_cast<unsigned int>(id), num_sides_per_set.size());
00570   libmesh_assert_less (static_cast<unsigned int>(id), num_df_per_set.size());
00571   libmesh_assert_less_equal (static_cast<unsigned int>(offset), elem_list.size());
00572   libmesh_assert_less_equal (static_cast<unsigned int>(offset), side_list.size());
00573 
00574   ex_err = exII::ex_get_side_set_param(ex_id,
00575                                        ss_ids[id],
00576                                        &num_sides_per_set[id],
00577                                        &num_df_per_set[id]);
00578   check_err(ex_err, "Error retrieving sideset parameters.");
00579   message("Parameters retrieved successfully for sideset: ", id);
00580 
00581 
00582   // It's OK for offset==elem_list.size() as long as num_sides_per_set[id]==0
00583   // because in that case we don't actually read anything...
00584 #ifdef DEBUG
00585   if (static_cast<unsigned int>(offset) == elem_list.size() ||
00586       static_cast<unsigned int>(offset) == side_list.size() )
00587     libmesh_assert_equal_to (num_sides_per_set[id], 0);
00588 #endif
00589 
00590 
00591   // Don't call ex_get_side_set unless there are actually sides there to get.
00592   // Exodus prints an annoying warning in DEBUG mode otherwise...
00593   if (num_sides_per_set[id] > 0)
00594     {
00595       ex_err = exII::ex_get_side_set(ex_id,
00596                                      ss_ids[id],
00597                                      &elem_list[offset],
00598                                      &side_list[offset]);
00599       check_err(ex_err, "Error retrieving sideset data.");
00600       message("Data retrieved successfully for sideset: ", id);
00601 
00602       for (int i=0; i<num_sides_per_set[id]; i++)
00603         id_list[i+offset] = ss_ids[id];
00604     }
00605 }

void libMesh::ExodusII_IO_Helper::read_sideset_info (  ) 

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

Definition at line 496 of file exodusII_io_helper.C.

References check_err(), elem_list, ex_err, ex_get_name(), ex_get_side_set_ids(), ex_id, EX_INQ_SS_ELEM_LEN, ex_inquire(), EX_SIDE_SET, id_list, id_to_ss_names, message(), num_df_per_set, num_elem_all_sidesets, num_side_sets, num_sides_per_set, req_info, ret_char, ret_float, ret_int, side_list, and ss_ids.

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

00497 {
00498   ss_ids.resize(num_side_sets);
00499   if (num_side_sets > 0)
00500     {
00501       ex_err = exII::ex_get_side_set_ids(ex_id,
00502                                          &ss_ids[0]);
00503       check_err(ex_err, "Error retrieving sideset information.");
00504       message("All sideset information retrieved successfully.");
00505 
00506       // Resize appropriate data structures -- only do this once outside the loop
00507       num_sides_per_set.resize(num_side_sets);
00508       num_df_per_set.resize(num_side_sets);
00509 
00510       // Inquire about the length of the
00511       // concatenated side sets element list
00512       req_info = exII::EX_INQ_SS_ELEM_LEN;
00513       ex_err = exII::ex_inquire(ex_id,
00514                                 req_info,
00515                                 &ret_int,
00516                                 &ret_float,
00517                                 &ret_char);
00518       check_err(ex_err, "Error inquiring about side set element list length.");
00519 
00520       //libMesh::out << "Value returned by ex_inquire was: " << ret_int << std::endl;
00521       num_elem_all_sidesets = ret_int;
00522       elem_list.resize (num_elem_all_sidesets);
00523       side_list.resize (num_elem_all_sidesets);
00524       id_list.resize   (num_elem_all_sidesets);
00525     }
00526 
00527   char name_buffer[MAX_STR_LENGTH+1];
00528   for (int i=0; i<num_side_sets; ++i)
00529   {
00530     ex_err = exII::ex_get_name(ex_id, exII::EX_SIDE_SET,
00531                                ss_ids[i], name_buffer);
00532     check_err(ex_err, "Error getting side set name.");
00533     id_to_ss_names[ss_ids[i]] = name_buffer;
00534   }
00535   message("All side set mames retrieved successfully.");
00536 }

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

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

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

Definition at line 1596 of file exodusII_io_helper.C.

References _use_mesh_dimension_instead_of_spatial_dimension.

Referenced by libMesh::ExodusII_IO::use_mesh_dimension_instead_of_spatial_dimension().

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

Get/set flag telling whether message printing is on or off.

Definition at line 223 of file exodusII_io_helper.C.

References _verbose.

Referenced by libMesh::Nemesis_IO::verbose(), and libMesh::ExodusII_IO::verbose().

00224 {
00225   _verbose = set_verbosity;
00226 }

void libMesh::ExodusII_IO_Helper::write_element_values ( const MeshBase mesh,
const std::vector< Number > &  values,
int  timestep 
)

Writes the vector of values to the element variables.

Definition at line 1484 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::Elem::active(), libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), check_err(), data, end, ex_err, ex_id, ex_put_elem_var(), ex_update(), get_block_id(), libMesh::DofObject::id(), num_elem, libMesh::processor_id(), and libMesh::Elem::subdomain_id().

01485 {
01486   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01487     return;
01488 
01489   // Loop over the element blocks and write the data one block at a time
01490   std::map<unsigned int, std::vector<unsigned int>  > subdomain_map;
01491 
01492   const unsigned int num_vars = values.size() / num_elem;
01493 
01494   MeshBase::const_element_iterator mesh_it = mesh.active_elements_begin();
01495   const MeshBase::const_element_iterator end = mesh.active_elements_end();
01496   //loop through element and map between block and element vector
01497   for( ; mesh_it != end; ++mesh_it)
01498     {
01499       const Elem * elem = *mesh_it;
01500 
01501       //Only write out the active elements
01502       if(elem->active())
01503       {
01504         unsigned int cur_subdomain = elem->subdomain_id();
01505 
01506         subdomain_map[cur_subdomain].push_back(elem->id());
01507       }
01508     }
01509 
01510   for (unsigned int l=0; l < num_vars; ++l)
01511   {
01512     // The size of the subdomain map is the number of blocks.
01513     std::map<unsigned int, std::vector<unsigned int>  >::iterator it( subdomain_map.begin() );
01514 
01515     for(unsigned int j=0; it != subdomain_map.end(); ++it, ++j)
01516     {
01517       const std::vector<unsigned int> & elem_nums = (*it).second;
01518       const unsigned int num_elems_this_block = elem_nums.size();
01519       std::vector<Number> data( num_elems_this_block );
01520       for (unsigned int k=0; k < num_elems_this_block; ++k)
01521       {
01522         data[k] = values[l*num_elem+elem_nums[k]];
01523       }
01524 
01525       ex_err = exII::ex_put_elem_var(ex_id, timestep, l+1, get_block_id(j), num_elems_this_block, &data[0]);
01526       check_err(ex_err, "Error writing element values.");
01527 
01528     }
01529   }
01530 
01531   ex_err = exII::ex_update(ex_id);
01532   check_err(ex_err, "Error flushing buffers to file.");
01533 }

void libMesh::ExodusII_IO_Helper::write_elements ( const MeshBase mesh  )  [virtual]

Writes the elements contained in "mesh" FIXME: This only works for Mesh's having a single type of element!

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 998 of file exodusII_io_helper.C.

References _run_only_on_proc0, _verbose, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), block_ids, libMesh::Elem::build(), check_err(), connect, libMesh::MeshBase::elem(), elem_id, end, EX_ELEM_BLOCK, ex_err, ex_id, ex_put_elem_block(), ex_put_elem_conn(), ex_put_elem_num_map(), libMesh::ExodusII_IO_Helper::Conversion::exodus_elem_type(), libMesh::ExodusII_IO_Helper::Conversion::get_canonical_type(), libMesh::ExodusII_IO_Helper::Conversion::get_inverse_node_map(), libMesh::DofObject::id(), libmesh_elem_num_to_exodus, libMesh::MeshBase::n_active_elem(), n_nodes, libMesh::Elem::n_nodes(), libMesh::Elem::node(), num_elem_blk, num_nodes_per_elem, libMesh::out, libMesh::processor_id(), libMesh::ExodusII_IO_Helper::NamesData::push_back_entry(), libMesh::Elem::subdomain_id(), libMesh::MeshBase::subdomain_name(), libMesh::Elem::type(), and libMesh::ExodusII_IO_Helper::NamesData::write_to_exodus().

00999 {
01000   // n_active_elem() is a parallel_only function
01001   unsigned int n_active_elem = mesh.n_active_elem();
01002 
01003   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01004     return;
01005 
01006   std::map<unsigned int, std::vector<unsigned int>  > subdomain_map;
01007 
01008   MeshBase::const_element_iterator mesh_it = mesh.active_elements_begin();
01009   const MeshBase::const_element_iterator end = mesh.active_elements_end();
01010   //loop through element and map between block and element vector
01011   for (; mesh_it != end; ++mesh_it)
01012   {
01013     const Elem * elem = *mesh_it;
01014 
01015     unsigned int cur_subdomain = elem->subdomain_id();
01016 
01017     subdomain_map[cur_subdomain].push_back(elem->id());
01018   }
01019 
01020   std::vector<int> elem_num_map_out;
01021 
01022   std::map<unsigned int, std::vector<unsigned int>  >::iterator it;
01023 
01024   // element map vector
01025   num_elem_blk = subdomain_map.size();
01026   block_ids.resize(num_elem_blk);
01027   std::vector<unsigned int> elem_map(n_active_elem);
01028   std::vector<unsigned int>::iterator curr_elem_map_end = elem_map.begin();
01029 
01030   // Note: It appears that there is a bug in exodusII::ex_put_name where
01031   // the index returned from the ex_id_lkup is erronously used.  For now
01032   // the work around is to use the alternative function ex_put_names, but
01033   // this function requires a char** datastructure.
01034   NamesData names_table(num_elem_blk);
01035 
01036   unsigned int counter=0;
01037   for(it = subdomain_map.begin() ; it != subdomain_map.end(); it++)
01038     {
01039       block_ids[counter] = (*it).first;
01040       names_table.push_back_entry(mesh.subdomain_name((*it).first));
01041 
01042       std::vector<unsigned int> & tmp_vec = (*it).second;
01043 
01044       ExodusII_IO_Helper::ElementMaps em;
01045 
01046       //Use the first element in this block to get representative information.
01047       //Note that Exodus assumes all elements in a block are of the same type!
01048       //We are using that same assumption here!
01049       const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(mesh.elem(tmp_vec[0])->type());
01050       num_nodes_per_elem = mesh.elem(tmp_vec[0])->n_nodes();
01051 
01052       ex_err = exII::ex_put_elem_block(ex_id, (*it).first, conv.exodus_elem_type().c_str(), tmp_vec.size(),num_nodes_per_elem,0);
01053 
01054       check_err(ex_err, "Error writing element block.");
01055 
01056       connect.resize(tmp_vec.size()*num_nodes_per_elem);
01057 
01058       for (unsigned int i=0; i<tmp_vec.size(); i++)
01059         {
01060           unsigned int elem_id = tmp_vec[i];
01061           elem_num_map_out.push_back(elem_id);
01062           libmesh_elem_num_to_exodus[elem_id] = elem_num_map_out.size();
01063 
01064           const Elem* elem = mesh.elem(elem_id);
01065 
01066           // Exodus/Nemesis want every block to have the same element type
01067           // libmesh_assert_equal_to (elem->type(), conv.get_canonical_type());
01068 
01069           // But we can get away with writing e.g. HEX8 and INFHEX8 in
01070           // the same block...
01071           libmesh_assert_equal_to (elem->n_nodes(), Elem::build(conv.get_canonical_type(), NULL)->n_nodes());
01072 
01073           for (unsigned int j=0; j < static_cast<unsigned int>(num_nodes_per_elem); j++)
01074             {
01075               const unsigned int connect_index   = (i*num_nodes_per_elem)+j;
01076               const unsigned int elem_node_index = conv.get_inverse_node_map(j); // inverse node map is for writing.
01077               if (_verbose)
01078                 {
01079                   libMesh::out << "Exodus node index: " << j
01080                                 << "=LibMesh node index " << elem_node_index << std::endl;
01081                 }
01082               connect[connect_index] = elem->node(elem_node_index)+1;
01083             }
01084         }
01085     ex_err = exII::ex_put_elem_conn(ex_id, (*it).first, &connect[0]);
01086     check_err(ex_err, "Error writing element connectivities");
01087 
01088     // write out the element number map
01089     curr_elem_map_end = std::transform(tmp_vec.begin(), tmp_vec.end(), curr_elem_map_end,
01090                    std::bind2nd(std::plus<unsigned int>(), 1));  // Add one to each id for exodus!
01091     ex_err = exII::ex_put_elem_num_map(ex_id, (int *)&elem_map[0]);
01092     check_err(ex_err, "Error writing element map");
01093 
01094     counter++;
01095   }
01096 //  ex_err = exII::ex_put_elem_num_map(ex_id, &elem_num_map_out[0]);
01097   check_err(ex_err, "Error writing element connectivities");
01098 
01099   // Write out the block names
01100   ex_err = names_table.write_to_exodus(ex_id, exII::EX_ELEM_BLOCK);
01101   check_err(ex_err, "Error writing element names");
01102 }

void libMesh::ExodusII_IO_Helper::write_elements_discontinuous ( const MeshBase mesh  ) 

Writes the elements contained in "mesh" FIXME: This only works for Mesh's having a single type of element!

Definition at line 1107 of file exodusII_io_helper.C.

References _run_only_on_proc0, _verbose, libMesh::Elem::active(), libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), check_err(), connect, libMesh::MeshBase::elem(), elem_id, end, ex_err, ex_id, ex_put_elem_block(), ex_put_elem_conn(), ex_put_elem_num_map(), ex_update(), libMesh::ExodusII_IO_Helper::Conversion::exodus_elem_type(), libMesh::ExodusII_IO_Helper::Conversion::get_inverse_node_map(), libMesh::DofObject::id(), libmesh_elem_num_to_exodus, libMesh::Elem::n_nodes(), num_nodes_per_elem, libMesh::out, libMesh::processor_id(), libMesh::Elem::subdomain_id(), and libMesh::Elem::type().

Referenced by libMesh::ExodusII_IO::write_nodal_data_discontinuous().

01108 {
01109   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01110     return;
01111 
01112   std::map<unsigned int, std::vector<unsigned int>  > subdomain_map;
01113 
01114   MeshBase::const_element_iterator mesh_it = mesh.active_elements_begin();
01115   const MeshBase::const_element_iterator end = mesh.active_elements_end();
01116   //loop through element and map between block and element vector
01117   for(; mesh_it != end; ++mesh_it)
01118     {
01119       const Elem * elem = *mesh_it;
01120 
01121       //Only write out the active elements
01122       if(elem->active())
01123       {
01124         unsigned int cur_subdomain = elem->subdomain_id();
01125 
01126         subdomain_map[cur_subdomain].push_back(elem->id());
01127       }
01128     }
01129 
01130   std::vector<int> elem_num_map_out;
01131 
01132   std::map<unsigned int, std::vector<unsigned int>  >::iterator it;
01133 
01134   for(it = subdomain_map.begin() ; it != subdomain_map.end(); it++)
01135     {
01136       std::vector<unsigned int> & tmp_vec = (*it).second;
01137 
01138       ExodusII_IO_Helper::ElementMaps em;
01139 
01140       //Use the first element in this block to get representative information.
01141       //Note that Exodus assumes all elements in a block are of the same type!
01142       //We are using that same assumption here!
01143       const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(mesh.elem(tmp_vec[0])->type());
01144       num_nodes_per_elem = mesh.elem(tmp_vec[0])->n_nodes();
01145 
01146       ex_err = exII::ex_put_elem_block(ex_id, (*it).first, conv.exodus_elem_type().c_str(), tmp_vec.size(),num_nodes_per_elem,0);
01147 
01148       check_err(ex_err, "Error writing element block.");
01149 
01150       connect.resize(tmp_vec.size()*num_nodes_per_elem);
01151 
01152       for (unsigned int i=0; i<tmp_vec.size(); i++)
01153         {
01154           unsigned int elem_id = tmp_vec[i];
01155           elem_num_map_out.push_back(elem_id);
01156           libmesh_elem_num_to_exodus[elem_id] = elem_num_map_out.size();
01157 
01158           for (unsigned int j=0; j < static_cast<unsigned int>(num_nodes_per_elem); j++)
01159             {
01160               const unsigned int connect_index   = (i*num_nodes_per_elem)+j;
01161               const unsigned int elem_node_index = conv.get_inverse_node_map(j); // Inverse node map is for writing
01162               if (_verbose)
01163                 {
01164                   libMesh::out << "Exodus node index: " << j
01165                                 << "=LibMesh node index " << elem_node_index << std::endl;
01166                 }
01167               connect[connect_index] = i*num_nodes_per_elem+elem_node_index+1;
01168             }
01169         }
01170     ex_err = exII::ex_put_elem_conn(ex_id, (*it).first, &connect[0]);
01171     check_err(ex_err, "Error writing element connectivities");
01172 
01173     // write out the element number map
01174     std::vector<unsigned int> elem_map(tmp_vec.size());
01175     std::transform(tmp_vec.begin(), tmp_vec.end(), elem_map.begin(),
01176                    std::bind2nd(std::plus<unsigned int>(), 1));  // Add one to each id for exodus!
01177     ex_err = exII::ex_put_elem_num_map(ex_id, (int *)&elem_map[0]);
01178     check_err(ex_err, "Error writing element map");
01179   }
01180 
01181 //  ex_err = exII::ex_put_elem_num_map(ex_id, &elem_num_map_out[0]);
01182   check_err(ex_err, "Error writing element connectivities");
01183 
01184   ex_err = exII::ex_update(ex_id);
01185   check_err(ex_err, "Error flushing buffers to file.");
01186 }

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

Writes the vector of global variables.

Definition at line 1582 of file exodusII_io_helper.C.

References _run_only_on_proc0, check_err(), ex_err, ex_id, ex_put_glob_vars(), ex_update(), num_globals, and libMesh::processor_id().

Referenced by libMesh::Nemesis_IO::write_global_data().

01583 {
01584   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01585     return;
01586 
01587   ex_err = exII::ex_put_glob_vars(ex_id, timestep, num_globals, &values[0]);
01588   check_err(ex_err, "Error writing global values.");
01589 
01590   ex_err = exII::ex_update(ex_id);
01591   check_err(ex_err, "Error flushing buffers to file.");
01592 }

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

Writes the vector of information records.

Definition at line 1551 of file exodusII_io_helper.C.

References _run_only_on_proc0, check_err(), libMesh::err, ex_err, ex_id, ex_put_info(), ex_update(), and libMesh::processor_id().

Referenced by libMesh::Nemesis_IO::write_information_records().

01552 {
01553   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01554     return;
01555 
01556   int num_records = records.size();
01557   std::vector<char*> info(num_records);
01558 
01559   // This is an abuse of the const char* returned by std::string, we trust that Exodus won't
01560   // modify these when it's writing them out...
01561   for (unsigned i=0; i<records.size(); ++i)
01562   {
01563     // Records cannot be longer than MAX_LINE_LENGTH, as defined in exodusII.h
01564     if (records[i].size() > MAX_LINE_LENGTH)
01565       {
01566         libMesh::err << "Error, cannot write records longer than " << MAX_LINE_LENGTH << " characters!" << std::endl;
01567         libmesh_error();
01568       }
01569 
01570     info[i] = const_cast<char*>(records[i].c_str());
01571   }
01572 
01573   ex_err = exII::ex_put_info(ex_id, num_records, &info[0]);
01574   check_err(ex_err, "Error writing global values.");
01575 
01576   ex_err = exII::ex_update(ex_id);
01577   check_err(ex_err, "Error flushing buffers to file.");
01578 }

void libMesh::ExodusII_IO_Helper::write_nodal_coordinates ( const MeshBase mesh  )  [virtual]

Writes the nodal coordinates contained in "mesh"

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 915 of file exodusII_io_helper.C.

References _run_only_on_proc0, check_err(), end, ex_err, ex_id, ex_put_coord(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), num_nodes, libMesh::processor_id(), x, y, and z.

00916 {
00917   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
00918     return;
00919 
00920   x.resize(num_nodes);
00921   y.resize(num_nodes);
00922   z.resize(num_nodes);
00923 
00924   // Use a node iterator instead of looping over i!
00925   {
00926     unsigned i = 0;
00927     MeshBase::const_node_iterator it = mesh.nodes_begin();
00928     const MeshBase::const_node_iterator end = mesh.nodes_end();
00929     for ( ; it != end; ++it, ++i)
00930       {
00931         const Node* node = *it;
00932 
00933         x[i] = (*node)(0);
00934 
00935 #if LIBMESH_DIM > 1
00936         y[i]=(*node)(1);
00937 #else
00938         y[i]=0.;
00939 #endif
00940 #if LIBMESH_DIM > 2
00941         z[i]=(*node)(2);
00942 #else
00943         z[i]=0.;
00944 #endif
00945       }
00946   }
00947 
00948   ex_err = exII::ex_put_coord(ex_id,
00949                               x.empty() ? NULL : &x[0],
00950                               y.empty() ? NULL : &y[0],
00951                               z.empty() ? NULL : &z[0]);
00952 
00953   check_err(ex_err, "Error writing coordinates to Exodus file.");
00954 }

void libMesh::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous ( const MeshBase mesh  ) 

Writes the nodal coordinates contained in "mesh"

Definition at line 958 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), check_err(), end, ex_err, ex_id, ex_put_coord(), num_nodes, libMesh::processor_id(), x, y, and z.

Referenced by libMesh::ExodusII_IO::write_nodal_data_discontinuous().

00959 {
00960   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
00961     return;
00962 
00963   x.resize(num_nodes);
00964   y.resize(num_nodes);
00965   z.resize(num_nodes);
00966 
00967   MeshBase::const_element_iterator       it  = mesh.active_elements_begin();
00968   const MeshBase::const_element_iterator end = mesh.active_elements_end();
00969 
00970   unsigned int i = 0;
00971   for ( ; it != end; ++it)
00972         for (unsigned int n=0; n<(*it)->n_nodes(); n++)
00973     {
00974       x[i]=(*it)->point(n)(0);
00975 #if LIBMESH_DIM > 1
00976       y[i]=(*it)->point(n)(1);
00977 #else
00978       y[i]=0.;
00979 #endif
00980 #if LIBMESH_DIM > 2
00981       z[i]=(*it)->point(n)(2);
00982 #else
00983       z[i]=0.;
00984 #endif
00985       i++;
00986     }
00987 
00988   ex_err = exII::ex_put_coord(ex_id,
00989                               x.empty() ? NULL : &x[0],
00990                               y.empty() ? NULL : &y[0],
00991                               z.empty() ? NULL : &z[0]);
00992 
00993   check_err(ex_err, "Error writing coordinates to Exodus file.");
00994 }

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

Writes the vector of values to a nodal variable.

Definition at line 1537 of file exodusII_io_helper.C.

References _run_only_on_proc0, check_err(), ex_err, ex_id, ex_put_nodal_var(), ex_update(), num_nodes, and libMesh::processor_id().

Referenced by libMesh::ExodusII_IO::write_nodal_data_discontinuous(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

01538 {
01539   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01540     return;
01541 
01542   ex_err = exII::ex_put_nodal_var(ex_id, timestep, var_id, num_nodes, &values[0]);
01543   check_err(ex_err, "Error writing nodal values.");
01544 
01545   ex_err = exII::ex_update(ex_id);
01546   check_err(ex_err, "Error flushing buffers to file.");
01547 }

void libMesh::ExodusII_IO_Helper::write_nodesets ( const MeshBase mesh  )  [virtual]

Writes the nodesets contained in "mesh"

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1258 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::MeshBase::boundary_info, check_err(), ex_err, ex_id, EX_NODE_SET, ex_put_node_set(), ex_put_node_set_param(), and libMesh::processor_id().

Referenced by libMesh::ExodusII_IO::write_nodal_data_discontinuous().

01259 {
01260   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01261     return;
01262 
01263   // FIXME: This is not used, should it be?
01264   ExodusII_IO_Helper::ElementMaps em;
01265 
01266   std::vector< dof_id_type > nl;
01267   std::vector< boundary_id_type > il;
01268 
01269   mesh.boundary_info->build_node_list(nl, il);
01270 
01271   //Maps from nodeset id to the nodes
01272   std::map<boundary_id_type, std::vector<int> > node;
01273 
01274   //Accumulate the vectors to pass into ex_put_node_set
01275   for(unsigned int i = 0; i < nl.size(); i++)
01276     node[il[i]].push_back(nl[i]+1);
01277 
01278   std::vector<boundary_id_type> node_boundary_ids;
01279   mesh.boundary_info->build_node_boundary_ids(node_boundary_ids);
01280   NamesData names_table(node_boundary_ids.size());
01281 
01282   for(unsigned int i = 0; i < node_boundary_ids.size(); i++)
01283   {
01284     int nodeset_id = node_boundary_ids[i];
01285 
01286     int actual_id = nodeset_id;
01287 
01288     names_table.push_back_entry(mesh.boundary_info->nodeset_name(nodeset_id));
01289 
01290     ex_err = exII::ex_put_node_set_param(ex_id, actual_id, node[nodeset_id].size(), 0);
01291     check_err(ex_err, "Error writing nodeset parameters");
01292 
01293     ex_err = exII::ex_put_node_set(ex_id, actual_id, &node[nodeset_id][0]);
01294     check_err(ex_err, "Error writing nodesets");
01295   }
01296 
01297   // Write out the nodeset names
01298   ex_err = names_table.write_to_exodus(ex_id, exII::EX_NODE_SET);
01299   check_err(ex_err, "Error writing nodeset names");
01300 }

void libMesh::ExodusII_IO_Helper::write_sidesets ( const MeshBase mesh  )  [virtual]

Writes the sidesets contained in "mesh"

We need to build up active elements if AMR is enabled and add them to the exodus sidesets instead of the potentially inactive "parent" elements

Reimplemented in libMesh::Nemesis_IO_Helper.

Definition at line 1190 of file exodusII_io_helper.C.

References _run_only_on_proc0, libMesh::Elem::active_family_tree_by_side(), libMesh::ExodusII_IO_Helper::ElementMaps::assign_conversion(), libMesh::MeshBase::boundary_info, check_err(), libMesh::MeshBase::elem(), ex_err, ex_id, ex_put_side_set(), ex_put_side_set_param(), EX_SIDE_SET, libMesh::ExodusII_IO_Helper::Conversion::get_inverse_side_map(), libmesh_elem_num_to_exodus, libMesh::processor_id(), and side.

Referenced by libMesh::ExodusII_IO::write_nodal_data_discontinuous().

01191 {
01192   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01193     return;
01194 
01195   ExodusII_IO_Helper::ElementMaps em;
01196 
01197   std::vector< dof_id_type > el;
01198   std::vector< unsigned short int > sl;
01199   std::vector< boundary_id_type > il;
01200 
01201   mesh.boundary_info->build_side_list(el, sl, il);
01202 
01203   //Maps from sideset id to the element and sides
01204   std::map<int, std::vector<int> > elem;
01205   std::map<int, std::vector<int> > side;
01206 
01207   //Accumulate the vectors to pass into ex_put_side_set
01208   for(unsigned int i = 0; i < el.size(); i++)
01209   {
01210     std::vector<const Elem *> family;
01211 #ifdef LIBMESH_ENABLE_AMR
01212 
01216     mesh.elem(el[i])->active_family_tree_by_side(family, sl[i], false);
01217 #else
01218     family.push_back(mesh.elem(el[i]));
01219 #endif
01220 
01221     for(unsigned int j = 0; j < family.size(); ++j)
01222     {
01223       const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(mesh.elem(family[j]->id())->type());
01224 
01225       // Use the libmesh to exodus datastructure map to get the proper sideset IDs
01226       // The datastructure contains the "collapsed" contiguous ids
01227       elem[il[i]].push_back(libmesh_elem_num_to_exodus[family[j]->id()]);
01228       side[il[i]].push_back(conv.get_inverse_side_map(sl[i]));
01229     }
01230   }
01231 
01232   std::vector<boundary_id_type> side_boundary_ids;
01233   mesh.boundary_info->build_side_boundary_ids(side_boundary_ids);
01234   NamesData names_table(side_boundary_ids.size());
01235 
01236   for(unsigned int i = 0; i < side_boundary_ids.size(); i++)
01237   {
01238     int ss_id = side_boundary_ids[i];
01239 
01240     int actual_id = ss_id;
01241 
01242     names_table.push_back_entry(mesh.boundary_info->sideset_name(ss_id));
01243 
01244     ex_err = exII::ex_put_side_set_param(ex_id, actual_id, elem[ss_id].size(), 0);
01245     check_err(ex_err, "Error writing sideset parameters");
01246 
01247     ex_err = exII::ex_put_side_set(ex_id, actual_id, &elem[ss_id][0], &side[ss_id][0]);
01248     check_err(ex_err, "Error writing sidesets");
01249   }
01250 
01251   // Write out the sideset names
01252   ex_err = names_table.write_to_exodus(ex_id, exII::EX_SIDE_SET);
01253   check_err(ex_err, "Error writing sideset names");
01254 }

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

Writes the time for the timestep

Definition at line 1470 of file exodusII_io_helper.C.

References _run_only_on_proc0, check_err(), ex_err, ex_id, ex_put_time(), ex_update(), and libMesh::processor_id().

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

01471 {
01472   if ((_run_only_on_proc0) && (libMesh::processor_id() != 0))
01473     return;
01474 
01475   ex_err = exII::ex_put_time(ex_id, timestep, &time);
01476   check_err(ex_err, "Error writing timestep.");
01477 
01478   ex_err = exII::ex_update(ex_id);
01479   check_err(ex_err, "Error flushing buffers to file.");
01480 }


Member Data Documentation

If true, use the Mesh's dimension (as determined by the dimension of the elements comprising the mesh) instead of the mesh's spatial dimension, when writing. By default this is false.

Definition at line 711 of file exodusII_io_helper.h.

Referenced by initialize(), initialize_discontinuous(), and use_mesh_dimension_instead_of_spatial_dimension().

Definition at line 701 of file exodusII_io_helper.h.

Referenced by libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::Nemesis_IO_Helper::create(), create(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), get_nodal_var_names(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), initialize_element_variables(), initialize_global_variables(), initialize_nodal_variables(), message(), open(), print_header(), libMesh::Nemesis_IO_Helper::put_node_cmap(), read_elem_in_block(), read_elem_num_map(), read_node_num_map(), verbose(), write_elements(), write_elements_discontinuous(), libMesh::Nemesis_IO_Helper::write_nodesets(), and libMesh::Nemesis_IO_Helper::write_sidesets().

Definition at line 653 of file exodusII_io_helper.h.

Referenced by read_elem_num_map().

Definition at line 625 of file exodusII_io_helper.h.

Referenced by close(), libMesh::Nemesis_IO_Helper::create(), create(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), get_nodal_var_names(), get_nodal_var_values(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), get_time_steps(), initialize(), initialize_discontinuous(), initialize_element_variables(), initialize_global_variables(), initialize_nodal_variables(), inquire(), open(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_eb_info_global(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_init_global(), libMesh::Nemesis_IO_Helper::put_init_info(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_n_coord(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::Nemesis_IO_Helper::put_ns_param_global(), libMesh::Nemesis_IO_Helper::put_ss_param_global(), read_block_info(), read_elem_in_block(), read_elem_num_map(), read_header(), read_node_num_map(), read_nodes(), read_nodeset(), read_nodeset_info(), read_sideset(), read_sideset_info(), libMesh::Nemesis_IO::write(), write_element_values(), libMesh::Nemesis_IO_Helper::write_elements(), write_elements(), write_elements_discontinuous(), libMesh::Nemesis_IO_Helper::write_exodus_initialization_info(), write_global_values(), write_information_records(), libMesh::Nemesis_IO_Helper::write_nodal_coordinates(), write_nodal_coordinates(), write_nodal_coordinates_discontinuous(), write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), write_nodesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), write_sidesets(), write_timestep(), and libMesh::Nemesis_IO_Helper::~Nemesis_IO_Helper().

Definition at line 654 of file exodusII_io_helper.h.

Referenced by open().

Definition at line 651 of file exodusII_io_helper.h.

Referenced by get_id_list(), read_sideset(), and read_sideset_info().

Maps of Ids to named entities

Definition at line 695 of file exodusII_io_helper.h.

Referenced by get_block_name(), and read_block_info().

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

Definition at line 697 of file exodusII_io_helper.h.

Referenced by get_node_set_name(), and read_nodeset_info().

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

Definition at line 696 of file exodusII_io_helper.h.

Referenced by get_side_set_name(), and read_sideset_info().

Map of all node numbers connected to local node numbers to their exodus numbering.

The exodus numbers are stored in here starting with 1

Definition at line 674 of file exodusII_io_helper.h.

Referenced by libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_node_maps(), and libMesh::Nemesis_IO_Helper::write_nodesets().

Definition at line 681 of file exodusII_io_helper.h.

Referenced by get_nodal_var_names(), and get_nodal_var_values().

Definition at line 650 of file exodusII_io_helper.h.

Referenced by get_node_list(), and read_nodeset().

Definition at line 646 of file exodusII_io_helper.h.

Referenced by read_sideset(), and read_sideset_info().

Definition at line 647 of file exodusII_io_helper.h.

Referenced by read_nodeset(), and read_nodeset_info().

Definition at line 659 of file exodusII_io_helper.h.

Referenced by inquire(), and read_sideset_info().

Definition at line 655 of file exodusII_io_helper.h.

Referenced by inquire(), and read_sideset_info().

Definition at line 638 of file exodusII_io_helper.h.

Referenced by inquire(), and read_sideset_info().

Definition at line 679 of file exodusII_io_helper.h.

Referenced by get_time_steps().

Definition at line 661 of file exodusII_io_helper.h.

Referenced by ExodusII_IO_Helper(), print_header(), and read_header().


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:18 UTC

Hosted By:
SourceForge.net Logo