ExodusII_IO Class Reference
#include <exodusII_io.h>

Public Member Functions | |
| ExodusII_IO (MeshBase &mesh) | |
| virtual | ~ExodusII_IO () |
| virtual void | read (const std::string &name) |
| virtual void | write (const std::string &fname) |
| void | verbose (bool set_verbosity) |
| void | copy_nodal_solution (System &es, std::string nodal_var_name, unsigned int timestep=1) |
| void | write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) |
| void | write_timestep (const std::string &fname, const EquationSystems &es, const int timestep, const double time) |
| virtual void | write_equation_systems (const std::string &, const EquationSystems &) |
Protected Member Functions | |
| MT & | mesh () |
| void | skip_comment_lines (std::istream &in, const char comment_start) |
| const MT & | mesh () const |
Private Attributes | |
| ExodusII_IO_Helper | exio_helper |
| int | _timestep |
| bool | _verbose |
Detailed Description
TheExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs. By default, LibMesh expects ExodusII files to have a ".exd" or ".e" file extension.
Definition at line 48 of file exodusII_io.h.
Constructor & Destructor Documentation
| ExodusII_IO::ExodusII_IO | ( | MeshBase & | mesh | ) |
Constructor. Takes a writeable reference to a mesh object. This is the constructor required to read a mesh.
Definition at line 41 of file exodusII_io.C.
00041 : 00042 MeshInput<MeshBase> (mesh), 00043 MeshOutput<MeshBase> (mesh), 00044 _timestep(1), 00045 _verbose (false) 00046 { 00047 }
| ExodusII_IO::~ExodusII_IO | ( | ) | [virtual] |
Destructor.
Definition at line 51 of file exodusII_io.C.
References ExodusII_IO_Helper::close(), exio_helper, and libMesh::processor_id().
00052 { 00053 #ifndef LIBMESH_HAVE_EXODUS_API 00054 00055 std::cerr << "ERROR, ExodusII API is not defined.\n" 00056 << std::endl; 00057 libmesh_error(); 00058 00059 #else 00060 00061 if(libMesh::processor_id() == 0) 00062 exio_helper.close(); 00063 00064 #endif 00065 }
Member Function Documentation
| void ExodusII_IO::copy_nodal_solution | ( | System & | es, | |
| std::string | nodal_var_name, | |||
| unsigned int | timestep = 1 | |||
| ) |
If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution into an EquationSystems object.
Definition at line 238 of file exodusII_io.C.
00239 { 00240 00241 std::cerr << "ERROR, ExodusII API is not defined.\n" 00242 << std::endl; 00243 libmesh_error(); 00244 }
| const MT& MeshOutput< MT >::mesh | ( | ) | const [protected, inherited] |
Returns the object as a read-only reference.
Referenced by PostscriptIO::write(), FroIO::write(), TecplotIO::write_ascii(), MEDITIO::write_ascii(), TecplotIO::write_binary(), EnsightIO::write_geometry_ascii(), EnsightIO::write_scalar_ascii(), GnuPlotIO::write_solution(), DivaIO::write_stream(), and EnsightIO::write_vector_ascii().
| MT& MeshInput< MT >::mesh | ( | ) | [protected, inherited] |
Returns the object as a writeable reference.
Referenced by GMVIO::_read_materials(), GMVIO::_read_nodes(), GMVIO::_read_one_cell(), GMVIO::add_cell_centered_data(), GMVIO::copy_nodal_solution(), UNVIO::element_in(), TetGenIO::element_in(), UNVIO::element_out(), UNVIO::node_in(), TetGenIO::node_in(), UNVIO::node_out(), XdrIO::read(), VTKIO::read(), GMVIO::read(), read(), LegacyXdrIO::read_ascii(), LegacyXdrIO::read_binary(), UCDIO::read_implementation(), LegacyXdrIO::read_mesh(), GmshIO::read_mesh(), XdrIO::read_serialized_bcs(), XdrIO::read_serialized_connectivity(), XdrIO::read_serialized_nodes(), OFFIO::read_stream(), MatlabIO::read_stream(), VTKIO::solution_to_vtk(), XdrIO::write(), VTKIO::write(), TetGenIO::write(), GMVIO::write_ascii_new_impl(), GMVIO::write_ascii_old_impl(), GMVIO::write_binary(), GMVIO::write_discontinuous_gmv(), UNVIO::write_implementation(), UCDIO::write_implementation(), LegacyXdrIO::write_mesh(), GmshIO::write_mesh(), GmshIO::write_post(), XdrIO::write_serialized_bcs(), XdrIO::write_serialized_connectivity(), XdrIO::write_serialized_nodes(), and LegacyXdrIO::write_soln().
| void ExodusII_IO::read | ( | const std::string & | name | ) | [virtual] |
This method implements reading a mesh from a specified file. Open the file named name and read the mesh in Sandia National Lab's ExodusII format. This is the method to use for reading in meshes generated by cubit. Works in 2D for TRIs, TRI6s, QUAD s, and QUAD9s. Works in 3D for TET4s, TET10s, HEX8s, and HEX27s.
Implements MeshInput< MeshBase >.
Definition at line 82 of file exodusII_io.C.
References MeshBase::add_elem(), MeshBase::add_point(), ExodusII_IO_Helper::ElementMaps::assign_conversion(), MeshBase::boundary_info, Elem::build(), MeshBase::clear(), MeshBase::elem(), exio_helper, ExodusII_IO_Helper::get_block_id(), ExodusII_IO_Helper::get_connect(), ExodusII_IO_Helper::get_elem_list(), ExodusII_IO_Helper::get_elem_type(), ExodusII_IO_Helper::get_id_list(), ExodusII_IO_Helper::get_node_list(), ExodusII_IO_Helper::get_nodeset_id(), ExodusII_IO_Helper::get_num_elem(), ExodusII_IO_Helper::get_num_elem_blk(), ExodusII_IO_Helper::get_num_elem_this_blk(), ExodusII_IO_Helper::get_num_node_sets(), ExodusII_IO_Helper::get_num_nodes(), ExodusII_IO_Helper::get_num_nodes_per_elem(), ExodusII_IO_Helper::get_num_side_sets(), ExodusII_IO_Helper::get_num_sides_per_set(), ExodusII_IO_Helper::get_side_list(), ExodusII_IO_Helper::Conversion::get_side_map(), ExodusII_IO_Helper::get_x(), ExodusII_IO_Helper::get_y(), ExodusII_IO_Helper::get_z(), DofObject::id(), MeshInput< MeshBase >::mesh(), MeshBase::mesh_dimension(), MeshBase::n_elem(), MeshBase::n_nodes(), MeshBase::node_ptr(), ExodusII_IO_Helper::open(), ExodusII_IO_Helper::print_header(), ExodusII_IO_Helper::read_block_info(), ExodusII_IO_Helper::read_elem_in_block(), ExodusII_IO_Helper::read_header(), ExodusII_IO_Helper::read_nodes(), ExodusII_IO_Helper::read_nodeset(), ExodusII_IO_Helper::read_nodeset_info(), ExodusII_IO_Helper::read_sideset(), ExodusII_IO_Helper::read_sideset_info(), MeshBase::reserve_elem(), MeshBase::reserve_nodes(), Elem::set_node(), Elem::subdomain_id(), Elem::type(), and verbose().
00083 { 00084 // This is a serial-only process for now; 00085 // the Mesh should be read on processor 0 and 00086 // broadcast later 00087 // libmesh_assert(libMesh::processor_id() == 0); 00088 00089 #ifndef LIBMESH_HAVE_EXODUS_API 00090 00091 std::cerr << "ERROR, ExodusII API is not defined.\n" 00092 << "Input file " << fname << " cannot be read" 00093 << std::endl; 00094 libmesh_error(); 00095 00096 #else 00097 00098 // Get a reference to the mesh we are reading 00099 MeshBase& mesh = MeshInput<MeshBase>::mesh(); 00100 00101 // Clear any existing mesh data 00102 mesh.clear(); 00103 00104 if (mesh.mesh_dimension() == 1) // No support for 1D ExodusII meshes 00105 libmesh_not_implemented(); 00106 00107 #ifdef DEBUG 00108 this->verbose(true); 00109 #endif 00110 00111 00112 ExodusII_IO_Helper::ElementMaps em; // Instantiate the ElementMaps interface 00113 00114 exio_helper.open(fname.c_str()); // Open the exodus file, if possible 00115 exio_helper.read_header(); // Get header information from exodus file 00116 exio_helper.print_header(); // Print header information 00117 00118 //assertion fails due to inconsistent mesh dimension 00119 // libmesh_assert(static_cast<unsigned int>(exio_helper.get_num_dim()) == mesh.mesh_dimension()); // Be sure number of dimensions 00120 // is equal to the number of 00121 // dimensions in the mesh supplied. 00122 00123 exio_helper.read_nodes(); // Read nodes from the exodus file 00124 mesh.reserve_nodes(exio_helper.get_num_nodes()); // Reserve space for the nodes. 00125 00126 // Loop over the nodes, create Nodes with local processor_id 0. 00127 for (int i=0; i<exio_helper.get_num_nodes(); i++) 00128 mesh.add_point (Point(exio_helper.get_x(i), 00129 exio_helper.get_y(i), 00130 exio_helper.get_z(i)), i); 00131 00132 libmesh_assert (static_cast<unsigned int>(exio_helper.get_num_nodes()) == mesh.n_nodes()); 00133 00134 exio_helper.read_block_info(); // Get information about all the blocks 00135 mesh.reserve_elem(exio_helper.get_num_elem()); // Reserve space for the elements 00136 00137 00138 // Read in the element connectivity for each block. 00139 int nelem_last_block = 0; 00140 00141 std::map<int, unsigned int> exodus_id_to_mesh_id; 00142 00143 // Loop over all the blocks 00144 for (int i=0; i<exio_helper.get_num_elem_blk(); i++) 00145 { 00146 // Read the information for block i 00147 exio_helper.read_elem_in_block (i); 00148 int subdomain_id = exio_helper.get_block_id(i); 00149 00150 // Set any relevant node/edge maps for this element 00151 const std::string type_str (exio_helper.get_elem_type()); 00152 const ExodusII_IO_Helper::Conversion conv = em.assign_conversion(type_str); 00153 //if (_verbose) 00154 //std::cout << "Reading a block of " << type_str << " elements." << std::endl; 00155 00156 // Loop over all the faces in this block 00157 int jmax = nelem_last_block+exio_helper.get_num_elem_this_blk(); 00158 for (int j=nelem_last_block; j<jmax; j++) 00159 { 00160 Elem* elem = Elem::build (conv.get_canonical_type()).release(); 00161 libmesh_assert (elem); 00162 elem->subdomain_id() = static_cast<subdomain_id_type>(subdomain_id) ; 00163 //elem->set_id(j);// Don't try to second guess the Element ID setting scheme! 00164 elem = mesh.add_elem (elem); // Catch the Elem pointer that the Mesh throws back 00165 00166 exodus_id_to_mesh_id[j+1] = elem->id(); 00167 00168 // Set all the nodes for this element 00169 for (int k=0; k<exio_helper.get_num_nodes_per_elem(); k++) 00170 { 00171 int gi = (j-nelem_last_block)*exio_helper.get_num_nodes_per_elem() + conv.get_node_map(k); // global index 00172 int node_number = exio_helper.get_connect(gi); // Global node number (1-based) 00173 elem->set_node(k) = mesh.node_ptr((node_number-1)); // Set node number 00174 // Subtract 1 since 00175 // exodus is internally 1-based 00176 } 00177 } 00178 00179 // running sum of # of elements per block, 00180 // (should equal total number of elements in the end) 00181 nelem_last_block += exio_helper.get_num_elem_this_blk(); 00182 } 00183 libmesh_assert (static_cast<unsigned int>(nelem_last_block) == mesh.n_elem()); 00184 00185 // Read in sideset information -- this is useful for applying boundary conditions 00186 { 00187 exio_helper.read_sideset_info(); // Get basic information about ALL sidesets 00188 int offset=0; 00189 for (int i=0; i<exio_helper.get_num_side_sets(); i++) 00190 { 00191 offset += (i > 0 ? exio_helper.get_num_sides_per_set(i-1) : 0); // Compute new offset 00192 exio_helper.read_sideset (i, offset); 00193 } 00194 00195 const std::vector<int>& elem_list = exio_helper.get_elem_list(); 00196 const std::vector<int>& side_list = exio_helper.get_side_list(); 00197 const std::vector<int>& id_list = exio_helper.get_id_list(); 00198 00199 for (unsigned int e=0; e<elem_list.size(); e++) 00200 { 00201 // Set any relevant node/edge maps for this element 00202 00203 Elem * elem = mesh.elem(exodus_id_to_mesh_id[elem_list[e]]); 00204 00205 const ExodusII_IO_Helper::Conversion conv = 00206 em.assign_conversion(elem->type()); 00207 00208 mesh.boundary_info->add_side (exodus_id_to_mesh_id[elem_list[e]], 00209 conv.get_side_map(side_list[e]-1), 00210 id_list[e]); 00211 } 00212 } 00213 00214 // Read nodeset info 00215 { 00216 exio_helper.read_nodeset_info(); 00217 00218 for (int nodeset=0; nodeset<exio_helper.get_num_node_sets(); nodeset++) 00219 { 00220 int nodeset_id = exio_helper.get_nodeset_id(nodeset); 00221 00222 exio_helper.read_nodeset(nodeset); 00223 00224 const std::vector<int>& node_list = exio_helper.get_node_list(); 00225 00226 for(unsigned int node=0; node<node_list.size(); node++) 00227 mesh.boundary_info->add_node(node_list[node], nodeset_id); 00228 } 00229 } 00230 00231 #endif 00232 }
| void MeshInput< MT >::skip_comment_lines | ( | std::istream & | in, | |
| const char | comment_start | |||
| ) | [protected, inherited] |
Reads input from in, skipping all the lines that start with the character comment_start.
Referenced by TetGenIO::read(), and UCDIO::read_implementation().
| void ExodusII_IO::verbose | ( | bool | set_verbosity | ) |
Set the flag indicationg if we should be verbose.
Definition at line 69 of file exodusII_io.C.
References _verbose, exio_helper, and ExodusII_IO_Helper::verbose().
Referenced by read().
00070 { 00071 _verbose = set_verbosity; 00072 00073 #ifdef LIBMESH_HAVE_EXODUS_API 00074 // Set the verbose flag in the helper object 00075 // as well. 00076 exio_helper.verbose(_verbose); 00077 #endif 00078 }
| void ExodusII_IO::write | ( | const std::string & | fname | ) | [virtual] |
This method implements writing a mesh to a specified file.
Implements MeshOutput< MeshBase >.
Definition at line 365 of file exodusII_io.C.
00366 { 00367 std::cerr << "ERROR, ExodusII API is not defined.\n" 00368 << std::endl; 00369 libmesh_error(); 00370 }
| virtual void MeshOutput< MT >::write_equation_systems | ( | const std::string & | , | |
| const EquationSystems & | ||||
| ) | [virtual, inherited] |
This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object.
Reimplemented in VTKIO.
| void ExodusII_IO::write_nodal_data | ( | const std::string & | fname, | |
| const std::vector< Number > & | soln, | |||
| const std::vector< std::string > & | names | |||
| ) | [virtual] |
Write out a nodal solution.
Reimplemented from MeshOutput< MeshBase >.
Definition at line 279 of file exodusII_io.C.
00282 { 00283 00284 std::cerr << "ERROR, ExodusII API is not defined.\n" 00285 << std::endl; 00286 libmesh_error(); 00287 }
| void ExodusII_IO::write_timestep | ( | const std::string & | fname, | |
| const EquationSystems & | es, | |||
| const int | timestep, | |||
| const double | time | |||
| ) |
Writes out the solution at a specific timestep.
- Parameters:
-
timestep The timestep to write out, should be _1_ indexed.
Definition at line 334 of file exodusII_io.C.
00338 { 00339 00340 std::cerr << "ERROR, ExodusII API is not defined.\n" 00341 << std::endl; 00342 libmesh_error(); 00343 }
Member Data Documentation
int ExodusII_IO::_timestep [private] |
Definition at line 120 of file exodusII_io.h.
bool ExodusII_IO::_verbose [private] |
ExodusII_IO_Helper ExodusII_IO::exio_helper [private] |
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined. This class will have no functionality when LIBMESH_HAVE_EXODUS_API is not defined.
Definition at line 114 of file exodusII_io.h.
Referenced by read(), verbose(), and ~ExodusII_IO().
The documentation for this class was generated from the following files: