From bf311d0bcb6251b2f2cc45951eb09439173957eb Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 30 May 2012 08:48:39 +0000 Subject: [PATCH] More tests. git-svn-id: https://svn.dealii.org/trunk@25566 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/find_cells_adjacent_to_vertex_3.cc | 92 ++++++++++++++++++ .../cmp/generic | 50 ++++++++++ tests/bits/find_cells_adjacent_to_vertex_4.cc | 97 +++++++++++++++++++ .../cmp/generic | 69 +++++++++++++ 4 files changed, 308 insertions(+) create mode 100644 tests/bits/find_cells_adjacent_to_vertex_3.cc create mode 100644 tests/bits/find_cells_adjacent_to_vertex_3/cmp/generic create mode 100644 tests/bits/find_cells_adjacent_to_vertex_4.cc create mode 100644 tests/bits/find_cells_adjacent_to_vertex_4/cmp/generic diff --git a/tests/bits/find_cells_adjacent_to_vertex_3.cc b/tests/bits/find_cells_adjacent_to_vertex_3.cc new file mode 100644 index 0000000000..807a8ad788 --- /dev/null +++ b/tests/bits/find_cells_adjacent_to_vertex_3.cc @@ -0,0 +1,92 @@ +// ---------------- find_cells_adjacent_to_vertex_3.cc ------------------ +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006, 2012 by the deal.II authors and Ralf B. Schulz +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +// ---------------- find_cells_adjacent_to_vertex_3.cc ------------------ + + +// a slightly more complex case than the _1 test: a mesh where 8 2d +// cells meet at one point. using this point as the pivot we must get +// all 8 cells back +// +// this test does not use any local refinement + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include + + +void check (Triangulation<2> &tria) +{ + for(unsigned i=0; i::active_cell_iterator> + cells = GridTools::find_cells_adjacent_to_vertex(tria, i); + + deallog << "Vertex " << i << " at " + << tria.get_vertices()[i] << ": " + << cells.size() << " cells" << std::endl; + + for(unsigned c=0; c > vertices; + vertices.push_back (Point()); + + for (unsigned int i=0; i<16; ++i) + vertices.push_back (Point(std::cos(i*2*numbers::PI/16), + std::sin(i*2*numbers::PI/16))); + + // now create the 8 cells + std::vector > cells; + for (unsigned int c=0; c<8; ++c) + { + CellData d; + d.vertices[0] = 0; + d.vertices[1] = 1+2*c; + d.vertices[2] = 1+((2*c+2) % 16); + d.vertices[3] = 1+2*c+1; + cells.push_back(d); + } + + Triangulation coarse_grid; + coarse_grid.create_triangulation (vertices, cells, + SubCellData()); + check (coarse_grid); + } + catch (const std::exception &exc) + { + // we shouldn't get here... + deallog << "Caught an error..." << std::endl; + deallog << exc.what() << std::endl; + } +} diff --git a/tests/bits/find_cells_adjacent_to_vertex_3/cmp/generic b/tests/bits/find_cells_adjacent_to_vertex_3/cmp/generic new file mode 100644 index 0000000000..c0fa806c98 --- /dev/null +++ b/tests/bits/find_cells_adjacent_to_vertex_3/cmp/generic @@ -0,0 +1,50 @@ + +DEAL::Vertex 0 at 0.00000 0.00000: 8 cells +DEAL:: 0.0 +DEAL:: 0.1 +DEAL:: 0.2 +DEAL:: 0.3 +DEAL:: 0.4 +DEAL:: 0.5 +DEAL:: 0.6 +DEAL:: 0.7 +DEAL::Vertex 1 at 1.00000 0.00000: 2 cells +DEAL:: 0.0 +DEAL:: 0.7 +DEAL::Vertex 2 at 0.923880 0.382683: 1 cells +DEAL:: 0.0 +DEAL::Vertex 3 at 0.707107 0.707107: 2 cells +DEAL:: 0.0 +DEAL:: 0.1 +DEAL::Vertex 4 at 0.382683 0.923880: 1 cells +DEAL:: 0.1 +DEAL::Vertex 5 at 6.12323e-17 1.00000: 2 cells +DEAL:: 0.1 +DEAL:: 0.2 +DEAL::Vertex 6 at -0.382683 0.923880: 1 cells +DEAL:: 0.2 +DEAL::Vertex 7 at -0.707107 0.707107: 2 cells +DEAL:: 0.2 +DEAL:: 0.3 +DEAL::Vertex 8 at -0.923880 0.382683: 1 cells +DEAL:: 0.3 +DEAL::Vertex 9 at -1.00000 1.22465e-16: 2 cells +DEAL:: 0.3 +DEAL:: 0.4 +DEAL::Vertex 10 at -0.923880 -0.382683: 1 cells +DEAL:: 0.4 +DEAL::Vertex 11 at -0.707107 -0.707107: 2 cells +DEAL:: 0.4 +DEAL:: 0.5 +DEAL::Vertex 12 at -0.382683 -0.923880: 1 cells +DEAL:: 0.5 +DEAL::Vertex 13 at -1.83697e-16 -1.00000: 2 cells +DEAL:: 0.5 +DEAL:: 0.6 +DEAL::Vertex 14 at 0.382683 -0.923880: 1 cells +DEAL:: 0.6 +DEAL::Vertex 15 at 0.707107 -0.707107: 2 cells +DEAL:: 0.6 +DEAL:: 0.7 +DEAL::Vertex 16 at 0.923880 -0.382683: 1 cells +DEAL:: 0.7 diff --git a/tests/bits/find_cells_adjacent_to_vertex_4.cc b/tests/bits/find_cells_adjacent_to_vertex_4.cc new file mode 100644 index 0000000000..ebc5ed4ed6 --- /dev/null +++ b/tests/bits/find_cells_adjacent_to_vertex_4.cc @@ -0,0 +1,97 @@ +// ---------------- find_cells_adjacent_to_vertex_4.cc ------------------ +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006, 2012 by the deal.II authors and Ralf B. Schulz +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +// ---------------- find_cells_adjacent_to_vertex_4.cc ------------------ + + +// a slightly more complex case than the _1 test: a mesh where 8 2d +// cells meet at one point. using this point as the pivot we must get +// all 8 cells back +// +// this test is like _3 but we refine one cell + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include + + +void check (Triangulation<2> &tria) +{ + for(unsigned i=0; i::active_cell_iterator> + cells = GridTools::find_cells_adjacent_to_vertex(tria, i); + + deallog << "Vertex " << i << " at " + << tria.get_vertices()[i] << ": " + << cells.size() << " cells" << std::endl; + + for(unsigned c=0; c > vertices; + vertices.push_back (Point()); + + for (unsigned int i=0; i<16; ++i) + vertices.push_back (Point(std::cos(i*2*numbers::PI/16), + std::sin(i*2*numbers::PI/16))); + + // now create the 8 cells + std::vector > cells; + for (unsigned int c=0; c<8; ++c) + { + CellData d; + d.vertices[0] = 0; + d.vertices[1] = 1+2*c; + d.vertices[2] = 1+((2*c+2) % 16); + d.vertices[3] = 1+2*c+1; + cells.push_back(d); + } + + Triangulation coarse_grid; + coarse_grid.create_triangulation (vertices, cells, + SubCellData()); + + // now also refine one cell + coarse_grid.begin_active()->set_refine_flag(); + coarse_grid.execute_coarsening_and_refinement(); + + check (coarse_grid); + } + catch (const std::exception &exc) + { + // we shouldn't get here... + deallog << "Caught an error..." << std::endl; + deallog << exc.what() << std::endl; + } +} diff --git a/tests/bits/find_cells_adjacent_to_vertex_4/cmp/generic b/tests/bits/find_cells_adjacent_to_vertex_4/cmp/generic new file mode 100644 index 0000000000..6a45d40f7f --- /dev/null +++ b/tests/bits/find_cells_adjacent_to_vertex_4/cmp/generic @@ -0,0 +1,69 @@ + +DEAL::Vertex 0 at 0.00000 0.00000: 8 cells +DEAL:: 0.1 +DEAL:: 0.2 +DEAL:: 0.3 +DEAL:: 0.4 +DEAL:: 0.5 +DEAL:: 0.6 +DEAL:: 0.7 +DEAL:: 1.0 +DEAL::Vertex 1 at 1.00000 0.00000: 2 cells +DEAL:: 0.7 +DEAL:: 1.1 +DEAL::Vertex 2 at 0.923880 0.382683: 1 cells +DEAL:: 1.3 +DEAL::Vertex 3 at 0.707107 0.707107: 2 cells +DEAL:: 0.1 +DEAL:: 1.2 +DEAL::Vertex 4 at 0.382683 0.923880: 1 cells +DEAL:: 0.1 +DEAL::Vertex 5 at 6.12323e-17 1.00000: 2 cells +DEAL:: 0.1 +DEAL:: 0.2 +DEAL::Vertex 6 at -0.382683 0.923880: 1 cells +DEAL:: 0.2 +DEAL::Vertex 7 at -0.707107 0.707107: 2 cells +DEAL:: 0.2 +DEAL:: 0.3 +DEAL::Vertex 8 at -0.923880 0.382683: 1 cells +DEAL:: 0.3 +DEAL::Vertex 9 at -1.00000 1.22465e-16: 2 cells +DEAL:: 0.3 +DEAL:: 0.4 +DEAL::Vertex 10 at -0.923880 -0.382683: 1 cells +DEAL:: 0.4 +DEAL::Vertex 11 at -0.707107 -0.707107: 2 cells +DEAL:: 0.4 +DEAL:: 0.5 +DEAL::Vertex 12 at -0.382683 -0.923880: 1 cells +DEAL:: 0.5 +DEAL::Vertex 13 at -1.83697e-16 -1.00000: 2 cells +DEAL:: 0.5 +DEAL:: 0.6 +DEAL::Vertex 14 at 0.382683 -0.923880: 1 cells +DEAL:: 0.6 +DEAL::Vertex 15 at 0.707107 -0.707107: 2 cells +DEAL:: 0.6 +DEAL:: 0.7 +DEAL::Vertex 16 at 0.923880 -0.382683: 1 cells +DEAL:: 0.7 +DEAL::Vertex 17 at 0.500000 0.00000: 3 cells +DEAL:: 0.7 +DEAL:: 1.0 +DEAL:: 1.1 +DEAL::Vertex 18 at 0.353553 0.353553: 3 cells +DEAL:: 0.1 +DEAL:: 1.0 +DEAL:: 1.2 +DEAL::Vertex 19 at 0.961940 0.191342: 2 cells +DEAL:: 1.1 +DEAL:: 1.3 +DEAL::Vertex 20 at 0.815493 0.544895: 2 cells +DEAL:: 1.2 +DEAL:: 1.3 +DEAL::Vertex 21 at 0.657747 0.272448: 4 cells +DEAL:: 1.0 +DEAL:: 1.1 +DEAL:: 1.2 +DEAL:: 1.3 -- 2.39.5