From: Peter Munch Date: Mon, 2 Jun 2025 06:51:45 +0000 (+0200) Subject: Enabel high-order VTK output in 1D X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba82c4215fa57c8e2560d4b23ead55cd1ae2ddec;p=dealii.git Enabel high-order VTK output in 1D --- diff --git a/doc/news/changes/minor/20250602Munch b/doc/news/changes/minor/20250602Munch new file mode 100644 index 0000000000..7b5d41713b --- /dev/null +++ b/doc/news/changes/minor/20250602Munch @@ -0,0 +1,3 @@ +New: Enable high-order VTK output in 1D. +
+(Peter Munch, 2025/04/28) diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 01ab0b2f13..4b72e9f273 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -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 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; } diff --git a/source/grid/reference_cell.cc b/source/grid/reference_cell.cc index 090792d502..b1bf43b63e 100644 --- a/source/grid/reference_cell.cc +++ b/source/grid/reference_cell.cc @@ -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 &, - const std::array &, + const std::array &node_indices, + const std::array &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; } diff --git a/tests/data_out/data_out_base_vtk_03.cc b/tests/data_out/data_out_base_vtk_03.cc index 1cea104608..584cf1c792 100644 --- a/tests/data_out/data_out_base_vtk_03.cc +++ b/tests/data_out/data_out_base_vtk_03.cc @@ -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); } diff --git a/tests/data_out/data_out_base_vtk_03.output b/tests/data_out/data_out_base_vtk_03.output index c7c2c1da0b..88ce53b857 100644 --- a/tests/data_out/data_out_base_vtk_03.output +++ b/tests/data_out/data_out_base_vtk_03.output @@ -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