From ebc5b9fcf0a4fdd447cb5fa4dd5874446dbd94c2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 12 Dec 2023 18:42:19 -0700 Subject: [PATCH] Add a test for a recent patch. --- tests/grid/grid_in_vtk_1d_3d.cc | 78 ++++++++++++++++++++++++++ tests/grid/grid_in_vtk_1d_3d.output | 59 +++++++++++++++++++ tests/grid/grid_in_vtk_1d_3d.tria1.vtk | 37 ++++++++++++ tests/grid/grid_in_vtk_1d_3d.tria2.vtk | 37 ++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 tests/grid/grid_in_vtk_1d_3d.cc create mode 100644 tests/grid/grid_in_vtk_1d_3d.output create mode 100644 tests/grid/grid_in_vtk_1d_3d.tria1.vtk create mode 100644 tests/grid/grid_in_vtk_1d_3d.tria2.vtk diff --git a/tests/grid/grid_in_vtk_1d_3d.cc b/tests/grid/grid_in_vtk_1d_3d.cc new file mode 100644 index 0000000000..235815ffd6 --- /dev/null +++ b/tests/grid/grid_in_vtk_1d_3d.cc @@ -0,0 +1,78 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2023 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Read in two dim=1, spacedim=3 files in VTK format, and merge them +// into one triangulation. This failed at one point because we +// erroneously tried to find correct directions for each line. + + +#include +#include +#include +#include + +#include +#include +#include + +#include "../tests.h" + + +int +main() +{ + initlog(); + + Triangulation<1, 3> triangulation1; + GridIn<1, 3> grid_in1; + grid_in1.attach_triangulation(triangulation1); + std::ifstream input_file1(SOURCE_DIR "/grid_in_vtk_1d_3d.tria1.vtk"); + grid_in1.read_vtk(input_file1); + + Triangulation<1, 3> triangulation2; + GridIn<1, 3> grid_in2; + grid_in2.attach_triangulation(triangulation2); + std::ifstream input_file2(SOURCE_DIR "/grid_in_vtk_1d_3d.tria2.vtk"); + grid_in2.read_vtk(input_file2); + + deallog << "Triangulation 1:\n"; + for (const auto &cell : triangulation1.active_cell_iterators()) + { + deallog << " cell=" << cell << std::endl; + for (const auto c : cell->vertex_indices()) + { + Point<3> &v = cell->vertex(c); + deallog << " vertex: " << v << std::endl; + } + } + + deallog << "Triangulation 2:\n"; + for (const auto &cell : triangulation2.active_cell_iterators()) + { + deallog << " cell=" << cell << std::endl; + for (const auto c : cell->vertex_indices()) + { + Point<3> &v = cell->vertex(c); + deallog << " vertex: " << v << std::endl; + } + } + + GridGenerator::merge_triangulations(triangulation2, + triangulation1, + triangulation2); + GridOut go; + go.write_gnuplot(triangulation2, deallog.get_file_stream()); +} diff --git a/tests/grid/grid_in_vtk_1d_3d.output b/tests/grid/grid_in_vtk_1d_3d.output new file mode 100644 index 0000000000..f1d25018eb --- /dev/null +++ b/tests/grid/grid_in_vtk_1d_3d.output @@ -0,0 +1,59 @@ + +DEAL::Triangulation 1: + cell=0.0 +DEAL:: vertex: 0.00000 2.01000 0.00000 +DEAL:: vertex: 0.00000 2.01000 1.00000 +DEAL:: cell=0.1 +DEAL:: vertex: 0.00000 2.01000 0.00000 +DEAL:: vertex: 0.00000 1.01000 0.00000 +DEAL:: cell=0.2 +DEAL:: vertex: 0.00000 2.01000 0.00000 +DEAL:: vertex: 0.00000 2.01000 -1.00000 +DEAL:: cell=0.3 +DEAL:: vertex: 0.00000 2.01000 0.00000 +DEAL:: vertex: 0.00000 3.01000 0.00000 +DEAL::Triangulation 2: + cell=0.0 +DEAL:: vertex: 0.00000 0.00000 0.00000 +DEAL:: vertex: 0.00000 0.00000 1.00000 +DEAL:: cell=0.1 +DEAL:: vertex: 0.00000 0.00000 0.00000 +DEAL:: vertex: 0.00000 -1.00000 0.00000 +DEAL:: cell=0.2 +DEAL:: vertex: 0.00000 0.00000 0.00000 +DEAL:: vertex: 0.00000 0.00000 -1.00000 +DEAL:: cell=0.3 +DEAL:: vertex: 0.00000 0.00000 0.00000 +DEAL:: vertex: 0.00000 1.00000 0.00000 +0.00000 0.00000 0.00000 0 0 +0.00000 0.00000 1.00000 0 0 + + +0.00000 0.00000 0.00000 0 1 +0.00000 -1.00000 0.00000 0 1 + + +0.00000 0.00000 0.00000 0 2 +0.00000 0.00000 -1.00000 0 2 + + +0.00000 0.00000 0.00000 0 3 +0.00000 1.00000 0.00000 0 3 + + +0.00000 2.01000 0.00000 0 0 +0.00000 2.01000 1.00000 0 0 + + +0.00000 2.01000 0.00000 0 1 +0.00000 1.01000 0.00000 0 1 + + +0.00000 2.01000 0.00000 0 2 +0.00000 2.01000 -1.00000 0 2 + + +0.00000 2.01000 0.00000 0 3 +0.00000 3.01000 0.00000 0 3 + + diff --git a/tests/grid/grid_in_vtk_1d_3d.tria1.vtk b/tests/grid/grid_in_vtk_1d_3d.tria1.vtk new file mode 100644 index 0000000000..e9e55dfd07 --- /dev/null +++ b/tests/grid/grid_in_vtk_1d_3d.tria1.vtk @@ -0,0 +1,37 @@ +# vtk DataFile Version 3.0 +Triangulation generated with deal.II +ASCII +DATASET UNSTRUCTURED_GRID +POINTS 8 double +0 2.01 0 +0 2.01 1 +0 2.01 0 +0 1.01 0 +0 2.01 0 +0 2.01 -1 +0 2.01 0 +0 3.01 0 + +CELLS 4 12 +2 0 1 +2 2 3 +2 4 5 +2 6 7 + +CELL_TYPES 4 +3 3 3 3 + + + +CELL_DATA 4 +SCALARS MaterialID int 1 +LOOKUP_TABLE default +0 1 2 3 + + + +SCALARS ManifoldID int 1 +LOOKUP_TABLE default +-1 -1 -1 -1 + + diff --git a/tests/grid/grid_in_vtk_1d_3d.tria2.vtk b/tests/grid/grid_in_vtk_1d_3d.tria2.vtk new file mode 100644 index 0000000000..c7e2416d39 --- /dev/null +++ b/tests/grid/grid_in_vtk_1d_3d.tria2.vtk @@ -0,0 +1,37 @@ +# vtk DataFile Version 3.0 +Triangulation generated with deal.II +ASCII +DATASET UNSTRUCTURED_GRID +POINTS 8 double +0 0 0 +0 0 1 +0 0 0 +0 -1 0 +0 0 0 +0 0 -1 +0 0 0 +0 1 0 + +CELLS 4 12 +2 0 1 +2 2 3 +2 4 5 +2 6 7 + +CELL_TYPES 4 +3 3 3 3 + + + +CELL_DATA 4 +SCALARS MaterialID int 1 +LOOKUP_TABLE default +0 1 2 3 + + + +SCALARS ManifoldID int 1 +LOOKUP_TABLE default +-1 -1 -1 -1 + + -- 2.39.5