From 929816b7b81bec3abe3692601ecbfa4c5d63a5e2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 2 May 2006 19:57:24 +0000 Subject: [PATCH] Add new test git-svn-id: https://svn.dealii.org/trunk@12970 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/hp/Makefile | 3 +- tests/hp/n_dofs.cc | 179 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 tests/hp/n_dofs.cc diff --git a/tests/hp/Makefile b/tests/hp/Makefile index f3cbd0d937..19ab170824 100644 --- a/tests/hp/Makefile +++ b/tests/hp/Makefile @@ -26,7 +26,8 @@ tests_x = hp_dof_handler \ q_collection_* \ mapping_collection_* \ fe_collection_* \ - continuous_2d_* + continuous_2d_* \ + n_dofs # from above list of regular expressions, generate the real set of # tests diff --git a/tests/hp/n_dofs.cc b/tests/hp/n_dofs.cc new file mode 100644 index 0000000000..110619473b --- /dev/null +++ b/tests/hp/n_dofs.cc @@ -0,0 +1,179 @@ +//---------------------------- n_dofs_2d.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2005, 2006 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. +// +//---------------------------- n_dofs_2d.cc --------------------------- + + +// check that even for wickedly complicated finite elements the +// hp::DoFHandler allocates the same number of degrees of freedom as a +// ::DoFHandler, as long as the same element is used on all cells + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +void test (const FiniteElement &fe) +{ + Triangulation tria; + GridGenerator::hyper_cube(tria); + tria.refine_global (2); + tria.begin_active()->set_refine_flag (); + tria.execute_coarsening_and_refinement (); + tria.refine_global (1); + + const hp::FECollection fe_collection (fe); + + hp::DoFHandler hp_dof_handler(tria); + hp_dof_handler.distribute_dofs(fe_collection); + + DoFHandler dof_handler(tria); + dof_handler.distribute_dofs (fe); + + deallog << fe.get_name() << ' ' << dof_handler.n_dofs() + << ' ' << hp_dof_handler.n_dofs() << std::endl; + + Assert (dof_handler.n_dofs() == hp_dof_handler.n_dofs(), + ExcInternalError()); +} + + + +#define CHECK(EL,deg,dim)\ + { FE_ ## EL EL(deg); \ + test(EL); } + +#define CHECK_SYS1(sub1,N1,dim) \ + { FESystem q(sub1, N1); \ + test(q); } + +#define CHECK_SYS2(sub1,N1,sub2,N2,dim) \ + { FESystem q(sub1, N1, sub2, N2); \ + test(q); } + +#define CHECK_SYS3(sub1,N1,sub2,N2,sub3,N3,dim) \ + { FESystem q(sub1, N1, sub2, N2, sub3, N3); \ + test(q); } + + +#define CHECK_ALL(EL,deg)\ + { CHECK(EL,deg,1); \ + CHECK(EL,deg,2); \ + CHECK(EL,deg,3); \ + } + + + +int main () +{ + std::ofstream logfile("n_dofs_2d/output"); + logfile.precision(2); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + CHECK_ALL(Q,1); + CHECK_ALL(Q,2); + CHECK_ALL(Q,3); + + CHECK_ALL(DGQ,0); + CHECK_ALL(DGQ,1); + CHECK_ALL(DGQ,3); + + CHECK_ALL(DGP,0); + CHECK_ALL(DGP,1); + CHECK_ALL(DGP,3); + + CHECK(Nedelec, 1, 2); + CHECK(Nedelec, 1, 3); + + CHECK(RaviartThomas, 0, 2); + CHECK(RaviartThomas, 1, 2); + CHECK(RaviartThomas, 2, 2); + + CHECK(RaviartThomasNodal, 0, 2); + CHECK(RaviartThomasNodal, 1, 2); + CHECK(RaviartThomasNodal, 2, 2); + CHECK(RaviartThomasNodal, 0, 3); + CHECK(RaviartThomasNodal, 1, 3); + CHECK(RaviartThomasNodal, 2, 3); + + CHECK_SYS1(FE_Q<1>(1), 3,1); + CHECK_SYS1(FE_DGQ<1>(2),2,1); + CHECK_SYS1(FE_DGP<1>(3),1,1); + + CHECK_SYS1(FE_Q<2>(1), 3,2); + CHECK_SYS1(FE_DGQ<2>(2),2,2); + CHECK_SYS1(FE_DGP<2>(3),1,2); + + CHECK_SYS1(FE_Q<3>(1), 3,3); + CHECK_SYS1(FE_DGQ<3>(2),2,3); + CHECK_SYS1(FE_DGP<3>(3),1,3); + + + CHECK_SYS2(FE_Q<1>(1), 3,FE_DGQ<1>(2),2,1); + CHECK_SYS2(FE_DGQ<1>(2),2,FE_DGP<1>(3),1,1); + CHECK_SYS2(FE_DGP<1>(3),1,FE_DGQ<1>(2),2,1); + + CHECK_SYS2(FE_Q<2>(1), 3,FE_DGQ<2>(2),2,2); + CHECK_SYS2(FE_DGQ<2>(2),2,FE_DGP<2>(3),1,2); + CHECK_SYS2(FE_DGP<2>(3),1,FE_DGQ<2>(2),2,2); + + CHECK_SYS3(FE_Q<1>(1), 3,FE_DGP<1>(3),1,FE_Q<1>(1),3,1); + CHECK_SYS3(FE_DGQ<1>(2),2,FE_DGQ<1>(2),2,FE_Q<1>(3),3,1); + CHECK_SYS3(FE_DGP<1>(3),1,FE_DGP<1>(3),1,FE_Q<1>(2),3,1); + + CHECK_SYS3(FE_Q<2>(1), 3,FE_DGP<2>(3),1,FE_Q<2>(1),3,2); + CHECK_SYS3(FE_DGQ<2>(2),2,FE_DGQ<2>(2),2,FE_Q<2>(3),3,2); + CHECK_SYS3(FE_DGP<2>(3),1,FE_DGP<2>(3),1,FE_Q<2>(2),3,2); + + CHECK_SYS3(FE_DGQ<3>(1), 3,FE_DGP<3>(3),1,FE_Q<3>(1),3,3); + + // systems of systems + CHECK_SYS3((FESystem<2>(FE_Q<2>(1),3)), 3, + FE_DGQ<2>(0), 1, + FE_Q<2>(1), 3, + 2); + CHECK_SYS3(FE_DGQ<2>(3), 1, + FESystem<2>(FE_DGQ<2>(0),3), 1, + FESystem<2>(FE_Q<2>(2),1, + FE_DGQ<2>(0),1),2, + 2); + + // systems with Nedelec elements + CHECK_SYS2 (FE_DGQ<2>(3), 1, + FE_Nedelec<2>(1), 2, + 2); + CHECK_SYS3(FE_Nedelec<2>(1), 1, + FESystem<2>(FE_DGQ<2>(1),2), 1, + FESystem<2>(FE_Q<2>(2),1, + FE_Nedelec<2>(1),2),2, + 2); + + deallog << "OK" << std::endl; +} -- 2.39.5