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

This class implements writing meshes in the GMV format. More...

#include <gmv_io.h>

Inheritance diagram for libMesh::GMVIO:
[legend]

Public Member Functions

 GMVIO (const MeshBase &)
 Constructor. More...
 
 GMVIO (MeshBase &)
 Constructor. More...
 
virtual void write (const std::string &) override
 This method implements writing a mesh to a specified file. More...
 
virtual void read (const std::string &mesh_file) override
 This method implements reading a mesh from a specified file. More...
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided. More...
 
bool & binary ()
 Flag indicating whether or not to write a binary file. More...
 
bool & discontinuous ()
 Flag indicating whether or not to write the mesh as discontinuous cell patches. More...
 
bool & partitioning ()
 Flag indicating whether or not to write the partitioning information for the mesh. More...
 
bool & write_subdomain_id_as_material ()
 Flag to write element subdomain_id's as GMV "materials" instead of element processor_id's. More...
 
bool & subdivide_second_order ()
 Flag indicating whether or not to subdivide second order elements. More...
 
bool & p_levels ()
 Flag indicating whether or not to write p level information for p refined meshes. More...
 
void write_discontinuous_gmv (const std::string &name, const EquationSystems &es, const bool write_partitioning, const std::set< std::string > *system_names=nullptr) const
 Writes a GMV file with discontinuous data. More...
 
void write_ascii_new_impl (const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided. More...
 
void add_cell_centered_data (const std::string &cell_centered_data_name, const std::vector< Real > *cell_centered_data_vals)
 Takes a vector of cell-centered data to be plotted. More...
 
void copy_nodal_solution (EquationSystems &es)
 If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution into an EquationSystems object. 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 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 write_ascii_old_impl (const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided. More...
 
void write_binary (const std::string &, const std::vector< Number > *=nullptr, const std::vector< std::string > *=nullptr)
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided. More...
 
void _read_nodes ()
 Helper functions for reading nodes/cells from a GMV file. More...
 
void _read_one_cell ()
 
ElemType gmv_elem_to_libmesh_elem (std::string elemname)
 
void _read_materials ()
 
void _read_var ()
 

Static Private Member Functions

static std::map< std::string, ElemTypebuild_reading_element_map ()
 Static function used to build the _reading_element_map. More...
 

Private Attributes

bool _binary
 Flag to write binary data. More...
 
bool _discontinuous
 Flag to write the mesh as discontinuous patches. More...
 
bool _partitioning
 Flag to write the mesh partitioning. More...
 
bool _write_subdomain_id_as_material
 Flag to write element subdomain_id's as GMV "materials" instead of element processor_id's. More...
 
bool _subdivide_second_order
 Flag to subdivide second order elements. More...
 
bool _p_levels
 Flag to write the mesh p refinement levels. More...
 
std::map< std::string, const std::vector< Real > *> _cell_centered_data
 Storage for arbitrary cell-centered data. More...
 
unsigned int _next_elem_id
 
std::map< std::string, std::vector< Number > > _nodal_data
 

Static Private Attributes

static std::map< std::string, ElemType_reading_element_map
 Static map from string -> ElementType for use during reading. More...
 

Detailed Description

This class implements writing meshes in the GMV format.

For a full description of the GMV format and to obtain the GMV software see http://www.generalmeshviewer.com

Author
Benjamin S. Kirk
Date
2004

Definition at line 54 of file gmv_io.h.

Constructor & Destructor Documentation

◆ GMVIO() [1/2]

libMesh::GMVIO::GMVIO ( const MeshBase )
explicit

Constructor.

Takes a reference to a constant mesh object. This constructor will only allow us to write the mesh.

◆ GMVIO() [2/2]

libMesh::GMVIO::GMVIO ( MeshBase )
explicit

Constructor.

Takes a writable reference to a mesh object. This constructor is required to let us read in a mesh.

Member Function Documentation

◆ _read_materials()

void libMesh::GMVIO::_read_materials ( )
private

◆ _read_nodes()

void libMesh::GMVIO::_read_nodes ( )
private

Helper functions for reading nodes/cells from a GMV file.

◆ _read_one_cell()

void libMesh::GMVIO::_read_one_cell ( )
private

◆ _read_var()

void libMesh::GMVIO::_read_var ( )
private

◆ add_cell_centered_data()

void libMesh::GMVIO::add_cell_centered_data ( const std::string &  cell_centered_data_name,
const std::vector< Real > *  cell_centered_data_vals 
)

Takes a vector of cell-centered data to be plotted.

You must ensure that for every active element e, v[e->id()] is a valid number. You can add an arbitrary number of different cell-centered data sets by calling this function multiple times.

.) GMV does not like spaces in the cell_centered_data_name .) No matter what order you add cell-centered data, it will be output alphabetically.

◆ 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

◆ binary()

bool& libMesh::GMVIO::binary ( )

Flag indicating whether or not to write a binary file.

While binary files may end up being smaller than equivalent ASCII files, they are harder to debug if anything goes wrong, since they are not human-readable.

Definition at line 103 of file gmv_io.h.

References _binary.

103 { return _binary; }
bool _binary
Flag to write binary data.
Definition: gmv_io.h:199

◆ build_reading_element_map()

static std::map<std::string, ElemType> libMesh::GMVIO::build_reading_element_map ( )
staticprivate

Static function used to build the _reading_element_map.

◆ copy_nodal_solution()

void libMesh::GMVIO::copy_nodal_solution ( EquationSystems es)

If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution into an EquationSystems object.

◆ discontinuous()

bool& libMesh::GMVIO::discontinuous ( )

Flag indicating whether or not to write the mesh as discontinuous cell patches.

Definition at line 109 of file gmv_io.h.

References _discontinuous.

109 { return _discontinuous; }
bool _discontinuous
Flag to write the mesh as discontinuous patches.
Definition: gmv_io.h:204

◆ gmv_elem_to_libmesh_elem()

ElemType libMesh::GMVIO::gmv_elem_to_libmesh_elem ( std::string  elemname)
private

◆ 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

◆ p_levels()

bool& libMesh::GMVIO::p_levels ( )

Flag indicating whether or not to write p level information for p refined meshes.

Definition at line 134 of file gmv_io.h.

References _p_levels.

134 { return _p_levels; }
bool _p_levels
Flag to write the mesh p refinement levels.
Definition: gmv_io.h:225

◆ partitioning()

bool& libMesh::GMVIO::partitioning ( )

Flag indicating whether or not to write the partitioning information for the mesh.

Definition at line 115 of file gmv_io.h.

References _partitioning.

115 { return _partitioning; }
bool _partitioning
Flag to write the mesh partitioning.
Definition: gmv_io.h:209

◆ read()

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

This method implements reading a mesh from a specified file.

Implements libMesh::MeshInput< MeshBase >.

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

◆ subdivide_second_order()

bool& libMesh::GMVIO::subdivide_second_order ( )

Flag indicating whether or not to subdivide second order elements.

Definition at line 128 of file gmv_io.h.

References _subdivide_second_order.

128 { return _subdivide_second_order; }
bool _subdivide_second_order
Flag to subdivide second order elements.
Definition: gmv_io.h:220

◆ write()

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

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

◆ write_ascii_new_impl()

void libMesh::GMVIO::write_ascii_new_impl ( const std::string &  ,
const std::vector< Number > *  = nullptr,
const std::vector< std::string > *  = nullptr 
)

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided.

This will write an ASCII file. This is the new implementation (without subcells).

◆ write_ascii_old_impl()

void libMesh::GMVIO::write_ascii_old_impl ( const std::string &  ,
const std::vector< Number > *  = nullptr,
const std::vector< std::string > *  = nullptr 
)
private

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided.

This will write an ASCII file. This is the old implementation (using subcells) which was the default in libMesh-0.4.3-rc2.

◆ write_binary()

void libMesh::GMVIO::write_binary ( const std::string &  ,
const std::vector< Number > *  = nullptr,
const std::vector< std::string > *  = nullptr 
)
private

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are optionally provided.

◆ 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_discontinuous_gmv()

void libMesh::GMVIO::write_discontinuous_gmv ( const std::string &  name,
const EquationSystems es,
const bool  write_partitioning,
const std::set< std::string > *  system_names = nullptr 
) const

Writes a GMV file with discontinuous data.

◆ 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_nodal_data() [1/2]

virtual void libMesh::GMVIO::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
overridevirtual

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided.

Reimplemented from libMesh::MeshOutput< MeshBase >.

◆ 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(); }

◆ write_subdomain_id_as_material()

bool& libMesh::GMVIO::write_subdomain_id_as_material ( )

Flag to write element subdomain_id's as GMV "materials" instead of element processor_id's.

Allows you to generate exploded views on user-defined subdomains, potentially creating a pretty picture.

Definition at line 122 of file gmv_io.h.

References _write_subdomain_id_as_material.

bool _write_subdomain_id_as_material
Flag to write element subdomain_id&#39;s as GMV "materials" instead of element processor_id&#39;s.
Definition: gmv_io.h:215

Member Data Documentation

◆ _binary

bool libMesh::GMVIO::_binary
private

Flag to write binary data.

Definition at line 199 of file gmv_io.h.

Referenced by binary().

◆ _cell_centered_data

std::map<std::string, const std::vector<Real> * > libMesh::GMVIO::_cell_centered_data
private

Storage for arbitrary cell-centered data.

Ex: You can use this to plot the effectivity index for a given cell. The map is between the string representing the variable name and a pointer to a vector containing the data.

Definition at line 233 of file gmv_io.h.

◆ _discontinuous

bool libMesh::GMVIO::_discontinuous
private

Flag to write the mesh as discontinuous patches.

Definition at line 204 of file gmv_io.h.

Referenced by discontinuous().

◆ _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.

◆ _next_elem_id

unsigned int libMesh::GMVIO::_next_elem_id
private

Definition at line 239 of file gmv_io.h.

◆ _nodal_data

std::map<std::string, std::vector<Number> > libMesh::GMVIO::_nodal_data
private

Definition at line 244 of file gmv_io.h.

◆ _p_levels

bool libMesh::GMVIO::_p_levels
private

Flag to write the mesh p refinement levels.

Definition at line 225 of file gmv_io.h.

Referenced by p_levels().

◆ _partitioning

bool libMesh::GMVIO::_partitioning
private

Flag to write the mesh partitioning.

Definition at line 209 of file gmv_io.h.

Referenced by partitioning().

◆ _reading_element_map

std::map<std::string, ElemType> libMesh::GMVIO::_reading_element_map
staticprivate

Static map from string -> ElementType for use during reading.

Definition at line 250 of file gmv_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.

◆ _subdivide_second_order

bool libMesh::GMVIO::_subdivide_second_order
private

Flag to subdivide second order elements.

Definition at line 220 of file gmv_io.h.

Referenced by subdivide_second_order().

◆ _write_subdomain_id_as_material

bool libMesh::GMVIO::_write_subdomain_id_as_material
private

Flag to write element subdomain_id's as GMV "materials" instead of element processor_id's.

Definition at line 215 of file gmv_io.h.

Referenced by write_subdomain_id_as_material().

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