From f1250703fd2ba09ccb2e6d8b8f344d482bf8ec61 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 2 May 2003 00:35:35 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@7542 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/geometry_info_1.cc | 73 +++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/bits/geometry_info_1.cc diff --git a/tests/bits/geometry_info_1.cc b/tests/bits/geometry_info_1.cc new file mode 100644 index 0000000000..45bf4abba1 --- /dev/null +++ b/tests/bits/geometry_info_1.cc @@ -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 +#include + +#include +#include + +double rand_2 () +{ + return 1.*rand()/RAND_MAX*4-2.; +} + + +template +void test () +{ + Point 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::is_inside_unit_cell (p) << std::endl; + for (unsigned int c=0; c::children_per_cell; ++c) + { + const Point q = GeometryInfo::cell_to_child_coordinates(p,c); + const Point pp = GeometryInfo::child_to_cell_coordinates(q,c); + + deallog << " " << c << " [" << q << "] [" << pp << ']' + << std::endl; + Assert ((p-pp).square() < 1e-15*1e-15, ExcInternalError()); + Assert (GeometryInfo::is_inside_unit_cell (p) == + GeometryInfo::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; +} -- 2.39.5