From bb4b5faeac406023169911e54e67b43a73649e29 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Thu, 27 Sep 2012 08:37:30 +0000 Subject: [PATCH] test iterator functions of DoFHandler git-svn-id: https://svn.dealii.org/trunk@26775 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/dof_accessor_01.cc | 3 +- tests/deal.II/dof_iterators_01.cc | 321 +++++++++++++++++++++ tests/deal.II/dof_iterators_01/cmp/generic | 4 + 3 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 tests/deal.II/dof_iterators_01.cc create mode 100644 tests/deal.II/dof_iterators_01/cmp/generic diff --git a/tests/deal.II/dof_accessor_01.cc b/tests/deal.II/dof_accessor_01.cc index 5cd5655d57..9882db1b89 100644 --- a/tests/deal.II/dof_accessor_01.cc +++ b/tests/deal.II/dof_accessor_01.cc @@ -1,8 +1,7 @@ //---------------------------- dof_accessor_01.cc --------------------------- // $Id$ -// Version: $Name$ // -// Copyright (C) 2010 by the deal.II authors +// Copyright (C) 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer diff --git a/tests/deal.II/dof_iterators_01.cc b/tests/deal.II/dof_iterators_01.cc new file mode 100644 index 0000000000..2387429d24 --- /dev/null +++ b/tests/deal.II/dof_iterators_01.cc @@ -0,0 +1,321 @@ +//-------------------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2010, 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. +// +//-------------------------------------------------------------------------------- + +// Output the results of all begin and end functions. + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + + +template +void test_cell(const Triangulation& tria, const DoFHandler& dof) +{ + LogStream::Prefix lp("cell"); + for (typename Triangulation::cell_iterator cell = tria.begin(); cell != tria.end();++cell) + { + deallog << '\t'; + cell.print(deallog); + } + deallog << std::endl; + + for (typename DoFHandler::cell_iterator cell = dof.begin(); cell != dof.end();++cell) + { + deallog << '\t'; + cell.print(deallog); + } + deallog << std::endl; + + deallog.push("Regular"); + + deallog << "begin\t\t"; dof.begin().print(deallog); deallog << '\t'; tria.begin().print(deallog); deallog << std::endl; + deallog << "last \t\t"; dof.last() .print(deallog); deallog << '\t'; tria.last() .print(deallog); deallog << std::endl; + deallog << "end \t\t"; dof.end() .print(deallog); deallog << '\t'; tria.end() .print(deallog); deallog << std::endl; + + for (unsigned int l=0;l +void test_line(const Triangulation& tria, const DoFHandler& dof) +{ + LogStream::Prefix lp("line"); + for (typename Triangulation::line_iterator line = tria.begin_line(); line != tria.end_line();++line) + { + deallog << '\t'; + line.print(deallog); + } + deallog << std::endl; + + for (typename DoFHandler::line_iterator line = dof.begin_line(); line != dof.end_line();++line) + { + deallog << '\t'; + line.print(deallog); + } + deallog << std::endl; + + deallog.push("Regular"); + + deallog << "begin\t\t"; dof.begin_line().print(deallog); deallog << '\t'; tria.begin_line().print(deallog); deallog << std::endl; + deallog << "last \t\t"; dof.last_line() .print(deallog); deallog << '\t'; tria.last_line() .print(deallog); deallog << std::endl; + deallog << "end \t\t"; dof.end_line() .print(deallog); deallog << '\t'; tria.end_line() .print(deallog); deallog << std::endl; + + if (dim == 1) + for (unsigned int l=0;l +void test_quad(const Triangulation& tria, const DoFHandler& dof) +{ + LogStream::Prefix lp("quad"); + for (typename Triangulation::quad_iterator quad = tria.begin_quad(); quad != tria.end_quad();++quad) + { + deallog << '\t'; + quad.print(deallog); + } + deallog << std::endl; + + for (typename DoFHandler::quad_iterator quad = dof.begin_quad(); quad != dof.end_quad();++quad) + { + deallog << '\t'; + quad.print(deallog); + } + deallog << std::endl; + + deallog.push("Regular"); + + deallog << "begin\t\t"; dof.begin_quad().print(deallog); deallog << '\t'; tria.begin_quad().print(deallog); deallog << std::endl; + deallog << "last \t\t"; dof.last_quad() .print(deallog); deallog << '\t'; tria.last_quad() .print(deallog); deallog << std::endl; + deallog << "end \t\t"; dof.end_quad() .print(deallog); deallog << '\t'; tria.end_quad() .print(deallog); deallog << std::endl; + + if (dim == 2) + for (unsigned int l=0;l +void test_hex(const Triangulation& tria, const DoFHandler& dof) +{ + LogStream::Prefix lp("hex"); + for (typename Triangulation::hex_iterator hex = tria.begin_hex(); hex != tria.end_hex();++hex) + { + deallog << '\t'; + hex.print(deallog); + } + deallog << std::endl; + + for (typename DoFHandler::hex_iterator hex = dof.begin_hex(); hex != dof.end_hex();++hex) + { + deallog << '\t'; + hex.print(deallog); + } + deallog << std::endl; + + deallog.push("Regular"); + + deallog << "begin\t\t"; dof.begin_hex().print(deallog); deallog << '\t'; tria.begin_hex().print(deallog); deallog << std::endl; + deallog << "last \t\t"; dof.last_hex() .print(deallog); deallog << '\t'; tria.last_hex() .print(deallog); deallog << std::endl; + deallog << "end \t\t"; dof.end_hex() .print(deallog); deallog << '\t'; tria.end_hex() .print(deallog); deallog << std::endl; + + if (dim == 3) + for (unsigned int l=0;l +void test () +{ + deallog << dim << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube (tria); + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement(); + + FE_Q fe(1); + DoFHandler dof (tria); + dof.distribute_dofs (fe); + + test_cell(tria, dof); + if (dim >= 1) test_line(tria, dof); + if (dim >= 2) test_quad(tria, dof); + if (dim >= 3) test_hex(tria, dof); +} + + + +int main () +{ + const std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output"); + std::ofstream logfile(logname.c_str()); + deallog.attach(logfile); +//deallog.depth_console(0); + + test<1> (); + test<2> (); + test<3> (); + + return 0; +} diff --git a/tests/deal.II/dof_iterators_01/cmp/generic b/tests/deal.II/dof_iterators_01/cmp/generic new file mode 100644 index 0000000000..5bfd19ba7f --- /dev/null +++ b/tests/deal.II/dof_iterators_01/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::3 3 +DEAL::40 40 +DEAL::281 281 -- 2.39.5