libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
libMesh::UNVIO Class Reference

The UNVIO class implements the Ideas UNV universal file format. More...

#include <unv_io.h>

Inheritance diagram for libMesh::UNVIO:
[legend]

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

MeshBasemesh ()
 
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 MeshBasemesh () const
 

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
 label for the node dataset More...
 
static const std::string _elements_dataset_label
 label for the element dataset More...
 
static const std::string _groups_dataset_label
 label for the groups dataset More...
 

Detailed Description

The UNVIO class implements the Ideas UNV universal file format.

This class enables both reading and writing UNV files.

Author history

Author
Tammo Kaschner
Daniel Dreyer
Benjamin S. Kirk
John W. Peterson
Date
2003, 2004, 2014

Definition at line 52 of file unv_io.h.

Constructor & Destructor Documentation

◆ UNVIO() [1/2]

libMesh::UNVIO::UNVIO ( MeshBase mesh)

Constructor.

Takes a writable reference to a mesh object. This is the constructor required to read a mesh.

◆ UNVIO() [2/2]

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.

◆ ~UNVIO()

virtual libMesh::UNVIO::~UNVIO ( )
virtual

Destructor.

Member Function Documentation

◆ ascii_precision()

unsigned int & libMesh::MeshOutput< MeshBase >::ascii_precision ( )
inherited

Return/set the precision to use when writing ASCII files.

By default we use numeric_limits<Real>::digits10 + 2, which should be enough to write out to ASCII and get the exact same Real back when reading in.

Definition at line 244 of file mesh_output.h.

245 {
246  return _ascii_precision;
247 }
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:182

◆ elements_in()

void libMesh::UNVIO::elements_in ( std::istream &  in_file)
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.

◆ elements_out()

void libMesh::UNVIO::elements_out ( std::ostream &  out_file)
private

Outputs the element data to the file out_file.

Do not use this directly, but through the proper write method.

◆ get_data()

const std::vector<Number>* libMesh::UNVIO::get_data ( Node node) const
Returns
A pointer the values associated with the node 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.

◆ groups_in()

void libMesh::UNVIO::groups_in ( std::istream &  in_file)
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

◆ max_elem_dimension_seen()

unsigned char libMesh::UNVIO::max_elem_dimension_seen ( )
private
Returns
The maximum geometric element dimension encountered while reading the Mesh. Only valid after the elements have been read in and the elems_of_dimension array has been populated.

◆ mesh() [1/2]

MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited
Returns
The object as a writable reference.

Definition at line 169 of file mesh_input.h.

Referenced by libMesh::XdrIO::write_parallel().

170 {
171  if (_obj == nullptr)
172  libmesh_error_msg("ERROR: _obj should not be nullptr!");
173  return *_obj;
174 }
MeshBase * _obj
A pointer to a non-const object object.
Definition: mesh_input.h:114

◆ mesh() [2/2]

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
protectedinherited
Returns
The object as a read-only reference.

Definition at line 234 of file mesh_output.h.

235 {
236  libmesh_assert(_obj);
237  return *_obj;
238 }
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:177

◆ need_D_to_e()

bool libMesh::UNVIO::need_D_to_e ( std::string &  number)
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.

Returns
true if the replacement occurs, false otherwise.

◆ nodes_in()

void libMesh::UNVIO::nodes_in ( std::istream &  in_file)
private

Read nodes from file.

◆ nodes_out()

void libMesh::UNVIO::nodes_out ( std::ostream &  out_file)
private

Outputs nodes to the file out_file.

Do not use this directly, but through the proper write method.

◆ read()

virtual void libMesh::UNVIO::read ( const std::string &  )
overridevirtual

This method implements reading a mesh from a specified file.

Implements libMesh::MeshInput< MeshBase >.

◆ read_dataset()

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

◆ read_implementation()

void libMesh::UNVIO::read_implementation ( std::istream &  in_stream)
private

The actual implementation of the read function.

The public read interface simply decides which type of stream to pass the implementation.

◆ set_n_partitions()

void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
protectedinherited

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 91 of file mesh_input.h.

References libMesh::MeshInput< MT >::mesh().

91 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1371

◆ skip_comment_lines()

void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
)
protectedinherited

Reads input from in, skipping all the lines that start with the character comment_start.

Definition at line 179 of file mesh_input.h.

181 {
182  char c, line[256];
183 
184  while (in.get(c), c==comment_start)
185  in.getline (line, 255);
186 
187  // put back first character of
188  // first non-comment line
189  in.putback (c);
190 }

◆ verbose()

bool& libMesh::UNVIO::verbose ( )

Set the flag indicating if we should be verbose.

◆ write()

virtual void libMesh::UNVIO::write ( const std::string &  )
overridevirtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

◆ write_discontinuous_equation_systems()

virtual void libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = nullptr 
)
virtualinherited

This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object.

◆ write_equation_systems()

virtual void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = nullptr 
)
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.

◆ write_implementation()

void libMesh::UNVIO::write_implementation ( std::ostream &  out_stream)
private

The actual implementation of the write function.

The public write interface simply decides which type of stream to pass the implementation.

◆ write_nodal_data() [1/2]

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
virtualinherited

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::UCDIO, libMesh::NameBasedIO, libMesh::GmshIO, libMesh::GMVIO, libMesh::VTKIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 105 of file mesh_output.h.

108  { libmesh_not_implemented(); }

◆ write_nodal_data() [2/2]

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const NumericVector< Number > &  ,
const std::vector< std::string > &   
)
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 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.

◆ write_nodal_data_discontinuous()

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
virtualinherited

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 114 of file mesh_output.h.

117  { libmesh_not_implemented(); }

Member Data Documentation

◆ _elements_dataset_label

const std::string libMesh::UNVIO::_elements_dataset_label
staticprivate

label for the element dataset

Definition at line 198 of file unv_io.h.

◆ _groups_dataset_label

const std::string libMesh::UNVIO::_groups_dataset_label
staticprivate

label for the groups dataset

Definition at line 203 of file unv_io.h.

◆ _is_parallel_format

const bool libMesh::MeshOutput< MeshBase >::_is_parallel_format
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 159 of file mesh_output.h.

◆ _node_data

std::map<Node *, std::vector<Number> > libMesh::UNVIO::_node_data
private

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.

◆ _nodes_dataset_label

const std::string libMesh::UNVIO::_nodes_dataset_label
staticprivate

label for the node dataset

Definition at line 193 of file unv_io.h.

◆ _serial_only_needed_on_proc_0

const bool libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
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 168 of file mesh_output.h.

◆ _unv_elem_id_to_libmesh_elem_id

std::map<unsigned, unsigned> libMesh::UNVIO::_unv_elem_id_to_libmesh_elem_id
private

Map UNV element IDs to libmesh element IDs.

Definition at line 208 of file unv_io.h.

◆ _unv_node_id_to_libmesh_node_ptr

std::map<dof_id_type, Node *> libMesh::UNVIO::_unv_node_id_to_libmesh_node_ptr
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.

◆ _verbose

bool libMesh::UNVIO::_verbose
private

should be be verbose?

Definition at line 182 of file unv_io.h.

◆ elems_of_dimension

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited

A vector of bools describing what dimension elements have been encountered when reading a mesh.

Definition at line 97 of file mesh_input.h.


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