From: bangerth Date: Thu, 10 Aug 2006 19:42:30 +0000 (+0000) Subject: Add tests equivalent to the ones in deal.II/ with the same name, except that they... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dc0a79fcf657056ba045419f97ee21b46b3cead;p=dealii-svn.git Add tests equivalent to the ones in deal.II/ with the same name, except that they use an hp::DoFHandler. git-svn-id: https://svn.dealii.org/trunk@13640 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/hp/Makefile b/tests/hp/Makefile index 908f7e6709..217e72af6a 100644 --- a/tests/hp/Makefile +++ b/tests/hp/Makefile @@ -33,7 +33,8 @@ tests_x = hp_dof_handler \ n_active_fe_indices \ integrate_difference \ hp_*_dof_identities_* \ - hp_hanging_nodes_* + hp_hanging_nodes_* \ + interpolate_* # from above list of regular expressions, generate the real set of # tests diff --git a/tests/hp/interpolate_dgq_01.cc b/tests/hp/interpolate_dgq_01.cc new file mode 100644 index 0000000000..e02bee9098 --- /dev/null +++ b/tests/hp/interpolate_dgq_01.cc @@ -0,0 +1,119 @@ +//---------------------------- interpolate_dgq_01.cc --------------------------- +// $Id: interpolate_dgq_01.cc 12732 2006-03-28 23:15:45Z wolf $ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- interpolate_dgq_01.cc --------------------------- + + +// check that VectorTools::interpolate works for FE_DGQ(p) elements correctly on +// a uniformly refined mesh for functions of degree q + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +class F : public Function +{ + public: + F (const unsigned int q) : q(q) {} + + virtual double value (const Point &p, + const unsigned int) const + { + double v=0; + for (unsigned int d=0; d +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (3); + + for (unsigned int p=1; p<7-dim; ++p) + { + FE_DGQ fe(p); + hp::FECollection hp_fe (fe); + hp::DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (hp_fe); + + Vector interpolant (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p+2; ++q) + { + // interpolate the function + VectorTools::interpolate (dof_handler, + F (q), + interpolant); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + interpolant, + F (q), + error, + hp::QCollection(QGauss(q+2)), + VectorTools::L2_norm); + if (q<=p) + Assert (error.l2_norm() < 1e-12*interpolant.l2_norm(), + ExcInternalError()); + + deallog << fe.get_name() << ", P_" << q + << ", rel. error=" << error.l2_norm() / interpolant.l2_norm() + << std::endl; + } + } +} + + + +int main () +{ + std::ofstream logfile("interpolate_dgq_01/output"); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/hp/interpolate_dgq_01/cmp/generic b/tests/hp/interpolate_dgq_01/cmp/generic new file mode 100644 index 0000000000..f9d84961f1 --- /dev/null +++ b/tests/hp/interpolate_dgq_01/cmp/generic @@ -0,0 +1,68 @@ + +DEAL::FE_DGQ<1>(1), P_0, rel. error=0 +DEAL::FE_DGQ<1>(1), P_1, rel. error=0 +DEAL::FE_DGQ<1>(1), P_2, rel. error=0.000638 +DEAL::FE_DGQ<1>(1), P_3, rel. error=0.00143 +DEAL::FE_DGQ<1>(2), P_0, rel. error=0 +DEAL::FE_DGQ<1>(2), P_1, rel. error=0 +DEAL::FE_DGQ<1>(2), P_2, rel. error=0 +DEAL::FE_DGQ<1>(2), P_3, rel. error=1.15e-05 +DEAL::FE_DGQ<1>(2), P_4, rel. error=3.26e-05 +DEAL::FE_DGQ<1>(3), P_0, rel. error=0 +DEAL::FE_DGQ<1>(3), P_1, rel. error=0 +DEAL::FE_DGQ<1>(3), P_2, rel. error=0 +DEAL::FE_DGQ<1>(3), P_3, rel. error=0 +DEAL::FE_DGQ<1>(3), P_4, rel. error=2.60e-07 +DEAL::FE_DGQ<1>(3), P_5, rel. error=8.88e-07 +DEAL::FE_DGQ<1>(4), P_0, rel. error=0 +DEAL::FE_DGQ<1>(4), P_1, rel. error=0 +DEAL::FE_DGQ<1>(4), P_2, rel. error=0 +DEAL::FE_DGQ<1>(4), P_3, rel. error=0 +DEAL::FE_DGQ<1>(4), P_4, rel. error=0 +DEAL::FE_DGQ<1>(4), P_5, rel. error=6.71e-09 +DEAL::FE_DGQ<1>(4), P_6, rel. error=2.68e-08 +DEAL::FE_DGQ<1>(5), P_0, rel. error=0 +DEAL::FE_DGQ<1>(5), P_1, rel. error=0 +DEAL::FE_DGQ<1>(5), P_2, rel. error=0 +DEAL::FE_DGQ<1>(5), P_3, rel. error=0 +DEAL::FE_DGQ<1>(5), P_4, rel. error=0 +DEAL::FE_DGQ<1>(5), P_5, rel. error=0 +DEAL::FE_DGQ<1>(5), P_6, rel. error=1.92e-10 +DEAL::FE_DGQ<1>(5), P_7, rel. error=8.80e-10 +DEAL::FE_DGQ<2>(1), P_0, rel. error=0 +DEAL::FE_DGQ<2>(1), P_1, rel. error=0 +DEAL::FE_DGQ<2>(1), P_2, rel. error=0.000161 +DEAL::FE_DGQ<2>(1), P_3, rel. error=0.000360 +DEAL::FE_DGQ<2>(2), P_0, rel. error=0 +DEAL::FE_DGQ<2>(2), P_1, rel. error=0 +DEAL::FE_DGQ<2>(2), P_2, rel. error=0 +DEAL::FE_DGQ<2>(2), P_3, rel. error=1.88e-06 +DEAL::FE_DGQ<2>(2), P_4, rel. error=5.44e-06 +DEAL::FE_DGQ<2>(3), P_0, rel. error=0 +DEAL::FE_DGQ<2>(3), P_1, rel. error=0 +DEAL::FE_DGQ<2>(3), P_2, rel. error=0 +DEAL::FE_DGQ<2>(3), P_3, rel. error=0 +DEAL::FE_DGQ<2>(3), P_4, rel. error=4.09e-08 +DEAL::FE_DGQ<2>(3), P_5, rel. error=1.41e-07 +DEAL::FE_DGQ<2>(4), P_0, rel. error=0 +DEAL::FE_DGQ<2>(4), P_1, rel. error=0 +DEAL::FE_DGQ<2>(4), P_2, rel. error=0 +DEAL::FE_DGQ<2>(4), P_3, rel. error=0 +DEAL::FE_DGQ<2>(4), P_4, rel. error=0 +DEAL::FE_DGQ<2>(4), P_5, rel. error=8.84e-10 +DEAL::FE_DGQ<2>(4), P_6, rel. error=3.59e-09 +DEAL::FE_DGQ<3>(1), P_0, rel. error=0 +DEAL::FE_DGQ<3>(1), P_1, rel. error=0 +DEAL::FE_DGQ<3>(1), P_2, rel. error=4.03e-05 +DEAL::FE_DGQ<3>(1), P_3, rel. error=9.02e-05 +DEAL::FE_DGQ<3>(2), P_0, rel. error=0 +DEAL::FE_DGQ<3>(2), P_1, rel. error=0 +DEAL::FE_DGQ<3>(2), P_2, rel. error=0 +DEAL::FE_DGQ<3>(2), P_3, rel. error=3.30e-07 +DEAL::FE_DGQ<3>(2), P_4, rel. error=9.67e-07 +DEAL::FE_DGQ<3>(3), P_0, rel. error=0 +DEAL::FE_DGQ<3>(3), P_1, rel. error=0 +DEAL::FE_DGQ<3>(3), P_2, rel. error=0 +DEAL::FE_DGQ<3>(3), P_3, rel. error=0 +DEAL::FE_DGQ<3>(3), P_4, rel. error=6.75e-09 +DEAL::FE_DGQ<3>(3), P_5, rel. error=2.32e-08 diff --git a/tests/hp/interpolate_dgq_02.cc b/tests/hp/interpolate_dgq_02.cc new file mode 100644 index 0000000000..418703417e --- /dev/null +++ b/tests/hp/interpolate_dgq_02.cc @@ -0,0 +1,129 @@ +//---------------------------- interpolate_dgq_02.cc --------------------------- +// $Id: interpolate_dgq_02.cc 12732 2006-03-28 23:15:45Z wolf $ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- interpolate_dgq_02.cc --------------------------- + + +// check that VectorTools::interpolate works for FE_DGQ(p) elements correctly on +// an adaptively refined mesh for functions of degree q + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +class F : public Function +{ + public: + F (const unsigned int q) : q(q) {} + + virtual double value (const Point &p, + const unsigned int) const + { + double v=0; + for (unsigned int d=0; d +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (1); + triangulation.begin_active()->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + triangulation.refine_global (1); + + for (unsigned int p=1; p<6-dim; ++p) + { + FE_DGQ fe(p); + hp::FECollection hp_fe (fe); + hp::DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (hp_fe); + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, constraints); + constraints.close (); + + Vector interpolant (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p+2; ++q) + { + // interpolate the function + VectorTools::interpolate (dof_handler, + F (q), + interpolant); + constraints.distribute (interpolant); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + interpolant, + F (q), + error, + hp::QCollection(QGauss(q+2)), + VectorTools::L2_norm); + if (q<=p) + Assert (error.l2_norm() < 1e-12*interpolant.l2_norm(), + ExcInternalError()); + + deallog << fe.get_name() << ", P_" << q + << ", rel. error=" << error.l2_norm() / interpolant.l2_norm() + << std::endl; + } + } +} + + + +int main () +{ + std::ofstream logfile("interpolate_dgq_02/output"); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/hp/interpolate_dgq_02/cmp/generic b/tests/hp/interpolate_dgq_02/cmp/generic new file mode 100644 index 0000000000..ad68d0fd2b --- /dev/null +++ b/tests/hp/interpolate_dgq_02/cmp/generic @@ -0,0 +1,47 @@ + +DEAL::FE_DGQ<1>(1), P_0, rel. error=0 +DEAL::FE_DGQ<1>(1), P_1, rel. error=0 +DEAL::FE_DGQ<1>(1), P_2, rel. error=0.00243 +DEAL::FE_DGQ<1>(1), P_3, rel. error=0.00676 +DEAL::FE_DGQ<1>(2), P_0, rel. error=0 +DEAL::FE_DGQ<1>(2), P_1, rel. error=0 +DEAL::FE_DGQ<1>(2), P_2, rel. error=0 +DEAL::FE_DGQ<1>(2), P_3, rel. error=8.78e-05 +DEAL::FE_DGQ<1>(2), P_4, rel. error=0.000315 +DEAL::FE_DGQ<1>(3), P_0, rel. error=0 +DEAL::FE_DGQ<1>(3), P_1, rel. error=0 +DEAL::FE_DGQ<1>(3), P_2, rel. error=0 +DEAL::FE_DGQ<1>(3), P_3, rel. error=0 +DEAL::FE_DGQ<1>(3), P_4, rel. error=3.99e-06 +DEAL::FE_DGQ<1>(3), P_5, rel. error=1.74e-05 +DEAL::FE_DGQ<1>(4), P_0, rel. error=0 +DEAL::FE_DGQ<1>(4), P_1, rel. error=0 +DEAL::FE_DGQ<1>(4), P_2, rel. error=0 +DEAL::FE_DGQ<1>(4), P_3, rel. error=0 +DEAL::FE_DGQ<1>(4), P_4, rel. error=0 +DEAL::FE_DGQ<1>(4), P_5, rel. error=2.07e-07 +DEAL::FE_DGQ<1>(4), P_6, rel. error=1.06e-06 +DEAL::FE_DGQ<2>(1), P_0, rel. error=0 +DEAL::FE_DGQ<2>(1), P_1, rel. error=0 +DEAL::FE_DGQ<2>(1), P_2, rel. error=0.00100 +DEAL::FE_DGQ<2>(1), P_3, rel. error=0.00249 +DEAL::FE_DGQ<2>(2), P_0, rel. error=0 +DEAL::FE_DGQ<2>(2), P_1, rel. error=0 +DEAL::FE_DGQ<2>(2), P_2, rel. error=0 +DEAL::FE_DGQ<2>(2), P_3, rel. error=2.41e-05 +DEAL::FE_DGQ<2>(2), P_4, rel. error=7.74e-05 +DEAL::FE_DGQ<2>(3), P_0, rel. error=0 +DEAL::FE_DGQ<2>(3), P_1, rel. error=0 +DEAL::FE_DGQ<2>(3), P_2, rel. error=0 +DEAL::FE_DGQ<2>(3), P_3, rel. error=0 +DEAL::FE_DGQ<2>(3), P_4, rel. error=1.07e-06 +DEAL::FE_DGQ<2>(3), P_5, rel. error=4.06e-06 +DEAL::FE_DGQ<3>(1), P_0, rel. error=0 +DEAL::FE_DGQ<3>(1), P_1, rel. error=0 +DEAL::FE_DGQ<3>(1), P_2, rel. error=0.000375 +DEAL::FE_DGQ<3>(1), P_3, rel. error=0.000898 +DEAL::FE_DGQ<3>(2), P_0, rel. error=0 +DEAL::FE_DGQ<3>(2), P_1, rel. error=0 +DEAL::FE_DGQ<3>(2), P_2, rel. error=0 +DEAL::FE_DGQ<3>(2), P_3, rel. error=6.40e-06 +DEAL::FE_DGQ<3>(2), P_4, rel. error=1.98e-05 diff --git a/tests/hp/interpolate_q_01.cc b/tests/hp/interpolate_q_01.cc new file mode 100644 index 0000000000..3911655ce7 --- /dev/null +++ b/tests/hp/interpolate_q_01.cc @@ -0,0 +1,120 @@ +//---------------------------- interpolate_q_01.cc --------------------------- +// $Id: interpolate_q_01.cc 12732 2006-03-28 23:15:45Z wolf $ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- interpolate_q_01.cc --------------------------- + + +// check that VectorTools::interpolate works for FE_Q(p) elements correctly on +// a uniformly refined mesh for functions of degree q + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +class F : public Function +{ + public: + F (const unsigned int q) : q(q) {} + + virtual double value (const Point &p, + const unsigned int) const + { + double v=0; + for (unsigned int d=0; d +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (3); + + for (unsigned int p=1; p<7-dim; ++p) + { + FE_Q fe(p); + hp::FECollection hp_fe (fe); + + hp::DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (hp_fe); + + Vector interpolant (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p+2; ++q) + { + // interpolate the function + VectorTools::interpolate (dof_handler, + F (q), + interpolant); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + interpolant, + F (q), + error, + hp::QCollection(QGauss(q+2)), + VectorTools::L2_norm); + if (q<=p) + Assert (error.l2_norm() < 1e-12*interpolant.l2_norm(), + ExcInternalError()); + + deallog << fe.get_name() << ", P_" << q + << ", rel. error=" << error.l2_norm() / interpolant.l2_norm() + << std::endl; + } + } +} + + + +int main () +{ + std::ofstream logfile("interpolate_q_01/output"); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/hp/interpolate_q_01/cmp/generic b/tests/hp/interpolate_q_01/cmp/generic new file mode 100644 index 0000000000..7f0730aef2 --- /dev/null +++ b/tests/hp/interpolate_q_01/cmp/generic @@ -0,0 +1,68 @@ + +DEAL::FE_Q<1>(1), P_0, rel. error=0 +DEAL::FE_Q<1>(1), P_1, rel. error=0 +DEAL::FE_Q<1>(1), P_2, rel. error=0.000822 +DEAL::FE_Q<1>(1), P_3, rel. error=0.00179 +DEAL::FE_Q<1>(2), P_0, rel. error=0 +DEAL::FE_Q<1>(2), P_1, rel. error=0 +DEAL::FE_Q<1>(2), P_2, rel. error=0 +DEAL::FE_Q<1>(2), P_3, rel. error=1.32e-05 +DEAL::FE_Q<1>(2), P_4, rel. error=3.70e-05 +DEAL::FE_Q<1>(3), P_0, rel. error=0 +DEAL::FE_Q<1>(3), P_1, rel. error=0 +DEAL::FE_Q<1>(3), P_2, rel. error=0 +DEAL::FE_Q<1>(3), P_3, rel. error=0 +DEAL::FE_Q<1>(3), P_4, rel. error=2.85e-07 +DEAL::FE_Q<1>(3), P_5, rel. error=9.66e-07 +DEAL::FE_Q<1>(4), P_0, rel. error=0 +DEAL::FE_Q<1>(4), P_1, rel. error=0 +DEAL::FE_Q<1>(4), P_2, rel. error=0 +DEAL::FE_Q<1>(4), P_3, rel. error=0 +DEAL::FE_Q<1>(4), P_4, rel. error=0 +DEAL::FE_Q<1>(4), P_5, rel. error=7.18e-09 +DEAL::FE_Q<1>(4), P_6, rel. error=2.85e-08 +DEAL::FE_Q<1>(5), P_0, rel. error=0 +DEAL::FE_Q<1>(5), P_1, rel. error=0 +DEAL::FE_Q<1>(5), P_2, rel. error=0 +DEAL::FE_Q<1>(5), P_3, rel. error=0 +DEAL::FE_Q<1>(5), P_4, rel. error=0 +DEAL::FE_Q<1>(5), P_5, rel. error=0 +DEAL::FE_Q<1>(5), P_6, rel. error=2.02e-10 +DEAL::FE_Q<1>(5), P_7, rel. error=9.20e-10 +DEAL::FE_Q<2>(1), P_0, rel. error=0 +DEAL::FE_Q<2>(1), P_1, rel. error=0 +DEAL::FE_Q<2>(1), P_2, rel. error=0.000278 +DEAL::FE_Q<2>(1), P_3, rel. error=0.000606 +DEAL::FE_Q<2>(2), P_0, rel. error=0 +DEAL::FE_Q<2>(2), P_1, rel. error=0 +DEAL::FE_Q<2>(2), P_2, rel. error=0 +DEAL::FE_Q<2>(2), P_3, rel. error=2.58e-06 +DEAL::FE_Q<2>(2), P_4, rel. error=7.37e-06 +DEAL::FE_Q<2>(3), P_0, rel. error=0 +DEAL::FE_Q<2>(3), P_1, rel. error=0 +DEAL::FE_Q<2>(3), P_2, rel. error=0 +DEAL::FE_Q<2>(3), P_3, rel. error=0 +DEAL::FE_Q<2>(3), P_4, rel. error=5.09e-08 +DEAL::FE_Q<2>(3), P_5, rel. error=1.74e-07 +DEAL::FE_Q<2>(4), P_0, rel. error=0 +DEAL::FE_Q<2>(4), P_1, rel. error=0 +DEAL::FE_Q<2>(4), P_2, rel. error=0 +DEAL::FE_Q<2>(4), P_3, rel. error=0 +DEAL::FE_Q<2>(4), P_4, rel. error=0 +DEAL::FE_Q<2>(4), P_5, rel. error=1.04e-09 +DEAL::FE_Q<2>(4), P_6, rel. error=4.21e-09 +DEAL::FE_Q<3>(1), P_0, rel. error=0 +DEAL::FE_Q<3>(1), P_1, rel. error=0 +DEAL::FE_Q<3>(1), P_2, rel. error=9.31e-05 +DEAL::FE_Q<3>(1), P_3, rel. error=0.000203 +DEAL::FE_Q<3>(2), P_0, rel. error=0 +DEAL::FE_Q<3>(2), P_1, rel. error=0 +DEAL::FE_Q<3>(2), P_2, rel. error=0 +DEAL::FE_Q<3>(2), P_3, rel. error=5.40e-07 +DEAL::FE_Q<3>(2), P_4, rel. error=1.56e-06 +DEAL::FE_Q<3>(3), P_0, rel. error=0 +DEAL::FE_Q<3>(3), P_1, rel. error=0 +DEAL::FE_Q<3>(3), P_2, rel. error=0 +DEAL::FE_Q<3>(3), P_3, rel. error=0 +DEAL::FE_Q<3>(3), P_4, rel. error=9.53e-09 +DEAL::FE_Q<3>(3), P_5, rel. error=3.25e-08 diff --git a/tests/hp/interpolate_q_02.cc b/tests/hp/interpolate_q_02.cc new file mode 100644 index 0000000000..af6f4d53a7 --- /dev/null +++ b/tests/hp/interpolate_q_02.cc @@ -0,0 +1,129 @@ +//---------------------------- interpolate_q_02.cc --------------------------- +// $Id: interpolate_q_02.cc 12732 2006-03-28 23:15:45Z wolf $ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- interpolate_q_02.cc --------------------------- + + +// check that VectorTools::interpolate works for FE_Q(p) elements correctly on +// an adaptively refined mesh for functions of degree q + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +class F : public Function +{ + public: + F (const unsigned int q) : q(q) {} + + virtual double value (const Point &p, + const unsigned int) const + { + double v=0; + for (unsigned int d=0; d +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (1); + triangulation.begin_active()->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + triangulation.refine_global (1); + + for (unsigned int p=1; p<6-dim; ++p) + { + FE_Q fe(p); + hp::FECollection hp_fe (fe); + hp::DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (hp_fe); + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, constraints); + constraints.close (); + + Vector interpolant (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p+2; ++q) + { + // interpolate the function + VectorTools::interpolate (dof_handler, + F (q), + interpolant); + constraints.distribute (interpolant); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + interpolant, + F (q), + error, + hp::QCollection(QGauss(q+2)), + VectorTools::L2_norm); + if (q<=p) + Assert (error.l2_norm() < 1e-12*interpolant.l2_norm(), + ExcInternalError()); + + deallog << fe.get_name() << ", P_" << q + << ", rel. error=" << error.l2_norm() / interpolant.l2_norm() + << std::endl; + } + } +} + + + +int main () +{ + std::ofstream logfile("interpolate_q_02/output"); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/hp/interpolate_q_02/cmp/generic b/tests/hp/interpolate_q_02/cmp/generic new file mode 100644 index 0000000000..7f0730aef2 --- /dev/null +++ b/tests/hp/interpolate_q_02/cmp/generic @@ -0,0 +1,68 @@ + +DEAL::FE_Q<1>(1), P_0, rel. error=0 +DEAL::FE_Q<1>(1), P_1, rel. error=0 +DEAL::FE_Q<1>(1), P_2, rel. error=0.000822 +DEAL::FE_Q<1>(1), P_3, rel. error=0.00179 +DEAL::FE_Q<1>(2), P_0, rel. error=0 +DEAL::FE_Q<1>(2), P_1, rel. error=0 +DEAL::FE_Q<1>(2), P_2, rel. error=0 +DEAL::FE_Q<1>(2), P_3, rel. error=1.32e-05 +DEAL::FE_Q<1>(2), P_4, rel. error=3.70e-05 +DEAL::FE_Q<1>(3), P_0, rel. error=0 +DEAL::FE_Q<1>(3), P_1, rel. error=0 +DEAL::FE_Q<1>(3), P_2, rel. error=0 +DEAL::FE_Q<1>(3), P_3, rel. error=0 +DEAL::FE_Q<1>(3), P_4, rel. error=2.85e-07 +DEAL::FE_Q<1>(3), P_5, rel. error=9.66e-07 +DEAL::FE_Q<1>(4), P_0, rel. error=0 +DEAL::FE_Q<1>(4), P_1, rel. error=0 +DEAL::FE_Q<1>(4), P_2, rel. error=0 +DEAL::FE_Q<1>(4), P_3, rel. error=0 +DEAL::FE_Q<1>(4), P_4, rel. error=0 +DEAL::FE_Q<1>(4), P_5, rel. error=7.18e-09 +DEAL::FE_Q<1>(4), P_6, rel. error=2.85e-08 +DEAL::FE_Q<1>(5), P_0, rel. error=0 +DEAL::FE_Q<1>(5), P_1, rel. error=0 +DEAL::FE_Q<1>(5), P_2, rel. error=0 +DEAL::FE_Q<1>(5), P_3, rel. error=0 +DEAL::FE_Q<1>(5), P_4, rel. error=0 +DEAL::FE_Q<1>(5), P_5, rel. error=0 +DEAL::FE_Q<1>(5), P_6, rel. error=2.02e-10 +DEAL::FE_Q<1>(5), P_7, rel. error=9.20e-10 +DEAL::FE_Q<2>(1), P_0, rel. error=0 +DEAL::FE_Q<2>(1), P_1, rel. error=0 +DEAL::FE_Q<2>(1), P_2, rel. error=0.000278 +DEAL::FE_Q<2>(1), P_3, rel. error=0.000606 +DEAL::FE_Q<2>(2), P_0, rel. error=0 +DEAL::FE_Q<2>(2), P_1, rel. error=0 +DEAL::FE_Q<2>(2), P_2, rel. error=0 +DEAL::FE_Q<2>(2), P_3, rel. error=2.58e-06 +DEAL::FE_Q<2>(2), P_4, rel. error=7.37e-06 +DEAL::FE_Q<2>(3), P_0, rel. error=0 +DEAL::FE_Q<2>(3), P_1, rel. error=0 +DEAL::FE_Q<2>(3), P_2, rel. error=0 +DEAL::FE_Q<2>(3), P_3, rel. error=0 +DEAL::FE_Q<2>(3), P_4, rel. error=5.09e-08 +DEAL::FE_Q<2>(3), P_5, rel. error=1.74e-07 +DEAL::FE_Q<2>(4), P_0, rel. error=0 +DEAL::FE_Q<2>(4), P_1, rel. error=0 +DEAL::FE_Q<2>(4), P_2, rel. error=0 +DEAL::FE_Q<2>(4), P_3, rel. error=0 +DEAL::FE_Q<2>(4), P_4, rel. error=0 +DEAL::FE_Q<2>(4), P_5, rel. error=1.04e-09 +DEAL::FE_Q<2>(4), P_6, rel. error=4.21e-09 +DEAL::FE_Q<3>(1), P_0, rel. error=0 +DEAL::FE_Q<3>(1), P_1, rel. error=0 +DEAL::FE_Q<3>(1), P_2, rel. error=9.31e-05 +DEAL::FE_Q<3>(1), P_3, rel. error=0.000203 +DEAL::FE_Q<3>(2), P_0, rel. error=0 +DEAL::FE_Q<3>(2), P_1, rel. error=0 +DEAL::FE_Q<3>(2), P_2, rel. error=0 +DEAL::FE_Q<3>(2), P_3, rel. error=5.40e-07 +DEAL::FE_Q<3>(2), P_4, rel. error=1.56e-06 +DEAL::FE_Q<3>(3), P_0, rel. error=0 +DEAL::FE_Q<3>(3), P_1, rel. error=0 +DEAL::FE_Q<3>(3), P_2, rel. error=0 +DEAL::FE_Q<3>(3), P_3, rel. error=0 +DEAL::FE_Q<3>(3), P_4, rel. error=9.53e-09 +DEAL::FE_Q<3>(3), P_5, rel. error=3.25e-08 diff --git a/tests/hp/interpolate_q_system_01.cc b/tests/hp/interpolate_q_system_01.cc new file mode 100644 index 0000000000..20505e56ec --- /dev/null +++ b/tests/hp/interpolate_q_system_01.cc @@ -0,0 +1,123 @@ +//---------------------------- interpolate_q_system_01.cc --------------------------- +// $Id: interpolate_q_system_01.cc 12732 2006-03-28 23:15:45Z wolf $ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- interpolate_q_system_01.cc --------------------------- + + +// check that VectorTools::interpolate works for FE_System(FE_Q(p)) elements correctly on +// a uniformly refined mesh for functions of degree q + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +class F : public Function +{ + public: + F (const unsigned int q) : Function(3), q(q) {} + + virtual void vector_value (const Point &p, + Vector &v) const + { + for (unsigned int c=0; c +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (3); + + for (unsigned int p=1; p<6-dim; ++p) + { + FESystem fe(FE_Q(p), 2, + FE_Q(p+1), 1); + hp::FECollection hp_fe (fe); + hp::DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (hp_fe); + + Vector interpolant (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p+2; ++q) + { + // interpolate the function + VectorTools::interpolate (dof_handler, + F (q), + interpolant); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + interpolant, + F (q), + error, + hp::QCollection(QGauss(q+2)), + VectorTools::L2_norm); + if (q<=p) + Assert (error.l2_norm() < 1e-12*interpolant.l2_norm(), + ExcInternalError()); + + deallog << fe.get_name() << ", P_" << q + << ", rel. error=" << error.l2_norm() / interpolant.l2_norm() + << std::endl; + } + } +} + + + +int main () +{ + std::ofstream logfile("interpolate_q_system_01/output"); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/hp/interpolate_q_system_01/cmp/generic b/tests/hp/interpolate_q_system_01/cmp/generic new file mode 100644 index 0000000000..35cf8fe9c1 --- /dev/null +++ b/tests/hp/interpolate_q_system_01/cmp/generic @@ -0,0 +1,47 @@ + +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_2, rel. error=0.000278 +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_3, rel. error=0.000654 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_2, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_3, rel. error=5.15e-06 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_4, rel. error=1.52e-05 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_2, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_3, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_4, rel. error=1.20e-07 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_5, rel. error=4.27e-07 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_2, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_3, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_4, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_5, rel. error=3.21e-09 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_6, rel. error=1.33e-08 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_0, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_1, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_2, rel. error=8.74e-05 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_3, rel. error=0.000201 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_0, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_1, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_2, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_3, rel. error=1.02e-06 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_4, rel. error=3.01e-06 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_0, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_1, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_2, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_3, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_4, rel. error=2.22e-08 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_5, rel. error=7.82e-08 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_0, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_1, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_2, rel. error=2.52e-05 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_3, rel. error=5.74e-05 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_0, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_1, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_2, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_3, rel. error=2.04e-07 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_4, rel. error=6.07e-07 diff --git a/tests/hp/interpolate_q_system_02.cc b/tests/hp/interpolate_q_system_02.cc new file mode 100644 index 0000000000..1172bfab60 --- /dev/null +++ b/tests/hp/interpolate_q_system_02.cc @@ -0,0 +1,134 @@ +//---------------------------- interpolate_q_system_01.cc --------------------------- +// $Id: interpolate_q_system_02.cc 12732 2006-03-28 23:15:45Z wolf $ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- interpolate_q_system_02.cc --------------------------- + + +// check that VectorTools::interpolate works for FE_System(FE_Q(p)) elements correctly on +// an adaptively refined mesh for functions of degree q + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include + + +template +class F : public Function +{ + public: + F (const unsigned int q) : Function(3), q(q) {} + + virtual void vector_value (const Point &p, + Vector &v) const + { + for (unsigned int c=0; c +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (1); + triangulation.begin_active()->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + triangulation.refine_global (1); + + for (unsigned int p=1; p<6-dim; ++p) + { + FESystem fe(FE_Q(p), 2, + FE_Q(p+1), 1); + hp::FECollection hp_fe (fe); + hp::DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (hp_fe); + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, constraints); + constraints.close (); + + Vector interpolant (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p+2; ++q) + { + // interpolate the function + VectorTools::interpolate (dof_handler, + F (q), + interpolant); + constraints.distribute (interpolant); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + interpolant, + F (q), + error, + hp::QCollection(QGauss(q+2)), + VectorTools::L2_norm); + if (q<=p) + Assert (error.l2_norm() < 1e-12*interpolant.l2_norm(), + ExcInternalError()); + + deallog << fe.get_name() << ", P_" << q + << ", rel. error=" << error.l2_norm() / interpolant.l2_norm() + << std::endl; + } + } +} + + + +int main () +{ + std::ofstream logfile("interpolate_q_system_02/output"); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/hp/interpolate_q_system_02/cmp/generic b/tests/hp/interpolate_q_system_02/cmp/generic new file mode 100644 index 0000000000..1cc556796d --- /dev/null +++ b/tests/hp/interpolate_q_system_02/cmp/generic @@ -0,0 +1,47 @@ + +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_2, rel. error=0.000970 +DEAL::FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)], P_3, rel. error=0.00282 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_2, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_3, rel. error=3.59e-05 +DEAL::FESystem<1>[FE_Q<1>(2)^2-FE_Q<1>(3)], P_4, rel. error=0.000134 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_2, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_3, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_4, rel. error=1.69e-06 +DEAL::FESystem<1>[FE_Q<1>(3)^2-FE_Q<1>(4)], P_5, rel. error=7.67e-06 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_0, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_1, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_2, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_3, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_4, rel. error=0 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_5, rel. error=9.09e-08 +DEAL::FESystem<1>[FE_Q<1>(4)^2-FE_Q<1>(5)], P_6, rel. error=4.83e-07 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_0, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_1, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_2, rel. error=0.000478 +DEAL::FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)], P_3, rel. error=0.00120 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_0, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_1, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_2, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_3, rel. error=1.14e-05 +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(3)], P_4, rel. error=3.74e-05 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_0, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_1, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_2, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_3, rel. error=0 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_4, rel. error=5.13e-07 +DEAL::FESystem<2>[FE_Q<2>(3)^2-FE_Q<2>(4)], P_5, rel. error=1.99e-06 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_0, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_1, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_2, rel. error=0.000199 +DEAL::FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)], P_3, rel. error=0.000477 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_0, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_1, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_2, rel. error=0 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_3, rel. error=3.39e-06 +DEAL::FESystem<3>[FE_Q<3>(2)^2-FE_Q<3>(3)], P_4, rel. error=1.06e-05