]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 May 2003 00:35:35 +0000 (00:35 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 May 2003 00:35:35 +0000 (00:35 +0000)
git-svn-id: https://svn.dealii.org/trunk@7542 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/geometry_info_1.cc [new file with mode: 0644]

diff --git a/tests/bits/geometry_info_1.cc b/tests/bits/geometry_info_1.cc
new file mode 100644 (file)
index 0000000..45bf4ab
--- /dev/null
@@ -0,0 +1,73 @@
+//----------------------------  geometry_info_1.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2002, 2003 by the deal.II authors and Anna Schneebeli
+//
+//    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.
+//
+//----------------------------  geometry_info_1.cc  ---------------------------
+
+
+// check GeometryInfo::cell_to_child and back
+
+#include <base/logstream.h>
+#include <grid/geometry_info.h>
+
+#include <fstream>
+#include <cstdlib>
+
+double rand_2 ()
+{
+  return 1.*rand()/RAND_MAX*4-2.;
+}
+
+
+template <int dim>
+void test ()
+{
+  Point<dim> p;
+
+                                  // generate N random points in
+                                  // [-2:2]^d, and transform them
+                                  // back and forth between mother
+                                  // and child cell
+  const unsigned int N = 50;
+  for (unsigned int i=0; i<N; ++i)
+    {
+      for (unsigned int d=0; d<dim; ++d)
+       p[d] = rand_2();
+
+      deallog << i << ' ' << p << ' '
+             << GeometryInfo<dim>::is_inside_unit_cell (p) << std::endl;
+      for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
+       {
+         const Point<dim> q = GeometryInfo<dim>::cell_to_child_coordinates(p,c);
+         const Point<dim> pp = GeometryInfo<dim>::child_to_cell_coordinates(q,c);
+         
+         deallog << "    " << c << " [" << q << "] [" << pp << ']'
+                 << std::endl;
+         Assert ((p-pp).square() < 1e-15*1e-15, ExcInternalError());
+         Assert (GeometryInfo<dim>::is_inside_unit_cell (p) ==
+                 GeometryInfo<dim>::is_inside_unit_cell (pp),
+                 ExcInternalError());
+       }
+    }
+}
+
+
+int main () 
+{
+  std::ofstream logfile("geometry_info_1.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<1> ();
+  test<2> ();
+  test<3> ();
+
+  return 0;
+}

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.