Reference documentation for deal.II version 8.4.2
grid_out.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #include <deal.II/grid/grid_out.h>
17 #include <deal.II/base/parameter_handler.h>
18 #include <deal.II/base/exceptions.h>
19 #include <deal.II/base/point.h>
20 #include <deal.II/base/quadrature.h>
21 #include <deal.II/base/qprojector.h>
22 #include <deal.II/grid/tria.h>
23 #include <deal.II/grid/tria_accessor.h>
24 #include <deal.II/grid/tria_iterator.h>
25 #include <deal.II/fe/mapping.h>
26 
27 #include <cstring>
28 #include <iomanip>
29 #include <algorithm>
30 #include <list>
31 #include <set>
32 #include <ctime>
33 #include <cmath>
34 
35 
36 DEAL_II_NAMESPACE_OPEN
37 
38 
39 namespace GridOutFlags
40 {
41  DX::DX (const bool write_cells,
42  const bool write_faces,
43  const bool write_diameter,
44  const bool write_measure,
45  const bool write_all_faces) :
46  write_cells (write_cells),
47  write_faces (write_faces),
48  write_diameter (write_diameter),
49  write_measure (write_measure),
50  write_all_faces (write_all_faces)
51  {}
52 
54  {
55  param.declare_entry("Write cells", "true", Patterns::Bool(),
56  "Write the mesh connectivity as DX grid cells");
57  param.declare_entry("Write faces", "false", Patterns::Bool(),
58  "Write faces of cells. These may be boundary faces "
59  "or all faces between mesh cells, according to "
60  "\"Write all faces\"");
61  param.declare_entry("Write diameter", "false", Patterns::Bool(),
62  "If cells are written, additionally write their"
63  " diameter as data for visualization");
64  param.declare_entry("Write measure", "false", Patterns::Bool(),
65  "Write the volume of each cell as data");
66  param.declare_entry("Write all faces", "true", Patterns::Bool(),
67  "Write all faces, not only boundary");
68  }
69 
71  {
72  write_cells = param.get_bool("Write cells");
73  write_faces = param.get_bool("Write faces");
74  write_diameter = param.get_bool("Write diameter");
75  write_measure = param.get_bool("Write measure");
76  write_all_faces = param.get_bool("Write all faces");
77  }
78 
79 
80  Msh::Msh (const bool write_faces,
81  const bool write_lines) :
82  write_faces (write_faces),
83  write_lines (write_lines)
84  {}
85 
87  {
88  param.declare_entry("Write faces", "false", Patterns::Bool());
89  param.declare_entry("Write lines", "false", Patterns::Bool());
90  }
91 
92 
94  {
95  write_faces = param.get_bool("Write faces");
96  write_lines = param.get_bool("Write lines");
97  }
98 
99 
100  Ucd::Ucd (const bool write_preamble,
101  const bool write_faces,
102  const bool write_lines) :
103  write_preamble (write_preamble),
104  write_faces (write_faces),
105  write_lines (write_lines)
106  {}
107 
108 
109 
111  {
112  param.declare_entry("Write preamble", "true", Patterns::Bool());
113  param.declare_entry("Write faces", "false", Patterns::Bool());
114  param.declare_entry("Write lines", "false", Patterns::Bool());
115  }
116 
117 
119  {
120  write_preamble = param.get_bool("Write preamble");
121  write_faces = param.get_bool("Write faces");
122  write_lines = param.get_bool("Write lines");
123  }
124 
125 
126  Gnuplot::Gnuplot (const bool write_cell_numbers,
127  const unsigned int n_boundary_face_points,
128  const bool curved_inner_cells) :
129  write_cell_numbers (write_cell_numbers),
130  n_boundary_face_points(n_boundary_face_points),
131  curved_inner_cells(curved_inner_cells)
132  {}
133 
134 
135 
137  {
138  param.declare_entry("Cell number", "false", Patterns::Bool());
139  param.declare_entry("Boundary points", "2", Patterns::Integer());
140  }
141 
142 
144  {
145  write_cell_numbers = param.get_bool("Cell number");
146  n_boundary_face_points = param.get_integer("Boundary points");
147  }
148 
149 
151  const unsigned int size,
152  const double line_width,
153  const bool color_lines_on_user_flag,
154  const unsigned int n_boundary_face_points,
155  const bool color_lines_level) :
156  size_type (size_type),
157  size (size),
158  line_width (line_width),
159  color_lines_on_user_flag(color_lines_on_user_flag),
160  n_boundary_face_points(n_boundary_face_points),
161  color_lines_level(color_lines_level)
162  {}
163 
164 
166  {
167  param.declare_entry("Size by", "width",
168  Patterns::Selection("width|height"),
169  "Depending on this parameter, either the"
170  "width or height "
171  "of the eps is scaled to \"Size\"");
172  param.declare_entry("Size", "300", Patterns::Integer(),
173  "Size of the output in points");
174  param.declare_entry("Line width", "0.5", Patterns::Double(),
175  "Width of the lines drawn in points");
176  param.declare_entry("Color by flag", "false", Patterns::Bool(),
177  "Draw lines with user flag set in different color");
178  param.declare_entry("Boundary points", "2", Patterns::Integer(),
179  "Number of points on boundary edges. "
180  "Increase this beyond 2 to see curved boundaries.");
181  param.declare_entry("Color by level", "false", Patterns::Bool(),
182  "Draw different colors according to grid level.");
183  }
184 
185 
187  {
188  if (param.get("Size by") == std::string("width"))
189  size_type = width;
190  else if (param.get("Size by") == std::string("height"))
191  size_type = height;
192  size = param.get_integer("Size");
193  line_width = param.get_double("Line width");
194  color_lines_on_user_flag = param.get_bool("Color by flag");
195  n_boundary_face_points = param.get_integer("Boundary points");
196  color_lines_level = param.get_bool("Color by level");
197  }
198 
199 
200 
202  const unsigned int size,
203  const double line_width,
204  const bool color_lines_on_user_flag,
205  const unsigned int n_boundary_face_points)
206  :
207  EpsFlagsBase(size_type, size, line_width,
208  color_lines_on_user_flag,
209  n_boundary_face_points)
210  {}
211 
212 
214  {}
215 
216 
218  {
220  }
221 
222 
223 
224  Eps<2>::Eps (const SizeType size_type,
225  const unsigned int size,
226  const double line_width,
227  const bool color_lines_on_user_flag,
228  const unsigned int n_boundary_face_points,
229  const bool write_cell_numbers,
230  const bool write_cell_number_level,
231  const bool write_vertex_numbers,
232  const bool color_lines_level
233  )
234  :
235  EpsFlagsBase(size_type, size, line_width,
236  color_lines_on_user_flag,
237  n_boundary_face_points,
238  color_lines_level),
239  write_cell_numbers (write_cell_numbers),
240  write_cell_number_level (write_cell_number_level),
241  write_vertex_numbers (write_vertex_numbers)
242  {}
243 
244 
246  {
247  param.declare_entry("Cell number", "false", Patterns::Bool(),
248  "(2D only) Write cell numbers"
249  " into the centers of cells");
250  param.declare_entry("Level number", "false", Patterns::Bool(),
251  "(2D only) if \"Cell number\" is true, write"
252  "numbers in the form level.number");
253  param.declare_entry("Vertex number", "false", Patterns::Bool(),
254  "Write numbers for each vertex");
255  }
256 
257 
259  {
261  write_cell_numbers = param.get_bool("Cell number");
262  write_cell_number_level = param.get_bool("Level number");
263  write_vertex_numbers = param.get_bool("Vertex number");
264  }
265 
266 
267 
268  Eps<3>::Eps (const SizeType size_type,
269  const unsigned int size,
270  const double line_width,
271  const bool color_lines_on_user_flag,
272  const unsigned int n_boundary_face_points,
273  const double azimut_angle,
274  const double turn_angle)
275  :
276  EpsFlagsBase(size_type, size, line_width,
277  color_lines_on_user_flag,
278  n_boundary_face_points),
279  azimut_angle (azimut_angle),
280  turn_angle (turn_angle)
281  {}
282 
283 
285  {
286  param.declare_entry("Azimuth", "30", Patterns::Double(),
287  "Azimuth of the viw point, that is, the angle "
288  "in the plane from the x-axis.");
289  param.declare_entry("Elevation", "30", Patterns::Double(),
290  "Elevation of the view point above the xy-plane.");
291  }
292 
293 
295  {
297  azimut_angle = 90- param.get_double("Elevation");
298  turn_angle = param.get_double("Azimuth");
299  }
300 
301 
302 
304  :
305  draw_boundary(true),
306  color_by(material_id),
307  level_depth(true),
308  n_boundary_face_points(0),
309  scaling(1.,1.),
310  fill_style (20),
311  line_style(0),
312  line_thickness(1),
313  boundary_style(0),
314  boundary_thickness(3)
315  {}
316 
317 
319  {
320  param.declare_entry("Boundary", "true", Patterns::Bool());
321  param.declare_entry("Level color", "false", Patterns::Bool());
322  param.declare_entry("Level depth", "true", Patterns::Bool());
323 //TODO: Unify this number with other output formats
324  param.declare_entry("Boundary points", "0", Patterns::Integer());
325  param.declare_entry("Fill style", "20", Patterns::Integer());
326  param.declare_entry("Line style", "0", Patterns::Integer());
327  param.declare_entry("Line width", "1", Patterns::Integer());
328  param.declare_entry("Boundary style", "0", Patterns::Integer());
329  param.declare_entry("Boundary width", "3", Patterns::Integer());
330  }
331 
332 
334  {
335  draw_boundary = param.get_bool("Boundary");
336  level_depth = param.get_bool("Level depth");
337  n_boundary_face_points = param.get_integer("Boundary points");
338  fill_style = param.get_integer("Fill style");
339  line_style = param.get_integer("Line style");
340  line_thickness = param.get_integer("Line width");
341  boundary_style = param.get_integer("Boundary style");
342  boundary_thickness = param.get_integer("Boundary width");
343  }
344 
345  Svg::Svg(const unsigned int line_thickness,
346  const unsigned int boundary_line_thickness,
347  bool margin,
348  const Background background,
349  const int azimuth_angle,
350  const int polar_angle,
351  const Coloring coloring,
352  const bool convert_level_number_to_height,
353  const bool label_level_number,
354  const bool label_cell_index,
355  const bool label_material_id,
356  const bool label_subdomain_id,
357  const bool draw_colorbar,
358  const bool draw_legend)
359  :
360  height(1000),
361  width(0),
362  line_thickness(line_thickness),
363  boundary_line_thickness(boundary_line_thickness),
364  margin(margin),
365  background(background),
366  azimuth_angle(azimuth_angle),
367  polar_angle(polar_angle),
368  coloring(coloring),
369  convert_level_number_to_height(convert_level_number_to_height),
370  level_height_factor(0.3f),
371  cell_font_scaling(1.f),
372  label_level_number(label_level_number),
373  label_cell_index(label_cell_index),
374  label_material_id(label_material_id),
375  label_subdomain_id(label_subdomain_id),
376  label_level_subdomain_id(false),
377  draw_colorbar(draw_colorbar),
378  draw_legend(draw_legend)
379  {}
380 
382  :
383  draw_bounding_box (false) // box
384  {}
385 
387  {
388  param.declare_entry ("Draw bounding box", "false", Patterns::Bool ());
389  }
390 
392  {
393  draw_bounding_box = param.get_bool ("Draw bounding box");
394  }
395 } // end namespace GridOutFlags
396 
397 
398 
400  :
401  default_format (none)
402 {}
403 
404 
406 {
407  dx_flags = flags;
408 }
409 
410 
411 
413 {
414  msh_flags = flags;
415 }
416 
417 
419 {
420  ucd_flags = flags;
421 }
422 
423 
424 
426 {
427  gnuplot_flags = flags;
428 }
429 
430 
431 
433 {
434  eps_flags_1 = flags;
435 }
436 
437 
438 
440 {
441  eps_flags_2 = flags;
442 }
443 
444 
445 
447 {
448  eps_flags_3 = flags;
449 }
450 
451 
452 
454 {
455  xfig_flags = flags;
456 }
457 
458 
460 {
461  svg_flags = flags;
462 }
463 
464 
466 {
467  mathgl_flags = flags;
468 }
469 
471 {
472  vtk_flags = flags;
473 }
474 
476 {
477  vtu_flags = flags;
478 }
479 
480 std::string
482 {
483  switch (output_format)
484  {
485  case none:
486  return "";
487  case dx:
488  return ".dx";
489  case gnuplot:
490  return ".gnuplot";
491  case ucd:
492  return ".inp";
493  case eps:
494  return ".eps";
495  case xfig:
496  return ".fig";
497  case msh:
498  return ".msh";
499  case svg:
500  return ".svg";
501  case mathgl:
502  return ".mathgl";
503  case vtk:
504  return ".vtk";
505  case vtu:
506  return ".vtu";
507  default:
508  Assert (false, ExcNotImplemented());
509  return "";
510  }
511 }
512 
513 
514 
515 std::string
517 {
519 }
520 
521 
522 
524 GridOut::parse_output_format (const std::string &format_name)
525 {
526  if (format_name == "none" || format_name == "false")
527  return none;
528 
529  if (format_name == "dx")
530  return dx;
531 
532  if (format_name == "ucd")
533  return ucd;
534 
535  if (format_name == "gnuplot")
536  return gnuplot;
537 
538  if (format_name == "eps")
539  return eps;
540 
541  if (format_name == "xfig")
542  return xfig;
543 
544  if (format_name == "msh")
545  return msh;
546 
547  if (format_name == "svg")
548  return svg;
549 
550  if (format_name == "mathgl")
551  return mathgl;
552 
553  if (format_name == "vtk")
554  return vtk;
555 
556  if (format_name == "vtu")
557  return vtu;
558 
559  AssertThrow (false, ExcInvalidState ());
560  // return something weird
561  return OutputFormat(-1);
562 }
563 
564 
565 
567 {
568  return "none|dx|gnuplot|eps|ucd|xfig|msh|svg|mathgl|vtk|vtu";
569 }
570 
571 
572 void
574 {
575  param.declare_entry("Format", "none",
577 
578  param.enter_subsection("DX");
580  param.leave_subsection();
581 
582  param.enter_subsection("Msh");
584  param.leave_subsection();
585 
586  param.enter_subsection("Ucd");
588  param.leave_subsection();
589 
590  param.enter_subsection("Gnuplot");
592  param.leave_subsection();
593 
594  param.enter_subsection("Eps");
599  param.leave_subsection();
600 
601  param.enter_subsection("XFig");
603  param.leave_subsection();
604 
605  param.enter_subsection("MathGL");
607  param.leave_subsection();
608 
609  param.enter_subsection("Vtk");
611  param.leave_subsection();
612 
613  param.enter_subsection("Vtu");
615  param.leave_subsection();
616 }
617 
618 
619 
620 void
622 {
623  default_format = parse_output_format(param.get("Format"));
624 
625  param.enter_subsection("DX");
626  dx_flags.parse_parameters(param);
627  param.leave_subsection();
628 
629  param.enter_subsection("Msh");
631  param.leave_subsection();
632 
633  param.enter_subsection("Ucd");
635  param.leave_subsection();
636 
637  param.enter_subsection("Gnuplot");
639  param.leave_subsection();
640 
641  param.enter_subsection("Eps");
645  param.leave_subsection();
646 
647  param.enter_subsection("XFig");
649  param.leave_subsection();
650 
651  param.enter_subsection("MathGL");
653  param.leave_subsection();
654 
655  param.enter_subsection("Vtk");
657  param.leave_subsection();
658 
659  param.enter_subsection("Vtu");
661  param.leave_subsection();
662 }
663 
664 
665 
666 std::size_t
668 {
669  return (sizeof(dx_flags) +
670  sizeof(msh_flags) +
671  sizeof(ucd_flags) +
672  sizeof(gnuplot_flags) +
673  sizeof(eps_flags_1) +
674  sizeof(eps_flags_2) +
675  sizeof(eps_flags_3) +
676  sizeof(xfig_flags) +
677  sizeof(svg_flags) +
678  sizeof(mathgl_flags) +
679  sizeof(vtk_flags) +
680  sizeof(vtu_flags));
681 }
682 
683 
684 
685 template <>
686 void GridOut::write_dx (const Triangulation<1> &,
687  std::ostream &) const
688 {
689  Assert (false, ExcNotImplemented());
690 }
691 
692 template <>
694  std::ostream &) const
695 {
696  Assert (false, ExcNotImplemented());
697 }
698 
699 template <>
701  std::ostream &) const
702 {
703  Assert (false, ExcNotImplemented());
704 }
705 
706 
707 
708 template <int dim, int spacedim>
710  std::ostream &out) const
711 {
712 //TODO:[GK] allow for boundary faces only
713  Assert(dx_flags.write_all_faces, ExcNotImplemented());
714  AssertThrow (out, ExcIO());
715  // Copied and adapted from write_ucd
716  const std::vector<Point<spacedim> > &vertices = tria.get_vertices();
717  const std::vector<bool> &vertex_used = tria.get_used_vertices();
718 
719  const unsigned int n_vertices = tria.n_used_vertices();
720 
721  // vertices are implicitly numbered from 0 to
722  // n_vertices-1. we have to renumber the
723  // vertices, because otherwise we would end
724  // up with wrong results, if there are unused
725  // vertices
726  std::vector<unsigned int> renumber(vertices.size());
727  // fill this vector with new vertex numbers
728  // ranging from 0 to n_vertices-1
729  unsigned int new_number=0;
730  for (unsigned int i=0; i<vertices.size(); ++i)
731  if (vertex_used[i])
732  renumber[i]=new_number++;
733  Assert(new_number==n_vertices, ExcInternalError());
734 
736  const typename Triangulation<dim, spacedim>::active_cell_iterator endc=tria.end();
737 
738 
739  // write the vertices
740  out << "object \"vertices\" class array type float rank 1 shape " << dim
741  << " items " << n_vertices << " data follows"
742  << '\n';
743 
744  for (unsigned int i=0; i<vertices.size(); ++i)
745  if (vertex_used[i])
746  out << '\t' << vertices[i] << '\n';
747 
748  // write cells or faces
749  const bool write_cells = dx_flags.write_cells;
750  const bool write_faces = (dim>1) ? dx_flags.write_faces : false;
751 
752  const unsigned int n_cells = tria.n_active_cells();
753  const unsigned int n_faces = tria.n_active_cells()
755 
756  const unsigned int n_vertices_per_cell = GeometryInfo<dim>::vertices_per_cell;
757  const unsigned int n_vertices_per_face = GeometryInfo<dim>::vertices_per_face;
758 
759  if (write_cells)
760  {
761  out << "object \"cells\" class array type int rank 1 shape "
762  << n_vertices_per_cell
763  << " items " << n_cells << " data follows" << '\n';
764 
765  for (cell = tria.begin_active(); cell != endc; ++cell)
766  {
767  for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
768  out << '\t' << renumber[cell->vertex_index(GeometryInfo<dim>::dx_to_deal[v])];
769  out << '\n';
770  }
771  out << "attribute \"element type\" string \"";
772  if (dim==1) out << "lines";
773  if (dim==2) out << "quads";
774  if (dim==3) out << "cubes";
775  out << "\"" << '\n'
776  << "attribute \"ref\" string \"positions\"" << '\n' << '\n';
777 
778  // Additional cell information
779 
780  out << "object \"material\" class array type int rank 0 items "
781  << n_cells << " data follows" << '\n';
782  for (cell = tria.begin_active(); cell != endc; ++cell)
783  out << ' ' << (unsigned int)cell->material_id();
784  out << '\n'
785  << "attribute \"dep\" string \"connections\"" << '\n' << '\n';
786 
787  out << "object \"level\" class array type int rank 0 items "
788  << n_cells << " data follows" << '\n';
789  for (cell = tria.begin_active(); cell != endc; ++cell)
790  out << ' ' << cell->level();
791  out << '\n'
792  << "attribute \"dep\" string \"connections\"" << '\n' << '\n';
793 
795  {
796  out << "object \"measure\" class array type float rank 0 items "
797  << n_cells << " data follows" << '\n';
798  for (cell = tria.begin_active(); cell != endc; ++cell)
799  out << '\t' << cell->measure();
800  out << '\n'
801  << "attribute \"dep\" string \"connections\"" << '\n' << '\n';
802  }
803 
805  {
806  out << "object \"diameter\" class array type float rank 0 items "
807  << n_cells << " data follows" << '\n';
808  for (cell = tria.begin_active(); cell != endc; ++cell)
809  out << '\t' << cell->diameter();
810  out << '\n'
811  << "attribute \"dep\" string \"connections\"" << '\n' << '\n';
812  }
813  }
814 
815  if (write_faces)
816  {
817  out << "object \"faces\" class array type int rank 1 shape "
818  << n_vertices_per_face
819  << " items " << n_faces << " data follows"
820  << '\n';
821 
822  for (cell = tria.begin_active(); cell != endc; ++cell)
823  {
824  for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
825  {
826  typename Triangulation<dim, spacedim>::face_iterator face = cell->face(f);
827 
828  for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
829  out << '\t' << renumber[face->vertex_index(GeometryInfo<dim-1>::dx_to_deal[v])];
830  out << '\n';
831  }
832  }
833  out << "attribute \"element type\" string \"";
834  if (dim==2) out << "lines";
835  if (dim==3) out << "quads";
836  out << "\"" << '\n'
837  << "attribute \"ref\" string \"positions\"" << '\n' << '\n';
838 
839 
840  // Additional face information
841 
842  out << "object \"boundary\" class array type int rank 0 items "
843  << n_faces << " data follows" << '\n';
844  for (cell = tria.begin_active(); cell != endc; ++cell)
845  {
846  // Little trick to get -1
847  // for the interior
848  for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
849  out << ' ' << (int)(signed char)cell->face(f)->boundary_id();
850  out << '\n';
851  }
852  out << "attribute \"dep\" string \"connections\"" << '\n' << '\n';
853 
855  {
856  out << "object \"face measure\" class array type float rank 0 items "
857  << n_faces << " data follows" << '\n';
858  for (cell = tria.begin_active(); cell != endc; ++cell)
859  {
860  for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
861  out << ' ' << cell->face(f)->measure();
862  out << '\n';
863  }
864  out << "attribute \"dep\" string \"connections\"" << '\n' << '\n';
865  }
866 
868  {
869  out << "object \"face diameter\" class array type float rank 0 items "
870  << n_faces << " data follows" << '\n';
871  for (cell = tria.begin_active(); cell != endc; ++cell)
872  {
873  for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
874  out << ' ' << cell->face(f)->diameter();
875  out << '\n';
876  }
877  out << "attribute \"dep\" string \"connections\"" << '\n' << '\n';
878  }
879 
880  }
881 
882 
883  // Write additional face information
884 
885  if (write_faces)
886  {
887 
888  }
889  else
890  {
891  }
892 
893  // The wrapper
894  out << "object \"deal data\" class field" << '\n'
895  << "component \"positions\" value \"vertices\"" << '\n'
896  << "component \"connections\" value \"cells\"" << '\n';
897 
898  if (write_cells)
899  {
900  out << "object \"cell data\" class field" << '\n'
901  << "component \"positions\" value \"vertices\"" << '\n'
902  << "component \"connections\" value \"cells\"" << '\n';
903  out << "component \"material\" value \"material\"" << '\n';
904  out << "component \"level\" value \"level\"" << '\n';
906  out << "component \"measure\" value \"measure\"" << '\n';
908  out << "component \"diameter\" value \"diameter\"" << '\n';
909  }
910 
911  if (write_faces)
912  {
913  out << "object \"face data\" class field" << '\n'
914  << "component \"positions\" value \"vertices\"" << '\n'
915  << "component \"connections\" value \"faces\"" << '\n';
916  out << "component \"boundary\" value \"boundary\"" << '\n';
918  out << "component \"measure\" value \"face measure\"" << '\n';
920  out << "component \"diameter\" value \"face diameter\"" << '\n';
921  }
922 
923  out << '\n'
924  << "object \"grid data\" class group" << '\n';
925  if (write_cells)
926  out << "member \"cells\" value \"cell data\"" << '\n';
927  if (write_faces)
928  out << "member \"faces\" value \"face data\"" << '\n';
929  out << "end" << '\n';
930 
931  // make sure everything now gets to
932  // disk
933  out.flush ();
934 
935  AssertThrow (out, ExcIO());
936 }
937 
938 
939 
940 
941 template <int dim, int spacedim>
943  std::ostream &out) const
944 {
945  AssertThrow (out, ExcIO());
946 
947  // get the positions of the
948  // vertices and whether they are
949  // used.
950  const std::vector<Point<spacedim> > &vertices = tria.get_vertices();
951  const std::vector<bool> &vertex_used = tria.get_used_vertices();
952 
953  const unsigned int n_vertices = tria.n_used_vertices();
954 
956  const typename Triangulation<dim,spacedim>::active_cell_iterator endc=tria.end();
957 
958  // Write Header
959  // The file format is:
960  /*
961 
962 
963  @f$NOD
964  number-of-nodes
965  node-number x-coord y-coord z-coord
966  ...
967  @f$ENDNOD
968  @f$ELM
969  number-of-elements
970  elm-number elm-type reg-phys reg-elem number-of-nodes node-number-list
971  ...
972  @f$ENDELM
973  */
974  out << "@f$NOD" << '\n'
975  << n_vertices << '\n';
976 
977  // actually write the vertices.
978  // note that we shall number them
979  // with first index 1 instead of 0
980  for (unsigned int i=0; i<vertices.size(); ++i)
981  if (vertex_used[i])
982  {
983  out << i+1 // vertex index
984  << " "
985  << vertices[i];
986  for (unsigned int d=spacedim+1; d<=3; ++d)
987  out << " 0"; // fill with zeroes
988  out << '\n';
989  }
990 
991  // Write cells preamble
992  out << "@f$ENDNOD" << '\n'
993  << "@f$ELM" << '\n'
994  << tria.n_active_cells() + ((msh_flags.write_faces ?
995  n_boundary_faces(tria) : 0) +
997  n_boundary_lines(tria) : 0)) << '\n';
998 
999  /*
1000  elm-type
1001  defines the geometrical type of the n-th element:
1002  1
1003  Line (2 nodes).
1004  2
1005  Triangle (3 nodes).
1006  3
1007  Quadrangle (4 nodes).
1008  4
1009  Tetrahedron (4 nodes).
1010  5
1011  Hexahedron (8 nodes).
1012  6
1013  Prism (6 nodes).
1014  7
1015  Pyramid (5 nodes).
1016  8
1017  Second order line (3 nodes: 2 associated with the vertices and 1 with the edge).
1018  9
1019  Second order triangle (6 nodes: 3 associated with the vertices and 3 with the edges).
1020  10
1021  Second order quadrangle (9 nodes: 4 associated with the vertices, 4 with the edges and 1 with the face).
1022  11
1023  Second order tetrahedron (10 nodes: 4 associated with the vertices and 6 with the edges).
1024  12
1025  Second order hexahedron (27 nodes: 8 associated with the vertices, 12 with the edges, 6 with the faces and 1 with the volume).
1026  13
1027  Second order prism (18 nodes: 6 associated with the vertices, 9 with the edges and 3 with the quadrangular faces).
1028  14
1029  Second order pyramid (14 nodes: 5 associated with the vertices, 8 with the edges and 1 with the quadrangular face).
1030  15
1031  Point (1 node).
1032  */
1033  unsigned int elm_type;
1034  switch (dim)
1035  {
1036  case 1:
1037  elm_type = 1;
1038  break;
1039  case 2:
1040  elm_type = 3;
1041  break;
1042  case 3:
1043  elm_type = 5;
1044  break;
1045  default:
1046  Assert(false, ExcNotImplemented());
1047  }
1048 
1049  // write cells. Enumerate cells
1050  // consecutively, starting with 1
1051  for (cell=tria.begin_active(); cell!=endc; ++cell)
1052  {
1053  out << cell->active_cell_index()+1 << ' ' << elm_type << ' '
1054  << static_cast<unsigned int>(cell->material_id()) << ' '
1055  << cell->subdomain_id() << ' '
1057 
1058  // Vertex numbering follows UCD conventions.
1059 
1060  for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
1061  ++vertex)
1062  out << cell->vertex_index(GeometryInfo<dim>::ucd_to_deal[vertex])+1 << ' ';
1063  out << '\n';
1064  }
1065 
1066  // write faces and lines with non-zero boundary indicator
1067  unsigned int next_element_index = tria.n_active_cells()+1;
1068  if (msh_flags.write_faces)
1069  {
1070  next_element_index = write_msh_faces (tria, next_element_index, out);
1071  }
1072  if (msh_flags.write_lines)
1073  {
1074  next_element_index = write_msh_lines (tria, next_element_index, out);
1075  }
1076 
1077  out << "@f$ENDELM\n";
1078 
1079  // make sure everything now gets to
1080  // disk
1081  out.flush ();
1082 
1083  AssertThrow (out, ExcIO());
1084 }
1085 
1086 
1087 template <int dim, int spacedim>
1089  std::ostream &out) const
1090 {
1091  AssertThrow (out, ExcIO());
1092 
1093  // get the positions of the
1094  // vertices and whether they are
1095  // used.
1096  const std::vector<Point<spacedim> > &vertices = tria.get_vertices();
1097  const std::vector<bool> &vertex_used = tria.get_used_vertices();
1098 
1099  const unsigned int n_vertices = tria.n_used_vertices();
1100 
1102  const typename Triangulation<dim,spacedim>::active_cell_iterator endc=tria.end();
1103 
1104  // write preamble
1106  {
1107  // block this to have local
1108  // variables destroyed after
1109  // use
1110  std::time_t time1= std::time (0);
1111  std::tm *time = std::localtime(&time1);
1112  out << "# This file was generated by the deal.II library." << '\n'
1113  << "# Date = "
1114  << time->tm_year+1900 << "/"
1115  << time->tm_mon+1 << "/"
1116  << time->tm_mday << '\n'
1117  << "# Time = "
1118  << time->tm_hour << ":"
1119  << std::setw(2) << time->tm_min << ":"
1120  << std::setw(2) << time->tm_sec << '\n'
1121  << "#" << '\n'
1122  << "# For a description of the UCD format see the AVS Developer's guide."
1123  << '\n'
1124  << "#" << '\n';
1125  }
1126 
1127  // start with ucd data
1128  out << n_vertices << ' '
1129  << tria.n_active_cells() + ( (ucd_flags.write_faces ?
1130  n_boundary_faces(tria) : 0) +
1132  n_boundary_lines(tria) : 0) )
1133  << " 0 0 0" // no data
1134  << '\n';
1135 
1136  // actually write the vertices.
1137  // note that we shall number them
1138  // with first index 1 instead of 0
1139  for (unsigned int i=0; i<vertices.size(); ++i)
1140  if (vertex_used[i])
1141  {
1142  out << i+1 // vertex index
1143  << " "
1144  << vertices[i];
1145  for (unsigned int d=spacedim+1; d<=3; ++d)
1146  out << " 0"; // fill with zeroes
1147  out << '\n';
1148  }
1149 
1150  // write cells. Enumerate cells
1151  // consecutively, starting with 1
1152  for (cell=tria.begin_active(); cell!=endc; ++cell)
1153  {
1154  out << cell->active_cell_index()+1 << ' '
1155  << static_cast<unsigned int>(cell->material_id())
1156  << ' ';
1157  switch (dim)
1158  {
1159  case 1:
1160  out << "line ";
1161  break;
1162  case 2:
1163  out << "quad ";
1164  break;
1165  case 3:
1166  out << "hex ";
1167  break;
1168  default:
1169  Assert (false, ExcNotImplemented());
1170  }
1171 
1172  // it follows a list of the
1173  // vertices of each cell. in 1d
1174  // this is simply a list of the
1175  // two vertices, in 2d its counter
1176  // clockwise, as usual in this
1177  // library. in 3d, the same applies
1178  // (special thanks to AVS for
1179  // numbering their vertices in a
1180  // way compatible to deal.II!)
1181  //
1182  // technical reference:
1183  // AVS Developer's Guide, Release 4,
1184  // May, 1992, p. E6
1185  //
1186  // note: vertex numbers are 1-base
1187  for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
1188  ++vertex)
1189  out << cell->vertex_index(GeometryInfo<dim>::ucd_to_deal[vertex])+1 << ' ';
1190  out << '\n';
1191  }
1192 
1193  // write faces and lines with non-zero boundary indicator
1194  unsigned int next_element_index = tria.n_active_cells()+1;
1195  if (ucd_flags.write_faces)
1196  {
1197  next_element_index = write_ucd_faces (tria, next_element_index, out);
1198  }
1199  if (ucd_flags.write_lines)
1200  {
1201  next_element_index = write_ucd_lines (tria, next_element_index, out);
1202  }
1203 
1204  // make sure everything now gets to
1205  // disk
1206  out.flush ();
1207 
1208  AssertThrow (out, ExcIO());
1209 }
1210 
1211 
1212 
1213 template <int dim, int spacedim>
1216  std::ostream &,
1217  const Mapping<dim, spacedim> *) const
1218 {
1219  Assert (false, ExcNotImplemented());
1220 }
1221 
1222 
1223 //TODO:[GK] Obey parameters
1224 template <>
1225 void GridOut::write_xfig (
1226  const Triangulation<2> &tria,
1227  std::ostream &out,
1228  const Mapping<2> * /*mapping*/) const
1229 {
1230  const int dim = 2;
1231  const int spacedim = 2;
1232 
1233  const unsigned int nv = GeometryInfo<dim>::vertices_per_cell;
1234  const unsigned int nf = GeometryInfo<dim>::faces_per_cell;
1235  const unsigned int nvf = GeometryInfo<dim>::vertices_per_face;
1236 
1237  // The following text was copied
1238  // from an existing XFig file.
1239  out << "#FIG 3.2\nLandscape\nCenter\nInches" << std::endl
1240  << "A4\n100.00\nSingle" << std::endl
1241  // Background is transparent
1242  << "-3" << std::endl
1243  << "# generated by deal.II GridOut class" << std::endl
1244  << "# reduce first number to scale up image" << std::endl
1245  << "1200 2" << std::endl;
1246  // Write custom palette
1247  //grey
1248  unsigned int colno = 32;
1249  out << "0 " << colno++ << " #ff0000" << std::endl;
1250  out << "0 " << colno++ << " #ff8000" << std::endl;
1251  out << "0 " << colno++ << " #ffd000" << std::endl;
1252  out << "0 " << colno++ << " #ffff00" << std::endl;
1253  out << "0 " << colno++ << " #c0ff00" << std::endl;
1254  out << "0 " << colno++ << " #80ff00" << std::endl;
1255  out << "0 " << colno++ << " #00f000" << std::endl;
1256  out << "0 " << colno++ << " #00f0c0" << std::endl;
1257  out << "0 " << colno++ << " #00f0ff" << std::endl;
1258  out << "0 " << colno++ << " #00c0ff" << std::endl;
1259  out << "0 " << colno++ << " #0080ff" << std::endl;
1260  out << "0 " << colno++ << " #0040ff" << std::endl;
1261  out << "0 " << colno++ << " #0000c0" << std::endl;
1262  out << "0 " << colno++ << " #5000ff" << std::endl;
1263  out << "0 " << colno++ << " #8000ff" << std::endl;
1264  out << "0 " << colno++ << " #b000ff" << std::endl;
1265  out << "0 " << colno++ << " #ff00ff" << std::endl;
1266  out << "0 " << colno++ << " #ff80ff" << std::endl;
1267  // grey
1268  for (unsigned int i=0; i<8; ++i)
1269  out << "0 " << colno++ << " #" << std::hex << 32*i+31 << 32*i+31 << 32*i+31 << std::dec << std::endl;
1270  // green
1271  for (unsigned int i=1; i<16; ++i)
1272  out << "0 " << colno++ << " #00" << std::hex << 16*i+15 << std::dec << "00" << std::endl;
1273  // yellow
1274  for (unsigned int i=1; i<16; ++i)
1275  out << "0 " << colno++ << " #" << std::hex << 16*i+15 << 16*i+15 << std::dec << "00" << std::endl;
1276  // red
1277  for (unsigned int i=1; i<16; ++i)
1278  out << "0 " << colno++ << " #" << std::hex << 16*i+15 << std::dec << "0000" << std::endl;
1279  // purple
1280  for (unsigned int i=1; i<16; ++i)
1281  out << "0 " << colno++ << " #" << std::hex << 16*i+15 << "00" << 16*i+15 << std::dec << std::endl;
1282  // blue
1283  for (unsigned int i=1; i<16; ++i)
1284  out << "0 " << colno++ << " #0000" << std::hex << 16*i+15 << std::dec << std::endl;
1285  // cyan
1286  for (unsigned int i=1; i<16; ++i)
1287  out << "0 " << colno++ << " #00" << std::hex << 16*i+15 << 16*i+15 << std::dec << std::endl;
1288 
1289  // We write all cells and cells on
1290  // coarser levels are behind cells
1291  // on finer levels. Level 0
1292  // corresponds to a depth of 900,
1293  // each level subtracting 1
1296 
1297  for (; cell != end; ++cell)
1298  {
1299  // If depth is not encoded, write finest level only
1300  if (!xfig_flags.level_depth && !cell->active())
1301  continue;
1302  // Code for polygon
1303  out << "2 3 "
1304  << xfig_flags.line_style << ' '
1306  // with black line
1307  << " 0 ";
1308  // Fill color
1309  switch (xfig_flags.color_by)
1310  {
1311 //TODO[GK]: Simplify after deprecation period is over
1313  out << static_cast<unsigned int>(cell->material_id()) + 32;
1314  break;
1316  out << cell->level() + 8;
1317  break;
1319  out << cell->subdomain_id() + 32;
1320  break;
1322  out << cell->level_subdomain_id() + 32;
1323  break;
1324  default:
1325  Assert(false, ExcInternalError());
1326  }
1327 
1328  // Depth, unused, fill
1329  out << ' '
1331  ? (900-cell->level())
1332  : (900+cell->material_id()))
1333  << " 0 "
1334  << xfig_flags.fill_style << " 0.0 "
1335  // some style parameters
1336  << " 0 0 -1 0 0 "
1337  // number of points
1338  << nv+1 << std::endl;
1339 
1340  // For each point, write scaled
1341  // and shifted coordinates
1342  // multiplied by 1200
1343  // (dots/inch)
1344  for (unsigned int k=0; k<=nv; ++k)
1345  {
1346  const Point<dim> &p = cell->vertex(
1348  for (unsigned int d=0; d<static_cast<unsigned int>(dim); ++d)
1349  {
1350  int val = (int)(1200 * xfig_flags.scaling(d) *
1351  (p(d)-xfig_flags.offset(d)));
1352  out << '\t' << ((d==0) ? val : -val);
1353  }
1354  out << std::endl;
1355  }
1356  // Now write boundary edges
1357  static const unsigned int face_reorder[4]= {2,1,3,0};
1359  for (unsigned int f=0; f<nf; ++f)
1360  {
1362  face = cell->face(face_reorder[f]);
1363  const types::boundary_id bi = face->boundary_id();
1365  {
1366  // Code for polyline
1367  out << "2 1 "
1368  // with line style and thickness
1369  << xfig_flags.boundary_style << ' '
1370  << xfig_flags.boundary_thickness << ' '
1371  << (1 + (unsigned int) bi);
1372  // Fill color
1373  out << " -1 ";
1374  // Depth 100 less than cells
1375  out << (xfig_flags.level_depth
1376  ? (800-cell->level())
1377  : 800+bi)
1378  // unused, no fill
1379  << " 0 -1 0.0 "
1380  // some style parameters
1381  << " 0 0 -1 0 0 "
1382  // number of points
1383  << nvf << std::endl;
1384 
1385  // For each point, write scaled
1386  // and shifted coordinates
1387  // multiplied by 1200
1388  // (dots/inch)
1389 
1390  for (unsigned int k=0; k<nvf; ++k)
1391  {
1392  const Point<dim> &p = face->vertex(k % nv);
1393  for (unsigned int d=0; d<static_cast<unsigned int>(dim); ++d)
1394  {
1395  int val = (int)(1200 * xfig_flags.scaling(d) *
1396  (p(d)-xfig_flags.offset(d)));
1397  out << '\t' << ((d==0) ? val : -val);
1398  }
1399  out << std::endl;
1400  }
1401  }
1402  }
1403  }
1404 
1405  // make sure everything now gets to
1406  // disk
1407  out.flush ();
1408 
1409  AssertThrow (out, ExcIO());
1410 }
1411 
1412 
1413 
1414 template <int dim, int spacedim>
1416  std::ostream &/*out*/) const
1417 {
1418  Assert(false, ExcNotImplemented());
1419 }
1420 
1421 
1422 void GridOut::write_svg(const Triangulation<2,2> &tria, std::ostream &out) const
1423 {
1424 
1425  unsigned int n_materials = 0;
1426  unsigned int n_levels = 0;
1427  unsigned int n_subdomains = 0;
1428  unsigned int n_level_subdomains = 0;
1429 
1430  unsigned int n = 0;
1431 
1432  unsigned int min_level, max_level;
1433 
1434  // Svg files require an underlying drawing grid. The size of this
1435  // grid is provided in the parameters height and width. Each of them
1436  // may be zero, such that it is computed from the other. Obviously,
1437  // both of them zero does not produce reasonable output.
1438  unsigned int height = svg_flags.height;
1439  unsigned int width = svg_flags.width;
1440  Assert (height != 0 || width != 0, ExcMessage("You have to set at least one of width and height"));
1441 
1442  unsigned int margin_in_percent = 0;
1443  if (svg_flags.margin || svg_flags.background == GridOutFlags::Svg::dealii)
1444  margin_in_percent = 8;
1445 
1446  // initial font size for cell labels
1447  unsigned int cell_label_font_size;
1448 
1449  // get date and time
1450  // time_t time_stamp;
1451  // tm *now;
1452  // time_stamp = time(0);
1453  // now = localtime(&time_stamp);
1454 
1455  // vectors and variables for the perspective view
1456  Point<3> camera_position;
1457  Point<3> camera_direction;
1458  Point<3> camera_horizontal;
1459  float camera_focus;
1460 
1461  Point<3> point;
1462  Point<2> projection_decomposition;
1463 
1464  float x_max_perspective, x_min_perspective;
1465  float y_max_perspective, y_min_perspective;
1466 
1467  float x_dimension_perspective, y_dimension_perspective;
1468 
1469 
1470  // auxiliary variables for the bounding box and the range of cell levels
1471  double x_min = tria.begin()->vertex(0)[0];
1472  double x_max = tria.begin()->vertex(0)[0];
1473  double y_min = tria.begin()->vertex(0)[1];
1474  double y_max = tria.begin()->vertex(0)[1];
1475 
1476  double x_dimension, y_dimension;
1477 
1478  min_level = max_level = tria.begin()->level();
1479 
1480  // auxiliary array for the materials being used (material ids 255 max.)
1481  unsigned int materials[256];
1482  for (unsigned int material_index = 0; material_index < 256; material_index++)
1483  materials[material_index] = 0;
1484 
1485  // auxiliary array for the levels being used (level number 255 max.)
1486  unsigned int levels[256];
1487  for (unsigned int level_index = 0; level_index < 256; level_index++)
1488  levels[level_index] = 0;
1489 
1490  // auxiliary array for the subdomains being used (subdomain id 255 max.)
1491  unsigned int subdomains[256];
1492  for (unsigned int subdomain_index = 0; subdomain_index < 256; subdomain_index++)
1493  subdomains[subdomain_index] = 0;
1494 
1495  // auxiliary array for the level subdomains being used
1496  int level_subdomains[256];
1497  for (int level_subdomain_index = 0; level_subdomain_index < 256; level_subdomain_index++)
1498  level_subdomains[level_subdomain_index] = 0;
1499 
1500  // We use an active cell iterator to determine the
1501  // bounding box of the given triangulation and check
1502  // the cells for material id, level number, subdomain id
1503  // (, and level subdomain id).
1504  for (Triangulation<2,2>::cell_iterator cell = tria.begin(); cell != tria.end(); ++cell)
1505  {
1506  for (unsigned int vertex_index = 0; vertex_index < 4; vertex_index++)
1507  {
1508  if (cell->vertex(vertex_index)[0] < x_min) x_min = cell->vertex(vertex_index)[0];
1509  if (cell->vertex(vertex_index)[0] > x_max) x_max = cell->vertex(vertex_index)[0];
1510 
1511  if (cell->vertex(vertex_index)[1] < y_min) y_min = cell->vertex(vertex_index)[1];
1512  if (cell->vertex(vertex_index)[1] > y_max) y_max = cell->vertex(vertex_index)[1];
1513  }
1514 
1515  if ((unsigned int)cell->level() < min_level) min_level = cell->level();
1516  if ((unsigned int)cell->level() > max_level) max_level = cell->level();
1517 
1518  materials[(unsigned int)cell->material_id()] = 1;
1519  levels[(unsigned int)cell->level()] = 1;
1520  if (cell->active())
1521  subdomains[cell->subdomain_id()+2] = 1;
1522  level_subdomains[cell->level_subdomain_id()+2] = 1;
1523  }
1524 
1525  x_dimension = x_max - x_min;
1526  y_dimension = y_max - y_min;
1527 
1528  // count the materials being used
1529  for (unsigned int material_index = 0; material_index < 256; material_index++)
1530  {
1531  if (materials[material_index]) n_materials++;
1532  }
1533 
1534  // count the levels being used
1535  for (unsigned int level_index = 0; level_index < 256; level_index++)
1536  {
1537  if (levels[level_index]) n_levels++;
1538  }
1539 
1540  // count the subdomains being used
1541  for (unsigned int subdomain_index = 0; subdomain_index < 256; subdomain_index++)
1542  {
1543  if (subdomains[subdomain_index]) n_subdomains++;
1544  }
1545 
1546  // count the level subdomains being used
1547  for (int level_subdomain_index = 0; level_subdomain_index < 256; level_subdomain_index++)
1548  {
1549  if (level_subdomains[level_subdomain_index]) n_level_subdomains++;
1550  }
1551 
1552  switch (svg_flags.coloring)
1553  {
1555  n = n_materials;
1556  break;
1558  n = n_levels;
1559  break;
1561  n = n_subdomains;
1562  break;
1564  n = n_level_subdomains;
1565  break;
1566  default:
1567  break;
1568  }
1569 
1570  // set the camera position to top view, targeting at the origin
1571  camera_position[0] = 0;
1572  camera_position[1] = 0;
1573  camera_position[2] = 2. * std::max(x_dimension, y_dimension);
1574 
1575  camera_direction[0] = 0;
1576  camera_direction[1] = 0;
1577  camera_direction[2] = -1;
1578 
1579  camera_horizontal[0] = 1;
1580  camera_horizontal[1] = 0;
1581  camera_horizontal[2] = 0;
1582 
1583  camera_focus = .5 * std::max(x_dimension, y_dimension);
1584 
1585  Point<3> camera_position_temp;
1586  Point<3> camera_direction_temp;
1587  Point<3> camera_horizontal_temp;
1588 
1589  const double angle_factor = 3.14159265 / 180.;
1590 
1591  // (I) rotate the camera to the chosen polar angle
1592  camera_position_temp[1] = cos(angle_factor * svg_flags.polar_angle) * camera_position[1] - sin(angle_factor * svg_flags.polar_angle) * camera_position[2];
1593  camera_position_temp[2] = sin(angle_factor * svg_flags.polar_angle) * camera_position[1] + cos(angle_factor * svg_flags.polar_angle) * camera_position[2];
1594 
1595  camera_direction_temp[1] = cos(angle_factor * svg_flags.polar_angle) * camera_direction[1] - sin(angle_factor * svg_flags.polar_angle) * camera_direction[2];
1596  camera_direction_temp[2] = sin(angle_factor * svg_flags.polar_angle) * camera_direction[1] + cos(angle_factor * svg_flags.polar_angle) * camera_direction[2];
1597 
1598  camera_horizontal_temp[1] = cos(angle_factor * svg_flags.polar_angle) * camera_horizontal[1] - sin(angle_factor * svg_flags.polar_angle) * camera_horizontal[2];
1599  camera_horizontal_temp[2] = sin(angle_factor * svg_flags.polar_angle) * camera_horizontal[1] + cos(angle_factor * svg_flags.polar_angle) * camera_horizontal[2];
1600 
1601  camera_position[1] = camera_position_temp[1];
1602  camera_position[2] = camera_position_temp[2];
1603 
1604  camera_direction[1] = camera_direction_temp[1];
1605  camera_direction[2] = camera_direction_temp[2];
1606 
1607  camera_horizontal[1] = camera_horizontal_temp[1];
1608  camera_horizontal[2] = camera_horizontal_temp[2];
1609 
1610  // (II) rotate the camera to the chosen azimuth angle
1611  camera_position_temp[0] = cos(angle_factor * svg_flags.azimuth_angle) * camera_position[0] - sin(angle_factor * svg_flags.azimuth_angle) * camera_position[1];
1612  camera_position_temp[1] = sin(angle_factor * svg_flags.azimuth_angle) * camera_position[0] + cos(angle_factor * svg_flags.azimuth_angle) * camera_position[1];
1613 
1614  camera_direction_temp[0] = cos(angle_factor * svg_flags.azimuth_angle) * camera_direction[0] - sin(angle_factor * svg_flags.azimuth_angle) * camera_direction[1];
1615  camera_direction_temp[1] = sin(angle_factor * svg_flags.azimuth_angle) * camera_direction[0] + cos(angle_factor * svg_flags.azimuth_angle) * camera_direction[1];
1616 
1617  camera_horizontal_temp[0] = cos(angle_factor * svg_flags.azimuth_angle) * camera_horizontal[0] - sin(angle_factor * svg_flags.azimuth_angle) * camera_horizontal[1];
1618  camera_horizontal_temp[1] = sin(angle_factor * svg_flags.azimuth_angle) * camera_horizontal[0] + cos(angle_factor * svg_flags.azimuth_angle) * camera_horizontal[1];
1619 
1620  camera_position[0] = camera_position_temp[0];
1621  camera_position[1] = camera_position_temp[1];
1622 
1623  camera_direction[0] = camera_direction_temp[0];
1624  camera_direction[1] = camera_direction_temp[1];
1625 
1626  camera_horizontal[0] = camera_horizontal_temp[0];
1627  camera_horizontal[1] = camera_horizontal_temp[1];
1628 
1629  // translate the camera to the given triangulation
1630  camera_position[0] = x_min + .5 * x_dimension;
1631  camera_position[1] = y_min + .5 * y_dimension;
1632 
1633  camera_position[0] += 2. * std::max(x_dimension, y_dimension) * sin(angle_factor * svg_flags.polar_angle) * sin(angle_factor * svg_flags.azimuth_angle);
1634  camera_position[1] -= 2. * std::max(x_dimension, y_dimension) * sin(angle_factor * svg_flags.polar_angle) * cos(angle_factor * svg_flags.azimuth_angle);
1635 
1636 
1637  // determine the bounding box of the given triangulation on the projection plane of the camera viewing system
1638  point[0] = tria.begin()->vertex(0)[0];
1639  point[1] = tria.begin()->vertex(0)[1];
1640  point[2] = 0;
1641 
1642  float min_level_min_vertex_distance = 0;
1643 
1645  {
1646  point[2] = svg_flags.level_height_factor * ((float)tria.begin()->level() / (float)n_levels) * std::max(x_dimension, y_dimension);
1647  }
1648 
1649  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1650 
1651  x_max_perspective = projection_decomposition[0];
1652  x_min_perspective = projection_decomposition[0];
1653 
1654  y_max_perspective = projection_decomposition[1];
1655  y_min_perspective = projection_decomposition[1];
1656 
1657  for (Triangulation<2,2>::cell_iterator cell = tria.begin(); cell != tria.end(); ++cell)
1658  {
1659  point[0] = cell->vertex(0)[0];
1660  point[1] = cell->vertex(0)[1];
1661  point[2] = 0;
1662 
1664  {
1665  point[2] = svg_flags.level_height_factor * ((float)cell->level() / (float)n_levels) * std::max(x_dimension, y_dimension);
1666  }
1667 
1668  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1669 
1670  if (x_max_perspective < projection_decomposition[0]) x_max_perspective = projection_decomposition[0];
1671  if (x_min_perspective > projection_decomposition[0]) x_min_perspective = projection_decomposition[0];
1672 
1673  if (y_max_perspective < projection_decomposition[1]) y_max_perspective = projection_decomposition[1];
1674  if (y_min_perspective > projection_decomposition[1]) y_min_perspective = projection_decomposition[1];
1675 
1676  point[0] = cell->vertex(1)[0];
1677  point[1] = cell->vertex(1)[1];
1678 
1679  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1680 
1681  if (x_max_perspective < projection_decomposition[0]) x_max_perspective = projection_decomposition[0];
1682  if (x_min_perspective > projection_decomposition[0]) x_min_perspective = projection_decomposition[0];
1683 
1684  if (y_max_perspective < projection_decomposition[1]) y_max_perspective = projection_decomposition[1];
1685  if (y_min_perspective > projection_decomposition[1]) y_min_perspective = projection_decomposition[1];
1686 
1687  point[0] = cell->vertex(2)[0];
1688  point[1] = cell->vertex(2)[1];
1689 
1690  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1691 
1692  if (x_max_perspective < projection_decomposition[0]) x_max_perspective = projection_decomposition[0];
1693  if (x_min_perspective > projection_decomposition[0]) x_min_perspective = projection_decomposition[0];
1694 
1695  if (y_max_perspective < projection_decomposition[1]) y_max_perspective = projection_decomposition[1];
1696  if (y_min_perspective > projection_decomposition[1]) y_min_perspective = projection_decomposition[1];
1697 
1698  point[0] = cell->vertex(3)[0];
1699  point[1] = cell->vertex(3)[1];
1700 
1701  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1702 
1703  if (x_max_perspective < projection_decomposition[0]) x_max_perspective = projection_decomposition[0];
1704  if (x_min_perspective > projection_decomposition[0]) x_min_perspective = projection_decomposition[0];
1705 
1706  if (y_max_perspective < projection_decomposition[1]) y_max_perspective = projection_decomposition[1];
1707  if (y_min_perspective > projection_decomposition[1]) y_min_perspective = projection_decomposition[1];
1708 
1709  if ((unsigned int)cell->level() == min_level) min_level_min_vertex_distance = cell->minimum_vertex_distance();
1710  }
1711 
1712  x_dimension_perspective = x_max_perspective - x_min_perspective;
1713  y_dimension_perspective = y_max_perspective - y_min_perspective;
1714 
1715 // create the svg file with an internal style sheet
1716  if (width == 0)
1717  width = static_cast<unsigned int>(.5 + height * (x_dimension_perspective / y_dimension_perspective));
1718  else if (height == 0)
1719  height = static_cast<unsigned int>(.5 + width * (y_dimension_perspective / x_dimension_perspective));
1720  unsigned int additional_width = 0;
1721  // font size for date, time, legend, and colorbar
1722  unsigned int font_size = static_cast<unsigned int>(.5 + (height/100.) * 1.75);
1723  cell_label_font_size = static_cast<unsigned int>(.5 +
1724  (height * .15
1726  * min_level_min_vertex_distance
1727  / std::min(x_dimension, y_dimension)));
1728 
1730  {
1731  additional_width = static_cast<unsigned int>(.5 + height * .4); // additional width for legend
1732  }
1733  else if (svg_flags.draw_colorbar && svg_flags.coloring)
1734  {
1735  additional_width = static_cast<unsigned int>(.5 + height * .175); // additional width for colorbar
1736  }
1737 
1738  //out << "<!-- deal.ii GridOut " << now->tm_mday << '/' << now->tm_mon + 1 << '/' << now->tm_year + 1900
1739  // << ' ' << now->tm_hour << ':';
1740  //
1741  //if (now->tm_min < 10) out << '0';
1742  //
1743  //out << now->tm_min << " -->" << '\n';
1744 
1745  // basic svg header
1746  out << "<svg width=\"" << width + additional_width << "\" height=\"" << height << "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
1747  << '\n' << '\n';
1748 
1749 
1750  if (svg_flags.background == GridOutFlags::Svg::dealii)
1751  {
1752  out << " <linearGradient id=\"background_gradient\" gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"" << height << "\">" << '\n'
1753  << " <stop offset=\"0\" style=\"stop-color:white\"/>" << '\n'
1754  << " <stop offset=\"1\" style=\"stop-color:lightsteelblue\"/>" << '\n'
1755  << " </linearGradient>" << '\n';
1756  }
1757 
1758  out << '\n';
1759 
1760  // header for the internal style sheet
1761  out << "<!-- internal style sheet -->" << '\n'
1762  << "<style type=\"text/css\"><![CDATA[" << '\n';
1763 
1764  // set the background of the output graphic
1765  if (svg_flags.background == GridOutFlags::Svg::dealii) out << " rect.background{fill:url(#background_gradient)}" << '\n';
1766  else if (svg_flags.background == GridOutFlags::Svg::white) out << " rect.background{fill:white}" << '\n';
1767  else out << " rect.background{fill:none}" << '\n';
1768 
1769  // basic svg graphic element styles
1770  out << " rect{fill:none; stroke:rgb(25,25,25); stroke-width:" << svg_flags.line_thickness << '}' << '\n'
1771  << " text{font-family:Helvetica; text-anchor:middle; fill:rgb(25,25,25)}" << '\n'
1772  << " line{stroke:rgb(25,25,25); stroke-width:" << svg_flags.boundary_line_thickness << '}' << '\n'
1773  << " path{fill:none; stroke:rgb(25,25,25); stroke-width:" << svg_flags.line_thickness << '}' << '\n'
1774  << '\n';
1775 
1776  // polygon styles with respect to the chosen cell coloring
1777  if (svg_flags.coloring)
1778  {
1779  unsigned int labeling_index = 0;
1780 
1781  for (unsigned int index = 0; index < n; index++)
1782  {
1783  double h;
1784 
1785  if (n != 1) h = .6 - (index / (n-1.)) * .6;
1786  else h = .6;
1787 
1788  unsigned int r = 0;
1789  unsigned int g = 0;
1790  unsigned int b = 0;
1791 
1792  unsigned int i = static_cast<unsigned int>(h * 6);
1793 
1794  double f = h * 6 - i;
1795  double q = 1 - f;
1796  double t = f;
1797 
1798  switch (i % 6)
1799  {
1800  case 0:
1801  r = 255, g = static_cast<unsigned int>(.5 + 255*t);
1802  break;
1803  case 1:
1804  r = static_cast<unsigned int>(.5 + 255*q), g = 255;
1805  break;
1806  case 2:
1807  g = 255, b = static_cast<unsigned int>(.5 + 255*t);
1808  break;
1809  case 3:
1810  g = static_cast<unsigned int>(.5 + 255*q), b = 255;
1811  break;
1812  case 4:
1813  r = static_cast<unsigned int>(.5 + 255*t), b = 255;
1814  break;
1815  case 5:
1816  r = 255, b = static_cast<unsigned int>(.5 + 255*q);
1817  break;
1818  default:
1819  break;
1820  }
1821 
1822  switch (svg_flags.coloring)
1823  {
1825  while (!materials[labeling_index]) labeling_index++;
1826  break;
1828  while (!levels[labeling_index]) labeling_index++;
1829  break;
1831  while (!subdomains[labeling_index]) labeling_index++;
1832  break;
1834  while (!level_subdomains[labeling_index]) labeling_index++;
1835  break;
1836  default:
1837  break;
1838  }
1839 
1840  out << " path.p" << labeling_index
1841  << "{fill:rgb(" << r << ',' << g << ',' << b << "); "
1842  << "stroke:rgb(25,25,25); stroke-width:" << svg_flags.line_thickness << '}' << '\n';
1843 
1844  out << " path.ps" << labeling_index
1845  << "{fill:rgb(" << static_cast<unsigned int>(.5 + .75 * r) << ',' << static_cast<unsigned int>(.5 + .75 * g) << ',' << static_cast<unsigned int>(.5 + .75 * b) << "); "
1846  << "stroke:rgb(20,20,20); stroke-width:" << svg_flags.line_thickness << '}' << '\n';
1847 
1848  out << " rect.r" << labeling_index
1849  << "{fill:rgb(" << r << ',' << g << ',' << b << "); "
1850  << "stroke:rgb(25,25,25); stroke-width:" << svg_flags.line_thickness << '}' << '\n';
1851 
1852  labeling_index++;
1853  }
1854  }
1855 
1856  out << "]]></style>" << '\n' << '\n';
1857 
1858  // background rectangle
1859  out << " <rect class=\"background\" width=\"" << width << "\" height=\"" << height << "\"/>" << '\n';
1860 
1861  if (svg_flags.background == GridOutFlags::Svg::dealii)
1862  {
1863  unsigned int x_offset = 0;
1864 
1865  if (svg_flags.margin) x_offset = static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent/2.));
1866  else x_offset = static_cast<unsigned int>(.5 + height * .025);
1867 
1868  out << " <text x=\"" << x_offset << "\" y=\"" << static_cast<unsigned int>(.5 + height * .0525) << '\"'
1869  << " style=\"font-weight:100; fill:lightsteelblue; text-anchor:start; font-family:Courier; font-size:" << static_cast<unsigned int>(.5 + height * .045) << "px\">"
1870  << "deal.II" << "</text>" << '\n';
1871 
1872  // out << " <text x=\"" << x_offset + static_cast<unsigned int>(.5 + height * .045 * 4.75) << "\" y=\"" << static_cast<unsigned int>(.5 + height * .0525) << '\"'
1873  // << " style=\"fill:lightsteelblue; text-anchor:start; font-size:" << font_size << "\">"
1874  // << now->tm_mday << '/' << now->tm_mon + 1 << '/' << now->tm_year + 1900
1875  // << " - " << now->tm_hour << ':';
1876  //
1877  // if(now->tm_min < 10) out << '0';
1878  //
1879  // out << now->tm_min
1880  // << "</text>"<< '\n' << '\n';
1881  }
1882 
1883 // draw the cells, starting out from the minimal level (in order to guaranty a correct perspective view)
1884  out << " <!-- cells -->" << '\n';
1885 
1886  for (unsigned int level_index = min_level; level_index <= max_level; level_index++)
1887  {
1889  cell = tria.begin(level_index),
1890  endc = tria.end(level_index);
1891 
1892  for (; cell != endc; ++cell)
1893  {
1894  if (!svg_flags.convert_level_number_to_height && !cell->active()) continue;
1895 
1896  // draw the current cell
1897  out << " <path";
1898 
1899  if (svg_flags.coloring)
1900  {
1901  out << " class=\"p";
1902 
1903  if (!cell->active() && svg_flags.convert_level_number_to_height) out << 's';
1904 
1905  switch (svg_flags.coloring)
1906  {
1908  out << (unsigned int)cell->material_id();
1909  break;
1911  out << (unsigned int)cell->level();
1912  break;
1914  if (cell->active())
1915  out << cell->subdomain_id() + 2;
1916  else
1917  out << 'X';
1918  break;
1920  out << cell->level_subdomain_id() + 2;
1921  break;
1922  default:
1923  break;
1924  }
1925 
1926  out << '\"';
1927  }
1928 
1929  out << " d=\"M ";
1930 
1931  point[0] = cell->vertex(0)[0];
1932  point[1] = cell->vertex(0)[1];
1933  point[2] = 0;
1934 
1936  {
1937  point[2] = svg_flags.level_height_factor * ((float)cell->level() / (float)n_levels) * std::max(x_dimension, y_dimension);
1938  }
1939 
1940  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1941 
1942  out << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent)) << ' '
1943  << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent));
1944 
1945  out << " L ";
1946 
1947  point[0] = cell->vertex(1)[0];
1948  point[1] = cell->vertex(1)[1];
1949 
1950  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1951 
1952  out << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent)) << ' '
1953  << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent));
1954 
1955  out << " L ";
1956 
1957  point[0] = cell->vertex(3)[0];
1958  point[1] = cell->vertex(3)[1];
1959 
1960  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1961 
1962  out << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent)) << ' '
1963  << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent));
1964 
1965  out << " L ";
1966 
1967  point[0] = cell->vertex(2)[0];
1968  point[1] = cell->vertex(2)[1];
1969 
1970  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1971 
1972  out << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent)) << ' '
1973  << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent));
1974 
1975  out << " L ";
1976 
1977  point[0] = cell->vertex(0)[0];
1978  point[1] = cell->vertex(0)[1];
1979 
1980  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
1981 
1982  out << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent)) << ' '
1983  << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent));
1984 
1985  out << "\"/>" << '\n';
1986 
1987  // label the current cell
1989  {
1990  point[0] = cell->center()[0];
1991  point[1] = cell->center()[1];
1992  point[2] = 0;
1993 
1995  {
1996  point[2] = svg_flags.level_height_factor * ((float)cell->level() / (float)n_levels) * std::max(x_dimension, y_dimension);
1997  }
1998 
1999  float distance_to_camera = sqrt(pow(point[0] - camera_position[0], 2.) + pow(point[1] - camera_position[1], 2.) + pow(point[2] - camera_position[2], 2.));
2000  float distance_factor = distance_to_camera / (2. * std::max(x_dimension, y_dimension));
2001 
2002  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
2003 
2004  const unsigned int font_size_this_cell = static_cast<unsigned int>(.5 + cell_label_font_size * pow(.5, (float)cell->level() - 4. + 3.5 * distance_factor));
2005 
2006  out << " <text"
2007  << " x=\"" << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
2008  << "\" y=\"" << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent) + 0.5 * font_size_this_cell)
2009  << "\" style=\"font-size:" << font_size_this_cell
2010  << "px\">";
2011 
2013  {
2014  out << cell->level();
2015  }
2016 
2018  {
2019  if (svg_flags.label_level_number) out << ',';
2020  out << cell->index();
2021  }
2022 
2024  {
2026  out << (int)cell->material_id();
2027  }
2028 
2030  {
2034  out << ',';
2035  if (cell->active())
2036  out << static_cast<int>(cell->subdomain_id());
2037  else
2038  out << 'X';
2039  }
2040 
2042  {
2047  out << ',';
2048  out << static_cast<int>(cell->level_subdomain_id());
2049  }
2050 
2051  out << "</text>" << '\n';
2052  }
2053 
2054  // if the current cell lies at the boundary of the triangulation, draw the additional boundary line
2056  {
2057  for (unsigned int faceIndex = 0; faceIndex < 4; faceIndex++)
2058  {
2059  if (cell->at_boundary(faceIndex))
2060  {
2061 
2062  point[0] = cell->face(faceIndex)->vertex(0)[0];
2063  point[1] = cell->face(faceIndex)->vertex(0)[1];
2064  point[2] = 0;
2065 
2067  {
2068  point[2] = svg_flags.level_height_factor * ((float)cell->level() / (float)n_levels) * std::max(x_dimension, y_dimension);
2069  }
2070 
2071  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
2072 
2073  out << " <line x1=\""
2074  << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
2075  << "\" y1=\""
2076  << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent));
2077 
2078  point[0] = cell->face(faceIndex)->vertex(1)[0];
2079  point[1] = cell->face(faceIndex)->vertex(1)[1];
2080  point[2] = 0;
2081 
2083  {
2084  point[2] = svg_flags.level_height_factor * ((float)cell->level() / (float)n_levels) * std::max(x_dimension, y_dimension);
2085  }
2086 
2087  projection_decomposition = GridOut::svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
2088 
2089  out << "\" x2=\""
2090  << static_cast<unsigned int>(.5 + ((projection_decomposition[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
2091  << "\" y2=\""
2092  << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((projection_decomposition[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
2093  << "\"/>" << '\n';
2094  }
2095  }
2096  }
2097  }
2098  }
2099 
2100 
2101 // draw the legend
2102  if (svg_flags.draw_legend) out << '\n' << " <!-- legend -->" << '\n';
2103 
2104  unsigned int line_offset = 0;
2105 
2106  additional_width = 0;
2107  if (!svg_flags.margin) additional_width = static_cast<unsigned int>(.5 + (height/100.) * 2.5);
2108 
2109  // explanation of the cell labeling
2111  {
2112  out << " <rect x=\"" << width + additional_width << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent)
2113  << "\" width=\"" << static_cast<unsigned int>(.5 + (height/100.) * (40. - margin_in_percent)) << "\" height=\"" << static_cast<unsigned int>(.5 + height * .165) << "\"/>" << '\n';
2114 
2115  out << " <text x=\"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 1.25)
2116  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size)
2117  << "\" style=\"text-anchor:start; font-weight:bold; font-size:" << font_size
2118  << "px\">" << "cell label"
2119  << "</text>" << '\n';
2120 
2122  {
2123  out << " <text x=\"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 2.)
2124  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size)
2125  << "\" style=\"text-anchor:start; font-style:oblique; font-size:" << font_size
2126  << "px\">" << "level_number";
2127 
2129  out << ',';
2130 
2131  out << "</text>" << '\n';
2132  }
2133 
2135  {
2136  out << " <text x=\"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 2.)
2137  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size )
2138  << "\" style=\"text-anchor:start; font-style:oblique; font-size:" << font_size
2139  << "px\">"
2140  << "cell_index";
2141 
2143  out << ',';
2144 
2145  out << "</text>" << '\n';
2146  }
2147 
2149  {
2150  out << " <text x=\"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 2.)
2151  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size )
2152  << "\" style=\"text-anchor:start; font-style:oblique; font-size:" << font_size
2153  << "px\">"
2154  << "material_id";
2155 
2157  out << ',';
2158 
2159  out << "</text>" << '\n';
2160  }
2161 
2163  {
2164  out << " <text x= \"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 2.)
2165  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size )
2166  << "\" style=\"text-anchor:start; font-style:oblique; font-size:" << font_size
2167  << "px\">"
2168  << "subdomain_id";
2169 
2171  out << ',';
2172 
2173  out << "</text>" << '\n';
2174  }
2175 
2177  {
2178  out << " <text x= \"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 2.)
2179  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size )
2180  << "\" style=\"text-anchor:start; font-style:oblique; font-size:" << font_size
2181  << "px\">"
2182  << "level_subdomain_id"
2183  << "</text>" << '\n';
2184  }
2185  }
2186 
2187  // show azimuth angle and polar angle as text below the explanation of the cell labeling
2188  if (svg_flags.draw_legend)
2189  {
2190  out << " <text x=\"" << width + additional_width
2191  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + 10.75 * font_size)
2192  << "\" style=\"text-anchor:start; font-size:" << font_size << "px\">"
2193  << "azimuth: " << svg_flags.azimuth_angle << "°, polar: " << svg_flags.polar_angle << "°</text>" << '\n';
2194  }
2195 
2196 
2197 // draw the colorbar
2198  if (svg_flags.draw_colorbar && svg_flags.coloring)
2199  {
2200  out << '\n' << " <!-- colorbar -->" << '\n';
2201 
2202  out << " <text x=\"" << width + additional_width
2203  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29.) - (font_size/1.25))
2204  << "\" style=\"text-anchor:start; font-weight:bold; font-size:" << font_size << "px\">";
2205 
2206  switch (svg_flags.coloring)
2207  {
2208  case 1:
2209  out << "material_id";
2210  break;
2211  case 2:
2212  out << "level_number";
2213  break;
2214  case 3:
2215  out << "subdomain_id";
2216  break;
2217  case 4:
2218  out << "level_subdomain_id";
2219  break;
2220  default:
2221  break;
2222  }
2223 
2224  out << "</text>" << '\n';
2225 
2226  unsigned int element_height = static_cast<unsigned int>(((height/100.) * (71. - 2.*margin_in_percent)) / n);
2227  unsigned int element_width = static_cast<unsigned int>(.5 + (height/100.) * 2.5);
2228 
2229  int labeling_index = 0;
2230 
2231  for (unsigned int index = 0; index < n; index++)
2232  {
2233  switch (svg_flags.coloring)
2234  {
2236  while (!materials[labeling_index]) labeling_index++;
2237  break;
2239  while (!levels[labeling_index]) labeling_index++;
2240  break;
2242  while (!subdomains[labeling_index]) labeling_index++;
2243  break;
2245  while (!level_subdomains[labeling_index]) labeling_index++;
2246  break;
2247  default:
2248  break;
2249  }
2250 
2251  out << " <rect class=\"r" << labeling_index
2252  << "\" x=\"" << width + additional_width
2253  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (n-index-1) * element_height
2254  << "\" width=\"" << element_width
2255  << "\" height=\"" << element_height
2256  << "\"/>" << '\n';
2257 
2258  out << " <text x=\"" << width + additional_width + 1.5 * element_width
2259  << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (n-index-1 + .5) * element_height + static_cast<unsigned int>(.5 + font_size * .35) << "\""
2260  << " style=\"text-anchor:start; font-size:" << static_cast<unsigned int>(.5 + font_size) << "px";
2261 
2262  if (index == 0 || index == n-1) out << "; font-weight:bold";
2263 
2264  out << "\">" << labeling_index;
2265 
2266  if (index == n-1) out << " max";
2267  if (index == 0) out << " min";
2268 
2269  out << "</text>" << '\n';
2270 
2271  labeling_index++;
2272  }
2273  }
2274 
2275 
2276 // finalize the svg file
2277  out << '\n' << "</svg>";
2278  out.flush();
2279 
2280 }
2281 
2282 
2283 template <>
2285  std::ostream &) const
2286 {
2287  // 1d specialization not done yet
2288  Assert (false, ExcNotImplemented());
2289 }
2290 
2291 
2292 template <int dim, int spacedim>
2294  std::ostream &out) const
2295 {
2296  AssertThrow (out, ExcIO ());
2297 
2298  // (i) write header
2299  if (true)
2300  {
2301  // block this to have local variables destroyed after use
2302  const std::time_t time1 = std::time (0);
2303  const std::tm *time = std::localtime (&time1);
2304 
2305  out << "\n#"
2306  << "\n# This file was generated by the deal.II library."
2307  << "\n# Date = "
2308  << time->tm_year+1900 << "/"
2309  << std::setfill('0') << std::setw (2) << time->tm_mon+1 << "/"
2310  << std::setfill('0') << std::setw (2) << time->tm_mday
2311  << "\n# Time = "
2312  << std::setfill('0') << std::setw (2) << time->tm_hour << ":"
2313  << std::setfill('0') << std::setw (2) << time->tm_min << ":"
2314  << std::setfill('0') << std::setw (2) << time->tm_sec
2315  << "\n#"
2316  << "\n# For a description of the MathGL script format see the MathGL manual. "
2317  << "\n#"
2318  << "\n# Note: This file is understood by MathGL v2.1 and higher only, and can "
2319  << "\n# be quickly viewed in a graphical environment using \'mglview\'. "
2320  << "\n#" << "\n"
2321  ;
2322  }
2323 
2324  // define a helper to keep loops approximately dim-independent
2325  // since MathGL labels axes as x, y, z
2326  const std::string axes = "xyz";
2327 
2328  // (ii) write preamble and graphing tweaks
2329  out << "\n#"
2330  << "\n# Preamble."
2331  << "\n#" << "\n";
2332 
2334  out << "\nbox";
2335 
2336  // deal with dimension dependent preamble; eg. default sizes and
2337  // views for MathGL (cf. gnuplot).
2338  switch (dim)
2339  {
2340  case 2:
2341  out << "\nsetsize 800 800";
2342  out << "\nrotate 0 0";
2343  break;
2344  case 3:
2345  out << "\nsetsize 800 800";
2346  out << "\nrotate 60 40";
2347  break;
2348  default:
2349  Assert (false, ExcNotImplemented ());
2350  }
2351  out << "\n";
2352 
2353  // (iii) write vertex ordering
2354  out << "\n#"
2355  << "\n# Vertex ordering."
2356  << "\n# list <vertex order> <vertex indices>"
2357  << "\n#" << "\n";
2358 
2359  // todo: This denotes the natural ordering of vertices, but it needs
2360  // to check this is really always true for a given grid (it's not
2361  // true in @ref step_1 "step-1" grid-2 for instance).
2362  switch (dim)
2363  {
2364  case 2:
2365  out << "\nlist f 0 1 2 3"
2366  << "\n";
2367  break;
2368  case 3:
2369  out << "\nlist f 0 2 4 6 | 1 3 5 7 | 0 4 1 5 | 2 6 3 7 | 0 1 2 3 | 4 5 6 7"
2370  << "\n";
2371  break;
2372  default:
2373  Assert (false, ExcNotImplemented ());
2374  }
2375 
2376  // (iv) write a list of vertices of cells
2377  out << "\n#"
2378  << "\n# List of vertices."
2379  << "\n# list <id> <vertices>"
2380  << "\n#" << "\n";
2381 
2382  // run over all active cells and write out a list of
2383  // xyz-coordinates that correspond to vertices
2384  typename ::Triangulation<dim, spacedim>::active_cell_iterator
2385  cell=tria.begin_active (),
2386  endc=tria.end ();
2387 
2388  // No global indices in deal.II, so we make one up here.
2389  for (; cell!=endc; ++cell)
2390  {
2391  for (unsigned int i=0; i<dim; ++i)
2392  {
2393  // if (cell->direction_flag ()==true)
2394  // out << "\ntrue";
2395  // else
2396  // out << "\nfalse";
2397 
2398  out << "\nlist " << axes[i] << cell->active_cell_index() << " ";
2399  for (unsigned int j=0; j<GeometryInfo<dim>::vertices_per_cell; ++j)
2400  out << cell->vertex(j)[i] << " ";
2401  }
2402  out << '\n';
2403  }
2404 
2405  // (v) write out cells to plot as quadplot objects
2406  out << "\n#"
2407  << "\n# List of cells to quadplot."
2408  << "\n# quadplot <vertex order> <id> <style>"
2409  << "\n#" << "\n";
2410  for (unsigned int i=0; i<tria.n_active_cells (); ++i)
2411  {
2412  out << "\nquadplot f ";
2413  for (unsigned int j=0; j<dim; ++j)
2414  out << axes[j] << i << " ";
2415  out << "\'k#\'";
2416  }
2417  out << "\n";
2418 
2419  // (vi) write footer
2420  out << "\n#"
2421  << "\n#"
2422  << "\n#" << "\n";
2423 
2424  // make sure everything now gets to the output stream
2425  out.flush ();
2426  AssertThrow (out, ExcIO ());
2427 }
2428 
2429 
2430 
2431 namespace
2432 {
2439  template <int dim, int spacedim, typename ITERATOR, typename END>
2440  void
2441  generate_triangulation_patches (std::vector<DataOutBase::Patch<dim,spacedim> > &patches,
2442  ITERATOR cell, END end)
2443  {
2444  // convert each of the active cells into a patch
2445  for (; cell != end; ++cell)
2446  {
2448  patch.n_subdivisions = 1;
2450 
2451  for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
2452  {
2453  patch.vertices[v] = cell->vertex(v);
2454  patch.data(0,v) = cell->level();
2455  patch.data(1,v) = static_cast<int>(cell->manifold_id());
2456  patch.data(2,v) = cell->material_id();
2457  if (!cell->has_children())
2458  patch.data(3,v) = static_cast<int>(cell->subdomain_id());
2459  else
2460  patch.data(3,v) = -1;
2461  patch.data(4,v) = static_cast<int>(cell->level_subdomain_id());
2462  }
2463  patches.push_back (patch);
2464  }
2465  }
2466 
2467  std::vector<std::string> triangulation_patch_data_names ()
2468  {
2469  std::vector<std::string> v(5);
2470  v[0] = "level";
2471  v[1] = "manifold";
2472  v[2] = "material";
2473  v[3] = "subdomain";
2474  v[4] = "level_subdomain";
2475  return v;
2476  }
2477 }
2478 
2479 
2480 
2481 template <int dim, int spacedim>
2483  std::ostream &out) const
2484 {
2485  AssertThrow (out, ExcIO ());
2486 
2487  // convert the cells of the triangulation into a set of patches
2488  // and then have them output. since there is no data attached to
2489  // the geometry, we also do not have to provide any names, identifying
2490  // information, etc.
2491  std::vector<DataOutBase::Patch<dim,spacedim> > patches;
2492  patches.reserve (tria.n_active_cells());
2493  generate_triangulation_patches(patches, tria.begin_active(), tria.end());
2494  DataOutBase::write_vtk (patches,
2495  triangulation_patch_data_names(),
2496  std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >(),
2497  vtk_flags,
2498  out);
2499 
2500  AssertThrow (out, ExcIO ());
2501 }
2502 
2503 
2504 
2505 template <int dim, int spacedim>
2507  std::ostream &out) const
2508 {
2509  AssertThrow (out, ExcIO ());
2510 
2511  // convert the cells of the triangulation into a set of patches
2512  // and then have them output. since there is no data attached to
2513  // the geometry, we also do not have to provide any names, identifying
2514  // information, etc.
2515  std::vector<DataOutBase::Patch<dim,spacedim> > patches;
2516  patches.reserve (tria.n_active_cells());
2517  generate_triangulation_patches(patches, tria.begin_active(), tria.end());
2518  DataOutBase::write_vtu (patches,
2519  triangulation_patch_data_names(),
2520  std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >(),
2521  vtu_flags,
2522  out);
2523 
2524  AssertThrow (out, ExcIO ());
2525 }
2526 
2527 
2528 
2529 unsigned int GridOut::n_boundary_faces (const Triangulation<1> &) const
2530 {
2531  return 0;
2532 }
2533 
2534 unsigned int GridOut::n_boundary_lines (const Triangulation<1> &) const
2535 {
2536  return 0;
2537 }
2538 
2539 
2540 unsigned int GridOut::n_boundary_faces (const Triangulation<1,2> &) const
2541 {
2542  return 0;
2543 }
2544 
2545 unsigned int GridOut::n_boundary_lines (const Triangulation<1,2> &) const
2546 {
2547  return 0;
2548 }
2549 
2550 unsigned int GridOut::n_boundary_faces (const Triangulation<1,3> &) const
2551 {
2552  return 0;
2553 }
2554 
2555 unsigned int GridOut::n_boundary_lines (const Triangulation<1,3> &) const
2556 {
2557  return 0;
2558 }
2559 
2560 unsigned int GridOut::n_boundary_lines (const Triangulation<2> &) const
2561 {
2562  return 0;
2563 }
2564 
2565 unsigned int GridOut::n_boundary_lines (const Triangulation<2,3> &) const
2566 {
2567  return 0;
2568 }
2569 
2570 
2571 
2572 template <int dim, int spacedim>
2574 {
2576  unsigned int n_faces = 0;
2577 
2578  for (face=tria.begin_active_face(), endf=tria.end_face();
2579  face != endf; ++face)
2580  if ((face->at_boundary()) &&
2581  (face->boundary_id() != 0))
2582  n_faces++;
2583 
2584  return n_faces;
2585 }
2586 
2587 
2588 
2589 template <int dim, int spacedim>
2591 {
2592  // save the user flags for lines so
2593  // we can use these flags to track
2594  // which ones we've already counted
2595  std::vector<bool> line_flags;
2596  const_cast<::Triangulation<dim,spacedim>&>(tria)
2597  .save_user_flags_line (line_flags);
2598  const_cast<::Triangulation<dim,spacedim>&>(tria)
2599  .clear_user_flags_line ();
2600 
2601  unsigned int n_lines = 0;
2602 
2604 
2605  for (cell=tria.begin_active(), endc=tria.end();
2606  cell != endc; ++cell)
2607  for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
2608  if (cell->line(l)->at_boundary()
2609  &&
2610  (cell->line(l)->boundary_id() != 0)
2611  &&
2612  (cell->line(l)->user_flag_set() == false))
2613  {
2614  ++n_lines;
2615  cell->line(l)->set_user_flag();
2616  }
2617 
2618  // at the end, restore the user
2619  // flags for the lines
2620  const_cast<::Triangulation<dim,spacedim>&>(tria)
2621  .load_user_flags_line (line_flags);
2622 
2623  return n_lines;
2624 }
2625 
2626 
2627 
2628 
2629 unsigned int
2631  const unsigned int next_element_index,
2632  std::ostream &) const
2633 {
2634  return next_element_index;
2635 }
2636 
2637 
2638 unsigned int
2640  const unsigned int next_element_index,
2641  std::ostream &) const
2642 {
2643  return next_element_index;
2644 }
2645 
2646 unsigned int
2648  const unsigned int next_element_index,
2649  std::ostream &) const
2650 {
2651  return next_element_index;
2652 }
2653 
2654 
2655 unsigned int
2657  const unsigned int next_element_index,
2658  std::ostream &) const
2659 {
2660  return next_element_index;
2661 }
2662 
2663 unsigned int
2665  const unsigned int next_element_index,
2666  std::ostream &) const
2667 {
2668  return next_element_index;
2669 }
2670 
2671 
2672 unsigned int
2674  const unsigned int next_element_index,
2675  std::ostream &) const
2676 {
2677  return next_element_index;
2678 }
2679 
2680 
2681 unsigned int
2683  const unsigned int next_element_index,
2684  std::ostream &) const
2685 {
2686  return next_element_index;
2687 }
2688 
2689 unsigned int
2691  const unsigned int next_element_index,
2692  std::ostream &) const
2693 {
2694  return next_element_index;
2695 }
2696 
2697 
2698 
2699 
2700 template <int dim, int spacedim>
2701 unsigned int
2703  const unsigned int next_element_index,
2704  std::ostream &out) const
2705 {
2706  unsigned int current_element_index = next_element_index;
2708 
2709  for (face=tria.begin_active_face(), endf=tria.end_face();
2710  face != endf; ++face)
2711  if (face->at_boundary() &&
2712  (face->boundary_id() != 0))
2713  {
2714  out << current_element_index << ' ';
2715  switch (dim)
2716  {
2717  case 2:
2718  out << 1 << ' ';
2719  break;
2720  case 3:
2721  out << 3 << ' ';
2722  break;
2723  default:
2724  Assert (false, ExcNotImplemented());
2725  }
2726  out << static_cast<unsigned int>(face->boundary_id())
2727  << ' '
2728  << static_cast<unsigned int>(face->boundary_id())
2730  // note: vertex numbers are 1-base
2731  for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
2732  out << ' '
2733  << face->vertex_index(GeometryInfo<dim-1>::ucd_to_deal[vertex])+1;
2734  out << '\n';
2735 
2736  ++current_element_index;
2737  }
2738  return current_element_index;
2739 }
2740 
2741 
2742 template <int dim, int spacedim>
2743 unsigned int
2745  const unsigned int next_element_index,
2746  std::ostream &out) const
2747 {
2748  unsigned int current_element_index = next_element_index;
2749  // save the user flags for lines so
2750  // we can use these flags to track
2751  // which ones we've already taken
2752  // care of
2753  std::vector<bool> line_flags;
2754  const_cast<::Triangulation<dim,spacedim>&>(tria)
2755  .save_user_flags_line (line_flags);
2756  const_cast<::Triangulation<dim,spacedim>&>(tria)
2757  .clear_user_flags_line ();
2758 
2760 
2761  for (cell=tria.begin_active(), endc=tria.end();
2762  cell != endc; ++cell)
2763  for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
2764  if (cell->line(l)->at_boundary()
2765  &&
2766  (cell->line(l)->boundary_id() != 0)
2767  &&
2768  (cell->line(l)->user_flag_set() == false))
2769  {
2770  out << next_element_index << " 1 ";
2771  out << static_cast<unsigned int>(cell->line(l)->boundary_id())
2772  << ' '
2773  << static_cast<unsigned int>(cell->line(l)->boundary_id())
2774  << " 2 ";
2775  // note: vertex numbers are 1-base
2776  for (unsigned int vertex=0; vertex<2; ++vertex)
2777  out << ' '
2778  << cell->line(l)->vertex_index(GeometryInfo<dim-2>::ucd_to_deal[vertex])+1;
2779  out << '\n';
2780 
2781  // move on to the next line
2782  // but mark the current one
2783  // as taken care of
2784  ++current_element_index;
2785  cell->line(l)->set_user_flag();
2786  }
2787 
2788  // at the end, restore the user
2789  // flags for the lines
2790  const_cast<::Triangulation<dim,spacedim>&>(tria)
2791  .load_user_flags_line (line_flags);
2792 
2793  return current_element_index;
2794 }
2795 
2796 
2797 
2798 
2799 unsigned int
2801  const unsigned int next_element_index,
2802  std::ostream &) const
2803 {
2804  return next_element_index;
2805 }
2806 
2807 unsigned int
2809  const unsigned int next_element_index,
2810  std::ostream &) const
2811 {
2812  return next_element_index;
2813 }
2814 
2815 unsigned int
2817  const unsigned int next_element_index,
2818  std::ostream &) const
2819 {
2820  return next_element_index;
2821 }
2822 
2823 unsigned int
2825  const unsigned int next_element_index,
2826  std::ostream &) const
2827 {
2828  return next_element_index;
2829 }
2830 
2831 unsigned int
2833  const unsigned int next_element_index,
2834  std::ostream &) const
2835 {
2836  return next_element_index;
2837 }
2838 
2839 
2840 unsigned int
2842  const unsigned int next_element_index,
2843  std::ostream &) const
2844 {
2845  return next_element_index;
2846 }
2847 
2848 
2849 unsigned int
2851  const unsigned int next_element_index,
2852  std::ostream &) const
2853 {
2854  return next_element_index;
2855 }
2856 
2857 unsigned int
2859  const unsigned int next_element_index,
2860  std::ostream &) const
2861 {
2862  return next_element_index;
2863 }
2864 
2865 
2866 
2867 template <int dim, int spacedim>
2868 unsigned int
2870  const unsigned int next_element_index,
2871  std::ostream &out) const
2872 {
2873  unsigned int current_element_index = next_element_index;
2875 
2876  for (face=tria.begin_active_face(), endf=tria.end_face();
2877  face != endf; ++face)
2878  if (face->at_boundary() &&
2879  (face->boundary_id() != 0))
2880  {
2881  out << current_element_index << " "
2882  << static_cast<unsigned int>(face->boundary_id())
2883  << " ";
2884  switch (dim)
2885  {
2886  case 2:
2887  out << "line ";
2888  break;
2889  case 3:
2890  out << "quad ";
2891  break;
2892  default:
2893  Assert (false, ExcNotImplemented());
2894  }
2895  // note: vertex numbers are 1-base
2896  for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
2897  out << face->vertex_index(GeometryInfo<dim-1>::ucd_to_deal[vertex])+1 << ' ';
2898  out << '\n';
2899 
2900  ++current_element_index;
2901  }
2902  return current_element_index;
2903 }
2904 
2905 
2906 
2907 template <int dim, int spacedim>
2908 unsigned int
2910  const unsigned int next_element_index,
2911  std::ostream &out) const
2912 {
2913  unsigned int current_element_index = next_element_index;
2914  // save the user flags for lines so
2915  // we can use these flags to track
2916  // which ones we've already taken
2917  // care of
2918  std::vector<bool> line_flags;
2919  const_cast<::Triangulation<dim,spacedim>&>(tria)
2920  .save_user_flags_line (line_flags);
2921  const_cast<::Triangulation<dim,spacedim>&>(tria)
2922  .clear_user_flags_line ();
2923 
2925 
2926  for (cell=tria.begin_active(), endc=tria.end();
2927  cell != endc; ++cell)
2928  for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
2929  if (cell->line(l)->at_boundary()
2930  &&
2931  (cell->line(l)->boundary_id() != 0)
2932  &&
2933  (cell->line(l)->user_flag_set() == false))
2934  {
2935  out << current_element_index << " "
2936  << static_cast<unsigned int>(cell->line(l)->boundary_id())
2937  << " line ";
2938  // note: vertex numbers in ucd format are 1-base
2939  for (unsigned int vertex=0; vertex<2; ++vertex)
2940  out << cell->line(l)->vertex_index(GeometryInfo<dim-2>::ucd_to_deal[vertex])+1
2941  << ' ';
2942  out << '\n';
2943 
2944  // move on to the next line
2945  // but mark the current one
2946  // as taken care of
2947  ++current_element_index;
2948  cell->line(l)->set_user_flag();
2949  }
2950 
2951  // at the end, restore the user
2952  // flags for the lines
2953  const_cast<::Triangulation<dim,spacedim>&>(tria)
2954  .load_user_flags_line (line_flags);
2955  return current_element_index;
2956 }
2957 
2958 
2959 Point<2> GridOut::svg_project_point(Point<3> point, Point<3> camera_position, Point<3> camera_direction, Point<3> camera_horizontal, float camera_focus)
2960 {
2961  // ...
2962  Point<3> camera_vertical;
2963  camera_vertical[0] = camera_horizontal[1] * camera_direction[2] - camera_horizontal[2] * camera_direction[1];
2964  camera_vertical[1] = camera_horizontal[2] * camera_direction[0] - camera_horizontal[0] * camera_direction[2];
2965  camera_vertical[2] = camera_horizontal[0] * camera_direction[1] - camera_horizontal[1] * camera_direction[0];
2966 
2967  float phi;
2968  phi = camera_focus;
2969  phi /= (point[0] - camera_position[0]) * camera_direction[0] + (point[1] - camera_position[1]) * camera_direction[1] + (point[2] - camera_position[2]) * camera_direction[2];
2970 
2971  Point<3> projection;
2972  projection[0] = camera_position[0] + phi * (point[0] - camera_position[0]);
2973  projection[1] = camera_position[1] + phi * (point[1] - camera_position[1]);
2974  projection[2] = camera_position[2] + phi * (point[2] - camera_position[2]);
2975 
2976  Point<2> projection_decomposition;
2977  projection_decomposition[0] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_horizontal[0];
2978  projection_decomposition[0] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_horizontal[1];
2979  projection_decomposition[0] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_horizontal[2];
2980 
2981  projection_decomposition[1] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_vertical[0];
2982  projection_decomposition[1] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_vertical[1];
2983  projection_decomposition[1] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_vertical[2];
2984 
2985  return projection_decomposition;
2986 }
2987 
2988 
2989 
2990 namespace internal
2991 {
2992  namespace
2993  {
2994  template <int spacedim>
2995  void write_gnuplot (const ::Triangulation<1,spacedim> &tria,
2996  std::ostream &out,
2997  const Mapping<1,spacedim> *,
2999  {
3000  AssertThrow (out, ExcIO());
3001 
3002  const int dim = 1;
3003 
3004  typename ::Triangulation<dim,spacedim>::active_cell_iterator
3005  cell=tria.begin_active();
3006  const typename ::Triangulation<dim,spacedim>::active_cell_iterator
3007  endc=tria.end();
3008  for (; cell!=endc; ++cell)
3009  {
3010  if (gnuplot_flags.write_cell_numbers)
3011  out << "# cell " << cell << '\n';
3012 
3013  out << cell->vertex(0)
3014  << ' ' << cell->level()
3015  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3016  << cell->vertex(1)
3017  << ' ' << cell->level()
3018  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3019  << "\n\n";
3020  }
3021 
3022  // make sure everything now gets to
3023  // disk
3024  out.flush ();
3025 
3026  AssertThrow (out, ExcIO());
3027  }
3028 
3029 
3030 
3031  template <int spacedim>
3032  void write_gnuplot (const ::Triangulation<2,spacedim> &tria,
3033  std::ostream &out,
3034  const Mapping<2,spacedim> *mapping,
3035  const GridOutFlags::Gnuplot &gnuplot_flags)
3036  {
3037  AssertThrow (out, ExcIO());
3038 
3039  const int dim = 2;
3040 
3041  const unsigned int n_additional_points=
3042  gnuplot_flags.n_boundary_face_points;
3043  const unsigned int n_points=2+n_additional_points;
3044 
3045  typename ::Triangulation<dim,spacedim>::active_cell_iterator
3046  cell=tria.begin_active();
3047  const typename ::Triangulation<dim,spacedim>::active_cell_iterator
3048  endc=tria.end();
3049 
3050  // if we are to treat curved
3051  // boundaries, then generate a
3052  // quadrature formula which will be
3053  // used to probe boundary points at
3054  // curved faces
3055  Quadrature<dim> *q_projector=0;
3056  std::vector<Point<dim-1> > boundary_points;
3057  if (mapping!=0)
3058  {
3059  boundary_points.resize(n_points);
3060  boundary_points[0][0]=0;
3061  boundary_points[n_points-1][0]=1;
3062  for (unsigned int i=1; i<n_points-1; ++i)
3063  boundary_points[i](0)= 1.*i/(n_points-1);
3064 
3065  std::vector<double> dummy_weights(n_points, 1./n_points);
3066  Quadrature<dim-1> quadrature(boundary_points, dummy_weights);
3067 
3068  q_projector = new Quadrature<dim> (QProjector<dim>::project_to_all_faces(quadrature));
3069  }
3070 
3071  for (; cell!=endc; ++cell)
3072  {
3073  if (gnuplot_flags.write_cell_numbers)
3074  out << "# cell " << cell << '\n';
3075 
3076  if (mapping==0 ||
3077  (!cell->at_boundary() && !gnuplot_flags.curved_inner_cells))
3078  {
3079  // write out the four sides
3080  // of this cell by putting
3081  // the four points (+ the
3082  // initial point again) in
3083  // a row and lifting the
3084  // drawing pencil at the
3085  // end
3086  for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
3087  out << cell->vertex(GeometryInfo<dim>::ucd_to_deal[i])
3088  << ' ' << cell->level()
3089  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3090  out << cell->vertex(0)
3091  << ' ' << cell->level()
3092  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3093  << '\n' // double new line for gnuplot 3d plots
3094  << '\n';
3095  }
3096  else
3097  // cell is at boundary and we
3098  // are to treat curved
3099  // boundaries. so loop over
3100  // all faces and draw them as
3101  // small pieces of lines
3102  {
3103  for (unsigned int face_no=0;
3104  face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
3105  {
3106  const typename ::Triangulation<dim,spacedim>::face_iterator
3107  face = cell->face(face_no);
3108  if (face->at_boundary() || gnuplot_flags.curved_inner_cells)
3109  {
3110  // compute offset
3111  // of quadrature
3112  // points within
3113  // set of projected
3114  // points
3115  const unsigned int offset=face_no*n_points;
3116  for (unsigned int i=0; i<n_points; ++i)
3117  out << (mapping->transform_unit_to_real_cell
3118  (cell, q_projector->point(offset+i)))
3119  << ' ' << cell->level()
3120  << ' ' << static_cast<unsigned int>(cell->material_id())
3121  << '\n';
3122 
3123  out << '\n'
3124  << '\n';
3125  }
3126  else
3127  {
3128  // if, however, the
3129  // face is not at
3130  // the boundary,
3131  // then draw it as
3132  // usual
3133  out << face->vertex(0)
3134  << ' ' << cell->level()
3135  << ' ' << static_cast<unsigned int>(cell->material_id())
3136  << '\n'
3137  << face->vertex(1)
3138  << ' ' << cell->level()
3139  << ' ' << static_cast<unsigned int>(cell->material_id())
3140  << '\n'
3141  << '\n'
3142  << '\n';
3143  }
3144  }
3145  }
3146  }
3147 
3148  if (q_projector != 0)
3149  delete q_projector;
3150 
3151  // make sure everything now gets to
3152  // disk
3153  out.flush ();
3154 
3155  AssertThrow (out, ExcIO());
3156  }
3157 
3158 
3159 
3160  template <int spacedim>
3161  void write_gnuplot (const ::Triangulation<3,spacedim> &tria,
3162  std::ostream &out,
3163  const Mapping<3,spacedim> *mapping,
3164  const GridOutFlags::Gnuplot &gnuplot_flags)
3165  {
3166  AssertThrow (out, ExcIO());
3167 
3168  const int dim = 3;
3169 
3170  const unsigned int n_additional_points=
3171  gnuplot_flags.n_boundary_face_points;
3172  const unsigned int n_points=2+n_additional_points;
3173 
3174  typename ::Triangulation<dim,spacedim>::active_cell_iterator
3175  cell=tria.begin_active();
3176  const typename ::Triangulation<dim,spacedim>::active_cell_iterator
3177  endc=tria.end();
3178 
3179  // if we are to treat curved
3180  // boundaries, then generate a
3181  // quadrature formula which will be
3182  // used to probe boundary points at
3183  // curved faces
3184  Quadrature<dim> *q_projector=0;
3185  std::vector<Point<1> > boundary_points;
3186  if (mapping!=0)
3187  {
3188  boundary_points.resize(n_points);
3189  boundary_points[0][0]=0;
3190  boundary_points[n_points-1][0]=1;
3191  for (unsigned int i=1; i<n_points-1; ++i)
3192  boundary_points[i](0)= 1.*i/(n_points-1);
3193 
3194  std::vector<double> dummy_weights(n_points, 1./n_points);
3195  Quadrature<1> quadrature1d(boundary_points, dummy_weights);
3196 
3197  // tensor product of points,
3198  // only one copy
3199  QIterated<dim-1> quadrature(quadrature1d, 1);
3200  q_projector = new Quadrature<dim> (QProjector<dim>::project_to_all_faces(quadrature));
3201  }
3202 
3203  for (; cell!=endc; ++cell)
3204  {
3205  if (gnuplot_flags.write_cell_numbers)
3206  out << "# cell " << cell << '\n';
3207 
3208  if (mapping==0 || n_points==2 ||
3209  (!cell->has_boundary_lines() && !gnuplot_flags.curved_inner_cells))
3210  {
3211  // front face
3212  out << cell->vertex(0)
3213  << ' ' << cell->level()
3214  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3215  << cell->vertex(1)
3216  << ' ' << cell->level()
3217  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3218  << cell->vertex(5)
3219  << ' ' << cell->level()
3220  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3221  << cell->vertex(4)
3222  << ' ' << cell->level()
3223  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3224  << cell->vertex(0)
3225  << ' ' << cell->level()
3226  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3227  << '\n';
3228  // back face
3229  out << cell->vertex(2)
3230  << ' ' << cell->level()
3231  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3232  << cell->vertex(3)
3233  << ' ' << cell->level()
3234  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3235  << cell->vertex(7)
3236  << ' ' << cell->level()
3237  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3238  << cell->vertex(6)
3239  << ' ' << cell->level()
3240  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3241  << cell->vertex(2)
3242  << ' ' << cell->level()
3243  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3244  << '\n';
3245 
3246  // now for the four connecting lines
3247  out << cell->vertex(0)
3248  << ' ' << cell->level()
3249  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3250  << cell->vertex(2)
3251  << ' ' << cell->level()
3252  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3253  << '\n';
3254  out << cell->vertex(1)
3255  << ' ' << cell->level()
3256  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3257  << cell->vertex(3)
3258  << ' ' << cell->level()
3259  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3260  << '\n';
3261  out << cell->vertex(5)
3262  << ' ' << cell->level()
3263  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3264  << cell->vertex(7)
3265  << ' ' << cell->level()
3266  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3267  << '\n';
3268  out << cell->vertex(4)
3269  << ' ' << cell->level()
3270  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3271  << cell->vertex(6)
3272  << ' ' << cell->level()
3273  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3274  << '\n';
3275  }
3276  else
3277  {
3278  for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
3279  {
3280  const typename ::Triangulation<dim,spacedim>::face_iterator
3281  face = cell->face(face_no);
3282 
3283  if (face->at_boundary())
3284  {
3285  const unsigned int offset=face_no*n_points*n_points;
3286  for (unsigned int i=0; i<n_points-1; ++i)
3287  for (unsigned int j=0; j<n_points-1; ++j)
3288  {
3289  const Point<spacedim> p0=mapping->transform_unit_to_real_cell(
3290  cell, q_projector->point(offset+i*n_points+j));
3291  out << p0
3292  << ' ' << cell->level()
3293  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3294  out << (mapping->transform_unit_to_real_cell(
3295  cell, q_projector->point(offset+(i+1)*n_points+j)))
3296  << ' ' << cell->level()
3297  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3298  out << (mapping->transform_unit_to_real_cell(
3299  cell, q_projector->point(offset+(i+1)*n_points+j+1)))
3300  << ' ' << cell->level()
3301  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3302  out << (mapping->transform_unit_to_real_cell(
3303  cell, q_projector->point(offset+i*n_points+j+1)))
3304  << ' ' << cell->level()
3305  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3306  // and the
3307  // first
3308  // point
3309  // again
3310  out << p0
3311  << ' ' << cell->level()
3312  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3313  out << '\n' << '\n';
3314  }
3315  }
3316  else
3317  {
3318  for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
3319  {
3320  const typename ::Triangulation<dim,spacedim>::line_iterator
3321  line=face->line(l);
3322 
3323  const Point<spacedim> &v0=line->vertex(0),
3324  &v1=line->vertex(1);
3325  if (line->at_boundary() || gnuplot_flags.curved_inner_cells)
3326  {
3327  // transform_real_to_unit_cell
3328  // could be
3329  // replaced
3330  // by using
3331  // QProjector<dim>::project_to_line
3332  // which is
3333  // not yet
3334  // implemented
3335  const Point<spacedim> u0=mapping->transform_real_to_unit_cell(cell, v0),
3336  u1=mapping->transform_real_to_unit_cell(cell, v1);
3337 
3338  for (unsigned int i=0; i<n_points; ++i)
3339  out << (mapping->transform_unit_to_real_cell
3340  (cell, (1-boundary_points[i][0])*u0+boundary_points[i][0]*u1))
3341  << ' ' << cell->level()
3342  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3343  }
3344  else
3345  out << v0
3346  << ' ' << cell->level()
3347  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n'
3348  << v1
3349  << ' ' << cell->level()
3350  << ' ' << static_cast<unsigned int>(cell->material_id()) << '\n';
3351 
3352  out << '\n' << '\n';
3353  }
3354  }
3355  }
3356  }
3357  }
3358 
3359  if (q_projector != 0)
3360  delete q_projector;
3361 
3362 
3363  // make sure everything now gets to
3364  // disk
3365  out.flush ();
3366 
3367  AssertThrow (out, ExcIO());
3368  }
3369  }
3370 }
3371 
3372 
3373 
3374 template <int dim, int spacedim>
3376  const Triangulation<dim,spacedim> &tria,
3377  std::ostream &out,
3378  const Mapping<dim,spacedim> *mapping) const
3379 {
3380  internal::write_gnuplot (tria, out, mapping, gnuplot_flags);
3381 }
3382 
3383 
3384 
3385 namespace internal
3386 {
3387  namespace
3388  {
3389  struct LineEntry
3390  {
3391  Point<2> first;
3392  Point<2> second;
3393  bool colorize;
3394  unsigned int level;
3395  LineEntry (const Point<2> &f,
3396  const Point<2> &s,
3397  const bool c,
3398  const unsigned int l)
3399  :
3400  first(f), second(s),
3401  colorize(c), level(l)
3402  {}
3403  };
3404 
3405 
3406  void write_eps (const ::Triangulation<1> &,
3407  std::ostream &,
3408  const Mapping<1> *,
3409  const GridOutFlags::Eps<2> &,
3410  const GridOutFlags::Eps<3> &)
3411  {
3412  Assert(false, ExcNotImplemented());
3413  }
3414 
3415  void write_eps (const ::Triangulation<1,2> &,
3416  std::ostream &,
3417  const Mapping<1,2> *,
3418  const GridOutFlags::Eps<2> &,
3419  const GridOutFlags::Eps<3> &)
3420  {
3421  Assert(false, ExcNotImplemented());
3422  }
3423 
3424  void write_eps (const ::Triangulation<1,3> &,
3425  std::ostream &,
3426  const Mapping<1,3> *,
3427  const GridOutFlags::Eps<2> &,
3428  const GridOutFlags::Eps<3> &)
3429  {
3430  Assert(false, ExcNotImplemented());
3431  }
3432 
3433  void write_eps (const ::Triangulation<2,3> &,
3434  std::ostream &,
3435  const Mapping<2,3> *,
3436  const GridOutFlags::Eps<2> &,
3437  const GridOutFlags::Eps<3> &)
3438  {
3439  Assert(false, ExcNotImplemented());
3440  }
3441 
3442 
3443 
3444  template <int dim, int spacedim>
3445  void write_eps (const ::Triangulation<dim, spacedim> &tria,
3446  std::ostream &out,
3447  const Mapping<dim,spacedim> *mapping,
3450  {
3451  typedef std::list<LineEntry> LineList;
3452 
3453  // get a pointer to the flags
3454  // common to all dimensions, in
3455  // order to avoid the recurring
3456  // distinctions between
3457  // eps_flags_1, eps_flags_2, ...
3459  &eps_flags_base = (dim==2 ?
3460  static_cast<const GridOutFlags::EpsFlagsBase &>(eps_flags_2) :
3461  (dim==3 ?
3462  static_cast<const GridOutFlags::EpsFlagsBase &>(eps_flags_3) :
3463  *static_cast<const GridOutFlags::EpsFlagsBase *>(0)));
3464 
3465  AssertThrow (out, ExcIO());
3466  const unsigned int n_points = eps_flags_base.n_boundary_face_points;
3467 
3468  // make up a list of lines by which
3469  // we will construct the triangulation
3470  //
3471  // this part unfortunately is a bit
3472  // dimension dependent, so we have to
3473  // treat every dimension different.
3474  // however, by directly producing
3475  // the lines to be printed, i.e. their
3476  // 2d images, we can later do the
3477  // actual output dimension independent
3478  // again
3479  LineList line_list;
3480 
3481  switch (dim)
3482  {
3483  case 1:
3484  {
3485  Assert(false, ExcInternalError());
3486  break;
3487  }
3488 
3489  case 2:
3490  {
3491  for (typename ::Triangulation<dim, spacedim>::active_cell_iterator
3492  cell=tria.begin_active();
3493  cell!=tria.end(); ++cell)
3494  for (unsigned int line_no=0;
3495  line_no<GeometryInfo<dim>::lines_per_cell; ++line_no)
3496  {
3497  typename ::Triangulation<dim, spacedim>::line_iterator
3498  line=cell->line(line_no);
3499 
3500  // first treat all
3501  // interior lines and
3502  // make up a list of
3503  // them. if curved
3504  // lines shall not be
3505  // supported (i.e. no
3506  // mapping is
3507  // provided), then also
3508  // treat all other
3509  // lines
3510  if (!line->has_children() &&
3511  (mapping==0 || !line->at_boundary()))
3512  // one would expect
3513  // make_pair(line->vertex(0),
3514  // line->vertex(1))
3515  // here, but that is
3516  // not dimension
3517  // independent, since
3518  // vertex(i) is
3519  // Point<dim>, but we
3520  // want a Point<2>.
3521  // in fact, whenever
3522  // we're here, the
3523  // vertex is a
3524  // Point<dim>, but
3525  // the compiler does
3526  // not know
3527  // this. hopefully,
3528  // the compiler will
3529  // optimize away this
3530  // little kludge
3531  line_list.push_back (LineEntry(Point<2>(line->vertex(0)(0),
3532  line->vertex(0)(1)),
3533  Point<2>(line->vertex(1)(0),
3534  line->vertex(1)(1)),
3535  line->user_flag_set(),
3536  cell->level()));
3537  }
3538 
3539  // next if we are to treat
3540  // curved boundaries
3541  // specially, then add lines
3542  // to the list consisting of
3543  // pieces of the boundary
3544  // lines
3545  if (mapping!=0)
3546  {
3547  // to do so, first
3548  // generate a sequence of
3549  // points on a face and
3550  // project them onto the
3551  // faces of a unit cell
3552  std::vector<Point<dim-1> > boundary_points (n_points);
3553 
3554  for (unsigned int i=0; i<n_points; ++i)
3555  boundary_points[i](0) = 1.*(i+1)/(n_points+1);
3556 
3557  Quadrature<dim-1> quadrature (boundary_points);
3558  Quadrature<dim> q_projector (QProjector<dim>::project_to_all_faces(quadrature));
3559 
3560  // next loop over all
3561  // boundary faces and
3562  // generate the info from
3563  // them
3564  for (typename ::Triangulation<dim, spacedim>::active_cell_iterator
3565  cell=tria.begin_active();
3566  cell!=tria.end(); ++cell)
3567  for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
3568  {
3569  const typename ::Triangulation<dim, spacedim>::face_iterator
3570  face = cell->face(face_no);
3571 
3572  if (face->at_boundary())
3573  {
3574  Point<dim> p0_dim(face->vertex(0));
3575  Point<2> p0 (p0_dim(0), p0_dim(1));
3576 
3577  // loop over
3578  // all pieces
3579  // of the line
3580  // and generate
3581  // line-lets
3582  const unsigned int offset=face_no*n_points;
3583  for (unsigned int i=0; i<n_points; ++i)
3584  {
3585  const Point<dim> p1_dim (mapping->transform_unit_to_real_cell
3586  (cell, q_projector.point(offset+i)));
3587  const Point<2> p1 (p1_dim(0), p1_dim(1));
3588 
3589  line_list.push_back (LineEntry(p0, p1,
3590  face->user_flag_set(),
3591  cell->level() ));
3592  p0=p1;
3593  }
3594 
3595  // generate last piece
3596  const Point<dim> p1_dim (face->vertex(1));
3597  const Point<2> p1 (p1_dim(0), p1_dim(1));
3598  line_list.push_back (LineEntry(p0, p1,
3599  face->user_flag_set(),
3600  cell->level()));
3601  }
3602  }
3603  }
3604 
3605  break;
3606  }
3607 
3608  case 3:
3609  {
3610  // curved boundary output
3611  // presently not supported
3612  Assert (mapping == 0, ExcNotImplemented());
3613 
3614  typename ::Triangulation<dim, spacedim>::active_cell_iterator
3615  cell=tria.begin_active(),
3616  endc=tria.end();
3617 
3618  // loop over all lines and compute their
3619  // projection on the plane perpendicular
3620  // to the direction of sight
3621 
3622  // direction of view equals the unit
3623  // vector of the position of the
3624  // spectator to the origin.
3625  //
3626  // we chose here the viewpoint as in
3627  // gnuplot as default.
3628  //
3629  //TODO:[WB] Fix a potential problem with viewing angles in 3d Eps GridOut
3630  // note: the following might be wrong
3631  // if one of the base vectors below
3632  // is in direction of the viewer, but
3633  // I am too tired at present to fix
3634  // this
3635  const double pi = numbers::PI;
3636  const double z_angle = eps_flags_3.azimut_angle;
3637  const double turn_angle = eps_flags_3.turn_angle;
3638  const Point<dim> view_direction(-std::sin(z_angle * 2.*pi / 360.) * std::sin(turn_angle * 2.*pi / 360.),
3639  +std::sin(z_angle * 2.*pi / 360.) * std::cos(turn_angle * 2.*pi / 360.),
3640  -std::cos(z_angle * 2.*pi / 360.));
3641 
3642  // decide about the two unit vectors
3643  // in this plane. we chose the first one
3644  // to be the projection of the z-axis
3645  // to this plane
3646  const Tensor<1,dim> vector1
3647  = Point<dim>(0,0,1) - ((Point<dim>(0,0,1) * view_direction) * view_direction);
3648  const Tensor<1,dim> unit_vector1 = vector1 / vector1.norm();
3649 
3650  // now the third vector is fixed. we
3651  // chose the projection of a more or
3652  // less arbitrary vector to the plane
3653  // perpendicular to the first one
3654  const Tensor<1,dim> vector2
3655  = (Point<dim>(1,0,0)
3656  - ((Point<dim>(1,0,0) * view_direction) * view_direction)
3657  - ((Point<dim>(1,0,0) * unit_vector1) * unit_vector1));
3658  const Tensor<1,dim> unit_vector2 = vector2 / vector2.norm();
3659 
3660 
3661  for (; cell!=endc; ++cell)
3662  for (unsigned int line_no=0;
3663  line_no<GeometryInfo<dim>::lines_per_cell; ++line_no)
3664  {
3665  typename ::Triangulation<dim, spacedim>::line_iterator
3666  line=cell->line(line_no);
3667  line_list.push_back (LineEntry(Point<2>(line->vertex(0) * unit_vector2,
3668  line->vertex(0) * unit_vector1),
3669  Point<2>(line->vertex(1) * unit_vector2,
3670  line->vertex(1) * unit_vector1),
3671  line->user_flag_set(),
3672  cell->level()));
3673  }
3674 
3675  break;
3676  }
3677 
3678  default:
3679  Assert (false, ExcNotImplemented());
3680  }
3681 
3682 
3683 
3684  // find out minimum and maximum x and
3685  // y coordinates to compute offsets
3686  // and scaling factors
3687  double x_min = tria.begin_active()->vertex(0)(0);
3688  double x_max = x_min;
3689  double y_min = tria.begin_active()->vertex(0)(1);
3690  double y_max = y_min;
3691  unsigned int max_level = line_list.begin()->level;
3692 
3693  for (LineList::const_iterator line=line_list.begin();
3694  line!=line_list.end(); ++line)
3695  {
3696  x_min = std::min (x_min, line->first(0));
3697  x_min = std::min (x_min, line->second(0));
3698 
3699  x_max = std::max (x_max, line->first(0));
3700  x_max = std::max (x_max, line->second(0));
3701 
3702  y_min = std::min (y_min, line->first(1));
3703  y_min = std::min (y_min, line->second(1));
3704 
3705  y_max = std::max (y_max, line->first(1));
3706  y_max = std::max (y_max, line->second(1));
3707 
3708  max_level = std::max (max_level, line->level);
3709  }
3710 
3711  // scale in x-direction such that
3712  // in the output 0 <= x <= 300.
3713  // don't scale in y-direction to
3714  // preserve the shape of the
3715  // triangulation
3716  const double scale = (eps_flags_base.size /
3717  (eps_flags_base.size_type==GridOutFlags::EpsFlagsBase::width ?
3718  x_max - x_min :
3719  y_min - y_max));
3720 
3721 
3722  // now write preamble
3723  if (true)
3724  {
3725  // block this to have local
3726  // variables destroyed after
3727  // use
3728  std::time_t time1= std::time (0);
3729  std::tm *time = std::localtime(&time1);
3730  out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n'
3731  << "%%Title: deal.II Output" << '\n'
3732  << "%%Creator: the deal.II library" << '\n'
3733  << "%%Creation Date: "
3734  << time->tm_year+1900 << "/"
3735  << time->tm_mon+1 << "/"
3736  << time->tm_mday << " - "
3737  << time->tm_hour << ":"
3738  << std::setw(2) << time->tm_min << ":"
3739  << std::setw(2) << time->tm_sec << '\n'
3740  << "%%BoundingBox: "
3741  // lower left corner
3742  << "0 0 "
3743  // upper right corner
3744  << static_cast<unsigned int>(std::floor(( (x_max-x_min) * scale )+1))
3745  << ' '
3746  << static_cast<unsigned int>(std::floor(( (y_max-y_min) * scale )+1))
3747  << '\n';
3748 
3749  // define some abbreviations to keep
3750  // the output small:
3751  // m=move turtle to
3752  // x=execute line stroke
3753  // b=black pen
3754  // r=red pen
3755  out << "/m {moveto} bind def" << '\n'
3756  << "/x {lineto stroke} bind def" << '\n'
3757  << "/b {0 0 0 setrgbcolor} def" << '\n'
3758  << "/r {1 0 0 setrgbcolor} def" << '\n';
3759 
3760  // calculate colors for level
3761  // coloring; level 0 is black,
3762  // other levels are blue
3763  // ... red
3764  if (eps_flags_base.color_lines_level)
3765  out << "/l { neg "
3766  << (max_level)
3767  << " add "
3768  << (0.66666/std::max(1U,(max_level-1)))
3769  << " mul 1 0.8 sethsbcolor} def" << '\n';
3770 
3771  // in 2d, we can also plot cell
3772  // and vertex numbers, but this
3773  // requires a somewhat more
3774  // lengthy preamble. please
3775  // don't ask me what most of
3776  // this means, it is reverse
3777  // engineered from what GNUPLOT
3778  // uses in its output
3779  if ((dim == 2) && (eps_flags_2.write_cell_numbers ||
3780  eps_flags_2.write_vertex_numbers))
3781  {
3782  out << ("/R {rmoveto} bind def\n"
3783  "/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont\n"
3784  "dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall\n"
3785  "currentdict end definefont\n"
3786  "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n"
3787  "[ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n"
3788  "{show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n"
3789  "{2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n"
3790  "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n"
3791  "5 get stringwidth pop add}\n"
3792  "{pop} ifelse} forall} bind def\n"
3793  "/MCshow { currentpoint stroke m\n"
3794  "exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n")
3795  << '\n';
3796  }
3797 
3798  out << "%%EndProlog" << '\n'
3799  << '\n';
3800 
3801  // set fine lines
3802  out << eps_flags_base.line_width << " setlinewidth" << '\n';
3803  }
3804 
3805  // now write the lines
3806  const Point<2> offset(x_min, y_min);
3807 
3808  for (LineList::const_iterator line=line_list.begin();
3809  line!=line_list.end(); ++line)
3810  if (eps_flags_base.color_lines_level && (line->level > 0))
3811  // lines colored according to
3812  // refinement level,
3813  // contributed by J�rg
3814  // R. Weimar
3815  out << line->level
3816  << " l "
3817  << (line->first - offset) * scale << " m "
3818  << (line->second - offset) * scale << " x" << '\n';
3819  else
3820  out << ((line->colorize && eps_flags_base.color_lines_on_user_flag) ? "r " : "b ")
3821  << (line->first - offset) * scale << " m "
3822  << (line->second - offset) * scale << " x" << '\n';
3823 
3824  // finally write the cell numbers
3825  // in 2d, if that is desired
3826  if ((dim == 2) && (eps_flags_2.write_cell_numbers == true))
3827  {
3828  out << "(Helvetica) findfont 140 scalefont setfont"
3829  << '\n';
3830 
3831  typename ::Triangulation<dim, spacedim>::active_cell_iterator
3832  cell = tria.begin_active (),
3833  endc = tria.end ();
3834  for (; cell!=endc; ++cell)
3835  {
3836  out << (cell->center()(0)-offset(0))*scale << ' '
3837  << (cell->center()(1)-offset(1))*scale
3838  << " m" << '\n'
3839  << "[ [(Helvetica) 12.0 0.0 true true (";
3840  if (eps_flags_2.write_cell_number_level)
3841  out << cell;
3842  else
3843  out << cell->index();
3844 
3845  out << ")] "
3846  << "] -6 MCshow"
3847  << '\n';
3848  }
3849  }
3850 
3851  // and the vertex numbers
3852  if ((dim == 2) && (eps_flags_2.write_vertex_numbers == true))
3853  {
3854  out << "(Helvetica) findfont 140 scalefont setfont"
3855  << '\n';
3856 
3857  // have a list of those
3858  // vertices which we have
3859  // already tracked, to avoid
3860  // doing this multiply
3861  std::set<unsigned int> treated_vertices;
3862  typename ::Triangulation<dim, spacedim>::active_cell_iterator
3863  cell = tria.begin_active (),
3864  endc = tria.end ();
3865  for (; cell!=endc; ++cell)
3866  for (unsigned int vertex=0;
3867  vertex<GeometryInfo<dim>::vertices_per_cell;
3868  ++vertex)
3869  if (treated_vertices.find(cell->vertex_index(vertex))
3870  ==
3871  treated_vertices.end())
3872  {
3873  treated_vertices.insert (cell->vertex_index(vertex));
3874 
3875  out << (cell->vertex(vertex)(0)-offset(0))*scale << ' '
3876  << (cell->vertex(vertex)(1)-offset(1))*scale
3877  << " m" << '\n'
3878  << "[ [(Helvetica) 10.0 0.0 true true ("
3879  << cell->vertex_index(vertex)
3880  << ")] "
3881  << "] -6 MCshow"
3882  << '\n';
3883  }
3884  }
3885 
3886  out << "showpage" << '\n';
3887 
3888  // make sure everything now gets to
3889  // disk
3890  out.flush ();
3891 
3892  AssertThrow (out, ExcIO());
3893  }
3894  }
3895 }
3896 
3897 
3898 template <int dim, int spacedim>
3900  std::ostream &out,
3901  const Mapping<dim,spacedim> *mapping) const
3902 {
3903  internal::write_eps (tria, out, mapping,
3905 }
3906 
3907 
3908 template <int dim, int spacedim>
3910  std::ostream &out,
3911  const OutputFormat output_format,
3912  const Mapping<dim,spacedim> *mapping) const
3913 {
3914  switch (output_format)
3915  {
3916  case none:
3917  return;
3918 
3919  case dx:
3920  write_dx (tria, out);
3921  return;
3922 
3923  case ucd:
3924  write_ucd (tria, out);
3925  return;
3926 
3927  case gnuplot:
3928  write_gnuplot (tria, out, mapping);
3929  return;
3930 
3931  case eps:
3932  write_eps (tria, out, mapping);
3933  return;
3934 
3935  case xfig:
3936  write_xfig (tria, out, mapping);
3937  return;
3938 
3939  case msh:
3940  write_msh (tria, out);
3941  return;
3942 
3943  case svg:
3944  write_svg (tria, out);
3945  return;
3946 
3947  case mathgl:
3948  write_mathgl (tria, out);
3949  return;
3950 
3951  case vtk:
3952  write_vtk (tria, out);
3953  return;
3954 
3955  case vtu:
3956  write_vtu (tria, out);
3957  return;
3958  }
3959 
3960  Assert (false, ExcInternalError());
3961 }
3962 
3963 
3964 template <int dim, int spacedim>
3966  std::ostream &out,
3967  const Mapping<dim,spacedim> *mapping) const
3968 {
3969  write(tria, out, default_format, mapping);
3970 }
3971 
3972 
3973 // explicit instantiations
3974 #include "grid_out.inst"
3975 
3976 
3977 DEAL_II_NAMESPACE_CLOSE
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:143
Use white background.
Definition: grid_out.h:628
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:621
unsigned int n_boundary_faces(const Triangulation< dim, spacedim > &tria) const
Definition: grid_out.cc:2573
unsigned int n_active_cells() const
Definition: tria.cc:10973
long int get_integer(const std::string &entry_string) const
unsigned int n_used_vertices() const
Definition: tria.cc:11501
OutputFormat default_format
Definition: grid_out.h:1231
static void declare_parameters(ParameterHandler &prm)
DX(const bool write_cells=true, const bool write_faces=false, const bool write_diameter=false, const bool write_measure=false, const bool write_all_faces=true)
Definition: grid_out.cc:41
active_face_iterator begin_active_face() const
Definition: tria.cc:10577
static OutputFormat parse_output_format(const std::string &format_name)
Definition: grid_out.cc:524
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:294
bool margin
Margin around the plotted area.
Definition: grid_out.h:618
bool write_cells
Definition: grid_out.h:57
write() calls write_dx()
Definition: grid_out.h:845
Gnuplot(const bool write_cell_number=false, const unsigned int n_boundary_face_points=2, const bool curved_inner_cells=false)
Definition: grid_out.cc:126
unsigned int n_boundary_face_points
Definition: grid_out.h:542
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:386
GridOutFlags::Eps< 2 > eps_flags_2
Definition: grid_out.h:1266
unsigned int height
Height of the plot in SVG units, computed from width if zero. Defaults to 1000.
Definition: grid_out.h:609
OutputFormat
Definition: grid_out.h:840
bool draw_legend
Draw a legend next to the plotted grid, explaining the label of the cells.
Definition: grid_out.h:686
::ExceptionBase & ExcMessage(std::string arg1)
void write_vtu(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:2506
std::string get(const std::string &entry_string) const
GridOut()
Definition: grid_out.cc:399
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:186
const Point< dim > & point(const unsigned int i) const
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:318
Convert the level number into the cell color.
Definition: grid_out.h:655
write() calls write_eps()
Definition: grid_out.h:849
active_cell_iterator begin_active(const unsigned int level=0) const
Definition: tria.cc:10397
unsigned int line_thickness
Thickness of the lines between cells.
Definition: grid_out.h:613
void write_eps(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=0) const
Definition: grid_out.cc:3899
unsigned int n_boundary_face_points
Definition: grid_out.h:244
bool convert_level_number_to_height
Interpret the level number of the cells as altitude over the x-y-plane (useful in the perspective vie...
Definition: grid_out.h:665
#define AssertThrow(cond, exc)
Definition: exceptions.h:358
bool write_diameter
Definition: grid_out.h:67
numbers::NumberTraits< Number >::real_type norm() const
Definition: tensor.h:1047
static Point< 2 > svg_project_point(Point< 3 > point, Point< 3 > camera_position, Point< 3 > camera_direction, Point< 3 > camera_horizontal, float camera_focus)
Definition: grid_out.cc:2959
void write_mathgl(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:2293
virtual Point< dim > transform_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p) const =0
unsigned int boundary_line_thickness
Thickness of lines at the boundary.
Definition: grid_out.h:615
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
cell_iterator begin(const unsigned int level=0) const
Definition: tria.cc:10377
unsigned int write_msh_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:2702
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:70
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:258
bool write_all_faces
Definition: grid_out.h:78
write() calls write_ucd()
Definition: grid_out.h:851
cell_iterator end() const
Definition: tria.cc:10465
unsigned int n_boundary_lines(const Triangulation< dim, spacedim > &tria) const
Definition: grid_out.cc:2590
void enter_subsection(const std::string &subsection)
GridOutFlags::Vtk vtk_flags
Definition: grid_out.h:1292
Point< 2 > scaling
Definition: grid_out.h:547
bool label_cell_index
Write cell index into each cell. Defaults to true.
Definition: grid_out.h:675
static const double PI
Definition: numbers.h:74
GridOutFlags::Gnuplot gnuplot_flags
Definition: grid_out.h:1254
void write_svg(const Triangulation< 2, 2 > &tria, std::ostream &out) const
Definition: grid_out.cc:1422
Convert the global subdomain id into the cell color.
Definition: grid_out.h:526
Convert the material id into the cell color.
Definition: grid_out.h:522
void write_gnuplot(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=0) const
Definition: grid_out.cc:3375
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:136
std::size_t memory_consumption() const
Definition: grid_out.cc:667
double get_double(const std::string &entry_name) const
GridOutFlags::MathGL mathgl_flags
Definition: grid_out.h:1287
write() calls write_mathgl()
Definition: grid_out.h:859
GridOutFlags::DX dx_flags
Definition: grid_out.h:1236
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1242
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1260
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
write() calls write_gnuplot()
Definition: grid_out.h:847
#define Assert(cond, exc)
Definition: exceptions.h:294
void parse_parameters(const ParameterHandler &prm)
bool label_material_id
Write material id of each cell. Defaults to false.
Definition: grid_out.h:677
EpsFlagsBase(const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const bool color_lines_on_user_flag=false, const unsigned int n_boundary_face_points=2, const bool color_lines_level=false)
Definition: grid_out.cc:150
Abstract base class for mapping classes.
Definition: dof_tools.h:52
GridOutFlags::XFig xfig_flags
Definition: grid_out.h:1277
bool label_subdomain_id
Write subdomain id of each cell. Defaults to false.
Definition: grid_out.h:679
Use a gradient from white (top) to steelblue (bottom), and add date and time plus a deal...
Definition: grid_out.h:630
Ucd(const bool write_preamble=false, const bool write_faces=false, const bool write_lines=false)
Definition: grid_out.cc:100
const std::vector< Point< spacedim > > & get_vertices() const
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:573
bool label_level_subdomain_id
Write level subdomain id of each cell. Defaults to false.
Definition: grid_out.h:681
static std::string get_output_format_names()
Definition: grid_out.cc:566
Convert the subdomain id into the cell color.
Definition: grid_out.h:657
Msh(const bool write_faces=false, const bool write_lines=false)
Definition: grid_out.cc:80
unsigned int n_subdivisions
bool get_bool(const std::string &entry_name) const
void write_vtk(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:2482
GridOutFlags::Ucd ucd_flags
Definition: grid_out.h:1248
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:110
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:165
Do nothing in write()
Definition: grid_out.h:843
float cell_font_scaling
Scaling of the font for cell annotations. Defaults to 1.
Definition: grid_out.h:671
Convert the level subdomain id into the cell color.
Definition: grid_out.h:528
void write_vtk(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
write() calls write_xfig()
Definition: grid_out.h:853
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
Convert the level subdomain id into the cell color.
Definition: grid_out.h:659
static Quadrature< dim > project_to_all_faces(const SubQuadrature &quadrature)
void write(const Triangulation< dim, spacedim > &tria, std::ostream &out, const OutputFormat output_format, const Mapping< dim, spacedim > *mapping=0) const
Definition: grid_out.cc:3909
bool write_faces
Definition: grid_out.h:62
Convert the level into the cell color.
Definition: grid_out.h:524
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:93
unsigned int n_boundary_face_points
Definition: grid_out.h:330
Point< 2 > offset
Definition: grid_out.h:553
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:86
unsigned int write_ucd_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:2869
write() calls write_msh()
Definition: grid_out.h:855
const std::vector< bool > & get_used_vertices() const
Definition: tria.cc:11511
void write_ucd(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:1088
unsigned int write_ucd_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:2909
write() calls write_svg()
Definition: grid_out.h:857
unsigned int write_msh_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:2744
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1282
Svg(const unsigned int line_thickness=2, const unsigned int boundary_line_thickness=4, bool margin=true, const Background background=white, const int azimuth_angle=0, const int polar_angle=0, const Coloring coloring=level_number, const bool convert_level_number_to_height=false, const bool label_level_number=true, const bool label_cell_index=true, const bool label_material_id=false, const bool label_subdomain_id=false, const bool draw_colorbar=true, const bool draw_legend=true)
Definition: grid_out.cc:345
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:333
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
bool write_measure
Definition: grid_out.h:72
Convert the material id into the cell color (default)
Definition: grid_out.h:653
float level_height_factor
The factor determining the vertical distance between levels (default = 0.3)
Definition: grid_out.h:668
unsigned char boundary_id
Definition: types.h:110
GridOutFlags::Eps< 3 > eps_flags_3
Definition: grid_out.h:1272
face_iterator end_face() const
Definition: tria.cc:10598
const types::boundary_id internal_face_boundary_id
Definition: types.h:210
write() calls write_vtu()
Definition: grid_out.h:863
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:53
void set_flags(const GridOutFlags::DX &flags)
Definition: grid_out.cc:405
bool label_level_number
Write level number into each cell. Defaults to true.
Definition: grid_out.h:673
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:118
bool draw_colorbar
Draw a colorbar next to the plotted grid with respect to the chosen coloring of the cells...
Definition: grid_out.h:684
void write_dx(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:709
virtual Point< spacedim > transform_unit_to_real_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &p) const =0
GridOutFlags::Vtu vtu_flags
Definition: grid_out.h:1297
unsigned int width
The width of the plot. Computed automatically from height if zero (default)
Definition: grid_out.h:611
void write_xfig(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=0) const
Definition: grid_out.cc:1214
Table< 2, float > data
write() calls write_vtk()
Definition: grid_out.h:861
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:391
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:217
void write_msh(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:942
std::string default_suffix() const
Definition: grid_out.cc:516