libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
libMesh::MeshOutput< MT > Class Template Referenceabstract

This class defines an abstract interface for Mesh output. More...

#include <mesh_output.h>

Public Member Functions

virtual ~MeshOutput ()
 Destructor. More...
 
virtual void write (const std::string &)=0
 This method implements writing a mesh to a specified file. 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_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...
 
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...
 
unsigned int & ascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 

Protected Member Functions

 MeshOutput (const bool is_parallel_format=false, const bool serial_only_needed_on_proc_0=false)
 Default constructor. More...
 
 MeshOutput (const MT &, const bool is_parallel_format=false, const bool serial_only_needed_on_proc_0=false)
 Constructor. More...
 
const MT & mesh () const
 

Protected Attributes

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 Attributes

const MT *const _obj
 A pointer to a constant object. More...
 
unsigned int _ascii_precision
 Precision to use when writing ASCII files. More...
 

Detailed Description

template<class MT>
class libMesh::MeshOutput< MT >

This class defines an abstract interface for Mesh output.

Specific classes derived from this class actually implement writing various mesh formats.

Author
Benjamin S. Kirk
Date
2004

Definition at line 53 of file mesh_output.h.

Constructor & Destructor Documentation

◆ MeshOutput() [1/2]

template<class MT >
libMesh::MeshOutput< MT >::MeshOutput ( const bool  is_parallel_format = false,
const bool  serial_only_needed_on_proc_0 = false 
)
explicitprotected

Default constructor.

Will set the _obj to nullptr, effectively rendering this object useless.

Definition at line 194 of file mesh_output.h.

194  :
195  _is_parallel_format(is_parallel_format),
196  _serial_only_needed_on_proc_0(serial_only_needed_on_proc_0),
197  _obj(nullptr),
198  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
199 {}
const MT *const _obj
A pointer to a constant object.
Definition: mesh_output.h:177
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:159
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:182
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero...
Definition: mesh_output.h:168

◆ MeshOutput() [2/2]

template<class MT>
libMesh::MeshOutput< MT >::MeshOutput ( const MT &  obj,
const bool  is_parallel_format = false,
const bool  serial_only_needed_on_proc_0 = false 
)
explicitprotected

Constructor.

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

Definition at line 205 of file mesh_output.h.

205  :
206  _is_parallel_format(is_parallel_format),
207  _serial_only_needed_on_proc_0(serial_only_needed_on_proc_0),
208  _obj (&obj),
209  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
210 {
211  if (!_is_parallel_format && !this->mesh().is_serial())
212  {
213  if (this->mesh().processor_id() == 0)
214  {
215  libmesh_do_once(libMesh::out <<
216  "Warning: This MeshOutput subclass only supports meshes which have been serialized!"
217  << std::endl;);
218  }
219  }
220 }
const MT & mesh() const
Definition: mesh_output.h:234
const MT *const _obj
A pointer to a constant object.
Definition: mesh_output.h:177
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:159
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:182
OStreamProxy out
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero...
Definition: mesh_output.h:168

◆ ~MeshOutput()

template<class MT >
libMesh::MeshOutput< MT >::~MeshOutput ( )
virtual

Destructor.

Definition at line 226 of file mesh_output.h.

227 {
228 }

Member Function Documentation

◆ ascii_precision()

template<class MT >
unsigned int & libMesh::MeshOutput< MT >::ascii_precision ( )

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

◆ mesh()

template<class MT >
const MT & libMesh::MeshOutput< MT >::mesh ( ) const
protected
Returns
The object as a read-only reference.

Definition at line 234 of file mesh_output.h.

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

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

◆ write()

template<class MT>
virtual void libMesh::MeshOutput< MT >::write ( const std::string &  )
pure virtual

◆ write_discontinuous_equation_systems()

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

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

template<class MT>
virtual void libMesh::MeshOutput< MT >::write_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = nullptr 
)
virtual

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]

template<class MT>
virtual void libMesh::MeshOutput< MT >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
virtual

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]

template<class MT>
virtual void libMesh::MeshOutput< MT >::write_nodal_data ( const std::string &  ,
const NumericVector< Number > &  ,
const std::vector< std::string > &   
)
virtual

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

template<class MT>
virtual void libMesh::MeshOutput< MT >::write_nodal_data_discontinuous ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
virtual

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

◆ _ascii_precision

template<class MT>
unsigned int libMesh::MeshOutput< MT >::_ascii_precision
private

Precision to use when writing ASCII files.

Definition at line 182 of file mesh_output.h.

◆ _is_parallel_format

template<class MT>
const bool libMesh::MeshOutput< MT >::_is_parallel_format
protected

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.

◆ _obj

template<class MT>
const MT* const libMesh::MeshOutput< MT >::_obj
private

A pointer to a constant object.

This allows us to write the object to file.

Definition at line 177 of file mesh_output.h.

◆ _serial_only_needed_on_proc_0

template<class MT>
const bool libMesh::MeshOutput< MT >::_serial_only_needed_on_proc_0
protected

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.


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