From: David Wells Date: Fri, 18 May 2018 15:20:06 +0000 (-0400) Subject: Update the GNUPlot flags. X-Git-Tag: v9.1.0-rc1~1105^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9074eae88a7e3dc91aaa165f62a7e01bc797a4c8;p=dealii.git Update the GNUPlot flags. 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. --- diff --git a/include/deal.II/grid/grid_out.h b/include/deal.II/grid/grid_out.h index 144e7dffc8..3c976177e8 100644 --- a/include/deal.II/grid/grid_out.h +++ b/include/deal.II/grid/grid_out.h @@ -233,27 +233,79 @@ namespace GridOutFlags */ bool write_cell_numbers; + /** + * Number of points, excluding 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)dim-1 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>. + * Boolean indicating whether or not interior lines should be plotted with + * n_extra_curved_line_points line segments. */ bool curved_inner_cells; + /** + * Flag. If true then, when writing spacedim = 3 output, write + * 2*n_extra_curved_line_points extra lines on boundary faces. + * + * Setting this option has no effect when spacedim = 2 since, in + * that case, boundary faces are lines and outputting additional lines + * does not make sense. + * + * @note This is not yet implemented for the dim = 2 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. */ diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index 24ced608a4..42b8ad118a 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -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(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(flags)); + } + + + void Gnuplot::declare_parameters (ParameterHandler ¶m) { 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(cell->material_id()) @@ -3384,7 +3425,7 @@ namespace internal const typename dealii::Triangulation::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