From b2e72376388051a1375830b1ec92668eaecac80f Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 8 May 2014 23:41:57 +0000 Subject: [PATCH] Patch by Giorgos Kourakos: Make GridIn::read_vtk less rigid. git-svn-id: https://svn.dealii.org/trunk@32895 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/grid_in_vtk_3d_02.cc | 71 +++++++++++++++++++ tests/deal.II/grid_in_vtk_3d_02.output | 98 ++++++++++++++++++++++++++ tests/deal.II/grid_in_vtk_3d_02.vtk | 35 +++++++++ tests/deal.II/grid_in_vtk_3d_03.cc | 71 +++++++++++++++++++ tests/deal.II/grid_in_vtk_3d_03.output | 98 ++++++++++++++++++++++++++ tests/deal.II/grid_in_vtk_3d_03.vtk | 42 +++++++++++ 6 files changed, 415 insertions(+) create mode 100644 tests/deal.II/grid_in_vtk_3d_02.cc create mode 100644 tests/deal.II/grid_in_vtk_3d_02.output create mode 100644 tests/deal.II/grid_in_vtk_3d_02.vtk create mode 100644 tests/deal.II/grid_in_vtk_3d_03.cc create mode 100644 tests/deal.II/grid_in_vtk_3d_03.output create mode 100644 tests/deal.II/grid_in_vtk_3d_03.vtk diff --git a/tests/deal.II/grid_in_vtk_3d_02.cc b/tests/deal.II/grid_in_vtk_3d_02.cc new file mode 100644 index 0000000000..a1c296dc64 --- /dev/null +++ b/tests/deal.II/grid_in_vtk_3d_02.cc @@ -0,0 +1,71 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 2014 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// read a 3d file in the VTK format + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +std::ofstream logfile("output"); + + +template +void check_file (const std::string name, + typename GridIn::Format format) +{ + Triangulation tria; + GridIn gi; + gi.attach_triangulation (tria); + gi.read(name, format); + deallog << '\t' << tria.n_vertices() + << '\t' << tria.n_cells() + << std::endl; + + GridOut grid_out; + grid_out.write_gnuplot (tria, deallog.get_file_stream()); +} + +void filename_resolution() +{ + check_file<3> (std::string(SOURCE_DIR "/grid_in_vtk_3d_02.vtk"), GridIn<3>::vtk); +} + + +int main () +{ + deallog << std::setprecision (2); + logfile << std::setprecision (2); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + filename_resolution(); +} + diff --git a/tests/deal.II/grid_in_vtk_3d_02.output b/tests/deal.II/grid_in_vtk_3d_02.output new file mode 100644 index 0000000000..d4bc397853 --- /dev/null +++ b/tests/deal.II/grid_in_vtk_3d_02.output @@ -0,0 +1,98 @@ + +DEAL:: 20 4 +0.0 0.0 10. 0 0 +10. 0.0 10. 0 0 +10. 10. 10. 0 0 +0.0 10. 10. 0 0 +0.0 0.0 10. 0 0 + +0.0 0.0 0.0 0 0 +10. 0.0 0.0 0 0 +10. 10. 0.0 0 0 +0.0 10. 0.0 0 0 +0.0 0.0 0.0 0 0 + +0.0 0.0 10. 0 0 +0.0 0.0 0.0 0 0 + +10. 0.0 10. 0 0 +10. 0.0 0.0 0 0 + +10. 10. 10. 0 0 +10. 10. 0.0 0 0 + +0.0 10. 10. 0 0 +0.0 10. 0.0 0 0 + +10. 0.0 10. 0 0 +20. 0.0 10. 0 0 +20. 10. 10. 0 0 +10. 10. 10. 0 0 +10. 0.0 10. 0 0 + +10. 0.0 0.0 0 0 +20. 0.0 0.0 0 0 +20. 10. 0.0 0 0 +10. 10. 0.0 0 0 +10. 0.0 0.0 0 0 + +10. 0.0 10. 0 0 +10. 0.0 0.0 0 0 + +20. 0.0 10. 0 0 +20. 0.0 0.0 0 0 + +20. 10. 10. 0 0 +20. 10. 0.0 0 0 + +10. 10. 10. 0 0 +10. 10. 0.0 0 0 + +10. 10. 10. 0 0 +20. 10. 10. 0 0 +20. 20. 10. 0 0 +10. 20. 10. 0 0 +10. 10. 10. 0 0 + +10. 10. 0.0 0 0 +20. 10. 0.0 0 0 +20. 20. 0.0 0 0 +10. 20. 0.0 0 0 +10. 10. 0.0 0 0 + +10. 10. 10. 0 0 +10. 10. 0.0 0 0 + +20. 10. 10. 0 0 +20. 10. 0.0 0 0 + +20. 20. 10. 0 0 +20. 20. 0.0 0 0 + +10. 20. 10. 0 0 +10. 20. 0.0 0 0 + +20. 10. 10. 0 0 +30. 10. 10. 0 0 +30. 20. 10. 0 0 +20. 20. 10. 0 0 +20. 10. 10. 0 0 + +20. 10. 0.0 0 0 +30. 10. 0.0 0 0 +30. 20. 0.0 0 0 +20. 20. 0.0 0 0 +20. 10. 0.0 0 0 + +20. 10. 10. 0 0 +20. 10. 0.0 0 0 + +30. 10. 10. 0 0 +30. 10. 0.0 0 0 + +30. 20. 10. 0 0 +30. 20. 0.0 0 0 + +20. 20. 10. 0 0 +20. 20. 0.0 0 0 + diff --git a/tests/deal.II/grid_in_vtk_3d_02.vtk b/tests/deal.II/grid_in_vtk_3d_02.vtk new file mode 100644 index 0000000000..8c027c34ea --- /dev/null +++ b/tests/deal.II/grid_in_vtk_3d_02.vtk @@ -0,0 +1,35 @@ +# vtk DataFile Version 3.0 +write mesh on file +ASCII +DATASET UNSTRUCTURED_GRID +POINTS 20 double +0.000000 0.000000 10.000000 +10.000000 0.000000 10.000000 +10.000000 10.000000 10.000000 +0.000000 10.000000 10.000000 +20.000000 0.000000 10.000000 +20.000000 10.000000 10.000000 +30.000000 10.000000 10.000000 +10.000000 20.000000 10.000000 +20.000000 20.000000 10.000000 +30.000000 20.000000 10.000000 +0.000000 0.000000 0.000000 +10.000000 0.000000 0.000000 +10.000000 10.000000 0.000000 +0.000000 10.000000 0.000000 +20.000000 0.000000 0.000000 +20.000000 10.000000 0.000000 +30.000000 10.000000 0.000000 +10.000000 20.000000 0.000000 +20.000000 20.000000 0.000000 +30.000000 20.000000 0.000000 +CELLS 4 36 +8 10 11 12 13 0 1 2 3 +8 11 14 15 12 1 4 5 2 +8 12 15 18 17 2 5 8 7 +8 15 16 19 18 5 6 9 8 +CELL_TYPES 4 +12 +12 +12 +12 diff --git a/tests/deal.II/grid_in_vtk_3d_03.cc b/tests/deal.II/grid_in_vtk_3d_03.cc new file mode 100644 index 0000000000..4b8e053d4a --- /dev/null +++ b/tests/deal.II/grid_in_vtk_3d_03.cc @@ -0,0 +1,71 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2002 - 2014 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// read a 3d file in the VTK format + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +std::ofstream logfile("output"); + + +template +void check_file (const std::string name, + typename GridIn::Format format) +{ + Triangulation tria; + GridIn gi; + gi.attach_triangulation (tria); + gi.read(name, format); + deallog << '\t' << tria.n_vertices() + << '\t' << tria.n_cells() + << std::endl; + + GridOut grid_out; + grid_out.write_gnuplot (tria, deallog.get_file_stream()); +} + +void filename_resolution() +{ + check_file<3> (std::string(SOURCE_DIR "/grid_in_vtk_3d_03.vtk"), GridIn<3>::vtk); +} + + +int main () +{ + deallog << std::setprecision (2); + logfile << std::setprecision (2); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + filename_resolution(); +} + diff --git a/tests/deal.II/grid_in_vtk_3d_03.output b/tests/deal.II/grid_in_vtk_3d_03.output new file mode 100644 index 0000000000..2293dc9500 --- /dev/null +++ b/tests/deal.II/grid_in_vtk_3d_03.output @@ -0,0 +1,98 @@ + +DEAL:: 20 4 +0.0 0.0 10. 0 1 +10. 0.0 10. 0 1 +10. 10. 10. 0 1 +0.0 10. 10. 0 1 +0.0 0.0 10. 0 1 + +0.0 0.0 0.0 0 1 +10. 0.0 0.0 0 1 +10. 10. 0.0 0 1 +0.0 10. 0.0 0 1 +0.0 0.0 0.0 0 1 + +0.0 0.0 10. 0 1 +0.0 0.0 0.0 0 1 + +10. 0.0 10. 0 1 +10. 0.0 0.0 0 1 + +10. 10. 10. 0 1 +10. 10. 0.0 0 1 + +0.0 10. 10. 0 1 +0.0 10. 0.0 0 1 + +10. 0.0 10. 0 0 +20. 0.0 10. 0 0 +20. 10. 10. 0 0 +10. 10. 10. 0 0 +10. 0.0 10. 0 0 + +10. 0.0 0.0 0 0 +20. 0.0 0.0 0 0 +20. 10. 0.0 0 0 +10. 10. 0.0 0 0 +10. 0.0 0.0 0 0 + +10. 0.0 10. 0 0 +10. 0.0 0.0 0 0 + +20. 0.0 10. 0 0 +20. 0.0 0.0 0 0 + +20. 10. 10. 0 0 +20. 10. 0.0 0 0 + +10. 10. 10. 0 0 +10. 10. 0.0 0 0 + +10. 10. 10. 0 0 +20. 10. 10. 0 0 +20. 20. 10. 0 0 +10. 20. 10. 0 0 +10. 10. 10. 0 0 + +10. 10. 0.0 0 0 +20. 10. 0.0 0 0 +20. 20. 0.0 0 0 +10. 20. 0.0 0 0 +10. 10. 0.0 0 0 + +10. 10. 10. 0 0 +10. 10. 0.0 0 0 + +20. 10. 10. 0 0 +20. 10. 0.0 0 0 + +20. 20. 10. 0 0 +20. 20. 0.0 0 0 + +10. 20. 10. 0 0 +10. 20. 0.0 0 0 + +20. 10. 10. 0 0 +30. 10. 10. 0 0 +30. 20. 10. 0 0 +20. 20. 10. 0 0 +20. 10. 10. 0 0 + +20. 10. 0.0 0 0 +30. 10. 0.0 0 0 +30. 20. 0.0 0 0 +20. 20. 0.0 0 0 +20. 10. 0.0 0 0 + +20. 10. 10. 0 0 +20. 10. 0.0 0 0 + +30. 10. 10. 0 0 +30. 10. 0.0 0 0 + +30. 20. 10. 0 0 +30. 20. 0.0 0 0 + +20. 20. 10. 0 0 +20. 20. 0.0 0 0 + diff --git a/tests/deal.II/grid_in_vtk_3d_03.vtk b/tests/deal.II/grid_in_vtk_3d_03.vtk new file mode 100644 index 0000000000..eda6a1af1e --- /dev/null +++ b/tests/deal.II/grid_in_vtk_3d_03.vtk @@ -0,0 +1,42 @@ +# vtk DataFile Version 3.0 +write mesh on file +ASCII +DATASET UNSTRUCTURED_GRID +POINTS 20 double +0.000000 0.000000 10.000000 +10.000000 0.000000 10.000000 +10.000000 10.000000 10.000000 +0.000000 10.000000 10.000000 +20.000000 0.000000 10.000000 +20.000000 10.000000 10.000000 +30.000000 10.000000 10.000000 +10.000000 20.000000 10.000000 +20.000000 20.000000 10.000000 +30.000000 20.000000 10.000000 +0.000000 0.000000 0.000000 +10.000000 0.000000 0.000000 +10.000000 10.000000 0.000000 +0.000000 10.000000 0.000000 +20.000000 0.000000 0.000000 +20.000000 10.000000 0.000000 +30.000000 10.000000 0.000000 +10.000000 20.000000 0.000000 +20.000000 20.000000 0.000000 +30.000000 20.000000 0.000000 +CELLS 4 36 +8 10 11 12 13 0 1 2 3 +8 11 14 15 12 1 4 5 2 +8 12 15 18 17 2 5 8 7 +8 15 16 19 18 5 6 9 8 +CELL_TYPES 4 +12 +12 +12 +12 +CELL_DATA 4 +SCALARS MaterialID double 1 +LOOKUP_TABLE default +1.000000 +2.000000 +3.000000 +4.000000 -- 2.39.5