From 1aa3a9fcba3486e582a2c91652fff7a17c5b552e Mon Sep 17 00:00:00 2001 From: bangerth Date: Fri, 9 Feb 2007 06:03:12 +0000 Subject: [PATCH] Add another test. git-svn-id: https://svn.dealii.org/trunk@14439 0785d39b-7218-0410-832d-ea1e28bc413d --- .../face_orientation_and_fe_nedelec_01.cc | 214 ++++++++++++++++++ .../cmp/generic | 29 +++ 2 files changed, 243 insertions(+) create mode 100644 tests/bits/face_orientation_and_fe_nedelec_01.cc create mode 100644 tests/bits/face_orientation_and_fe_nedelec_01/cmp/generic diff --git a/tests/bits/face_orientation_and_fe_nedelec_01.cc b/tests/bits/face_orientation_and_fe_nedelec_01.cc new file mode 100644 index 0000000000..68e2cf9027 --- /dev/null +++ b/tests/bits/face_orientation_and_fe_nedelec_01.cc @@ -0,0 +1,214 @@ +//---------------------------- face_orientation_and_fe_nedelec_01.cc --------------------------- +// $Id: face_orientation_and_fe_nedelec_01.cc 12732 2006-03-28 23:15:45Z wolf $ +// Version: $Name$ +// +// Copyright (C) 2006, 2007 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. +// +//---------------------------- face_orientation_and_fe_nedelec_01.cc --------------------------- + + +// make sure that we treat FE_Nedelec elements correctly if +// face_orientation==false. for nedelec elements, there is actually nothing to +// do because these elements only have dofs on edges, not on faces, but we +// should test anyway that there is nothing that actively goes wrong. + +char logname[] = "face_orientation_and_fe_nedelec_01/output"; + + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +void test (); + + +template +class F : public Function +{ + public: + F (const unsigned int q, + const unsigned int n_components) + : + Function(n_components), + q(q) + {} + + virtual double value (const Point &p, + const unsigned int component) const + { + Assert ((component == 0) && (this->n_components == 1), + ExcInternalError()); + double val = 0; + for (unsigned int d=0; d &p, + Vector &v) const + { + for (unsigned int c=0; c +void do_project (const Triangulation &triangulation, + const FiniteElement &fe, + const unsigned int p, + const unsigned int order_difference) +{ + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs (fe); + + deallog << "n_dofs=" << dof_handler.n_dofs() << std::endl; + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, + constraints); + constraints.close (); + + Vector projection (dof_handler.n_dofs()); + Vector error (triangulation.n_active_cells()); + for (unsigned int q=0; q<=p+2-order_difference; ++q) + { + // project the function + VectorTools::project (dof_handler, + constraints, + QGauss(p+2), + F (q, fe.n_components()), + projection); + // just to make sure it doesn't get + // forgotten: handle hanging node + // constraints + constraints.distribute (projection); + + // then compute the interpolation error + VectorTools::integrate_difference (dof_handler, + projection, + F (q, fe.n_components()), + error, + QGauss(std::max(p,q)+1), + VectorTools::L2_norm); + deallog << fe.get_name() << ", P_" << q + << ", rel. error=" << error.l2_norm() / projection.l2_norm() + << std::endl; + + if (q<=p-order_difference) + Assert (error.l2_norm() <= 1e-10*projection.l2_norm(), + ExcFailedProjection(error.l2_norm() / projection.l2_norm())); + } +} + + + +// test with a 3d grid that has cells with face_orientation==false and hanging +// nodes. this trips up all sorts of pieces of code, for example there was a +// crash when computing hanging node constraints on such faces (see +// bits/face_orientation_crash), and it triggers all sorts of other +// assumptions that may be hidden in places +// +// the mesh we use is the 7 cells of the hyperball mesh in 3d, with each of +// the cells refined in turn. that then makes 7 meshes with 14 active cells +// each. this also cycles through all possibilities of coarser or finer cell +// having face_orientation==false +template +void test_with_wrong_face_orientation (const FiniteElement &fe, + const unsigned int p, + const unsigned int order_difference = 0) +{ + if (dim != 3) + return; + + for (unsigned int i=0; i<7; ++i) + { + Triangulation triangulation; + GridGenerator::hyper_ball (triangulation); + typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + std::advance (cell, i); + cell->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + + do_project (triangulation, fe, p, order_difference); + } +} + + + + +int main () +{ + std::ofstream logfile(logname); + logfile.precision (3); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + + + +template +void test () +{ + if (dim > 1) + test_with_wrong_face_orientation (FE_Nedelec(1), 0); +} diff --git a/tests/bits/face_orientation_and_fe_nedelec_01/cmp/generic b/tests/bits/face_orientation_and_fe_nedelec_01/cmp/generic new file mode 100644 index 0000000000..501a564332 --- /dev/null +++ b/tests/bits/face_orientation_and_fe_nedelec_01/cmp/generic @@ -0,0 +1,29 @@ + +DEAL::n_dofs=86 +DEAL::FE_Nedelec<3>(1), P_0, rel. error=0 +DEAL::FE_Nedelec<3>(1), P_1, rel. error=0.0356 +DEAL::FE_Nedelec<3>(1), P_2, rel. error=0.0329 +DEAL::n_dofs=86 +DEAL::FE_Nedelec<3>(1), P_0, rel. error=0 +DEAL::FE_Nedelec<3>(1), P_1, rel. error=0.0345 +DEAL::FE_Nedelec<3>(1), P_2, rel. error=0.0313 +DEAL::n_dofs=86 +DEAL::FE_Nedelec<3>(1), P_0, rel. error=0 +DEAL::FE_Nedelec<3>(1), P_1, rel. error=0.0279 +DEAL::FE_Nedelec<3>(1), P_2, rel. error=0.0256 +DEAL::n_dofs=86 +DEAL::FE_Nedelec<3>(1), P_0, rel. error=0 +DEAL::FE_Nedelec<3>(1), P_1, rel. error=0.0316 +DEAL::FE_Nedelec<3>(1), P_2, rel. error=0.0293 +DEAL::n_dofs=86 +DEAL::FE_Nedelec<3>(1), P_0, rel. error=0 +DEAL::FE_Nedelec<3>(1), P_1, rel. error=0.0294 +DEAL::FE_Nedelec<3>(1), P_2, rel. error=0.0272 +DEAL::n_dofs=86 +DEAL::FE_Nedelec<3>(1), P_0, rel. error=0 +DEAL::FE_Nedelec<3>(1), P_1, rel. error=0.0323 +DEAL::FE_Nedelec<3>(1), P_2, rel. error=0.0291 +DEAL::n_dofs=86 +DEAL::FE_Nedelec<3>(1), P_0, rel. error=0 +DEAL::FE_Nedelec<3>(1), P_1, rel. error=0.0299 +DEAL::FE_Nedelec<3>(1), P_2, rel. error=0.0277 -- 2.39.5