]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement gnuplot output for tetrahedra.
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 1 Nov 2021 22:48:42 +0000 (16:48 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 5 Nov 2021 03:48:48 +0000 (21:48 -0600)
source/base/data_out_base.cc

index 6a44dd6db025a138622967b86b720d5ba3b513f5..92b530f1a23a8de37912eb6f08b3d7224bc36431 100644 (file)
@@ -3873,101 +3873,150 @@ namespace DataOutBase
 
             case 3:
               {
-                Assert(patch.reference_cell == ReferenceCells::Hexahedron,
-                       ExcNotImplemented());
-                Assert(patch.data.n_cols() ==
-                         Utilities::fixed_power<dim>(n_points_per_direction),
-                       ExcInvalidDatasetSize(patch.data.n_cols(),
-                                             n_subdivisions + 1));
+                if (patch.reference_cell == ReferenceCells::Hexahedron)
+                  {
+                    Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
+                                                    n_points_per_direction),
+                           ExcInvalidDatasetSize(patch.data.n_cols(),
+                                                 n_subdivisions + 1));
 
-                // for all grid points: draw lines into all positive coordinate
-                // directions if there is another grid point there
-                for (unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
-                  for (unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
-                    for (unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
-                      {
-                        // compute coordinates for this patch point
-                        const Point<spacedim> this_point =
-                          get_equispaced_location(patch,
-                                                  {i1, i2, i3},
-                                                  n_subdivisions);
-                        // line into positive x-direction if possible
-                        if (i1 < n_subdivisions)
+                    // for all grid points: draw lines into all positive
+                    // coordinate directions if there is another grid point
+                    // there
+                    for (unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
+                      for (unsigned int i2 = 0; i2 < n_points_per_direction;
+                           ++i2)
+                        for (unsigned int i1 = 0; i1 < n_points_per_direction;
+                             ++i1)
                           {
-                            // write point here and its data
-                            out << this_point << ' ';
-                            output_point_data(i1 + i2 * n_points_per_direction +
-                                              i3 * n_points_per_direction *
-                                                n_points_per_direction);
-                            out << '\n';
-
-                            // write point there and its data
-                            out << get_equispaced_location(patch,
-                                                           {i1 + 1, i2, i3},
-                                                           n_subdivisions)
-                                << ' ';
-
-                            output_point_data((i1 + 1) +
-                                              i2 * n_points_per_direction +
-                                              i3 * n_points_per_direction *
-                                                n_points_per_direction);
-                            out << '\n';
-
-                            // end of line
-                            out << '\n' << '\n';
+                            // compute coordinates for this patch point
+                            const Point<spacedim> this_point =
+                              get_equispaced_location(patch,
+                                                      {i1, i2, i3},
+                                                      n_subdivisions);
+                            // line into positive x-direction if possible
+                            if (i1 < n_subdivisions)
+                              {
+                                // write point here and its data
+                                out << this_point << ' ';
+                                output_point_data(i1 +
+                                                  i2 * n_points_per_direction +
+                                                  i3 * n_points_per_direction *
+                                                    n_points_per_direction);
+                                out << '\n';
+
+                                // write point there and its data
+                                out << get_equispaced_location(patch,
+                                                               {i1 + 1, i2, i3},
+                                                               n_subdivisions)
+                                    << ' ';
+
+                                output_point_data((i1 + 1) +
+                                                  i2 * n_points_per_direction +
+                                                  i3 * n_points_per_direction *
+                                                    n_points_per_direction);
+                                out << '\n';
+
+                                // end of line
+                                out << '\n' << '\n';
+                              }
+
+                            // line into positive y-direction if possible
+                            if (i2 < n_subdivisions)
+                              {
+                                // write point here and its data
+                                out << this_point << ' ';
+                                output_point_data(i1 +
+                                                  i2 * n_points_per_direction +
+                                                  i3 * n_points_per_direction *
+                                                    n_points_per_direction);
+                                out << '\n';
+
+                                // write point there and its data
+                                out << get_equispaced_location(patch,
+                                                               {i1, i2 + 1, i3},
+                                                               n_subdivisions)
+                                    << ' ';
+
+                                output_point_data(
+                                  i1 + (i2 + 1) * n_points_per_direction +
+                                  i3 * n_points_per_direction *
+                                    n_points_per_direction);
+                                out << '\n';
+
+                                // end of line
+                                out << '\n' << '\n';
+                              }
+
+                            // line into positive z-direction if possible
+                            if (i3 < n_subdivisions)
+                              {
+                                // write point here and its data
+                                out << this_point << ' ';
+                                output_point_data(i1 +
+                                                  i2 * n_points_per_direction +
+                                                  i3 * n_points_per_direction *
+                                                    n_points_per_direction);
+                                out << '\n';
+
+                                // write point there and its data
+                                out << get_equispaced_location(patch,
+                                                               {i1, i2, i3 + 1},
+                                                               n_subdivisions)
+                                    << ' ';
+
+                                output_point_data(
+                                  i1 + i2 * n_points_per_direction +
+                                  (i3 + 1) * n_points_per_direction *
+                                    n_points_per_direction);
+                                out << '\n';
+                                // end of line
+                                out << '\n' << '\n';
+                              }
                           }
+                  }
+                else if (patch.reference_cell == ReferenceCells::Tetrahedron)
+                  {
+                    Assert(n_subdivisions == 1, ExcNotImplemented());
 
-                        // line into positive y-direction if possible
-                        if (i2 < n_subdivisions)
-                          {
-                            // write point here and its data
-                            out << this_point << ' ';
-                            output_point_data(i1 + i2 * n_points_per_direction +
-                                              i3 * n_points_per_direction *
-                                                n_points_per_direction);
-                            out << '\n';
+                    // Draw the tetrahedron as a two collections of lines.
+                    out << get_node_location(patch, 0) << ' ';
+                    output_point_data(0);
+                    out << '\n';
 
-                            // write point there and its data
-                            out << get_equispaced_location(patch,
-                                                           {i1, i2 + 1, i3},
-                                                           n_subdivisions)
-                                << ' ';
+                    out << get_node_location(patch, 1) << ' ';
+                    output_point_data(1);
+                    out << '\n';
 
-                            output_point_data(
-                              i1 + (i2 + 1) * n_points_per_direction +
-                              i3 * n_points_per_direction *
-                                n_points_per_direction);
-                            out << '\n';
+                    out << get_node_location(patch, 2) << ' ';
+                    output_point_data(2);
+                    out << '\n';
 
-                            // end of line
-                            out << '\n' << '\n';
-                          }
+                    out << get_node_location(patch, 0) << ' ';
+                    output_point_data(0);
+                    out << '\n';
 
-                        // line into positive z-direction if possible
-                        if (i3 < n_subdivisions)
-                          {
-                            // write point here and its data
-                            out << this_point << ' ';
-                            output_point_data(i1 + i2 * n_points_per_direction +
-                                              i3 * n_points_per_direction *
-                                                n_points_per_direction);
-                            out << '\n';
+                    out << get_node_location(patch, 3) << ' ';
+                    output_point_data(3);
+                    out << '\n';
 
-                            // write point there and its data
-                            out << get_equispaced_location(patch,
-                                                           {i1, i2, i3 + 1},
-                                                           n_subdivisions)
-                                << ' ';
+                    out << get_node_location(patch, 2) << ' ';
+                    output_point_data(2);
+                    out << '\n';
+                    out << '\n'; // end of first line
 
-                            output_point_data(i1 + i2 * n_points_per_direction +
-                                              (i3 + 1) *
-                                                n_points_per_direction *
-                                                n_points_per_direction);
-                            out << '\n';
-                            // end of line
-                            out << '\n' << '\n';
-                          }
-                      }
+                    out << get_node_location(patch, 3) << ' ';
+                    output_point_data(3);
+                    out << '\n';
+
+                    out << get_node_location(patch, 1) << ' ';
+                    output_point_data(1);
+                    out << '\n';
+                    out << '\n'; // end of second line
+                  }
+                else
+                  // No other reference cells are currently implemented
+                  Assert(false, ExcNotImplemented());
 
                 break;
               }

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.