]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add the ability to output tet meshes in gnuplot format.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 16 Nov 2021 00:46:59 +0000 (17:46 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 16 Nov 2021 00:46:59 +0000 (17:46 -0700)
source/grid/grid_out.cc

index 92362ce53a9f044d0035b15df5db6d8f8581b6e4..287364b001ffce3972406b781c23ec1f9d0e99e1 100644 (file)
@@ -4411,55 +4411,80 @@ namespace internal
               (!cell->has_boundary_lines() &&
                !gnuplot_flags.curved_inner_cells))
             {
-              // front face
-              out << cell->vertex(0) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(1) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(5) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(4) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(0) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << '\n';
-              // back face
-              out << cell->vertex(2) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(3) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(7) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(6) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(2) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << '\n';
+              if (cell->reference_cell() == ReferenceCells::Hexahedron)
+                {
+                  // front face
+                  out << cell->vertex(0) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(1) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(5) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(4) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(0) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << '\n';
+                  // back face
+                  out << cell->vertex(2) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(3) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(7) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(6) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(2) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << '\n';
+
+                  // now for the four connecting lines
+                  out << cell->vertex(0) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(2) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << '\n';
+                  out << cell->vertex(1) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(3) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << '\n';
+                  out << cell->vertex(5) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(7) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << '\n';
+                  out << cell->vertex(4) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << cell->vertex(6) << ' ' << cell->level() << ' '
+                      << cell->material_id() << '\n'
+                      << '\n';
+                }
+              else if (cell->reference_cell() == ReferenceCells::Tetrahedron)
+                {
+                  // Draw the tetrahedron as a two collections of lines.
+                  for (const unsigned int v : {0, 1, 2, 0, 3, 2})
+                    {
+                      out << cell->vertex(v) << ' ' << cell->level() << ' '
+                          << cell->material_id() << '\n';
+                    }
+                  out << '\n'; // end of first line
 
-              // now for the four connecting lines
-              out << cell->vertex(0) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(2) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << '\n';
-              out << cell->vertex(1) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(3) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << '\n';
-              out << cell->vertex(5) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(7) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << '\n';
-              out << cell->vertex(4) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << cell->vertex(6) << ' ' << cell->level() << ' '
-                  << cell->material_id() << '\n'
-                  << '\n';
+                  for (const unsigned int v : {3, 1})
+                    {
+                      out << cell->vertex(v) << ' ' << cell->level() << ' '
+                          << cell->material_id() << '\n';
+                    }
+                  out << '\n'; // end of second line
+                }
+              else
+                Assert(false, ExcNotImplemented());
             }
           else
             {
+              Assert(cell->reference_cell() == ReferenceCells::Hexahedron,
+                     ExcNotImplemented());
+
               for (const unsigned int face_no :
                    GeometryInfo<dim>::face_indices())
                 {

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

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.