]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Update the GNUPlot flags.
authorDavid Wells <wellsd2@rpi.edu>
Fri, 18 May 2018 15:20:06 +0000 (11:20 -0400)
committerDavid Wells <drwells@vt.edu>
Sat, 19 May 2018 16:09:59 +0000 (12:09 -0400)
This commit fixes two intertwined issues with the current set of flags:
1. The variable names and descriptions are written in a way that implies
only boundary lines can be curved (which is no longer true). This commit
renames n_boundary_face_points to n_curved_line_points to make this
clearer.
2. write_gnuplot currently writes a lot of extra lines for boundary
faces in 3D and there is no way to turn this off. I would like to use
this function to generate wireframes of meshes, so I do not want this
extra output. I added a boolean (defaults to true) that controls whether
or not these extra lines are plotted.

include/deal.II/grid/grid_out.h
source/grid/grid_out.cc

index 144e7dffc84dbc9beee0ed39036b24bdb465e1b4..3c976177e8fad9dd8113454a037065c7f2a9e92b 100644 (file)
@@ -233,27 +233,79 @@ namespace GridOutFlags
      */
     bool write_cell_numbers;
 
+    /**
+     * Number of points, <em>excluding</em> the vertices, to plot on curved
+     * lines. Since GNUPLOT can only plot straight lines, setting this number
+     * to a value greater than zero (4 or 5 is usually enough for refined
+     * grids) makes the plot look curved even though it is not.
+     */
+    unsigned int n_extra_curved_line_points;
+
     /**
      * Based on the vertices of the face and #n_boundary_face_points
      * additional points a tensor product mesh (transformed to the real space)
      * of (#n_boundary_face_points+2)<sup>dim-1</sup> points is plotted on
      * each boundary face.
+     *
+     * @deprecated Use n_extra_curved_line_points instead, which has
+     * a more precise name. For compatibility this is implemented as a
+     * reference to n_extra_curved_line_points.
      */
-    unsigned int n_boundary_face_points;
+    DEAL_II_DEPRECATED unsigned int &n_boundary_face_points;
 
     /**
-     * Flag. If true also inner cells are plotted with curved boundaries. This
-     * is useful when for e.g.  MappingQEulerian with
-     * #n_boundary_face_points&gt;.
+     * Boolean indicating whether or not interior lines should be plotted with
+     * <tt>n_extra_curved_line_points</tt> line segments.
      */
     bool curved_inner_cells;
 
+    /**
+     * Flag. If true then, when writing <tt>spacedim = 3</tt> output, write
+     * <tt>2*n_extra_curved_line_points</tt> extra lines on boundary faces.
+     *
+     * Setting this option has no effect when <tt>spacedim = 2</tt> since, in
+     * that case, boundary faces are lines and outputting additional lines
+     * does not make sense.
+     *
+     * @note This is not yet implemented for the <tt>dim = 2</tt> case. For
+     * backwards compatibility, however, this will not raise a runtime error.
+     */
+    bool write_additional_boundary_lines;
+
     /**
      * Constructor.
      */
     Gnuplot (const bool         write_cell_number = false,
-             const unsigned int n_boundary_face_points = 2,
-             const bool         curved_inner_cells = false);
+             const unsigned int n_extra_curved_line_points = 2,
+             const bool         curved_inner_cells = false,
+             const bool         write_additional_boundary_lines = true);
+
+    /**
+     * Copy constructor. Needed since this class (for backwards compatibility)
+     * has a reference member variable.
+     */
+    Gnuplot (const Gnuplot &flags);
+
+    /**
+     * Move constructor. Needed since this class (for backwards compatibility)
+     * has a reference member variable.
+     */
+    Gnuplot (Gnuplot &&flags);
+
+    /**
+     * Copy operator. Needed since this class (for backwards compatibility)
+     * has a reference member variable.
+     */
+    Gnuplot &
+    operator= (const Gnuplot &flags);
+
+    /**
+     * Move assignment operator. Needed since this class (for backwards
+     * compatibility) has a reference member variable.
+     */
+    Gnuplot &
+    operator= (Gnuplot &&flags);
+
     /**
      * Declare parameters in ParameterHandler.
      */
index 24ced608a4bc3d0807181df9814525b97be6db0f..42b8ad118a32aa04d1a1d8ab76000ab00d19ff50 100644 (file)
@@ -126,16 +126,57 @@ namespace GridOutFlags
   }
 
 
-  Gnuplot::Gnuplot (const bool write_cell_numbers,
-                    const unsigned int n_boundary_face_points,
-                    const bool         curved_inner_cells) :
+
+  Gnuplot::Gnuplot (const bool         write_cell_numbers,
+                    const unsigned int n_extra_curved_line_points,
+                    const bool         curved_inner_cells,
+                    const bool         write_additional_boundary_lines) :
     write_cell_numbers (write_cell_numbers),
-    n_boundary_face_points(n_boundary_face_points),
-    curved_inner_cells(curved_inner_cells)
+    n_extra_curved_line_points(n_extra_curved_line_points),
+    n_boundary_face_points(this->n_extra_curved_line_points),
+    curved_inner_cells(curved_inner_cells),
+    write_additional_boundary_lines(write_additional_boundary_lines)
+  {}
+
+
+  // TODO we can get rid of these extra constructors and assignment operators
+  // once we remove the reference member variable.
+  Gnuplot::Gnuplot(const Gnuplot &flags) :
+    Gnuplot(flags.write_cell_numbers,
+            flags.n_extra_curved_line_points,
+            flags.curved_inner_cells,
+            flags.write_additional_boundary_lines)
   {}
 
 
 
+  Gnuplot::Gnuplot(Gnuplot &&flags) :
+    Gnuplot(static_cast<const Gnuplot &>(flags))
+  {}
+
+
+
+  Gnuplot &
+  Gnuplot::operator=(const Gnuplot &flags)
+  {
+    write_cell_numbers = flags.write_cell_numbers;
+    n_extra_curved_line_points = flags.n_extra_curved_line_points;
+    curved_inner_cells = flags.curved_inner_cells;
+    write_additional_boundary_lines = flags.write_additional_boundary_lines;
+
+    return *this;
+  }
+
+
+
+  Gnuplot &
+  Gnuplot::operator=(Gnuplot &&flags)
+  {
+    return operator=(static_cast<const Gnuplot &>(flags));
+  }
+
+
+
   void Gnuplot::declare_parameters (ParameterHandler &param)
   {
     param.declare_entry("Cell number", "false", Patterns::Bool());
@@ -3237,8 +3278,8 @@ namespace internal
                     }
                   else
                     {
-                      // if, however, the face is not at the boundary, then
-                      // draw it as usual
+                      // if, however, the face is not at the boundary and we
+                      // don't want to curve anything, then draw it as usual
                       out << face->vertex(0)
                           << ' ' << cell->level()
                           << ' ' << static_cast<unsigned int>(cell->material_id())
@@ -3384,7 +3425,7 @@ namespace internal
                   const typename dealii::Triangulation<dim,spacedim>::face_iterator
                   face = cell->face(face_no);
 
-                  if (face->at_boundary())
+                  if (face->at_boundary() && gnuplot_flags.write_additional_boundary_lines)
                     {
                       const unsigned int offset=face_no*n_points*n_points;
                       for (unsigned int i=0; i<n_points-1; ++i)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.