Debian Codegraph @

include/deal.II/grid/grid_out.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 1999 - 2023 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_grid_out_h
16 #define dealii_grid_out_h
17
18
19
20 #include <deal.II/base/config.h>
21
22 #include <deal.II/base/data_out_base.h>
23 #include <deal.II/base/exceptions.h>
24 #include <deal.II/base/point.h>
25
26 #include <string>
27
28 DEAL_II_NAMESPACE_OPEN
29
30 // Forward declarations
31 #ifndef DOXYGEN
32 class ParameterHandler;
33 template <int dim, int spacedim>
34 DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
35 class Triangulation;
36 template <int dim, int spacedim>
37 class Mapping;
38 #endif
39
40
41 /**
42 * Within this namespace, we define several structures that are used to
43 * describe flags that can be given to grid output routines to modify the
44 * default outfit of the grids written into a file. See the different
45 * subclasses and the documentation of the GridOut class for more details.
46 *
47 * @ingroup output
48 */
49 namespace GridOutFlags
50 {
51 /**
52 * Flags for grid output in OpenDX format.
53 *
54 * @ingroup output
55 */
56 struct DX
57 {
58 /**
59 * Write cells.
60 */
61 bool write_cells;
62
63 /**
64 * Write faces.
65 */
66 bool write_faces;
67
68 /**
69 * Write field with diameters.
70 */
71 bool write_diameter;
72
73 /**
74 * Write field with area/volume.
75 */
76 bool write_measure;
77
78 /**
79 * Write all faces, including interior faces. If <tt>false</tt>, only
80 * boundary faces are written.
81 */
82 bool write_all_faces;
83
84 /**
85 * Constructor.
86 */
87 DX(const bool write_cells = true,
88 const bool write_faces = false,
89 const bool write_diameter = false,
90 const bool write_measure = false,
91 const bool write_all_faces = true);
92
93 /**
94 * Declare parameters in ParameterHandler.
95 */
96 static void
97 declare_parameters(ParameterHandler &param);
98
99 /**
100 * Parse parameters of ParameterHandler.
101 */
102 void
103 parse_parameters(ParameterHandler &param);
104 };
105
106 /**
107 * Flags describing the details of output in MSH format.
108 *
109 * @ingroup output
110 */
111 struct Msh
112 {
113 /**
114 * When writing a mesh, write boundary faces explicitly if their boundary
115 * indicator is not the default boundary indicator, which is zero. This
116 * is necessary if you later want to re-read the grid and want to get the
117 * same boundary indicators for the different parts of the boundary of the
118 * triangulation.
119 *
120 * It is not necessary if you only want to write the triangulation to view
121 * or print it.
122 *
123 * Default: @p false.
124 */
125 bool write_faces;
126 /**
127 * When writing a mesh, write boundary lines explicitly if their boundary
128 * indicator is not the default boundary indicator, which is zero. This
129 * is necessary if you later want to re-read the grid and want to get the
130 * same boundary indicators for the different parts of the boundary of the
131 * triangulation.
132 *
133 * It is not necessary if you only want to write the triangulation to view
134 * or print it.
135 *
136 * This is used only if <tt>dim==3</tt>, and ignored in all other cases.
137 *
138 * Default: @p false.
139 */
140 bool write_lines;
141
142 /**
143 * Constructor.
144 */
145 Msh(const bool write_faces = false, const bool write_lines = false);
146 /**
147 * Declare parameters in ParameterHandler.
148 */
149 static void
150 declare_parameters(ParameterHandler &param);
151
152 /**
153 * Parse parameters of ParameterHandler.
154 */
155 void
156 parse_parameters(ParameterHandler &param);
157 };
158
159
160 /**
161 * Flags describing the details of output in UCD format.
162 *
163 * @ingroup output
164 */
165 struct Ucd
166 {
167 /**
168 * Write a comment at the beginning of the file stating the date of
169 * creation and some other data. While this is supported by the UCD
170 * format (and the AVS program), some other programs get confused by this,
171 * so the default is to not write a preamble. However, a preamble can be
172 * written using this flag.
173 *
174 * Default: <code>false</code>.
175 */
176 bool write_preamble;
177
178 /**
179 * When writing a mesh, write boundary faces explicitly if their boundary
180 * indicator is not the default boundary indicator, which is zero. This
181 * is necessary if you later want to re-read the grid and want to get the
182 * same boundary indicators for the different parts of the boundary of the
183 * triangulation.
184 *
185 * It is not necessary if you only want to write the triangulation to view
186 * or print it.
187 *
188 * Default: @p false.
189 */
190 bool write_faces;
191
192 /**
193 * When writing a mesh, write boundary lines explicitly if their boundary
194 * indicator is not the default boundary indicator, which is zero. This
195 * is necessary if you later want to re-read the grid and want to get the
196 * same boundary indicators for the different parts of the boundary of the
197 * triangulation.
198 *
199 * It is not necessary if you only want to write the triangulation to view
200 * or print it.
201 *
202 * This directive is ignored if <tt>dim!=3</tt>.
203 *
204 * Default: @p false.
205 */
206 bool write_lines;
207
208 /**
209 * Constructor.
210 */
211 Ucd(const bool write_preamble = false,
212 const bool write_faces = false,
213 const bool write_lines = false);
214
215 /**
216 * Declare parameters in ParameterHandler.
217 */
218 static void
219 declare_parameters(ParameterHandler &param);
220
221 /**
222 * Parse parameters of ParameterHandler.
223 */
224 void
225 parse_parameters(ParameterHandler &param);
226 };
227
228
229 /**
230 * Flags describing the details of output in GNUPLOT format.
231 *
232 * @ingroup output
233 */
234 struct Gnuplot
235 {
236 /**
237 * Write the number of each cell into the output file before starting with
238 * the lines it is composed of, as a comment. This might be useful if you
239 * want to find out details about the grid, for example the position of
240 * cells of which you know the number. It enlarges the size of the output
241 * significantly, however.
242 *
243 * Default: @p false.
244 */
245 bool write_cell_numbers;
246
247 /**
248 * Number of points, <em>excluding</em> the vertices, to plot on curved
249 * lines. Since GNUPLOT can only plot straight lines, setting this number
250 * to a value greater than zero (4 or 5 is usually enough for refined
251 * grids) makes the plot look curved even though it is not.
252 */
253 unsigned int n_extra_curved_line_points;
254
255 /**
256 * Boolean indicating whether or not interior lines should be plotted with
257 * <tt>n_extra_curved_line_points</tt> line segments.
258 */
259 bool curved_inner_cells;
260
261 /**
262 * Flag. If true then, when writing <tt>spacedim = 3</tt> output, write
263 * <tt>2*n_extra_curved_line_points</tt> extra lines on boundary faces.
264 *
265 * Setting this option has no effect when <tt>spacedim = 2</tt> since, in
266 * that case, boundary faces are lines and outputting additional lines
267 * does not make sense.
268 *
269 * @note This is not yet implemented for the <tt>dim = 2</tt> case. For
270 * backwards compatibility, however, this will not raise a runtime error.
271 */
272 bool write_additional_boundary_lines;
273
274 /**
275 * Constructor.
276 */
277 Gnuplot(const bool write_cell_number = false,
278 const unsigned int n_extra_curved_line_points = 2,
279 const bool curved_inner_cells = false,
280 const bool write_additional_boundary_lines = true);
281
282 /**
283 * Declare parameters in ParameterHandler.
284 */
285 static void
286 declare_parameters(ParameterHandler &param);
287
288 /**
289 * Parse parameters of ParameterHandler.
290 */
291 void
292 parse_parameters(ParameterHandler &param);
293 };
294
295 /**
296 * Flags describing the details of output for encapsulated postscript. In
297 * this structure, the flags common to all dimensions are listed. Flags
298 * which are specific to one space dimension only are listed in derived
299 * classes.
300 *
301 * By default, the size of the picture is scaled such that the width equals
302 * 300 units.
303 *
304 * @ingroup output
305 */
306 struct EpsFlagsBase
307 {
308 /**
309 * Enum denoting the possibilities whether the scaling should be done such
310 * that the given @p size equals the width or the height of the resulting
311 * picture.
312 */
313 enum SizeType
314 {
315 /**
316 * Scale with the width.
317 */
318 width,
319 /**
320 * Scale with the height.
321 */
322 height
323 };
324
325 /**
326 * See above. Default is @p width.
327 */
328 SizeType size_type;
329
330 /**
331 * Width or height of the output as given in postscript units This usually
332 * is given by the strange unit 1/72 inch. Whether this is height or width
333 * is specified by the flag @p size_type.
334 *
335 * Default is 300.
336 */
337 unsigned int size;
338
339 /**
340 * Width of a line in postscript units. Default is 0.5.
341 */
342 double line_width;
343
344 /**
345 * Should lines with a set @p user_flag be drawn in a different color
346 * (red)? See
347 * @ref GlossUserFlags
348 * for information about user flags.
349 */
350 bool color_lines_on_user_flag;
351
352 /**
353 * The number of points on a boundary face that are plotted in addition to
354 * the vertices of the face.
355 *
356 * This number is only used if the mapping used is not simply the standard
357 * $Q_1$ mapping (i.e., an object of kind MappingQ(1)) that may
358 * describe edges of cells as curved and that will then be approximated
359 * using line segments with a number of intermediate points as described
360 * by the current variable.
361 */
362 unsigned int n_boundary_face_points;
363
364 /**
365 * Should lines be colored according to their refinement level? This
366 * overrides color_lines_on_user_flag for all levels except level 0.
367 * Colors are: level 0: black, other levels: rainbow scale from blue to
368 * red.
369 */
370 bool color_lines_level;
371
372 /**
373 * Constructor.
374 */
375 EpsFlagsBase(const SizeType size_type = width,
376 const unsigned int size = 300,
377 const double line_width = 0.5,
378 const bool color_lines_on_user_flag = false,
379 const unsigned int n_boundary_face_points = 2,
380 const bool color_lines_level = false);
381 /**
382 * Declare parameters in ParameterHandler.
383 */
384 static void
385 declare_parameters(ParameterHandler &param);
386
387 /**
388 * Parse parameters of ParameterHandler.
389 */
390 void
391 parse_parameters(ParameterHandler &param);
392 };
393
394
395 /**
396 * Flags describing the details of output for encapsulated postscript for
397 * all dimensions not explicitly specialized below. Some flags that are
398 * common to all dimensions are listed in the base class.
399 *
400 * This class does not actually exist, we only here declare the general
401 * template and declare explicit specializations below.
402 *
403 * @ingroup output
404 */
405 template <int dim>
406 struct Eps
407 {};
408
409 /**
410 * Flags specific to the output of grids in one space dimensions.
411 *
412 * @ingroup output
413 */
414 template <>
415 struct Eps<1> : public EpsFlagsBase
416 {
417 /**
418 * Constructor.
419 */
420 Eps(const SizeType size_type = width,
421 const unsigned int size = 300,
422 const double line_width = 0.5,
423 const bool color_lines_on_user_flag = false,
424 const unsigned int n_boundary_face_points = 2);
425 /**
426 * Declare parameters in ParameterHandler.
427 */
428 static void
429 declare_parameters(ParameterHandler &param);
430
431 /**
432 * Parse parameters of ParameterHandler.
433 */
434 void
435 parse_parameters(ParameterHandler &param);
436 };
437
438
439 /**
440 * Flags specific to the output of grids in two space dimensions.
441 *
442 * @ingroup output
443 */
444 template <>
445 struct Eps<2> : public EpsFlagsBase
446 {
447 /**
448 * If this flag is set, then we place the number of the cell into the
449 * middle of each cell. The default value is to not do this.
450 *
451 * The format of the cell number written is <tt>level.index</tt>, or
452 * simply @p index, depending on the value of the following flag.
453 */
454 bool write_cell_numbers;
455 /**
456 * If the cell numbers shall be written, using the above flag, then the
457 * value of this flag determines whether the format shall be
458 * <tt>level.index</tt>, or simply @p index. If @p true, the first format
459 * is taken. Default is @p true.
460 *
461 * The flag has obviously no effect if @p write_cell_numbers is @p false.
462 */
463 bool write_cell_number_level;
464
465 /**
466 * Vertex numbers can be written onto the vertices. This is controlled by
467 * the following flag. Default is @p false.
468 */
469 bool write_vertex_numbers;
470
471 /**
472 * Constructor.
473 */
474 Eps(const SizeType size_type = width,
475 const unsigned int size = 300,
476 const double line_width = 0.5,
477 const bool color_lines_on_user_flag = false,
478 const unsigned int n_boundary_face_points = 2,
479 const bool write_cell_numbers = false,
480 const bool write_cell_number_level = true,
481 const bool write_vertex_numbers = false,
482 const bool color_lines_level = false);
483 /**
484 * Declare parameters in ParameterHandler.
485 */
486 static void
487 declare_parameters(ParameterHandler &param);
488
489 /**
490 * Parse parameters of ParameterHandler.
491 */
492 void
493 parse_parameters(ParameterHandler &param);
494 };
495
496 /**
497 * Flags specific to the output of grids in three space dimensions.
498 *
499 * @ingroup output
500 */
501 template <>
502 struct Eps<3> : public EpsFlagsBase
503 {
504 /**
505 * Angle of the line origin-viewer against the z-axis in degrees.
506 *
507 * Default is the Gnuplot-default of 60.
508 */
509 double azimut_angle;
510
511 /**
512 * Angle by which the viewers position projected onto the x-y-plane is
513 * rotated around the z-axis, in positive sense when viewed from above.
514 * The unit are degrees, and zero equals a position above or below the
515 * negative y-axis.
516 *
517 * Default is the Gnuplot-default of 30.
518 */
519 double turn_angle;
520
521 /**
522 * Constructor.
523 */
524 Eps(const SizeType size_type = width,
525 const unsigned int size = 300,
526 const double line_width = 0.5,
527 const bool color_lines_on_user_flag = false,
528 const unsigned int n_boundary_face_points = 2,
529 const double azimut_angle = 60,
530 const double turn_angle = 30);
531 /**
532 * Declare parameters in ParameterHandler.
533 */
534 static void
535 declare_parameters(ParameterHandler &param);
536
537 /**
538 * Parse parameters of ParameterHandler.
539 */
540 void
541 parse_parameters(ParameterHandler &param);
542 };
543
544 /**
545 * Flags for XFig output.
546 *
547 * @ingroup output
548 */
549 struct XFig
550 {
551 /**
552 * Draw boundary lines. Default is true.
553 */
554 bool draw_boundary;
555
556 /**
557 * An enum used for deciding which field is used for coloring the cells.
558 */
559 enum Coloring
560 {
561 /// Convert the material id into the cell color
562 material_id,
563 /// Convert the level into the cell color
564 level_number,
565 /// Convert the global subdomain id into the cell color
566 subdomain_id,
567 /// Convert the level subdomain id into the cell color
568 level_subdomain_id
569 } color_by;
570
571 /**
572 * Code level to depth. Default is true. If false, color depends on
573 * material or boundary id.
574 *
575 * Depth of the object is 900-level, if this value is true.
576 */
577 bool level_depth;
578
579 /**
580 * Additional points for curved boundaries. Default is none.
581 */
582 unsigned int n_boundary_face_points;
583
584 /**
585 * Scaling of graph. The default is a unit length of one inch.
586 */
587 Point<2> scaling;
588
589 /**
590 * Offset of the graph. Before scaling, the coordinates are shifted by
591 * this value. Default is zero in each direction.
592 */
593 Point<2> offset;
594
595 /**
596 * Style for filling cells. Default is solid fill (20). This value is
597 * forwarded unchanged into the corresponding field <tt>fill_style</tt> of
598 * the polyline object of XFig.
599 */
600 int fill_style;
601
602 /**
603 * Style for drawing border lines of polygons. Defaults to solid (0) and
604 * is forwarded to XFig.
605 */
606 int line_style;
607
608 /**
609 * Thickness of border lines of polygons. Default is 1.
610 *
611 * Set this to zero to avoid border lines for very fine meshes.
612 */
613 int line_thickness;
614
615 /**
616 * Style for drawing lines at the boundary. Defaults to solid (0).
617 */
618 int boundary_style;
619
620 /**
621 * Thickness of boundary lines. Default is 3.
622 */
623 int boundary_thickness;
624
625 /**
626 * Constructor.
627 */
628 XFig();
629 /**
630 * Declare parameters in ParameterHandler.
631 */
632 static void
633 declare_parameters(ParameterHandler &param);
634
635 /**
636 * Parse parameters of ParameterHandler.
637 */
638 void
639 parse_parameters(ParameterHandler &param);
640 };
641
642
643 /**
644 * Flags controlling SVG output.
645 *
646 * The figure below is a zoomed-in illustration of what the SVG flags are
647 * capable of producing. These exact settings are the same as those used
648 * in the test <code>tests/grid/grid_out_svg_02.cc</code> with the addition
649 * of the flag <code>svg_flags.label_boundary_id = true;</code> .
650 *
651 * @image html svg_flags.png
652 *
653 * @ingroup output
654 */
655 struct Svg
656 {
657 /**
658 * Height of the plot in SVG units, computed from width if zero. Defaults
659 * to 1000.
660 */
661 unsigned int height;
662
663 /**
664 * The width of the plot. Computed automatically from height if zero
665 * (default).
666 */
667 unsigned int width;
668
669 /**
670 * Thickness of the lines between cells.
671 */
672 unsigned int line_thickness;
673 /**
674 * Thickness of lines at the boundary.
675 */
676 unsigned int boundary_line_thickness;
677
678 /**
679 * Margin around the plotted area.
680 */
681 bool margin;
682
683 /**
684 * An `enum` describing all possible background styles.
685 */
686 enum Background
687 {
688 /**
689 * Use transparent value of SVG.
690 */
691 transparent,
692
693 /**
694 * Use white background.
695 */
696 white,
697
698 /**
699 * Use a gradient from white (top) to steelblue (bottom), and add date
700 * and time plus a deal.II logo. Automatically draws a margin.
701 */
702 dealii
703 };
704
705 /**
706 * The style used for the background of the mesh.
707 */
708 Background background;
709
710 // View angles for the perspective view of the grid; Default is 0, 0 (top
711 // view).
712
713 /**
714 * The azimuth angle measured from ??? in degrees. Default is 0.
715 */
716 int azimuth_angle;
717
718 /**
719 * The angle from vertically above the xy-plane. Default is 0.
720 */
721 int polar_angle;
722
723 /**
724 * Cell coloring.
725 */
726 enum Coloring
727 {
728 /// No cell coloring
729 none,
730 /// Convert the material id into the cell color (default)
731 material_id,
732 /// Convert the level number into the cell color
733 level_number,
734 /// Convert the subdomain id into the cell color
735 subdomain_id,
736 /// Convert the level subdomain id into the cell color
737 level_subdomain_id
738 };
739
740 Coloring coloring;
741
742 /// Interpret the level number of the cells as altitude over the x-y-plane
743 /// (useful in the perspective view).
744 bool convert_level_number_to_height;
745
746 /**
747 * The factor determining the vertical distance between levels (default =
748 * 0.3.
749 */
750 float level_height_factor;
751
752 /**
753 * Scaling of the font for cell annotations. Defaults to 1.
754 */
755 float cell_font_scaling;
756 /**
757 * Write level number into each cell. Defaults to false.
758 */
759 bool label_level_number;
760
761 /**
762 * Write cell index into each cell. Defaults to false.
763 */
764 bool label_cell_index;
765
766 /**
767 * Write material id of each cell. Defaults to false.
768 */
769 bool label_material_id;
770
771 /**
772 * Write subdomain id of each cell. Defaults to false.
773 */
774 bool label_subdomain_id;
775
776 /**
777 * Write level subdomain id of each cell. Defaults to false.
778 */
779 bool label_level_subdomain_id;
780
781 /**
782 * Write boundary id of each boundary face in a circle on the
783 * corresponding boundary edge. Defaults to false.
784 *
785 * Note: Depending on the choice of image viewer, the boundary id
786 * labels may not appear to be centered in the circle.
787 */
788 bool label_boundary_id;
789
790 /**
791 * Draw a colorbar next to the plotted grid with respect to the chosen
792 * coloring of the cells.
793 */
794 bool draw_colorbar;
795
796 /**
797 * Draw a legend next to the plotted grid, explaining the label of the
798 * cells.
799 */
800 bool draw_legend;
801
802 /**
803 * Constructor.
804 */
805 Svg(const unsigned int line_thickness = 2,
806 const unsigned int boundary_line_thickness = 4,
807 const bool margin = true,
808 const Background background = white,
809 const int azimuth_angle = 0,
810 const int polar_angle = 0,
811 const Coloring coloring = level_number,
812 const bool convert_level_number_to_height = false,
813 const bool label_level_number = false,
814 const bool label_cell_index = false,
815 const bool label_material_id = false,
816 const bool label_subdomain_id = false,
817 const bool draw_colorbar = false,
818 const bool draw_legend = false,
819 const bool label_boundary_id = false);
820 };
821
822 /**
823 * Flags for grid output in MathGL format.
824 *
825 * @ingroup output
826 */
827 struct MathGL
828 {
829 /**
830 * Constructor.
831 */
832 MathGL();
833
834 /**
835 * Draw a bounding box around the graph.
836 */
837 bool draw_bounding_box;
838
839 /**
840 * Declare parameters in ParameterHandler.
841 */
842 static void
843 declare_parameters(ParameterHandler &param);
844
845 /**
846 * Parse parameters of ParameterHandler.
847 */
848 void
849 parse_parameters(ParameterHandler &param);
850 };
851
852
853 /**
854 * Flags for grid output in Vtk format. These flags are the same as those
855 * declared in DataOutBase::VtkFlags.
856 *
857 * @ingroup output
858 */
859 struct Vtk : public DataOutBase::VtkFlags
860 {
861 /**
862 * Default constructor.
863 */
864 Vtk(const bool output_cells = true,
865 const bool output_faces = true,
866 const bool output_edges = true,
867 const bool output_only_relevant = true)
868 : output_cells(output_cells)
869 , output_faces(output_faces)
870 , output_edges(output_edges)
871 , output_only_relevant(output_only_relevant)
872 {}
873
874 /**
875 * Output cells.
876 */
877 bool output_cells;
878
879 /**
880 * Output faces.
881 */
882 bool output_faces;
883
884 /**
885 * Output co-faces/edges.
886 */
887 bool output_edges;
888
889 /**
890 * Output only faces/co-faces that differ from the default settings
891 * (e.g boundary_id).
892 */
893 bool output_only_relevant;
894 };
895
896
897 /**
898 * Flags for grid output in Vtu format. These flags are the same as those
899 * declared in DataOutBase::VtkFlags, with the addition of a flag that
900 * determines if you want to add a entry in the vtu file (which is really
901 * a xml file) containing the entire serialization of the triangulation.
902 *
903 * @ingroup output
904 */
905 struct Vtu : public DataOutBase::VtkFlags
906 {
907 Vtu(const bool serialize_triangulation = false)
908 : serialize_triangulation(serialize_triangulation)
909 {}
910
911 /**
912 * Add to the vtu file also the serialized triangulation.
913 */
914 bool serialize_triangulation;
915 };
916 } // namespace GridOutFlags
917
918
919
920 /**
921 * This class provides a means to output a triangulation to a file in
922 * different formats. See the enum GridOut::OutputFormat for a list of formats
923 * and the corresponding output function names.
924 *
925 * Usage is simple: either you use the direct form
926 * @code
927 * std::ofstream output_file("some_filename");
928 * GridOut().write_gnuplot (tria, output_file);
929 * @endcode
930 * if you know which format you want to have, or if you want the format to be
931 * a runtime parameter, you can write
932 * @code
933 * GridOut::OutputFormat output_format =
934 * GridOut::parse_output_format(get_format_name_from_somewhere());
935 * std::ofstream output_file("some_filename"
936 * + GridOut::default_suffix(output_format));
937 * GridOut().write (tria, output_file, output_format);
938 * @endcode
939 * The function <tt>get_output_format_names()</tt> provides a list of possible
940 * names of output formats in a string that is understandable by the
941 * ParameterHandler class.
942 *
943 * Note that here, we have created an unnamed object of type GridOut and
944 * called one of its <tt>write_*</tt> functions. This looks like as if the
945 * respective function could really be made @p static. This was not done in
946 * order to allow for parameters to be passed to the different output
947 * functions in a way compatible with the scheme of allowing the right output
948 * format to be selected at run-time through the generic @p write function.
949 *
950 * In order to explain this, consider each function had one or more additional
951 * parameters giving the details of output, for example position of the
952 * spectator for 3d meshed, line thicknesses, etc. While this would allow each
953 * output function any flexibility it needs, it would not allow us to use the
954 * generic function @p write which is given a parameter determining the output
955 * format, since it is impractical to give it a list of parameters for each
956 * and every output format supported which it may then pass on to the
957 * respective output function.
958 *
959 * Rather, we have chosen to let each object of this class GridOut have a set
960 * of parameters for each supported output format. These are collected in
961 * structures GridOutFlags::Eps(), GridOutFlags::Gnuplot(), etc declared in
962 * the GridOutFlags namespace, and you can set your preferred flags like this:
963 * @code
964 * GridOut grid_out;
965 * GridOutFlags::Ucd ucd_flags;
966 * ... // set some fields in ucd_flags
967 * grid_out.set_flags (ucd_flags);
968 * ...
969 * ... // write some file with data_out
970 * @endcode
971 * The respective output function then use the so-set flags. By default, they
972 * are set to reasonable values as described above and in the documentation of
973 * the different flags structures. Resetting the flags can be done by calling
974 * <tt>grid_out.set_flags (GridOutFlags::Ucd());</tt>, since the default
975 * constructor of each of the flags structures sets the parameters to their
976 * initial values.
977 *
978 * The advantage of this approach is that it is possible to change the flags
979 * of one or more output formats according to your needs and later use the
980 * generic @p write function; the actual output function then called will use
981 * the flags as set before.
982 *
983 * Note that some of the structures describing the flags of the different
984 * output formats are empty since the respective format does not support any
985 * flags. The structure and the @p set_flags function are provided anyway.
986 * Note also that some of the structures may differ between the dimensions
987 * supported by this class; they then have a template parameter, as usual.
988 *
989 * @ingroup grid
990 * @ingroup output
991 */
992 class GridOut
993 {
994 public:
995 /**
996 * Declaration of a name for each of the different output formats. These are
997 * used by the generic output function write() to determine the actual
998 * output format.
999 */
1000 enum OutputFormat
1001 {
1002 /// Do nothing in write()
1003 none,
1004 /// write() calls write_dx()
1005 dx,
1006 /// write() calls write_gnuplot()
1007 gnuplot,
1008 /// write() calls write_eps()
1009 eps,
1010 /// write() calls write_ucd()
1011 ucd,
1012 /// write() calls write_xfig()
1013 xfig,
1014 /// write() calls write_msh()
1015 msh,
1016 /// write() calls write_svg()
1017 svg,
1018 /// write() calls write_mathgl()
1019 mathgl,
1020 /// write() calls write_vtk()
1021 vtk,
1022 /// write() calls write_vtu()
1023 vtu
1024 };
1025
1026 /**
1027 * Constructor.
1028 */
1029 GridOut();
1030
1031 /**
1032 * Write triangulation in OpenDX format.
1033 *
1034 * Cells or faces are written together with their level and their material
1035 * id or boundary indicator, resp.
1036 *
1037 * Not implemented for the codimension one case.
1038 */
1039 template <int dim, int spacedim>
1040 void
1041 write_dx(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1042
1043 /**
1044 * Write the triangulation in the gnuplot format.
1045 *
1046 * In GNUPLOT format, each cell is written as a sequence of its confining
1047 * lines. Apart from the coordinates of the lines' end points, the level and
1048 * the material of the cell are appended to each line of output. Therefore,
1049 * if you let GNUPLOT draw a 2d grid as a 3d plot, you will see more refined
1050 * cells being raised against cells with less refinement. Also, if you draw
1051 * a cut through a 3d grid, you can extrude the refinement level in the
1052 * direction orthogonal to the cut plane. The same can be done with the
1053 * material id, which is plotted after the level.
1054 *
1055 * A more useful application of this feature is the following: if you use
1056 * the GNUPLOT command (for a 2d grid here)
1057 * @verbatim
1058 * splot [:][:][2.5:3.5] "grid_file.gnuplot" *
1059 * @endverbatim
1060 * then the whole x- and y-range will be plotted, i.e. the whole grid, but
1061 * only those lines with a z-value between 2.5 and 3.5. Since the z-values
1062 * were chosen to be the level to which a cell belongs, this results in a
1063 * plot of those cells only that belong to level 3 in this example. This
1064 * way, it is easy to produce plots of the different levels of grid.
1065 *
1066 * @p mapping is a pointer to a mapping used for the transformation of cells
1067 * at the boundary. If zero, then use standard Q1 mapping.
1068 *
1069 * Names and values of additional flags controlling the output can be found
1070 * in the documentation of the GridOutFlags::Gnuplot class, which also
1071 * describes some caveats for the codimension one case.
1072 */
1073 template <int dim, int spacedim>
1074 void
1075 write_gnuplot(const Triangulation<dim, spacedim> &tria,
1076 std::ostream &out,
1077 const Mapping<dim, spacedim> *mapping = nullptr) const;
1078
1079 /**
1080 * Write the triangulation in the msh format.
1081 *
1082 * Msh is the format used by %Gmsh and it is described in the %Gmsh user's
1083 * guide. Besides the usual output of the grid only, you can decide through
1084 * additional flags (see below, and the documentation of the
1085 * GridOutFlags::Msh() class) whether boundary faces with non-zero boundary
1086 * indicator shall be written to the file explicitly. This is useful, if you
1087 * want to re-read the grid later on, since <tt>deal.II</tt> sets the
1088 * boundary indicator to zero by default; therefore, to obtain the same
1089 * triangulation as before, you have to specify faces with differing
1090 * boundary indicators explicitly, which is done by this flag.
1091 *
1092 * Names and values of further flags controlling the output can be found in
1093 * the documentation of the GridOutFlags::Msh() class.
1094 *
1095 * Works also in the codimension one case.
1096 */
1097 template <int dim, int spacedim>
1098 void
1099 write_msh(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1100
1101 #ifdef DEAL_II_GMSH_WITH_API
1102 /**
1103 * Write the triangulation in any format supported by gmsh API.
1104 *
1105 * Gmsh API allows writing its output in several formats through their C++
1106 * API. This function translates a Triangulation object into a gmsh collection
1107 * of entities and calls the gmsh::write() method with the filename passed as
1108 * argument. This method generates a different entity for each unique pair of
1109 * non default manifold id and boundary id, and writes a gmsh physical group
1110 * for each unique combination, allowing you to read back the triangulation
1111 * using the GridIn::read_msh() method that takes a string as argument.
1112 *
1113 * In particular, all cell objects with non default boundary id or non
1114 * default manifold id are grouped in a unique physical tag, whose name
1115 * contains the boundary and manifold indicators. The names are constructed
1116 * using Patterns::Tools::to_value() applied to a `std::map<std::string, int>`
1117 * where the keys are either `MaterialID`, `BoundaryID`, or `ManifoldID`,
1118 * i.e., a cell with material id 1, and manifold id 3 would be grouped in a
1119 * physical tag (whose numbering is not specified), named
1120 * `MaterialID:1, ManifoldID:3`.
1121 *
1122 * For example, calling the method with a hyper ball grid refined once,
1123 * would results in the following physical tags defined in the output file:
1124 * @code
1125 * MeshFormat
1126 * 4.1 0 8
1127 * \$EndMeshFormat
1128 * \$PhysicalNames
1129 * 3
1130 * 1 1 "ManifoldID:0"
1131 * 1 2 "BoundaryID:-1, ManifoldID:1"
1132 * 2 3 "ManifoldID:1"
1133 * \$EndPhysicalNames
1134 * \$Entities
1135 * ...
1136 * @endcode
1137 *
1138 * The special boundary id `-1` is used to indicate internal boundaries. The
1139 * internal boundaries must be specified whenever it is necessary to specify
1140 * a non-flat manifold id.
1141 */
1142 template <int dim, int spacedim>
1143 void
1144 write_msh(const Triangulation<dim, spacedim> &tria,
1145 const std::string &filename) const;
1146 #endif
1147
1148 /**
1149 * Write the triangulation in the ucd format.
1150 *
1151 * UCD (unstructured cell data) is the format used by AVS and some other
1152 * programs. It is described in the AVS developer's guide. Besides the usual
1153 * output of the grid only, you can decide through additional flags (see
1154 * below, and the documentation of the GridOutFlags::Ucd() class) whether
1155 * boundary faces with non-zero boundary indicator shall be written to the
1156 * file explicitly. This is useful, if you want to re-read the grid later
1157 * on, since <tt>deal.II</tt> sets the boundary indicator to zero by
1158 * default; therefore, to obtain the same triangulation as before, you have
1159 * to specify faces with differing boundary indicators explicitly, which is
1160 * done by this flag.
1161 *
1162 * Names and values of further flags controlling the output can be found in
1163 * the documentation of the GridOutFlags::Ucd() class.
1164 *
1165 * Works also for the codimension one case.
1166 */
1167 template <int dim, int spacedim>
1168 void
1169 write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1170
1171 /**
1172 * Write the triangulation in the encapsulated postscript format.
1173 *
1174 * In this format, each line of the triangulation is written separately. We
1175 * scale the picture such that either x-values or y-values range between
1176 * zero and a fixed size. The other axis is scaled by the same factor. Which
1177 * axis is taken to compute the scale and the size of the box it shall fit
1178 * into is determined by the output flags (see below, and the documentation
1179 * of the GridOutFlags::Eps() class).
1180 *
1181 * The bounding box is close to the triangulation on all four sides, without
1182 * an extra frame. The line width is chosen to be 0.5 by default, but can be
1183 * changed. The line width is to be compared with the extension of the
1184 * picture, of which the default is 300.
1185 *
1186 * The flag @p color_lines_on_user_flag allows to draw lines with the @p
1187 * user_flag set to be drawn in red. The colors black and red are defined as
1188 * @p b and @p r in the preamble of the output file and can be changed there
1189 * according to need.
1190 *
1191 * @p mapping is a pointer to a mapping used for the transformation of cells
1192 * at the boundary. If zero, then use standard Q1 mapping.
1193 *
1194 * Names and values of additional flags controlling the output can be found
1195 * in the documentation of the GridOutFlags::Eps() class. Especially the
1196 * viewpoint for three dimensional grids is of importance here.
1197 *
1198 * Not implemented for the codimension one case.
1199 */
1200 template <int dim, int spacedim>
1201 void
1202 write_eps(const Triangulation<dim, spacedim> &tria,
1203 std::ostream &out,
1204 const Mapping<dim, spacedim> *mapping = nullptr) const;
1205
1206 /**
1207 * Write two-dimensional XFig-file.
1208 *
1209 * This function writes all grid cells as polygons and optionally boundary
1210 * lines. Several parameters can be adjusted by the XFigFlags control
1211 * object.
1212 *
1213 * If levels are coded to depth, the complete grid hierarchy is plotted with
1214 * fine cells before their parents. This way, levels can be switched on and
1215 * off in xfig by selecting levels.
1216 *
1217 * Polygons are either at depth 900-level or at 900+@p material_id,
1218 * depending on the flag @p level_depth. Accordingly, boundary edges are at
1219 * depth 800-level or at 800+@p boundary_id. Therefore, boundary edges are
1220 * always in front of cells.
1221 *
1222 * Not implemented for the codimension one case.
1223 */
1224 template <int dim, int spacedim>
1225 void
1226 write_xfig(const Triangulation<dim, spacedim> &tria,
1227 std::ostream &out,
1228 const Mapping<dim, spacedim> *mapping = nullptr) const;
1229
1230 /**
1231 * Write the triangulation in the SVG format.
1232 *
1233 * SVG (Scalable Vector Graphics) is an XML-based vector image format
1234 * developed and maintained by the World Wide Web Consortium (W3C). This
1235 * function conforms to the latest specification SVG 1.1, released on August
1236 * 16, 2011.
1237 *
1238 * The cells of the triangulation are written as polygons with additional
1239 * lines at the boundary of the triangulation. A coloring of the cells is
1240 * further possible in order to visualize a certain property of the cells
1241 * such as their level or material id. A colorbar can be drawn to encode the
1242 * chosen coloring. Moreover, a cell label can be added, showing level
1243 * index, etc. Indeed, by using the set_flags() with an appropriately
1244 * generated object of type GridOutFlags::Svg, many aspects of how and
1245 * what is being visualized by this function can be customized.
1246 *
1247 * @note This function is currently only implemented for two-dimensional
1248 * grids in two space dimensions.
1249 */
1250 void
1251 write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1252
1253 /**
1254 * Declaration of the same function as above for all other dimensions and
1255 * space dimensions. This function is not currently implemented and is only
1256 * declared to exist to support dimension independent programming.
1257 */
1258 template <int dim, int spacedim>
1259 void
1260 write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1261
1262
1263 /**
1264 * Write triangulation in MathGL script format. To interpret this file a
1265 * version of MathGL>=2.0.0 is required.
1266 *
1267 * To get a handle on the resultant MathGL script within a graphical
1268 * environment an interpreter is needed. A suggestion to start with is
1269 * <code>mglview</code>, which is bundled with MathGL. <code>mglview</code>
1270 * can interpret and display small-to-medium MathGL scripts in a graphical
1271 * window and enables conversion to other formats such as EPS, PNG, JPG,
1272 * SVG, as well as view/display animations. Some minor editing, such as
1273 * modifying the lighting or alpha channels, can also be done.
1274 *
1275 * @note Not implemented for the codimension one case.
1276 */
1277 template <int dim, int spacedim>
1278 void
1279 write_mathgl(const Triangulation<dim, spacedim> &tria,
1280 std::ostream &out) const;
1281
1282 /**
1283 * Write triangulation in VTK format. This function writes a
1284 * UNSTRUCTURED_GRID file, that contains the following VTK cell types:
1285 * VTK_HEXAHEDRON, VTK_QUAD, and VTK_LINE, depending on the template
1286 * dimension.
1287 *
1288 * In three dimensions, this function writes a file that contains
1289 *
1290 * - VTK_HEXAHEDRON cell types, containing the cell information of the
1291 * Triangulation
1292 * - VTK_QUAD cell types, containing all boundary faces with non-zero
1293 * boundary ids, and all faces with non-flat manifold ids
1294 * - VTK_LINE cell types, containing all boundary edges with non-zero
1295 * boundary ids, and all edges with non-flat manifold ids
1296 *
1297 * In two dimensions:
1298 *
1299 * - VTK_QUAD cell types, containing the cell information of the
1300 * Triangulation
1301 * - VTK_LINE cell types, containing all boundary faces with non-zero
1302 * boundary ids, and all faces with non-flat manifold ids
1303 *
1304 * In one dimension
1305 *
1306 * - VTK_LINE cell types, containing the cell information of the
1307 * Triangulation
1308 *
1309 * The output file will contain two CELL_DATA sections, `MaterialID` and
1310 * `ManifoldID`, recording for each VTK cell type the material or boundary id,
1311 * and the manifold. See the
1312 * [VTK file format](http://www.vtk.org/VTK/img/file-formats.pdf)
1313 * documentation for an explanation of the generated output.
1314 *
1315 * The companion GridIn::read_vtk function can be used to read VTK files
1316 * generated with this method.
1317 */
1318 template <int dim, int spacedim>
1319 void
1320 write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1321
1322 /**
1323 * Write triangulation in VTU format.
1324 *
1325 * Due to the way this function writes data to the output stream,
1326 * the resulting output files correspond to a faithful representation
1327 * of the mesh in that all cells are visible for visualization. In general,
1328 * the data is not in a format that allows reading this file in again
1329 * through the GridIn class. This is because every vertex of the mesh is
1330 * duplicated as many times as there are adjacent cells. In other words,
1331 * every cell has its own, separate set of vertices that are at the
1332 * same location as the vertices of other cells, but are separately
1333 * numbered.
1334 *
1335 * In order to create a file that can be read with the GridIn class,
1336 * the flag GridOutFlags::Vtu::serialize_triangulation must be set to true. In
1337 * this case, the generated vtu file will contain the triangulation in a xml
1338 * section which is ignored by general vtu readers.
1339 */
1340 template <int dim, int spacedim>
1341 void
1342 write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1343
1344 /**
1345 * Write triangulation in VTU format for each processor, and add a .pvtu file
1346 * for visualization in VisIt or Paraview that describes the collection of VTU
1347 * files as all part of the same simulation. The output is in the form
1348 * <tt>filename_without_extension.proc000*.vtu</tt> where * is
1349 * 0,1,...,n_proc-1 and <tt>filename_without_extension.pvtu</tt>. The input
1350 * <tt>view_levels</tt> can be set as true to view each level of a multilevel
1351 * method. The input <tt>include_artificial</tt> can be set as true to view
1352 * the artificial cells for each processor. Each .vtu and .pvtu file will have
1353 * the attributes subdomain, level_subdomain, level, and proc_writing. The
1354 * level value can be used to separate the image into the view of the grid on
1355 * each level of a multilevel method and the proc_writing value can be used to
1356 * separate the image into each processor's owned and ghost cells. This is
1357 * accomplished by applying the "warp by scalar" filter in paraview to each of
1358 * the values. After opening the .pvtu file of a mesh where the input
1359 * <tt>view_levels</tt> is set to true, select the "warp by scalar"
1360 * filter. For the "Scalars" input select <tt>proc_writing</tt> and for the
1361 * "Normal" input enter in 1 0 0, then click Apply. Next select the "warp by
1362 * scalar" filter again. For the "Scalars" input select <tt>level</tt> and for
1363 * the "Normal" input enter in 0 1 0, then click Apply. This will give you the
1364 * following image.
1365 * @image html write_mesh_vtu_levels.png
1366 * If the <tt>view_levels</tt> remains at false, thereby only giving the mesh
1367 * for the active level, it is enough to separate the image into the views
1368 * written by different processors. This is shown in the following image where
1369 * the <tt>include_artificial</tt> input is set as true.
1370 * @image html write_mesh_vtu_active.png
1371 * Note: Depending on the size of the mesh you may need to increase the "Scale
1372 * Factor" input so that each piece does not overlap.
1373 */
1374 template <int dim, int spacedim>
1375 void
1376 write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
1377 const std::string &filename_without_extension,
1378 const bool view_levels = false,
1379 const bool include_artificial = false) const;
1380
1381 /**
1382 * Write grid to @p out according to the given data format. This function
1383 * simply calls the appropriate <tt>write_*</tt> function.
1384 */
1385 template <int dim, int spacedim>
1386 void
1387 write(const Triangulation<dim, spacedim> &tria,
1388 std::ostream &out,
1389 const OutputFormat output_format,
1390 const Mapping<dim, spacedim> *mapping = nullptr) const;
1391
1392 /**
1393 * Write mesh in default format set by ParameterHandler.
1394 */
1395 template <int dim, int spacedim>
1396 void
1397 write(const Triangulation<dim, spacedim> &tria,
1398 std::ostream &out,
1399 const Mapping<dim, spacedim> *mapping = nullptr) const;
1400
1401 /**
1402 * Set flags for DX output
1403 */
1404 void
1405 set_flags(const GridOutFlags::DX &flags);
1406
1407 /**
1408 * Set flags for %Gmsh output
1409 */
1410 void
1411 set_flags(const GridOutFlags::Msh &flags);
1412
1413 /**
1414 * Set flags for UCD output
1415 */
1416 void
1417 set_flags(const GridOutFlags::Ucd &flags);
1418
1419 /**
1420 * Set flags for GNUPLOT output
1421 */
1422 void
1423 set_flags(const GridOutFlags::Gnuplot &flags);
1424
1425 /**
1426 * Set flags for EPS output of a one-dimensional triangulation
1427 */
1428 void
1429 set_flags(const GridOutFlags::Eps<1> &flags);
1430
1431 /**
1432 * Set flags for EPS output of a two-dimensional triangulation
1433 */
1434 void
1435 set_flags(const GridOutFlags::Eps<2> &flags);
1436
1437 /**
1438 * Set flags for EPS output of a three-dimensional triangulation
1439 */
1440 void
1441 set_flags(const GridOutFlags::Eps<3> &flags);
1442
1443 /**
1444 * Set flags for EPS output of a three-dimensional triangulation
1445 */
1446 void
1447 set_flags(const GridOutFlags::XFig &flags);
1448
1449 /**
1450 * Set flags for SVG output
1451 */
1452 void
1453 set_flags(const GridOutFlags::Svg &flags);
1454
1455 /**
1456 * Set flags for MathGL output
1457 */
1458 void
1459 set_flags(const GridOutFlags::MathGL &flags);
1460
1461 /**
1462 * Set flags for VTK output
1463 */
1464 void
1465 set_flags(const GridOutFlags::Vtk &flags);
1466
1467 /**
1468 * Set flags for VTU output
1469 */
1470 void
1471 set_flags(const GridOutFlags::Vtu &flags);
1472
1473 /**
1474 * Provide a function that can tell us which suffix a given output format
1475 * usually has. For example, it defines the following mappings:
1476 * <ul>
1477 * <li> @p OpenDX: <tt>.dx</tt>
1478 * <li> @p gnuplot: <tt>.gnuplot</tt>
1479 * <li> @p ucd: <tt>.inp</tt>
1480 * <li> @p eps: <tt>.eps</tt>.
1481 * </ul>
1482 * Similar mappings are provided for all implemented formats.
1483 *
1484 * Since this function does not need data from this object, it is static and
1485 * can thus be called without creating an object of this class.
1486 */
1487 static std::string
1488 default_suffix(const OutputFormat output_format);
1489
1490 /**
1491 * Default suffix for the default output format selected through
1492 * ParameterHandler.
1493 */
1494 std::string
1495 default_suffix() const;
1496
1497 /**
1498 * Return the @p OutputFormat value corresponding to the given string. If
1499 * the string does not match any known format, an exception is thrown.
1500 *
1501 * Since this function does not need data from this object, it is static and
1502 * can thus be called without creating an object of this class. Its main
1503 * purpose is to allow a program to use any implemented output format
1504 * without the need to extend the program's parser each time a new format is
1505 * implemented.
1506 *
1507 * To get a list of presently available format names, e.g. to give it to the
1508 * ParameterHandler class, use the function get_output_format_names().
1509 */
1510 static OutputFormat
1511 parse_output_format(const std::string &format_name);
1512
1513 /**
1514 * Return a list of implemented output formats. The different names are
1515 * separated by vertical bar signs (<tt>`|'</tt>) as used by the
1516 * ParameterHandler classes.
1517 */
1518 static std::string
1519 get_output_format_names();
1520
1521 /**
1522 * Declare parameters in ParameterHandler.
1523 */
1524 static void
1525 declare_parameters(ParameterHandler &param);
1526
1527 /**
1528 * Parse parameters of ParameterHandler.
1529 */
1530 void
1531 parse_parameters(ParameterHandler &param);
1532
1533 /**
1534 * Determine an estimate for the memory consumption (in bytes) of this
1535 * object.
1536 */
1537 std::size_t
1538 memory_consumption() const;
1539
1540 /**
1541 * Exception
1542 */
1543 DeclException0(ExcInvalidState);
1544
1545 private:
1546 /**
1547 * The default output format, set by a ParameterHandler.
1548 */
1549 OutputFormat default_format;
1550
1551 /**
1552 * Flags for OpenDX output.
1553 */
1554 GridOutFlags::DX dx_flags;
1555
1556 /**
1557 * Flags for %Gmsh output. Can be changed by using the set_flags(const
1558 * GridOutFlags::Msh&) function.
1559 */
1560 GridOutFlags::Msh msh_flags;
1561
1562 /**
1563 * Flags for UCD output. Can be changed by using the set_flags(const
1564 * GridOutFlags::Ucd&) function.
1565 */
1566 GridOutFlags::Ucd ucd_flags;
1567
1568 /**
1569 * Flags to be used upon output of GNUPLOT data. Can be changed by using the
1570 * set_flags(const GridOutFlags::Gnuplot&) function.
1571 */
1572 GridOutFlags::Gnuplot gnuplot_flags;
1573
1574 /**
1575 * Flags to be used upon output of EPS data in one space dimension. Can be
1576 * changed by using the set_flags(const GridOutFlags::Eps<1>&) function.
1577 */
1578 GridOutFlags::Eps<1> eps_flags_1;
1579
1580 /**
1581 * Flags to be used upon output of EPS data in two space dimensions. Can be
1582 * changed by using the @p set_flags function.
1583 */
1584 GridOutFlags::Eps<2> eps_flags_2;
1585
1586 /**
1587 * Flags to be used upon output of EPS data in three space dimensions. Can
1588 * be changed by using the @p set_flags function.
1589 */
1590 GridOutFlags::Eps<3> eps_flags_3;
1591
1592 /**
1593 * Flags used for XFig output.
1594 */
1595 GridOutFlags::XFig xfig_flags;
1596
1597 /**
1598 * Flags used for Svg output.
1599 */
1600 GridOutFlags::Svg svg_flags;
1601
1602 /**
1603 * Flags for MathGL output.
1604 */
1605 GridOutFlags::MathGL mathgl_flags;
1606
1607 /**
1608 * Flags for VTK output.
1609 */
1610 GridOutFlags::Vtk vtk_flags;
1611
1612 /**
1613 * Flags for VTU output.
1614 */
1615 GridOutFlags::Vtu vtu_flags;
1616
1617 /**
1618 * Write the grid information about faces to @p out. Only those faces are
1619 * printed which are on the boundary and which have a boundary indicator not
1620 * equal to zero, since the latter is the default for boundary faces.
1621 *
1622 * Since, in %Gmsh, geometric elements are continuously numbered, this
1623 * function requires a parameter @p next_element_index providing the next
1624 * geometric element number. This index should have a numerical value equal
1625 * to one more than the index previously used to write a geometric element
1626 * to @p out.
1627 *
1628 * @returns The next unused geometric element index.
1629 *
1630 * @warning @p next_element_index should be (at least) one larger than the
1631 * current number of triangulation elements (lines, cells, faces) that have
1632 * been written to @p out. %Gmsh will not load the saved file correctly if
1633 * there are repeated indices.
1634 *
1635 * This function unfortunately can not be included in the regular @p
1636 * write_msh function, since it needs special treatment for the case
1637 * <tt>dim==1</tt>, in which case the face iterators are <tt>void*</tt>'s
1638 * and lack the member functions which are called. We would not actually
1639 * call these functions, but the compiler would complain anyway when
1640 * compiling the function for <tt>dim==1</tt>. Bad luck.
1641 */
1642 template <int dim, int spacedim>
1643 unsigned int
1644 write_msh_faces(const Triangulation<dim, spacedim> &tria,
1645 const unsigned int next_element_index,
1646 std::ostream &out) const;
1647
1648 /**
1649 * Declaration of the specialization of above function for 1d. Does nothing.
1650 */
1651 unsigned int
1652 write_msh_faces(const Triangulation<1, 1> &tria,
1653 const unsigned int next_element_index,
1654 std::ostream &out) const;
1655 /**
1656 * Declaration of the specialization of above function for 1d, 2sd. Does
1657 * nothing.
1658 */
1659 unsigned int
1660 write_msh_faces(const Triangulation<1, 2> &tria,
1661 const unsigned int next_element_index,
1662 std::ostream &out) const;
1663 unsigned int
1664 write_msh_faces(const Triangulation<1, 3> &tria,
1665 const unsigned int next_element_index,
1666 std::ostream &out) const;
1667
1668
1669
1670 /**
1671 * Write the grid information about lines to @p out. Only those lines are
1672 * printed which are on the boundary and which have a boundary indicator not
1673 * equal to zero, since the latter is the default for boundary faces.
1674 *
1675 * Since, in %Gmsh, geometric elements are continuously numbered, this
1676 * function requires a parameter @p next_element_index providing the next
1677 * geometric element number. This index should have a numerical value equal
1678 * to one more than the index previously used to write a geometric element
1679 * to @p out.
1680 *
1681 * @returns The next unused geometric element index.
1682 *
1683 * @warning @p next_element_index should be (at least) one larger than the
1684 * current number of triangulation elements (lines, cells, faces) that have
1685 * been written to @p out. %Gmsh will not load the saved file correctly if
1686 * there are repeated indices.
1687 *
1688 * This function unfortunately can not be included in the regular @p
1689 * write_msh function, since it needs special treatment for the case
1690 * <tt>dim==1</tt> and <tt>dim==2</tt>, in which case the edge iterators are
1691 * <tt>void*</tt>'s and lack the member functions which are called. We would
1692 * not actually call these functions, but the compiler would complain anyway
1693 * when compiling the function for <tt>dim==1/2</tt>. Bad luck.
1694 */
1695 template <int dim, int spacedim>
1696 unsigned int
1697 write_msh_lines(const Triangulation<dim, spacedim> &tria,
1698 const unsigned int next_element_index,
1699 std::ostream &out) const;
1700
1701 /**
1702 * Declaration of the specialization of above function for 1d. Does nothing.
1703 */
1704 unsigned int
1705 write_msh_lines(const Triangulation<1, 1> &tria,
1706 const unsigned int next_element_index,
1707 std::ostream &out) const;
1708
1709 /**
1710 * Declaration of the specialization of above function for 1d, 2sd. Does
1711 * nothing.
1712 */
1713 unsigned int
1714 write_msh_lines(const Triangulation<1, 2> &tria,
1715 const unsigned int next_element_index,
1716 std::ostream &out) const;
1717
1718 /**
1719 * Declaration of the specialization of above function for 1d, 3sd. Does
1720 * nothing.
1721 */
1722 unsigned int
1723 write_msh_lines(const Triangulation<1, 3> &tria,
1724 const unsigned int next_element_index,
1725 std::ostream &out) const;
1726 /**
1727 * Declaration of the specialization of above function for 2d. Does nothing.
1728 */
1729 unsigned int
1730 write_msh_lines(const Triangulation<2, 2> &tria,
1731 const unsigned int next_element_index,
1732 std::ostream &out) const;
1733 /**
1734 * Declaration of the specialization of above function for 2d, 3sd. Does
1735 * nothing.
1736 */
1737 unsigned int
1738 write_msh_lines(const Triangulation<2, 3> &tria,
1739 const unsigned int next_element_index,
1740 std::ostream &out) const;
1741
1742 /**
1743 * Write the grid information about faces to @p out. Only those faces are
1744 * printed which are on the boundary and which have a boundary indicator not
1745 * equal to zero, since the latter is the default for boundary faces.
1746 *
1747 * Since (in the UCD format) geometric elements are continuously numbered,
1748 * this function requires a parameter @p next_element_index providing the
1749 * next geometric element number. This index should have a numerical value
1750 * equal to one more than the index previously used to write a geometric
1751 * element to @p out.
1752 *
1753 * @returns The next unused geometric element index.
1754 *
1755 * @warning @p next_element_index should be (at least) one larger than the
1756 * current number of triangulation elements (lines, cells, faces) that have
1757 * been written to @p out. Visualization programs may not load the saved
1758 * file correctly if there are repeated indices.
1759 *
1760 * This function unfortunately can not be included in the regular @p
1761 * write_ucd function, since it needs special treatment for the case
1762 * <tt>dim==1</tt>, in which case the face iterators are <tt>void*</tt>'s
1763 * and lack the member functions which are called. We would not actually
1764 * call these functions, but the compiler would complain anyway when
1765 * compiling the function for <tt>dim==1</tt>. Bad luck.
1766 */
1767 template <int dim, int spacedim>
1768 unsigned int
1769 write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1770 const unsigned int next_element_index,
1771 std::ostream &out) const;
1772
1773 /**
1774 * Declaration of the specialization of above function for 1d. Does nothing.
1775 */
1776 unsigned int
1777 write_ucd_faces(const Triangulation<1, 1> &tria,
1778 const unsigned int next_element_index,
1779 std::ostream &out) const;
1780
1781 /**
1782 * Declaration of the specialization of above function for 1d, 2sd. Does
1783 * nothing.
1784 */
1785 unsigned int
1786 write_ucd_faces(const Triangulation<1, 2> &tria,
1787 const unsigned int next_element_index,
1788 std::ostream &out) const;
1789 unsigned int
1790 write_ucd_faces(const Triangulation<1, 3> &tria,
1791 const unsigned int next_element_index,
1792 std::ostream &out) const;
1793
1794
1795 /**
1796 * Write the grid information about lines to @p out. Only those lines are
1797 * printed which are on the boundary and which have a boundary indicator not
1798 * equal to zero, since the latter is the default for boundary lines.
1799 *
1800 * Since (in the UCD format) geometric elements are continuously numbered,
1801 * this function requires a parameter @p next_element_index providing the
1802 * next geometric element number. This index should have a numerical value
1803 * equal to one more than the index previously used to write a geometric
1804 * element to @p out.
1805 *
1806 * @returns The next unused geometric element index.
1807 *
1808 * @warning @p next_element_index should be (at least) one larger than the
1809 * current number of triangulation elements (lines, cells, faces) that have
1810 * been written to @p out. Visualization programs may not load the saved
1811 * file correctly if there are repeated indices.
1812 *
1813 * This function unfortunately can not be included in the regular @p
1814 * write_ucd function, since it needs special treatment for the case
1815 * <tt>dim==1/2</tt>, in which case the edge iterators are <tt>void*</tt>'s
1816 * and lack the member functions which are called. We would not actually
1817 * call these functions, but the compiler would complain anyway when
1818 * compiling the function for <tt>dim==1/2</tt>. Bad luck.
1819 */
1820 template <int dim, int spacedim>
1821 unsigned int
1822 write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1823 const unsigned int next_element_index,
1824 std::ostream &out) const;
1825
1826 /**
1827 * Declaration of the specialization of above function for 1d. Does nothing.
1828 */
1829 unsigned int
1830 write_ucd_lines(const Triangulation<1, 1> &tria,
1831 const unsigned int next_element_index,
1832 std::ostream &out) const;
1833 /**
1834 * Declaration of the specialization of above function for 1d, 2sd. Does
1835 * nothing.
1836 */
1837 unsigned int
1838 write_ucd_lines(const Triangulation<1, 2> &tria,
1839 const unsigned int next_element_index,
1840 std::ostream &out) const;
1841 /**
1842 * Declaration of the specialization of above function for 1d, 3sd. Does
1843 * nothing.
1844 */
1845 unsigned int
1846 write_ucd_lines(const Triangulation<1, 3> &tria,
1847 const unsigned int next_element_index,
1848 std::ostream &out) const;
1849
1850
1851 /**
1852 * Declaration of the specialization of above function for 2d. Does nothing.
1853 */
1854 unsigned int
1855 write_ucd_lines(const Triangulation<2, 2> &tria,
1856 const unsigned int next_element_index,
1857 std::ostream &out) const;
1858 /**
1859 * Declaration of the specialization of above function for 2d, 3sd. Does
1860 * nothing.
1861 */
1862 unsigned int
1863 write_ucd_lines(const Triangulation<2, 3> &tria,
1864 const unsigned int next_element_index,
1865 std::ostream &out) const;
1866
1867
1868 /**
1869 * Return the number of faces in the triangulation which have a boundary
1870 * indicator not equal to zero. Only these faces are explicitly printed in
1871 * the <tt>write_*</tt> functions; all faces with indicator
1872 * numbers::internal_face_boundary_id are interior ones and an indicator
1873 * with value zero for faces at the boundary are considered default.
1874 *
1875 * This function always returns an empty list in one dimension.
1876 *
1877 * The reason for this function is the same as for write_ucd_faces(). See
1878 * there for more information.
1879 */
1880 template <int dim, int spacedim>
1881 unsigned int
1882 n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
1883
1884 /**
1885 * Declaration of the specialization of above function for 1d. Simply
1886 * returns zero.
1887 */
1888 unsigned int
1889 n_boundary_faces(const Triangulation<1, 1> &tria) const;
1890
1891 /**
1892 * Declaration of the specialization of above function for 1d, 2sd. Simply
1893 * returns zero.
1894 */
1895 unsigned int
1896 n_boundary_faces(const Triangulation<1, 2> &tria) const;
1897
1898 /**
1899 * Declaration of the specialization of above function for 1d, 3sd. Simply
1900 * returns zero.
1901 */
1902 unsigned int
1903 n_boundary_faces(const Triangulation<1, 3> &tria) const;
1904
1905 /**
1906 * Return the number of lines in the triangulation which have a boundary
1907 * indicator not equal to zero. Only these lines are explicitly printed in
1908 * the <tt>write_*</tt> functions; all lines with indicator
1909 * numbers::internal_face_boundary_id are interior ones and an indicator
1910 * with value zero for faces at the boundary are considered default.
1911 *
1912 * This function always returns an empty list in one and two dimensions.
1913 *
1914 * The reason for this function is the same as for write_ucd_faces(). See
1915 * there for more information.
1916 */
1917 template <int dim, int spacedim>
1918 unsigned int
1919 n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
1920
1921 /**
1922 * Declaration of the specialization of above function for 1d. Simply
1923 * returns zero.
1924 */
1925 unsigned int
1926 n_boundary_lines(const Triangulation<1, 1> &tria) const;
1927
1928 /**
1929 * Declaration of the specialization of above function for 1d, 2sd. Simply
1930 * returns zero.
1931 */
1932 unsigned int
1933 n_boundary_lines(const Triangulation<1, 2> &tria) const;
1934
1935 /**
1936 * Declaration of the specialization of above function for 1d, 3sd. Simply
1937 * returns zero.
1938 */
1939 unsigned int
1940 n_boundary_lines(const Triangulation<1, 3> &tria) const;
1941
1942 /**
1943 * Declaration of the specialization of above function for 2d. Simply
1944 * returns zero.
1945 */
1946 unsigned int
1947 n_boundary_lines(const Triangulation<2, 2> &tria) const;
1948 /**
1949 * Declaration of the specialization of above function for 2d, 3sd. Simply
1950 * returns zero.
1951 */
1952 unsigned int
1953 n_boundary_lines(const Triangulation<2, 3> &tria) const;
1954 };
1955
1956
1957
1958 DEAL_II_NAMESPACE_CLOSE
1959
1960 #endif