From 5ee8d65ba3504358f4690b1df1ddcb3ae1022b6b Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 20 Jul 2011 12:15:05 +0000 Subject: [PATCH] New test, to be fixed by Daniel Gerecht. git-svn-id: https://svn.dealii.org/trunk@23952 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/hp/create_rhs_01.cc | 126 ++++++++++++++++++ tests/hp/create_rhs_01/cmp/generic | 4 + .../cmp/powerpc-apple-darwin8.10.0+gcc4.0 | 23 ++++ 3 files changed, 153 insertions(+) create mode 100644 tests/hp/create_rhs_01.cc create mode 100644 tests/hp/create_rhs_01/cmp/generic create mode 100644 tests/hp/create_rhs_01/cmp/powerpc-apple-darwin8.10.0+gcc4.0 diff --git a/tests/hp/create_rhs_01.cc b/tests/hp/create_rhs_01.cc new file mode 100644 index 0000000000..df240e112d --- /dev/null +++ b/tests/hp/create_rhs_01.cc @@ -0,0 +1,126 @@ +//---------------------------- create_rhs_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2011 by Daniel Gerecht and 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. +// +//---------------------------- create_rhs_01.cc --------------------------- + + +// call VectorTools::create_boundary_rhs. this crashed at the time of writing +// this because we forgot to resize the size of a local_dofs array on each +// cell. test and fix by Daniel Gerecht, University of Heidelberg + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +void test () +{ + //make grid + Triangulation<2> triangulation; + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global(1); + + //define DoFhandler and FEs + FE_Q<2> u(2),u2(3); + + hp::FECollection<2> fe_collection; + fe_collection.push_back(u); + fe_collection.push_back(u2); + + hp::FECollection<2> fe_collection2; + fe_collection2.push_back(u); + + hp::DoFHandler<2> hp_dof_handler(triangulation); + hp::DoFHandler<2> hp_dof_handler2(triangulation); + + //set different fe for testing + typename hp::DoFHandler<2>::active_cell_iterator + cell=hp_dof_handler.begin_active(),endc = hp_dof_handler.end(); + + for (; cell!=endc; ++cell) + cell->set_active_fe_index(1); + hp_dof_handler.begin_active()->set_active_fe_index(0); + + //distribute dofs + hp_dof_handler.distribute_dofs(fe_collection); + hp_dof_handler2.distribute_dofs(fe_collection2); + + // define input for create_rhs function + Vector rhs_vector(hp_dof_handler.n_dofs()); + Vector rhs_vector2(hp_dof_handler2.n_dofs()); + + unsigned char myints[1]; + std::set boundary_indicators (myints,myints+1); + myints[0]=0; + hp::QCollection<1> quadrature; + quadrature.push_back (QGauss<1>(1)); + + // choose rhs=1. because the circumference + // of the domain is four and the shape + // functions all add up to one, if you take + // the sum over the elements of the + // resulting rhs vector, you need to get + // four + ConstantFunction< 2 > rhs_function(1); + + VectorTools::create_boundary_right_hand_side ( hp_dof_handler2, + quadrature, + rhs_function, + rhs_vector2, + boundary_indicators); + Assert (std::fabs (std::accumulate (rhs_vector2.begin(), + rhs_vector2.end(), 0.) + - 4) < 1e-12, + ExcInternalError()); + deallog << rhs_vector2.l2_norm() << std::endl; + + VectorTools::create_boundary_right_hand_side ( hp_dof_handler, + quadrature, + rhs_function, + rhs_vector, + boundary_indicators); + Assert (std::fabs (std::accumulate (rhs_vector.begin(), + rhs_vector.end(), 0.) + - 4) < 1e-12, + ExcInternalError()); + deallog << rhs_vector.l2_norm() << std::endl; +} + + +int main () +{ + std::ofstream logfile("create_rhs_01/output"); + logfile.precision(2); + deallog << std::setprecision(2); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/hp/create_rhs_01/cmp/generic b/tests/hp/create_rhs_01/cmp/generic new file mode 100644 index 0000000000..5409153757 --- /dev/null +++ b/tests/hp/create_rhs_01/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::1.4 +DEAL::1.2 +DEAL::OK diff --git a/tests/hp/create_rhs_01/cmp/powerpc-apple-darwin8.10.0+gcc4.0 b/tests/hp/create_rhs_01/cmp/powerpc-apple-darwin8.10.0+gcc4.0 new file mode 100644 index 0000000000..20e891be89 --- /dev/null +++ b/tests/hp/create_rhs_01/cmp/powerpc-apple-darwin8.10.0+gcc4.0 @@ -0,0 +1,23 @@ + +DEAL::dim=1 +DEAL::i=0, diff=7.0 +DEAL::i=1, diff=7.0 +DEAL::i=2, diff=49. +DEAL::i=3, diff=3.7e+02 +DEAL::i=4, diff=1.3e+03 +DEAL::i=5, diff=1.3e+03 +DEAL::dim=2 +DEAL::i=0, diff=81. +DEAL::i=1, diff=81. +DEAL::i=2, diff=1.4e+03 +DEAL::i=3, diff=3.0e+04 +DEAL::i=4, diff=9.6e+03 +DEAL::i=5, diff=9.6e+03 +DEAL::dim=3 +DEAL::i=0, diff=5.6e+02 +DEAL::i=1, diff=5.6e+02 +DEAL::i=2, diff=1.3e+04 +DEAL::i=3, diff=3.6e+05 +DEAL::i=4, diff=4.1e+04 +DEAL::i=5, diff=4.1e+04 +DEAL::OK -- 2.39.5