From: maier Date: Mon, 21 May 2012 22:22:32 +0000 (+0000) Subject: Add a simple test for GridTools::collect_periodic_cell_pairs X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2996f70ddfa3beb8743ee5e93a943cb6eeccdd30;p=dealii-svn.git Add a simple test for GridTools::collect_periodic_cell_pairs git-svn-id: https://svn.dealii.org/trunk@25532 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/deal.II/grid_tools_05.cc b/tests/deal.II/grid_tools_05.cc new file mode 100644 index 0000000000..f403dc6691 --- /dev/null +++ b/tests/deal.II/grid_tools_05.cc @@ -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 + +#include +#include +#include + +#include + +std::ofstream logfile("grid_tools_05/output"); + +using namespace dealii; + +template +void test1 () +{ + Triangulation 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::cell_iterator CELL_IT; + typedef typename std::map 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 +void test2 () +{ + /* Unfortunately, there is no parallelogram for 3D.. */ + Assert(dim == 2, + ExcNotImplemented()); + + Triangulation 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::cell_iterator CELL_IT; + typedef typename std::map 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 index 0000000000..677327fbb2 --- /dev/null +++ b/tests/deal.II/grid_tools_05/cmp/generic @@ -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