From: bangerth Date: Thu, 20 Sep 2012 15:41:46 +0000 (+0000) Subject: New tests. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a782489a483b18f4fda2d82aa0a59f46a0659ac;p=dealii-svn.git New tests. git-svn-id: https://svn.dealii.org/trunk@26572 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/hp/renumber_block_wise_01.cc b/tests/hp/renumber_block_wise_01.cc new file mode 100644 index 0000000000..dd429fdd6d --- /dev/null +++ b/tests/hp/renumber_block_wise_01.cc @@ -0,0 +1,138 @@ +//---------------------------- renumber_block_wise_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2003, 2004, 2009, 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. +// +//---------------------------- renumber_block_wise_01.cc --------------------------- + + +// Test DoFRenumbering::block_wise. For the element used here, it +// needs to produce the exact same numbering as that for +// DoFRenumber::component_wise + + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +std::vector +get_dofs (const hp::DoFHandler &dof) +{ + std::vector local; + std::vector global; + for (typename hp::DoFHandler::active_cell_iterator cell=dof.begin_active(); + cell != dof.end(); ++cell) + { + local.resize (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (local); + + global.insert (global.end(), local.begin(), local.end()); + } + + return global; +} + + + +template +void +check_renumbering(hp::DoFHandler& dof) +{ + // do component-wise and save the + // results + DoFRenumbering::component_wise (dof); + const std::vector vc = get_dofs (dof); + + // now do the same with blocks + DoFRenumbering::block_wise (dof); + const std::vector vb = get_dofs (dof); + + Assert (vc == vb, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + +template +void +check () +{ + Triangulation tr; + if (dim==2) + GridGenerator::hyper_ball(tr, Point(), 1); + else + GridGenerator::hyper_cube(tr, -1,1); + tr.refine_global (1); + tr.begin_active()->set_refine_flag (); + tr.execute_coarsening_and_refinement (); + if (dim==1) + tr.refine_global(2); + + hp::DoFHandler dof(tr); + { + bool coin = false; + for (typename hp::DoFHandler::active_cell_iterator cell=dof.begin_active(); + cell != dof.end(); ++cell) + { + cell->set_active_fe_index (coin ? 0 : 1); + coin = !coin; + } + } + + FESystem e1 (FE_Q(2), 2, FE_DGQ(1), 2); + FESystem e2 (FE_Q(1), 2, FE_DGQ(2), 2); + + hp::FECollection fe_collection; + fe_collection.push_back (e1); + fe_collection.push_back (e2); + + dof.distribute_dofs(fe_collection); + check_renumbering(dof); + dof.clear(); +} + + +int main () +{ + std::ofstream logfile ("renumber_block_wise_01/output"); + deallog << std::setprecision (2); + deallog << std::fixed; + deallog.attach(logfile); + deallog.depth_console (0); + + deallog.push ("1d"); + check<1> (); + deallog.pop (); + deallog.push ("2d"); + check<2> (); + deallog.pop (); + deallog.push ("3d"); + check<3> (); + deallog.pop (); +} diff --git a/tests/hp/renumber_block_wise_01/cmp/generic b/tests/hp/renumber_block_wise_01/cmp/generic new file mode 100644 index 0000000000..1899741293 --- /dev/null +++ b/tests/hp/renumber_block_wise_01/cmp/generic @@ -0,0 +1,4 @@ + +DEAL:1d::OK +DEAL:2d::OK +DEAL:3d::OK diff --git a/tests/hp/renumber_block_wise_02.cc b/tests/hp/renumber_block_wise_02.cc new file mode 100644 index 0000000000..4295eae54c --- /dev/null +++ b/tests/hp/renumber_block_wise_02.cc @@ -0,0 +1,147 @@ +//---------------------------- renumber_block_wise_02.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2003, 2004, 2009, 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. +// +//---------------------------- renumber_block_wise_02.cc --------------------------- + + +// Test DoFRenumbering::block_wise. For the element used here, it +// needs to produce the exact same numbering as that for +// DoFRenumber::component_wise + + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +std::vector +get_dofs (const hp::DoFHandler &dof) +{ + std::vector local; + std::vector global; + for (typename hp::DoFHandler::active_cell_iterator cell=dof.begin_active(); + cell != dof.end(); ++cell) + { + local.resize (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (local); + + global.insert (global.end(), local.begin(), local.end()); + } + + return global; +} + + + +template +void +check_renumbering(hp::DoFHandler& dof) +{ + // Prepare a reordering of + // components so that each + // component maps to its natural + // block + std::vector order(dof.get_fe().n_components()); + order[0] = 0; + order[1] = 1; + order[2] = 1; + + // do component-wise and save the + // results + DoFRenumbering::component_wise (dof, order); + const std::vector vc = get_dofs (dof); + + // now do the same with blocks + DoFRenumbering::block_wise (dof); + const std::vector vb = get_dofs (dof); + + Assert (vc == vb, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + +template +void +check () +{ + Triangulation tr; + if (dim==2) + GridGenerator::hyper_ball(tr, Point(), 1); + else + GridGenerator::hyper_cube(tr, -1,1); + tr.refine_global (1); + tr.begin_active()->set_refine_flag (); + tr.execute_coarsening_and_refinement (); + if (dim==1) + tr.refine_global(2); + + hp::DoFHandler dof(tr); + { + bool coin = false; + for (typename hp::DoFHandler::active_cell_iterator cell=dof.begin_active(); + cell != dof.end(); ++cell) + { + cell->set_active_fe_index (coin ? 0 : 1); + coin = !coin; + } + } + + // note that the following elements + // have 3 components but 2 blocks + FESystem e1 (FE_DGQ(1), 1, FESystem(FE_DGQ(2), 2), 1); + FESystem e2 (FE_DGQ(2), 1, FESystem(FE_DGQ(1), 2), 1); + + hp::FECollection fe_collection; + fe_collection.push_back (e1); + fe_collection.push_back (e2); + + dof.distribute_dofs(fe_collection); + check_renumbering(dof); + dof.clear(); +} + + +int main () +{ + std::ofstream logfile ("renumber_block_wise_02/output"); + deallog << std::setprecision (2); + deallog << std::fixed; + deallog.attach(logfile); + deallog.depth_console (0); + + deallog.push ("2d"); + check<2> (); + deallog.pop (); + deallog.push ("3d"); + check<3> (); + deallog.pop (); +} diff --git a/tests/hp/renumber_block_wise_02/cmp/generic b/tests/hp/renumber_block_wise_02/cmp/generic new file mode 100644 index 0000000000..25966e9bd0 --- /dev/null +++ b/tests/hp/renumber_block_wise_02/cmp/generic @@ -0,0 +1,3 @@ + +DEAL:2d::OK +DEAL:3d::OK