From: bangerth Date: Thu, 11 Jan 2007 03:50:48 +0000 (+0000) Subject: Check in a test that shows that our FE_Q doesn't work quite right with wrong face... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1766194b60d1a2e8674eb5ca4283048b430c9473;p=dealii-svn.git Check in a test that shows that our FE_Q doesn't work quite right with wrong face orientations when q>=3. git-svn-id: https://svn.dealii.org/trunk@14300 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/fail/face_orientation_and_fe_q_01.cc b/tests/fail/face_orientation_and_fe_q_01.cc new file mode 100644 index 0000000000..d059f08269 --- /dev/null +++ b/tests/fail/face_orientation_and_fe_q_01.cc @@ -0,0 +1,213 @@ +//---------------------------- face_orientation_and_fe_q_01.cc --------------------------- +// $Id: face_orientation_and_fe_q_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_q_01.cc --------------------------- + + +// make sure that we treat FE_Q elements correctly if +// face_orientation==false. for p>=3, we need to revert the order of dofs +// somehow between the two sides of the face. this test is derived from +// deal.II/project_q_03 + +char logname[] = "face_orientation_and_fe_q_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 () +{ + test_with_wrong_face_orientation (FE_Q(3), 3); +} diff --git a/tests/fail/face_orientation_and_fe_q_01/cmp/generic b/tests/fail/face_orientation_and_fe_q_01/cmp/generic new file mode 100644 index 0000000000..d34f09d46b --- /dev/null +++ b/tests/fail/face_orientation_and_fe_q_01/cmp/generic @@ -0,0 +1,78 @@ + +DEAL::n_dofs=35 +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=0.0200 +DEAL::FE_Q<3>(1), P_3, rel. error=0.0213 +DEAL::n_dofs=35 +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=0.0210 +DEAL::FE_Q<3>(1), P_3, rel. error=0.0229 +DEAL::n_dofs=35 +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=0.0147 +DEAL::FE_Q<3>(1), P_3, rel. error=0.0160 +DEAL::n_dofs=35 +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=0.0154 +DEAL::FE_Q<3>(1), P_3, rel. error=0.0156 +DEAL::n_dofs=35 +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=0.0162 +DEAL::FE_Q<3>(1), P_3, rel. error=0.0175 +DEAL::n_dofs=35 +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=0.0193 +DEAL::FE_Q<3>(1), P_3, rel. error=0.0206 +DEAL::n_dofs=35 +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=0.0158 +DEAL::FE_Q<3>(1), P_3, rel. error=0.0165 +DEAL::n_dofs=195 +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=0.00312 +DEAL::FE_Q<3>(2), P_4, rel. error=0.00305 +DEAL::n_dofs=194 +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=0.00316 +DEAL::FE_Q<3>(2), P_4, rel. error=0.00295 +DEAL::n_dofs=194 +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=0.00234 +DEAL::FE_Q<3>(2), P_4, rel. error=0.00227 +DEAL::n_dofs=194 +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=0.00211 +DEAL::FE_Q<3>(2), P_4, rel. error=0.00204 +DEAL::n_dofs=194 +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=0.00267 +DEAL::FE_Q<3>(2), P_4, rel. error=0.00253 +DEAL::n_dofs=194 +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=0.00288 +DEAL::FE_Q<3>(2), P_4, rel. error=0.00270 +DEAL::n_dofs=194 +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=0.00221 +DEAL::FE_Q<3>(2), P_4, rel. error=0.00214