libMesh
|
The UNVIO
class implements the Ideas UNV
universal file format.
More...
#include <unv_io.h>
Public Member Functions | |
UNVIO (MeshBase &mesh) | |
Constructor. More... | |
UNVIO (const MeshBase &mesh) | |
Constructor. More... | |
virtual | ~UNVIO () |
Destructor. More... | |
virtual void | read (const std::string &) override |
This method implements reading a mesh from a specified file. More... | |
virtual void | write (const std::string &) override |
This method implements writing a mesh to a specified file. More... | |
bool & | verbose () |
Set the flag indicating if we should be verbose. More... | |
void | read_dataset (std::string file_name) |
Read a UNV data file containing a dataset of type "2414". More... | |
const std::vector< Number > * | get_data (Node *node) const |
bool | is_parallel_format () const |
Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once. More... | |
virtual void | write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr) |
This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More... | |
virtual void | write_discontinuous_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr) |
This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object. More... | |
virtual void | write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) |
This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided. More... | |
virtual void | write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &) |
This method may be overridden by "parallel" output formats for writing nodal data. More... | |
virtual void | write_nodal_data (const std::string &, const EquationSystems &, const std::set< std::string > *) |
This method should be overridden by "parallel" output formats for writing nodal data. More... | |
virtual void | write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) |
This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided. More... | |
unsigned int & | ascii_precision () |
Return/set the precision to use when writing ASCII files. More... | |
Protected Member Functions | |
MeshBase & | mesh () |
void | set_n_partitions (unsigned int n_parts) |
Sets the number of partitions in the mesh. More... | |
void | skip_comment_lines (std::istream &in, const char comment_start) |
Reads input from in , skipping all the lines that start with the character comment_start . More... | |
const MeshBase & | mesh () const |
virtual bool | get_add_sides () |
Protected Attributes | |
std::vector< bool > | elems_of_dimension |
A vector of bools describing what dimension elements have been encountered when reading a mesh. More... | |
const bool | _is_parallel_format |
Flag specifying whether this format is parallel-capable. More... | |
const bool | _serial_only_needed_on_proc_0 |
Flag specifying whether this format can be written by only serializing the mesh to processor zero. More... | |
Private Member Functions | |
void | read_implementation (std::istream &in_stream) |
The actual implementation of the read function. More... | |
void | write_implementation (std::ostream &out_stream) |
The actual implementation of the write function. More... | |
void | nodes_in (std::istream &in_file) |
Read nodes from file. More... | |
void | elements_in (std::istream &in_file) |
Method reads elements and stores them in std::vector<Elem *> _elements in the same order as they come in. More... | |
void | groups_in (std::istream &in_file) |
Reads the "groups" section of the file. More... | |
void | nodes_out (std::ostream &out_file) |
Outputs nodes to the file out_file . More... | |
void | elements_out (std::ostream &out_file) |
Outputs the element data to the file out_file . More... | |
unsigned char | max_elem_dimension_seen () |
bool | need_D_to_e (std::string &number) |
Replaces "1.1111D+00" with "1.1111e+00" if necessary. More... | |
Private Attributes | |
bool | _verbose |
should be be verbose? More... | |
std::map< dof_id_type, Node * > | _unv_node_id_to_libmesh_node_ptr |
Maps UNV node IDs to libMesh Node*s. More... | |
std::map< unsigned, unsigned > | _unv_elem_id_to_libmesh_elem_id |
Map UNV element IDs to libmesh element IDs. More... | |
std::map< Node *, std::vector< Number > > | _node_data |
Map from libMesh Node* to data at that node, as read in by the read_dataset() function. More... | |
Static Private Attributes | |
static const std::string | _nodes_dataset_label = "2411" |
label for the node dataset More... | |
static const std::string | _elements_dataset_label = "2412" |
label for the element dataset More... | |
static const std::string | _groups_dataset_label = "2467" |
label for the groups dataset More... | |
The UNVIO
class implements the Ideas UNV
universal file format.
This class enables both reading and writing UNV
files.
Author history
libMesh::UNVIO::UNVIO | ( | MeshBase & | mesh | ) |
Constructor.
Takes a writable reference to a mesh object. This is the constructor required to read a mesh.
Definition at line 70 of file unv_io.C.
libMesh::UNVIO::UNVIO | ( | const MeshBase & | mesh | ) |
Constructor.
Takes a reference to a constant mesh object. This constructor will only allow us to write the mesh.
Definition at line 79 of file unv_io.C.
|
virtualdefault |
Destructor.
|
inlineinherited |
Return/set the precision to use when writing ASCII files.
By default we use numeric_limits<Real>::max_digits10, which should be enough to write out to ASCII and get the exact same Real back when reading in.
Definition at line 269 of file mesh_output.h.
Referenced by nodes_out(), libMesh::FroIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().
|
private |
Method reads elements and stores them in std::vector<Elem *>
_elements
in the same order as they come in.
Within UNVIO
, element labels are ignored.
Definition at line 585 of file unv_io.C.
References _unv_elem_id_to_libmesh_elem_id, _unv_node_id_to_libmesh_node_ptr, libMesh::MeshBase::add_elem(), libMesh::Elem::build(), libMesh::EDGE2, libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::HEX20, libMesh::HEX8, libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), n_nodes, libMesh::out, libMesh::PRISM6, libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::TET10, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, and verbose().
Referenced by read_implementation().
|
private |
Outputs the element data to the file out_file
.
Do not use this directly, but through the proper write method.
Definition at line 934 of file unv_io.C.
References _elements_dataset_label, libMesh::Utility::enum_to_string(), libMesh::HEX20, libMesh::HEX8, libMesh::DofObject::id(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::out, libMesh::PRISM6, libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::TET10, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, and verbose().
Referenced by write_implementation().
|
inlineprotectedvirtualinherited |
Reimplemented in libMesh::ExodusII_IO.
Definition at line 176 of file mesh_output.h.
node
, as read in by the read_dataset() method.If no values exist for the node in question, a nullptr is returned instead. It is up to the user to check the return value before using it.
Definition at line 1319 of file unv_io.C.
References _node_data.
|
private |
Reads the "groups" section of the file.
The format of the groups section is described here: http://www.sdrl.uc.edu/universal-file-formats-for-modal-analysis-testing-1/file-format-storehouse/unv_2467.htm
Definition at line 419 of file unv_io.C.
References _unv_elem_id_to_libmesh_elem_id, libMesh::BoundaryInfo::add_side(), libMesh::as_range(), libMesh::Elem::dim(), libMesh::MeshBase::elem_ptr(), libMesh::err, libMesh::MeshBase::get_boundary_info(), libMesh::Elem::key(), max_elem_dimension_seen(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::BoundaryInfo::sideset_name(), libMesh::Elem::subdomain_id(), and libMesh::MeshBase::subdomain_name().
Referenced by read_implementation().
|
inlineinherited |
Returns true iff this mesh file format and input class are parallelized, so that all processors can read their share of the data at once.
Definition at line 87 of file mesh_input.h.
References libMesh::MeshInput< MT >::_is_parallel_format.
|
private |
Definition at line 386 of file unv_io.C.
References libMesh::MeshInput< MeshBase >::elems_of_dimension.
Referenced by groups_in(), and read_implementation().
|
inlineprotectedinherited |
Definition at line 178 of file mesh_input.h.
Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::VTKIO::cells_to_vtk(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::TetGenIO::element_in(), elements_in(), elements_out(), libMesh::VTKIO::get_local_node_values(), libMesh::ExodusII_IO::get_sideset_data_indices(), groups_in(), libMesh::TetGenIO::node_in(), nodes_in(), nodes_out(), libMesh::VTKIO::nodes_to_vtk(), libMesh::Nemesis_IO::prepare_to_write_nodal_data(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::VTKIO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::UCDIO::read_implementation(), read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::DynaIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::CheckpointIO::read_remote_elem(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::ExodusII_IO::read_sideset_data(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::TetGenIO::write(), libMesh::Nemesis_IO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::ExodusII_IO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::Nemesis_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_elemsets(), libMesh::UCDIO::write_header(), libMesh::UCDIO::write_implementation(), libMesh::UCDIO::write_interior_elems(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::UCDIO::write_nodes(), libMesh::CheckpointIO::write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::ExodusII_IO::write_sideset_data(), libMesh::UCDIO::write_soln(), and libMesh::CheckpointIO::write_subdomain_names().
|
inlineprotectedinherited |
Definition at line 259 of file mesh_output.h.
References libMesh::libmesh_assert().
Referenced by libMesh::FroIO::write(), libMesh::TecplotIO::write(), libMesh::MEDITIO::write(), libMesh::PostscriptIO::write(), libMesh::EnsightIO::write(), libMesh::TecplotIO::write_ascii(), libMesh::TecplotIO::write_binary(), libMesh::TecplotIO::write_nodal_data(), libMesh::MEDITIO::write_nodal_data(), and libMesh::GnuPlotIO::write_solution().
|
private |
Replaces "1.1111D+00" with "1.1111e+00" if necessary.
This function only needs to be called once per stream, one can assume that if one number needs rewriting, they all do.
true
if the replacement occurs, false otherwise. Definition at line 402 of file unv_io.C.
Referenced by read_dataset().
|
private |
Read nodes from file.
Definition at line 300 of file unv_io.C.
References _unv_node_id_to_libmesh_node_ptr, libMesh::MeshBase::add_point(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::out, and verbose().
Referenced by read_implementation().
|
private |
Outputs nodes to the file out_file
.
Do not use this directly, but through the proper write method.
Definition at line 872 of file unv_io.C.
References _nodes_dataset_label, libMesh::MeshOutput< MeshBase >::ascii_precision(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::out, libMesh::Real, and verbose().
Referenced by write_implementation().
|
overridevirtual |
This method implements reading a mesh from a specified file.
Implements libMesh::MeshInput< MeshBase >.
Definition at line 98 of file unv_io.C.
References read_implementation().
Referenced by libMesh::NameBasedIO::read().
void libMesh::UNVIO::read_dataset | ( | std::string | file_name | ) |
Read a UNV data file containing a dataset of type "2414".
For more info, see http://tinyurl.com/htcf6zm
Definition at line 1163 of file unv_io.C.
References _node_data, _unv_node_id_to_libmesh_node_ptr, need_D_to_e(), and libMesh::Real.
|
private |
The actual implementation of the read function.
The public read interface simply decides which type of stream to pass the implementation.
Definition at line 124 of file unv_io.C.
References _elements_dataset_label, _groups_dataset_label, _nodes_dataset_label, libMesh::MeshBase::delete_elem(), elements_in(), libMesh::MeshInput< MeshBase >::elems_of_dimension, groups_in(), max_elem_dimension_seen(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), nodes_in(), libMesh::out, and verbose().
Referenced by read().
|
inlineprotectedinherited |
Sets the number of partitions in the mesh.
Typically this gets done by the partitioner, but some parallel file formats begin "pre-partitioned".
Definition at line 101 of file mesh_input.h.
References libMesh::MeshInput< MT >::mesh().
Referenced by libMesh::Nemesis_IO::read(), and libMesh::XdrIO::read_header().
|
protectedinherited |
Reads input from in
, skipping all the lines that start with the character comment_start
.
Definition at line 187 of file mesh_input.h.
Referenced by libMesh::TetGenIO::read(), and libMesh::UCDIO::read_implementation().
bool & libMesh::UNVIO::verbose | ( | ) |
Set the flag indicating if we should be verbose.
Definition at line 91 of file unv_io.C.
References _verbose.
Referenced by elements_in(), elements_out(), nodes_in(), nodes_out(), and read_implementation().
|
overridevirtual |
This method implements writing a mesh to a specified file.
Implements libMesh::MeshOutput< MeshBase >.
Definition at line 259 of file unv_io.C.
References write_implementation().
Referenced by libMesh::NameBasedIO::write().
|
virtualinherited |
This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems
object.
Definition at line 89 of file mesh_output.C.
References libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.
Referenced by libMesh::ExodusII_IO::write_timestep_discontinuous().
|
virtualinherited |
This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems
object.
Reimplemented in libMesh::NameBasedIO.
Definition at line 31 of file mesh_output.C.
References libMesh::EquationSystems::build_solution_vector(), libMesh::EquationSystems::build_variable_names(), libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), and libMesh::out.
Referenced by libMesh::Nemesis_IO::write_timestep(), and libMesh::ExodusII_IO::write_timestep().
|
private |
The actual implementation of the write function.
The public write interface simply decides which type of stream to pass the implementation.
Definition at line 288 of file unv_io.C.
References elements_out(), and nodes_out().
Referenced by write().
|
inlinevirtualinherited |
This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided.
Reimplemented in libMesh::ExodusII_IO, libMesh::Nemesis_IO, libMesh::GmshIO, libMesh::NameBasedIO, libMesh::VTKIO, libMesh::UCDIO, libMesh::GMVIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.
Definition at line 109 of file mesh_output.h.
|
virtualinherited |
This method may be overridden by "parallel" output formats for writing nodal data.
Instead of getting a localized copy of the nodal solution vector, it is passed a NumericVector of type=PARALLEL which is in node-major order i.e. (u0,v0,w0, u1,v1,w1, u2,v2,w2, u3,v3,w3, ...) and contains n_nodes*n_vars total entries. Then, it is up to the individual I/O class to extract the required solution values from this vector and write them in parallel.
If not implemented, localizes the parallel vector into a std::vector and calls the other version of this function.
Reimplemented in libMesh::Nemesis_IO.
Definition at line 149 of file mesh_output.C.
References libMesh::NumericVector< T >::localize().
|
virtualinherited |
This method should be overridden by "parallel" output formats for writing nodal data.
Instead of getting a localized copy of the nodal solution vector, it directly uses EquationSystems current_local_solution vectors to look up nodal values.
If not implemented, reorders the solutions into a nodal-only NumericVector and calls the above version of this function.
Reimplemented in libMesh::Nemesis_IO.
Definition at line 162 of file mesh_output.C.
References libMesh::EquationSystems::build_parallel_solution_vector(), and libMesh::EquationSystems::build_variable_names().
|
inlinevirtualinherited |
This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided.
Reimplemented in libMesh::ExodusII_IO.
Definition at line 118 of file mesh_output.h.
|
staticprivate |
label for the element dataset
Definition at line 198 of file unv_io.h.
Referenced by elements_out(), and read_implementation().
|
staticprivate |
label for the groups dataset
Definition at line 203 of file unv_io.h.
Referenced by read_implementation().
|
protectedinherited |
Flag specifying whether this format is parallel-capable.
If this is false (default) I/O is only permitted when the mesh has been serialized.
Definition at line 184 of file mesh_output.h.
Referenced by libMesh::FroIO::write(), libMesh::PostscriptIO::write(), and libMesh::EnsightIO::write().
Map from libMesh Node* to data at that node, as read in by the read_dataset() function.
Definition at line 214 of file unv_io.h.
Referenced by get_data(), and read_dataset().
|
staticprivate |
label for the node dataset
Definition at line 193 of file unv_io.h.
Referenced by nodes_out(), and read_implementation().
|
protectedinherited |
Flag specifying whether this format can be written by only serializing the mesh to processor zero.
If this is false (default) the mesh will be serialized to all processors
Definition at line 193 of file mesh_output.h.
|
private |
Map UNV element IDs to libmesh element IDs.
Definition at line 208 of file unv_io.h.
Referenced by elements_in(), and groups_in().
|
private |
Maps UNV node IDs to libMesh Node*s.
Used when reading. Even if the libMesh Mesh is renumbered, this map should continue to be valid.
Definition at line 188 of file unv_io.h.
Referenced by elements_in(), nodes_in(), and read_dataset().
|
private |
|
protectedinherited |
A vector of bools describing what dimension elements have been encountered when reading a mesh.
Definition at line 107 of file mesh_input.h.
Referenced by libMesh::GMVIO::_read_one_cell(), elements_in(), max_elem_dimension_seen(), libMesh::AbaqusIO::max_elem_dimension_seen(), libMesh::AbaqusIO::read(), libMesh::GMVIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::VTKIO::read(), libMesh::AbaqusIO::read_elements(), libMesh::UCDIO::read_implementation(), read_implementation(), and libMesh::XdrIO::read_serialized_connectivity().