From 0375fac0c74cbe23e90cb7c0eb2e94bed08b2e3c Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 10 Aug 2006 19:16:23 +0000 Subject: [PATCH] Same test, but for DGQ git-svn-id: https://svn.dealii.org/trunk@13636 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/interpolate_dgq_01.cc | 117 +++++++++++++++++++ tests/deal.II/interpolate_dgq_01/cmp/generic | 68 +++++++++++ tests/deal.II/interpolate_q_01.cc | 4 +- 3 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 tests/deal.II/interpolate_dgq_01.cc create mode 100644 tests/deal.II/interpolate_dgq_01/cmp/generic diff --git a/tests/deal.II/interpolate_dgq_01.cc b/tests/deal.II/interpolate_dgq_01.cc new file mode 100644 index 0000000000..1d7c6b6cfb --- /dev/null +++ b/tests/deal.II/interpolate_dgq_01.cc @@ -0,0 +1,117 @@ +//---------------------------- 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_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 + + +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); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (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, + 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/deal.II/interpolate_dgq_01/cmp/generic b/tests/deal.II/interpolate_dgq_01/cmp/generic new file mode 100644 index 0000000000..f9d84961f1 --- /dev/null +++ b/tests/deal.II/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/deal.II/interpolate_q_01.cc b/tests/deal.II/interpolate_q_01.cc index c4739a58e2..7a2b5de7d0 100644 --- a/tests/deal.II/interpolate_q_01.cc +++ b/tests/deal.II/interpolate_q_01.cc @@ -12,7 +12,7 @@ //---------------------------- interpolate_q_01.cc --------------------------- -// check that VectorTools::interpolate works for FE_Q(p) elements correctly on +// check that VectorTools::interpolate works for FE_DGQ(p) elements correctly on // a uniformly refined mesh for functions of degree q #include "../tests.h" @@ -92,7 +92,7 @@ void test () Assert (error.l2_norm() < 1e-12*interpolant.l2_norm(), ExcInternalError()); - deallog << "FE_Q<" << dim << ">(" << p << "), P_" << q + deallog << fe.get_name() << ", P_" << q << ", rel. error=" << error.l2_norm() / interpolant.l2_norm() << std::endl; } -- 2.39.5