]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a simple test for GridTools::collect_periodic_cell_pairs
authorMatthias Maier <tamiko@kyomu.43-1.org>
Mon, 21 May 2012 22:22:32 +0000 (22:22 +0000)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Mon, 21 May 2012 22:22:32 +0000 (22:22 +0000)
git-svn-id: https://svn.dealii.org/trunk@25532 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/grid_tools_05.cc [new file with mode: 0644]
tests/deal.II/grid_tools_05/cmp/generic [new file with mode: 0644]

diff --git a/tests/deal.II/grid_tools_05.cc b/tests/deal.II/grid_tools_05.cc
new file mode 100644 (file)
index 0000000..f403dc6
--- /dev/null
@@ -0,0 +1,108 @@
+//----------------------------  grid_tools.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2011, 2012 by the deal.II authors
+//
+//    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.
+//
+//----------------------------  grid_tools.cc  ---------------------------
+
+
+// check GridTools::collect_periodic_cell_pairs for some simple cases
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
+
+#include <fstream>
+
+std::ofstream logfile("grid_tools_05/output");
+
+using namespace dealii;
+
+template<int dim>
+void test1 ()
+{
+  Triangulation<dim> triangulation;
+
+  GridGenerator::hyper_cube(triangulation, 0., 1.);
+  triangulation.refine_global(2);
+
+  deallog << std::endl << std::endl << "Hyper cube, dimension " << dim << ":" << std::endl;
+
+  typedef typename Triangulation<dim>::cell_iterator CELL_IT;
+  typedef typename std::map<CELL_IT, CELL_IT> MAP;
+
+  MAP matched_cells = GridTools::collect_periodic_cell_pairs(triangulation, 0, /* direction: */1);
+
+  deallog << "Matching:" << std::endl;
+  for (typename MAP::const_iterator it = matched_cells.begin(); it != matched_cells.end(); ++it) {
+    deallog << it->first << "  -  " << it->second << std::endl;
+  }
+}
+
+template<int dim>
+void test2 ()
+{
+  /* Unfortunately, there is no parallelogram for 3D.. */
+  Assert(dim == 2,
+         ExcNotImplemented());
+
+  Triangulation<dim> triangulation;
+
+  Tensor<2,dim> vectors;
+  vectors[0][0] = 1.;
+  vectors[0][1] = 0.;
+  vectors[1][0] = 0.5;
+  vectors[1][1] = 1.;
+
+  Tensor<1,dim> offset;
+  offset[0] = 0.5;
+  offset[1] = 1.;
+
+  GridGenerator::parallelogram(triangulation, vectors);
+  triangulation.refine_global(3);
+
+  deallog << std::endl << std::endl << "Parallelogram, dimension " << dim << ":" << std::endl;
+
+
+  typedef typename Triangulation<dim>::cell_iterator CELL_IT;
+  typedef typename std::map<CELL_IT, CELL_IT> MAP;
+
+  MAP matched_cells = GridTools::collect_periodic_cell_pairs(triangulation, 0, /* direction: */0);
+  deallog << "Matching, direction 0:" << std::endl;
+  for (typename MAP::const_iterator it = matched_cells.begin(); it != matched_cells.end(); ++it) {
+    deallog << it->first << "  -  " << it->second << std::endl;
+  }
+
+  MAP matched_cells_2 = GridTools::collect_periodic_cell_pairs(triangulation, 0, /* direction: */1, offset);
+  deallog << "Matching, direction 1:" << std::endl;
+  for (typename MAP::const_iterator it = matched_cells_2.begin(); it != matched_cells_2.end(); ++it) {
+    deallog << it->first << "  -  " << it->second << std::endl;
+  }
+}
+
+int main()
+{
+  deallog << std::setprecision(4);
+  logfile << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  /* Let's try to match the hyper_cube in 3D:*/
+  test1<3> ();
+
+  /* Let's try to match a parallelogramm in 2D */
+  test2<2> ();
+
+  return 0;
+}
diff --git a/tests/deal.II/grid_tools_05/cmp/generic b/tests/deal.II/grid_tools_05/cmp/generic
new file mode 100644 (file)
index 0000000..677327f
--- /dev/null
@@ -0,0 +1,42 @@
+
+DEAL::
+DEAL::
+DEAL::Hyper cube, dimension 3:
+DEAL::Matching:
+DEAL::2.0  -  2.18
+DEAL::2.1  -  2.19
+DEAL::2.4  -  2.22
+DEAL::2.5  -  2.23
+DEAL::2.8  -  2.26
+DEAL::2.9  -  2.27
+DEAL::2.12  -  2.30
+DEAL::2.13  -  2.31
+DEAL::2.32  -  2.50
+DEAL::2.33  -  2.51
+DEAL::2.36  -  2.54
+DEAL::2.37  -  2.55
+DEAL::2.40  -  2.58
+DEAL::2.41  -  2.59
+DEAL::2.44  -  2.62
+DEAL::2.45  -  2.63
+DEAL::
+DEAL::
+DEAL::Parallelogram, dimension 2:
+DEAL::Matching, direction 0:
+DEAL::3.0  -  3.21
+DEAL::3.2  -  3.23
+DEAL::3.8  -  3.29
+DEAL::3.10  -  3.31
+DEAL::3.32  -  3.53
+DEAL::3.34  -  3.55
+DEAL::3.40  -  3.61
+DEAL::3.42  -  3.63
+DEAL::Matching, direction 1:
+DEAL::3.0  -  3.42
+DEAL::3.1  -  3.43
+DEAL::3.4  -  3.46
+DEAL::3.5  -  3.47
+DEAL::3.16  -  3.58
+DEAL::3.17  -  3.59
+DEAL::3.20  -  3.62
+DEAL::3.21  -  3.63

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.