From aab1601ff7c3cdd2b50fa210b190a77254dd8d41 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 26 Aug 2013 17:00:24 +0000 Subject: [PATCH] New test case derived from step-10 which computes pi to 14 digits on 5 cells with mappings of orders 8 and 20. git-svn-id: https://svn.dealii.org/trunk@30496 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/step-10-high-order.cc | 193 ++++++++++++++++++++++ tests/bits/step-10-high-order/cmp/generic | 18 ++ 2 files changed, 211 insertions(+) create mode 100644 tests/bits/step-10-high-order.cc create mode 100644 tests/bits/step-10-high-order/cmp/generic diff --git a/tests/bits/step-10-high-order.cc b/tests/bits/step-10-high-order.cc new file mode 100644 index 0000000000..f4c9fa3bf7 --- /dev/null +++ b/tests/bits/step-10-high-order.cc @@ -0,0 +1,193 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2005 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// step-10 with MappingQ(8) that shows pi with 14 digits already at the first +// iteration for the volume and MappingQ(20) for the boundary part that shows +// that things still work for very high order + + +#include "../tests.h" +#include +#include +std::ofstream logfile("step-10-high-order/output"); + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +const long double pi = 3.141592653589793238462643; + + + +template +void compute_pi_by_area () +{ + deallog << "Computation of Pi by the area:" << std::endl + << "==============================" << std::endl; + + const unsigned int degree = 10-dim; + deallog << "Degree = " << degree << std::endl; + + Triangulation triangulation; + GridGenerator::hyper_ball (triangulation); + + static const HyperBallBoundary boundary; + triangulation.set_boundary (0, boundary); + + MappingQ mapping(degree); + const FE_Q dummy_fe (1); + const QGauss quadrature (degree+3); + + DoFHandler dof_handler (triangulation); + + FEValues x_fe_values (mapping, dummy_fe, quadrature, + update_JxW_values); + + // in 3D, we obtain many digits only on a finer mesh + if (dim == 3) + triangulation.refine_global(1); + for (int refinement=0; refinement<4-dim; + ++refinement, triangulation.refine_global (1)) + { + dof_handler.distribute_dofs (dummy_fe); + + long double area = 0; + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + for (; cell!=endc; ++cell) + { + x_fe_values.reinit (cell); + const FEValues &fe_values = x_fe_values.get_present_fe_values(); + for (unsigned int i=0; i +void compute_pi_by_perimeter () +{ + deallog << "Computation of Pi by the perimeter:" << std::endl + << "===================================" << std::endl; + + + const unsigned int degree = 20; + deallog << "Degree = " << degree << std::endl; + Triangulation triangulation; + GridGenerator::hyper_ball (triangulation); + + static const HyperBallBoundary boundary; + triangulation.set_boundary (0, boundary); + + const MappingQ mapping (degree); + const FE_Q fe (1); + const QGauss quadrature (degree); + + DoFHandler dof_handler (triangulation); + + FEFaceValues x_fe_face_values (mapping, fe, quadrature, + update_JxW_values); + for (unsigned int refinement=0; refinement<2; + ++refinement, triangulation.refine_global (1)) + { + dof_handler.distribute_dofs (fe); + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + long double perimeter = 0; + for (; cell!=endc; ++cell) + for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) + if (cell->face(face_no)->at_boundary()) + { + x_fe_face_values.reinit (cell, face_no); + const FEFaceValues &fe_face_values + = x_fe_face_values.get_present_fe_values (); + + for (unsigned int i=0; i (); + compute_pi_by_perimeter<2> (); + + compute_pi_by_area<3> (); + + return 0; +} diff --git a/tests/bits/step-10-high-order/cmp/generic b/tests/bits/step-10-high-order/cmp/generic new file mode 100644 index 0000000000..eb1d6ebe43 --- /dev/null +++ b/tests/bits/step-10-high-order/cmp/generic @@ -0,0 +1,18 @@ + +DEAL::Computation of Pi by the area: +DEAL::============================== +DEAL::Degree = 8 +DEAL::Evaluation of pi on 5 cells: 3.141592653589792 +DEAL::Evaluation of pi on 20 cells: 3.141592653589791 +DEAL:: +DEAL::Computation of Pi by the perimeter: +DEAL::=================================== +DEAL::Degree = 20 +DEAL::Evaluation of pi on 5 cells: 3.141592653589791 +DEAL::Evaluation of pi on 20 cells: 3.141592653589791 +DEAL:: +DEAL::Computation of Pi by the area: +DEAL::============================== +DEAL::Degree = 7 +DEAL::Evaluation of pi on in 3D 56 cells: 3.141592653589096 +DEAL:: -- 2.39.5