From 0c7d47e66ed60c285fd295a4101eb00022f06c2e Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 8 May 2003 14:54:41 +0000 Subject: [PATCH] New tests. git-svn-id: https://svn.dealii.org/trunk@7608 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/fe/dgq_1.cc | 82 +++++++++++++++++++++++++++ tests/fe/q_4.cc | 82 +++++++++++++++++++++++++++ tests/fe/system_1.cc | 130 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) create mode 100644 tests/fe/dgq_1.cc create mode 100644 tests/fe/q_4.cc create mode 100644 tests/fe/system_1.cc diff --git a/tests/fe/dgq_1.cc b/tests/fe/dgq_1.cc new file mode 100644 index 0000000000..09bde3f6cf --- /dev/null +++ b/tests/fe/dgq_1.cc @@ -0,0 +1,82 @@ +//---------------------------- dgq_1.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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 +// fuqher information on this license. +// +//---------------------------- dgq_1.cc --------------------------- + + +// previously, the FETools::get_interpolation_matrix function would +// compute its result itself by interpolation. now, the different +// finite elements do that themselves, if they can. make sure the +// result doesn't change + +#include +#include +#include + +#include +#include + +#define PRECISION 5 + + + +template +void +test(const unsigned int degree1, + const unsigned int degree2) +{ + deallog << "FE_DGQ<" << dim << "> (" << degree1 << ")" + << " to FE_DGQ<" << dim << "> (" << degree2 << ")" + << std::endl; + + FE_DGQ fe1(degree1); + FE_DGQ fe2(degree2); + + FullMatrix m (fe2.dofs_per_cell, + fe1.dofs_per_cell); + FETools::get_interpolation_matrix (fe1, fe2, m); + + for (unsigned int i=0; i(degree1, degree2); + for (unsigned int degree1=0; degree1<=3; ++degree1) + for (unsigned int degree2=0; degree2<=3; ++degree2) + test<2>(degree1, degree2); + for (unsigned int degree1=0; degree1<=2; ++degree1) + for (unsigned int degree2=0; degree2<=2; ++degree2) + test<3>(degree1, degree2); + + return 0; +} + + + diff --git a/tests/fe/q_4.cc b/tests/fe/q_4.cc new file mode 100644 index 0000000000..cfd4726718 --- /dev/null +++ b/tests/fe/q_4.cc @@ -0,0 +1,82 @@ +//---------------------------- q_4.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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 +// fuqher information on this license. +// +//---------------------------- q_4.cc --------------------------- + + +// previously, the FETools::get_interpolation_matrix function would +// compute its result itself by interpolation. now, the different +// finite elements do that themselves, if they can. make sure the +// result doesn't change + +#include +#include +#include + +#include +#include + +#define PRECISION 5 + + + +template +void +test(const unsigned int degree1, + const unsigned int degree2) +{ + deallog << "FE_Q<" << dim << "> (" << degree1 << ")" + << " to FE_Q<" << dim << "> (" << degree2 << ")" + << std::endl; + + FE_Q fe1(degree1); + FE_Q fe2(degree2); + + FullMatrix m (fe2.dofs_per_cell, + fe1.dofs_per_cell); + FETools::get_interpolation_matrix (fe1, fe2, m); + + for (unsigned int i=0; i(degree1, degree2); + for (unsigned int degree1=1; degree1<=3; ++degree1) + for (unsigned int degree2=1; degree2<=3; ++degree2) + test<2>(degree1, degree2); + for (unsigned int degree1=1; degree1<=2; ++degree1) + for (unsigned int degree2=1; degree2<=2; ++degree2) + test<3>(degree1, degree2); + + return 0; +} + + + diff --git a/tests/fe/system_1.cc b/tests/fe/system_1.cc new file mode 100644 index 0000000000..093c0b95fb --- /dev/null +++ b/tests/fe/system_1.cc @@ -0,0 +1,130 @@ +//---------------------------- system_1.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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 +// fuqher information on this license. +// +//---------------------------- system_1.cc --------------------------- + + +// previously, the FETools::get_interpolation_matrix function would +// compute its result itself by interpolation. now, the different +// finite elements do that themselves, if they can. make sure the +// result doesn't change, in this case for this function in FESystem +// that does it's job by calling the respective function in the base +// elements and then munging the results + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define PRECISION 5 + + + +template +void +check(const FiniteElement &fe1, + const FiniteElement &fe2) +{ + deallog << fe1.get_name () << " to " << fe2.get_name () + << std::endl; + + FullMatrix m (fe2.dofs_per_cell, + fe1.dofs_per_cell); + FETools::get_interpolation_matrix (fe1, fe2, m); + + for (unsigned int i=0; i fe1(sub1_1, N1_1); \ + FESystem fe2(sub2_1, N2_1); \ + check(fe1, fe2); \ + check(fe2, fe1); \ + } + +#define CHECK_SYS3(sub1,N1,sub2,N2,sub3,N3,dim) \ + { FESystem q(sub1, N1, sub2, N2, sub3, N3); \ + check(q, q); } + + +int +main() +{ + std::ofstream logfile ("system_1.output"); + logfile.precision (PRECISION); + logfile.setf(std::ios::fixed); + deallog.attach(logfile); + deallog.depth_console(0); + + CHECK_SYS1(FE_Q<1>(1), 3, + FE_Q<1>(2), 3, + 1); + CHECK_SYS1(FE_DGQ<1>(2),2, + FE_DGQ<1>(3),2, + 1); + + CHECK_SYS1(FE_Q<2>(1), 3, + FE_Q<2>(2), 3, + 2); + CHECK_SYS1(FE_DGQ<2>(2),2, + FE_DGQ<2>(3),2, + 2); + + CHECK_SYS1(FE_Q<3>(1), 3, + FE_Q<3>(2), 3, + 3); + CHECK_SYS1(FE_DGQ<3>(2),2, + FE_DGQ<3>(3),2, + 3); + + // systems in 1d + CHECK_SYS3(FE_Q<1>(1), 3,FE_DGQ<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_DGQ<1>(3),1,FE_DGQ<1>(3),1,FE_Q<1>(2),3,1); + + // systems in 2d + CHECK_SYS3(FE_Q<2>(1), 3,FE_DGQ<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); + + // systems in 3d + CHECK_SYS3(FE_Q<3>(1), 3,FE_DGQ<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>(3), 1, + FE_Q<2>(1), 3, + 2); + CHECK_SYS3(FE_DGQ<2>(3), 1, + FESystem<2>(FE_DGQ<2>(3),3), 1, + FESystem<2>(FE_Q<2>(2),3, + FE_DGQ<2>(0),1),2, + 2); + + return 0; +} + + + -- 2.39.5