]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
More tests.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 May 2012 08:48:39 +0000 (08:48 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 May 2012 08:48:39 +0000 (08:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@25566 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/find_cells_adjacent_to_vertex_3.cc [new file with mode: 0644]
tests/bits/find_cells_adjacent_to_vertex_3/cmp/generic [new file with mode: 0644]
tests/bits/find_cells_adjacent_to_vertex_4.cc [new file with mode: 0644]
tests/bits/find_cells_adjacent_to_vertex_4/cmp/generic [new file with mode: 0644]

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 (file)
index 0000000..807a8ad
--- /dev/null
@@ -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 <deal.II/base/logstream.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_tools.h>
+
+#include <fstream>
+
+
+void check (Triangulation<2> &tria)
+{
+  for(unsigned i=0; i<tria.n_vertices(); i++)
+    {
+      std::vector<Triangulation<2>::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<cells.size(); c++)
+       deallog << "   " << cells[c] << std::endl;
+    }
+}
+
+
+int main ()
+{
+  std::ofstream logfile("find_cells_adjacent_to_vertex_3/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+                                      // set up the vertices of the
+                                      // cells: the center plus 16
+                                      // points on the perimeter of a
+                                      // circle
+      const unsigned int dim = 2;
+      std::vector<Point<dim> > vertices;
+      vertices.push_back (Point<dim>());
+
+      for (unsigned int i=0; i<16; ++i)
+       vertices.push_back (Point<dim>(std::cos(i*2*numbers::PI/16),
+                                      std::sin(i*2*numbers::PI/16)));
+
+                                      // now create the 8 cells
+      std::vector<CellData<dim> > cells;
+      for (unsigned int c=0; c<8; ++c)
+       {
+         CellData<dim> 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<dim> 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 (file)
index 0000000..c0fa806
--- /dev/null
@@ -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 (file)
index 0000000..ebc5ed4
--- /dev/null
@@ -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 <deal.II/base/logstream.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_tools.h>
+
+#include <fstream>
+
+
+void check (Triangulation<2> &tria)
+{
+  for(unsigned i=0; i<tria.n_vertices(); i++)
+    {
+      std::vector<Triangulation<2>::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<cells.size(); c++)
+       deallog << "   " << cells[c] << std::endl;
+    }
+}
+
+
+int main ()
+{
+  std::ofstream logfile("find_cells_adjacent_to_vertex_4/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+                                      // set up the vertices of the
+                                      // cells: the center plus 16
+                                      // points on the perimeter of a
+                                      // circle
+      const unsigned int dim = 2;
+      std::vector<Point<dim> > vertices;
+      vertices.push_back (Point<dim>());
+
+      for (unsigned int i=0; i<16; ++i)
+       vertices.push_back (Point<dim>(std::cos(i*2*numbers::PI/16),
+                                      std::sin(i*2*numbers::PI/16)));
+
+                                      // now create the 8 cells
+      std::vector<CellData<dim> > cells;
+      for (unsigned int c=0; c<8; ++c)
+       {
+         CellData<dim> 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<dim> 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 (file)
index 0000000..6a45d40
--- /dev/null
@@ -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

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.