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 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 intascii_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...
 
const MeshBase *const _obj
 A pointer to a constant object. More...
 
unsigned int _ascii_precision
 Precision to use when writing ASCII files. 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.

Definition at line 43 of file postscript_io.C.

43  :
44  MeshOutput<MeshBase> (mesh_in),
45  shade_value(0.0),
46  line_width(0.5),
47  //_M(3,3),
48  _offset(0., 0.),
49  _scale(1.0),
50  _current_point(0., 0.)
51 {
52  // This code is still undergoing some development.
53  libmesh_experimental();
54 
55  // Entries of transformation matrix from physical to Bezier coords.
56  // _M(0,0) = -1./6.; _M(0,1) = 1./6.; _M(0,2) = 1.;
57  // _M(1,0) = -1./6.; _M(1,1) = 0.5 ; _M(1,2) = 1./6.;
58  // _M(2,0) = 0. ; _M(2,1) = 1. ; _M(2,2) = 0.;
59 
60  // Make sure there is enough room to store Bezier coefficients.
61  _bezier_coeffs.resize(3);
62 }

References _bezier_coeffs.

◆ ~PostscriptIO()

libMesh::PostscriptIO::~PostscriptIO ( )
virtual

Destructor.

Definition at line 66 of file postscript_io.C.

67 {
68 }

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

Definition at line 265 of file postscript_io.C.

266 {
267  // I only know how to do this for an Edge3!
268  libmesh_assert_equal_to (elem->type(), EDGE3);
269 
270  // Get x-coordinates into an array, transform them,
271  // and repeat for y.
272  float phys_coords[3] = {0., 0., 0.};
273  float bez_coords[3] = {0., 0., 0.};
274 
275  for (unsigned int i=0; i<2; ++i)
276  {
277  // Initialize vectors. Physical coordinates are initialized
278  // by their postscript-scaled values.
279  for (unsigned int j=0; j<3; ++j)
280  {
281  phys_coords[j] = static_cast<float>
282  ((elem->point(j)(i) - _offset(i)) * _scale);
283  bez_coords[j] = 0.; // zero out result vector
284  }
285 
286  // Multiply matrix times vector
287  for (unsigned int j=0; j<3; ++j)
288  for (unsigned int k=0; k<3; ++k)
289  bez_coords[j] += _bezier_transform[j][k]*phys_coords[k];
290 
291  // Store result in _bezier_coeffs
292  for (unsigned int j=0; j<3; ++j)
293  _bezier_coeffs[j](i) = phys_coords[j];
294  }
295 }

References _bezier_coeffs, _bezier_transform, _offset, _scale, libMesh::EDGE3, libMesh::Elem::point(), and libMesh::Elem::type().

Referenced by plot_quadratic_elem().

◆ ascii_precision()

unsigned int & libMesh::MeshOutput< MeshBase >::ascii_precision ( )
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 257 of file mesh_output.h.

258 {
259  return _ascii_precision;
260 }

◆ mesh()

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

Definition at line 247 of file mesh_output.h.

248 {
250  return *_obj;
251 }

◆ plot_linear_elem()

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

Draws an element with straight lines.

Definition at line 191 of file postscript_io.C.

192 {
193  // Clear the string contents. Yes, this really is how you do that...
194  _cell_string.str("");
195 
196  // The general strategy is:
197  // 1.) Use m := {moveto} to go to vertex 0.
198  // 2.) Use l := {lineto} commands to draw lines to vertex 1, 2, ... N-1.
199  // 3a.) Use lx := {lineto closepath stroke} command at vertex N to draw the last line.
200  // 3b.) lf := {lineto closepath fill} command to shade the cell just drawn
201  // All of our 2D elements' vertices are numbered in counterclockwise order,
202  // so we can just draw them in the same order.
203 
204  // 1.)
205  _current_point = (elem->point(0) - _offset) * _scale;
206  _cell_string << _current_point(0) << " " << _current_point(1) << " "; // write x y
207  _cell_string << "m ";
208 
209  // 2.)
210  const unsigned int nv=elem->n_vertices();
211  for (unsigned int v=1; v<nv-1; ++v)
212  {
213  _current_point = (elem->point(v) - _offset) * _scale;
214  _cell_string << _current_point(0) << " " << _current_point(1) << " "; // write x y
215  _cell_string << "l ";
216  }
217 
218  // 3.)
219  _current_point = (elem->point(nv-1) - _offset) * _scale;
220  _cell_string << _current_point(0) << " " << _current_point(1) << " "; // write x y
221 
222  // We draw the shaded (interior) parts first, if applicable.
223  if (shade_value > 0.0)
224  _out << shade_value << " sg " << _cell_string.str() << "lf\n";
225 
226  // Draw the black lines (I guess we will always do this)
227  _out << "0 sg " << _cell_string.str() << "lx\n";
228 }

References _cell_string, _current_point, _offset, _out, _scale, libMesh::Elem::n_vertices(), libMesh::Elem::point(), and shade_value.

Referenced by write().

◆ plot_quadratic_elem()

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

Draws an element with Bezier curves.

Definition at line 233 of file postscript_io.C.

234 {
235  for (auto ns : elem->side_index_range())
236  {
237  // Build the quadratic side
238  std::unique_ptr<const Elem> side = elem->build_side_ptr(ns);
239 
240  // Be sure it's quadratic (Edge2). Eventually we could
241  // handle cubic elements as well...
242  libmesh_assert_equal_to ( side->type(), EDGE3 );
243 
244  _out << "0 sg ";
245 
246  // Move to the first point on this side.
247  _current_point = (side->point(0) - _offset) * _scale;
248  _out << _current_point(0) << " " << _current_point(1) << " "; // write x y
249  _out << "m ";
250 
251  // Compute _bezier_coeffs for this edge. This fills up
252  // the _bezier_coeffs vector.
253  this->_compute_edge_bezier_coeffs(side.get());
254 
255  // Print curveto path to file
256  for (auto i : index_range(_bezier_coeffs))
257  _out << _bezier_coeffs[i](0) << " " << _bezier_coeffs[i](1) << " ";
258  _out << " cs\n";
259  }
260 }

References _bezier_coeffs, _compute_edge_bezier_coeffs(), _current_point, _offset, _out, _scale, libMesh::Elem::build_side_ptr(), libMesh::EDGE3, libMesh::index_range(), and libMesh::Elem::side_index_range().

◆ write()

void libMesh::PostscriptIO::write ( const std::string &  fname)
overridevirtual

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 72 of file postscript_io.C.

73 {
74  // We may need to gather a DistributedMesh to output it, making that
75  // const qualifier in our constructor a dirty lie
76  MeshSerializer serialize(const_cast<MeshBase &>(this->mesh()), !_is_parallel_format);
77 
78  if (this->mesh().processor_id() == 0)
79  {
80  // Get a constant reference to the mesh.
81  const MeshBase & the_mesh = MeshOutput<MeshBase>::mesh();
82 
83  // Only works in 2D
84  libmesh_assert_equal_to (the_mesh.mesh_dimension(), 2);
85 
86  // Create output file stream.
87  // _out is now a private member of the class.
88  _out.open(fname.c_str());
89 
90  // Make sure it opened correctly
91  if (!_out.good())
92  libmesh_file_error(fname.c_str());
93 
94  // The mesh bounding box gives us info about what the
95  // Postscript bounding box should be.
96  BoundingBox bbox = MeshTools::create_bounding_box(the_mesh);
97 
98  // Add a little extra padding to the "true" bounding box so
99  // that we can still see the boundary
100  const Real percent_padding = 0.01;
101  const Real dx=bbox.second(0)-bbox.first(0); libmesh_assert_greater (dx, 0.0);
102  const Real dy=bbox.second(1)-bbox.first(1); libmesh_assert_greater (dy, 0.0);
103 
104  const Real x_min = bbox.first(0) - percent_padding*dx;
105  const Real y_min = bbox.first(1) - percent_padding*dy;
106  const Real x_max = bbox.second(0) + percent_padding*dx;
107  const Real y_max = bbox.second(1) + percent_padding*dy;
108 
109  // Width of the output as given in postscript units.
110  // This usually is given by the strange unit 1/72 inch.
111  // A width of 300 represents a size of roughly 10 cm.
112  const Real width = 300;
113  _scale = width / (x_max-x_min);
114  _offset(0) = x_min;
115  _offset(1) = y_min;
116 
117  // Header writing stuff stolen from Deal.II
118  std::time_t time1= std::time (0);
119  std::tm * time = std::localtime(&time1);
120  _out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n'
121  //<< "%!PS-Adobe-1.0" << '\n' // Lars' PS version
122  << "%%Filename: " << fname << '\n'
123  << "%%Title: LibMesh Output" << '\n'
124  << "%%Creator: LibMesh: A C++ finite element library" << '\n'
125  << "%%Creation Date: "
126  << time->tm_year+1900 << "/"
127  << time->tm_mon+1 << "/"
128  << time->tm_mday << " - "
129  << time->tm_hour << ":"
130  << std::setw(2) << time->tm_min << ":"
131  << std::setw(2) << time->tm_sec << '\n'
132  << "%%BoundingBox: "
133  // lower left corner
134  << "0 0 "
135  // upper right corner
136  << static_cast<unsigned int>( rint(double((x_max-x_min) * _scale )))
137  << ' '
138  << static_cast<unsigned int>( rint(double((y_max-y_min) * _scale )))
139  << '\n';
140 
141  // define some abbreviations to keep
142  // the output small:
143  // m=move turtle to
144  // l=define a line
145  // s=set rgb color
146  // sg=set gray value
147  // lx=close the line and plot the line
148  // lf=close the line and fill the interior
149  _out << "/m {moveto} bind def" << '\n'
150  << "/l {lineto} bind def" << '\n'
151  << "/s {setrgbcolor} bind def" << '\n'
152  << "/sg {setgray} bind def" << '\n'
153  << "/cs {curveto stroke} bind def" << '\n'
154  << "/lx {lineto closepath stroke} bind def" << '\n'
155  << "/lf {lineto closepath fill} bind def" << '\n';
156 
157  _out << "%%EndProlog" << '\n';
158  // << '\n';
159 
160  // Set line width in the postscript file.
161  _out << line_width << " setlinewidth" << '\n';
162 
163  // Set line cap and join options
164  _out << "1 setlinecap" << '\n';
165  _out << "1 setlinejoin" << '\n';
166 
167  // allow only five digits for output (instead of the default
168  // six); this should suffice even for fine grids, but reduces
169  // the file size significantly
170  _out << std::setprecision (5);
171 
172  // Loop over the active elements, draw lines for the edges. We
173  // draw even quadratic elements with straight sides, i.e. a straight
174  // line sits between each pair of vertices. Also we draw every edge
175  // for an element regardless of the fact that it may overlap with
176  // another. This would probably be a useful optimization...
177  for (const auto & elem : the_mesh.active_element_ptr_range())
178  this->plot_linear_elem(elem);
179 
180  // Issue the showpage command, and we're done.
181  _out << "showpage" << std::endl;
182 
183  } // end if (this->mesh().processor_id() == 0)
184 }

References libMesh::MeshOutput< MeshBase >::_is_parallel_format, _offset, _out, _scale, libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshTools::create_bounding_box(), line_width, libMesh::MeshOutput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), plot_linear_elem(), and libMesh::Real.

◆ write_discontinuous_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems ( const std::string &  fname,
const EquationSystems es,
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.

Definition at line 87 of file mesh_output.C.

90 {
91  LOG_SCOPE("write_discontinuous_equation_systems()", "MeshOutput");
92 
93  // We may need to gather and/or renumber a DistributedMesh to output
94  // it, making that const qualifier in our constructor a dirty lie
95  MT & my_mesh = const_cast<MT &>(*_obj);
96 
97  // If we're asked to write data that's associated with a different
98  // mesh, output files full of garbage are the result.
99  libmesh_assert_equal_to(&es.get_mesh(), _obj);
100 
101  // A non-renumbered mesh may not have a contiguous numbering, and
102  // that needs to be fixed before we can build a solution vector.
103  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
104  my_mesh.max_node_id() != my_mesh.n_nodes())
105  {
106  // If we were allowed to renumber then we should have already
107  // been properly renumbered...
108  libmesh_assert(!my_mesh.allow_renumbering());
109 
110  libmesh_do_once(libMesh::out <<
111  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
112  << std::endl;);
113 
114  my_mesh.allow_renumbering(true);
115 
116  my_mesh.renumber_nodes_and_elements();
117 
118  // Not sure what good going back to false will do here, the
119  // renumbering horses have already left the barn...
120  my_mesh.allow_renumbering(false);
121  }
122 
123  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
124 
125  // Build the list of variable names that will be written.
126  std::vector<std::string> names;
127  es.build_variable_names (names, nullptr, system_names);
128 
129  if (!_is_parallel_format)
130  {
131  // Build the nodal solution values & get the variable
132  // names from the EquationSystems object
133  std::vector<Number> soln;
134  es.build_discontinuous_solution_vector (soln, system_names);
135 
136  this->write_nodal_data_discontinuous (fname, soln, names);
137  }
138  else // _is_parallel_format
139  {
140  libmesh_not_implemented();
141  }
142 }

◆ write_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  fname,
const EquationSystems es,
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.

Definition at line 31 of file mesh_output.C.

34 {
35  LOG_SCOPE("write_equation_systems()", "MeshOutput");
36 
37  // We may need to gather and/or renumber a DistributedMesh to output
38  // it, making that const qualifier in our constructor a dirty lie
39  MT & my_mesh = const_cast<MT &>(*_obj);
40 
41  // If we're asked to write data that's associated with a different
42  // mesh, output files full of garbage are the result.
43  libmesh_assert_equal_to(&es.get_mesh(), _obj);
44 
45  // A non-renumbered mesh may not have a contiguous numbering, and
46  // that needs to be fixed before we can build a solution vector.
47  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
48  my_mesh.max_node_id() != my_mesh.n_nodes())
49  {
50  // If we were allowed to renumber then we should have already
51  // been properly renumbered...
52  libmesh_assert(!my_mesh.allow_renumbering());
53 
54  libmesh_do_once(libMesh::out <<
55  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
56  << std::endl;);
57 
58  my_mesh.allow_renumbering(true);
59 
60  my_mesh.renumber_nodes_and_elements();
61 
62  // Not sure what good going back to false will do here, the
63  // renumbering horses have already left the barn...
64  my_mesh.allow_renumbering(false);
65  }
66 
68  {
69  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
70 
71  // Build the list of variable names that will be written.
72  std::vector<std::string> names;
73  es.build_variable_names (names, nullptr, system_names);
74 
75  // Build the nodal solution values & get the variable
76  // names from the EquationSystems object
77  std::vector<Number> soln;
78  es.build_solution_vector (soln, system_names);
79 
80  this->write_nodal_data (fname, soln, names);
81  }
82  else // _is_parallel_format
83  this->write_nodal_data (fname, es, system_names);
84 }

◆ write_nodal_data() [1/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names 
)
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 158 of file mesh_output.C.

161 {
162  std::vector<std::string> names;
163  es.build_variable_names (names, nullptr, system_names);
164 
165  std::unique_ptr<NumericVector<Number>> parallel_soln =
166  es.build_parallel_solution_vector(system_names);
167 
168  this->write_nodal_data (fname, *parallel_soln, names);
169 }

◆ write_nodal_data() [2/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const NumericVector< Number > &  parallel_soln,
const std::vector< std::string > &  names 
)
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 145 of file mesh_output.C.

148 {
149  // This is the fallback implementation for parallel I/O formats that
150  // do not yet implement proper writing in parallel, and instead rely
151  // on the full solution vector being available on all processors.
152  std::vector<Number> soln;
153  parallel_soln.localize(soln);
154  this->write_nodal_data(fname, soln, names);
155 }

◆ write_nodal_data() [3/3]

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
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::Nemesis_IO, libMesh::UCDIO, libMesh::ExodusII_IO, libMesh::GmshIO, libMesh::NameBasedIO, 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_discontinuous()

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
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 114 of file mesh_output.h.

117  { libmesh_not_implemented(); }

Member Data Documentation

◆ _ascii_precision

unsigned int libMesh::MeshOutput< MeshBase >::_ascii_precision
privateinherited

Precision to use when writing ASCII files.

Definition at line 195 of file mesh_output.h.

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

Referenced by _compute_edge_bezier_coeffs(), plot_quadratic_elem(), and PostscriptIO().

◆ _bezier_transform

const float libMesh::PostscriptIO::_bezier_transform
staticprivate
Initial value:
=
{
{-1.f/6.f, 1.f/6.f, 1.},
{-1.f/6.f, 0.5, 1.f/6.f},
{0., 1., 0.}
}

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.

Referenced by _compute_edge_bezier_coeffs().

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

Referenced by plot_linear_elem().

◆ _current_point

Point libMesh::PostscriptIO::_current_point
private

A point object used for temporary calculations.

Definition at line 135 of file postscript_io.h.

Referenced by plot_linear_elem(), and plot_quadratic_elem().

◆ _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 172 of file mesh_output.h.

◆ _obj

const MeshBase * const libMesh::MeshOutput< MeshBase >::_obj
privateinherited

A pointer to a constant object.

This allows us to write the object to file.

Definition at line 190 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.

Referenced by _compute_edge_bezier_coeffs(), plot_linear_elem(), plot_quadratic_elem(), and write().

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

Referenced by plot_linear_elem(), plot_quadratic_elem(), and write().

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

Referenced by _compute_edge_bezier_coeffs(), plot_linear_elem(), plot_quadratic_elem(), and write().

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

Referenced by write().

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

Referenced by plot_linear_elem().


The documentation for this class was generated from the following files:
libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
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:181
libMesh::index_range
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:106
libMesh::PostscriptIO::plot_linear_elem
void plot_linear_elem(const Elem *elem)
Draws an element with straight lines.
Definition: postscript_io.C:191
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::PostscriptIO::shade_value
Real shade_value
Controls greyscale shading of cells.
Definition: postscript_io.h:80
libMesh::MeshTools::create_bounding_box
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
The same functionality as the deprecated MeshTools::bounding_box().
Definition: mesh_tools.C:389
libMesh::NumericVector::localize
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
libMesh::PostscriptIO::_offset
Point _offset
Amount to add to every (x,y) point to place it in Postscript coordinates.
Definition: postscript_io.h:125
libMesh::MeshOutput< MeshBase >::_is_parallel_format
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:172
libMesh::PostscriptIO::_compute_edge_bezier_coeffs
void _compute_edge_bezier_coeffs(const Elem *elem)
Given a quadratic edge Elem which lies in the x-y plane, computes the Bezier coefficients.
Definition: postscript_io.C:265
libMesh::PostscriptIO::_current_point
Point _current_point
A point object used for temporary calculations.
Definition: postscript_io.h:135
libMesh::PostscriptIO::_bezier_transform
static const float _bezier_transform[3][3]
Coefficients of the transformation from physical-space edge coordinates to Bezier basis coefficients.
Definition: postscript_io.h:114
libMesh::PostscriptIO::_bezier_coeffs
std::vector< Point > _bezier_coeffs
Vector containing 3 points corresponding to Bezier coefficients, as computed by _compute_edge_bezier_...
Definition: postscript_io.h:120
libMesh::MeshOutput< MeshBase >::write_nodal_data
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 va...
Definition: mesh_output.h:105
libMesh::MeshOutput< MeshBase >::mesh
const MeshBase & mesh() const
Definition: mesh_output.h:247
libMesh::EDGE3
Definition: enum_elem_type.h:36
libMesh::PostscriptIO::_scale
Real _scale
Amount by which to stretch each point to place it in Postscript coordinates.
Definition: postscript_io.h:130
libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous
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 dat...
Definition: mesh_output.h:114
libMesh::MeshOutput< MeshBase >::_obj
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:190
libMesh::PostscriptIO::line_width
Real line_width
Control the thickness of the lines used.
Definition: postscript_io.h:88
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::out
OStreamProxy out
libMesh::PostscriptIO::_out
std::ofstream _out
Output file stream which will be opened when the file name is known.
Definition: postscript_io.h:147
libMesh::MeshOutput< MeshBase >::_ascii_precision
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:195
libMesh::PostscriptIO::_cell_string
std::ostringstream _cell_string
Drawing style-independent data for a single cell.
Definition: postscript_io.h:142