]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Enabel high-order VTK output in 1D 18536/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 2 Jun 2025 06:51:45 +0000 (08:51 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 2 Jun 2025 20:00:24 +0000 (22:00 +0200)
doc/news/changes/minor/20250602Munch [new file with mode: 0644]
source/base/data_out_base.cc
source/grid/reference_cell.cc
tests/data_out/data_out_base_vtk_03.cc
tests/data_out/data_out_base_vtk_03.output

diff --git a/doc/news/changes/minor/20250602Munch b/doc/news/changes/minor/20250602Munch
new file mode 100644 (file)
index 0000000..7b5d417
--- /dev/null
@@ -0,0 +1,3 @@
+New: Enable high-order VTK output in 1D.
+<br>
+(Peter Munch, 2025/04/28)
index 01ab0b2f131432f2184243a8b395c2f2113bd4cd..4b72e9f273c6b86072fc0a369578cb2c79dfb1a7 100644 (file)
@@ -2728,7 +2728,6 @@ namespace DataOutBase
                          StreamType                              &out,
                          const bool                               legacy_format)
   {
-    Assert(dim <= 3 && dim > 1, ExcNotImplemented());
     unsigned int first_vertex_of_patch = 0;
     // Array to hold all the node numbers of a cell
     std::vector<unsigned> connectivity;
@@ -5675,8 +5674,8 @@ namespace DataOutBase
                                     /* use VTU, not VTK: */ false);
                               local_vertex_order[connectivity_index] =
                                 local_index;
-                              flush_current_cell();
                             }
+                          flush_current_cell();
 
                           break;
                         }
index 090792d50251d370288a5866e1624614b70ac0e2..b1bf43b63edc4509aa20899cafd2db582a01cec7 100644 (file)
@@ -484,15 +484,30 @@ ReferenceCell::vtk_lexicographic_to_node_index<0>(
 
 
 
+/**
+ * Modified from
+ * https://github.com/Kitware/VTK/blob/265ca48a79a36538c95622c237da11133608bbe5/Common/DataModel/vtkLagrangeCurve.cxx#L478
+ */
 template <>
 unsigned int
 ReferenceCell::vtk_lexicographic_to_node_index<1>(
-  const std::array<unsigned, 1> &,
-  const std::array<unsigned, 1> &,
+  const std::array<unsigned, 1> &node_indices,
+  const std::array<unsigned, 1> &nodes_per_direction,
   const bool) const
 {
-  DEAL_II_NOT_IMPLEMENTED();
-  return 0;
+  const unsigned int i = node_indices[0];
+
+  const bool ibdy = (i == 0 || i == nodes_per_direction[0]);
+  // How many boundaries do we lie on at once?
+  const int nbdy = (ibdy ? 1 : 0);
+
+  if (nbdy == 1) // Vertex DOF
+    { // ijk is a corner node. Return the proper index (somewhere in [0,7]):
+      return i ? 1 : 0;
+    }
+
+  const int offset = 2;
+  return (i - 1) + offset;
 }
 
 
index 1cea10460801e90b8ebaa1d0b2104c21a08642bb..584cf1c7921c5299396145c1709dd90519ffe1a5 100644 (file)
@@ -47,6 +47,7 @@ main()
   initlog();
 
   unsigned cell_order = 4;
+  check<1>(deallog.get_file_stream(), cell_order);
   check<2>(deallog.get_file_stream(), cell_order);
   check<3>(deallog.get_file_stream(), cell_order);
 }
index c7c2c1da0bbb88814b4628043171803dfbdb364b..88ce53b857d8e577dd132223fdb0ec0a9d0fb4b2 100644 (file)
@@ -4,6 +4,24 @@
 ASCII
 DATASET UNSTRUCTURED_GRID
 
+POINTS 5 double
+0.00000 0 0
+0.250000 0 0
+0.500000 0 0
+0.750000 0 0
+1.00000 0 0
+
+CELLS 1 6
+5      0       4       1       2       3
+
+CELL_TYPES 1
+ 68
+POINT_DATA 5
+# vtk DataFile Version 3.0
+#This file was generated 
+ASCII
+DATASET UNSTRUCTURED_GRID
+
 POINTS 25 double
 0.00000 0.00000 0
 0.250000 0.00000 0

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.