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

This class implements writing 2D meshes in Postscript. More...

#include <postscript_io.h>

Inheritance diagram for libMesh::PostscriptIO:
[legend]

Public Member Functions

 PostscriptIO (const MeshBase &mesh)
 Constructor. More...
 
virtual ~PostscriptIO ()
 Destructor. More...
 
virtual void write (const std::string &) override
 This method implements writing a mesh to a specified file. More...
 
void plot_quadratic_elem (const Elem *elem)
 Draws an element with Bezier curves. More...
 
void plot_linear_elem (const Elem *elem)
 Draws an element with straight lines. 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 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...
 

Public Attributes

Real shade_value
 Controls greyscale shading of cells. More...
 
Real line_width
 Control the thickness of the lines used. More...
 

Protected Member Functions

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

void _compute_edge_bezier_coeffs (const Elem *elem)
 Given a quadratic edge Elem which lies in the x-y plane, computes the Bezier coefficients. More...
 

Private Attributes

std::vector< Point_bezier_coeffs
 Vector containing 3 points corresponding to Bezier coefficients, as computed by _compute_edge_bezier_coeffs. More...
 
Point _offset
 Amount to add to every (x,y) point to place it in Postscript coordinates. More...
 
Real _scale
 Amount by which to stretch each point to place it in Postscript coordinates. More...
 
Point _current_point
 A point object used for temporary calculations. More...
 
std::ostringstream _cell_string
 Drawing style-independent data for a single cell. More...
 
std::ofstream _out
 Output file stream which will be opened when the file name is known. More...
 

Static Private Attributes

static const float _bezier_transform [3][3]
 Coefficients of the transformation from physical-space edge coordinates to Bezier basis coefficients. More...
 

Detailed Description

This class implements writing 2D meshes in Postscript.

It borrows several ideas from, and is a more simple-minded version of, the DataOutBase::write_eps() function from Deal II. Only output is supported here, and only the Mesh (none of the data) is written. The main use I imagined for this class is creating nice Mesh images for publications, since I didn't find/don't know of a free visualization program which would do this.

Author
John W. Peterson
Date
2008

Definition at line 53 of file postscript_io.h.

Constructor & Destructor Documentation

◆ PostscriptIO()

libMesh::PostscriptIO::PostscriptIO ( const MeshBase mesh)
explicit

Constructor.

◆ ~PostscriptIO()

virtual libMesh::PostscriptIO::~PostscriptIO ( )
virtual

Destructor.

Member Function Documentation

◆ _compute_edge_bezier_coeffs()

void libMesh::PostscriptIO::_compute_edge_bezier_coeffs ( const Elem elem)
private

Given a quadratic edge Elem which lies in the x-y plane, computes the Bezier coefficients.

These may be passed to the Postscript routine "curveto".

◆ 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

◆ mesh()

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

◆ plot_linear_elem()

void libMesh::PostscriptIO::plot_linear_elem ( const Elem elem)

Draws an element with straight lines.

◆ plot_quadratic_elem()

void libMesh::PostscriptIO::plot_quadratic_elem ( const Elem elem)

Draws an element with Bezier curves.

◆ write()

virtual void libMesh::PostscriptIO::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_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

◆ _bezier_coeffs

std::vector<Point> libMesh::PostscriptIO::_bezier_coeffs
private

Vector containing 3 points corresponding to Bezier coefficients, as computed by _compute_edge_bezier_coeffs.

Definition at line 120 of file postscript_io.h.

◆ _bezier_transform

const float libMesh::PostscriptIO::_bezier_transform[3][3]
staticprivate

Coefficients of the transformation from physical-space edge coordinates to Bezier basis coefficients.

Transforms x and y separately.

Definition at line 114 of file postscript_io.h.

◆ _cell_string

std::ostringstream libMesh::PostscriptIO::_cell_string
private

Drawing style-independent data for a single cell.

This can be used as a temporary buffer for storing data which may be sent to the output stream multiple times.

Definition at line 142 of file postscript_io.h.

◆ _current_point

Point libMesh::PostscriptIO::_current_point
private

A point object used for temporary calculations.

Definition at line 135 of file postscript_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.

◆ _offset

Point libMesh::PostscriptIO::_offset
private

Amount to add to every (x,y) point to place it in Postscript coordinates.

Definition at line 125 of file postscript_io.h.

◆ _out

std::ofstream libMesh::PostscriptIO::_out
private

Output file stream which will be opened when the file name is known.

Definition at line 147 of file postscript_io.h.

◆ _scale

Real libMesh::PostscriptIO::_scale
private

Amount by which to stretch each point to place it in Postscript coordinates.

Definition at line 130 of file postscript_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.

◆ line_width

Real libMesh::PostscriptIO::line_width

Control the thickness of the lines used.

0.5 is a reasonable default for printed images, but you may need to decrease this value (or choose it adaptively) when there are very slim cells present in the mesh.

Definition at line 88 of file postscript_io.h.

◆ shade_value

Real libMesh::PostscriptIO::shade_value

Controls greyscale shading of cells.

By default this value is 0.0 (which actually corresponds to black) and this indicates "no shading" i.e. only mesh lines will be drawn. Any other value in (0,1] will cause the cells to be grey-shaded to some degree, with higher values being lighter. A value of 0.75 gives decent results.

Definition at line 80 of file postscript_io.h.


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