From 333f9b2d3160b290659ea65a88701f467365bae1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 9 Jun 2003 16:00:38 +0000 Subject: [PATCH] Add RT tests. git-svn-id: https://svn.dealii.org/trunk@7772 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/fe/Makefile | 1 + tests/fe/rt_1.cc | 90 ++++++++++++++++++++++++ tests/fe/rt_2.cc | 171 ++++++++++++++++++++++++++++++++++++++++++++++ tests/fe/rt_3.cc | 64 +++++++++++++++++ tests/fe/rt_4.cc | 69 +++++++++++++++++++ 5 files changed, 395 insertions(+) create mode 100644 tests/fe/rt_1.cc create mode 100644 tests/fe/rt_2.cc create mode 100644 tests/fe/rt_3.cc create mode 100644 tests/fe/rt_4.cc diff --git a/tests/fe/Makefile b/tests/fe/Makefile index 2ba9d037c3..3fadc7e152 100644 --- a/tests/fe/Makefile +++ b/tests/fe/Makefile @@ -57,6 +57,7 @@ tests = fe_data_test fe_traits fe_tools_test mapping \ transfer internals \ dgq_1 \ q_1 q_2 q_3 q_4 \ + rt_1 rt_2 rt_3 rt_4 rt_5 rt_6 \ system_1 \ non_primitive_1 non_primitive_2 \ nedelec nedelec_2 nedelec_3 up_and_down diff --git a/tests/fe/rt_1.cc b/tests/fe/rt_1.cc new file mode 100644 index 0000000000..841b7d29cd --- /dev/null +++ b/tests/fe/rt_1.cc @@ -0,0 +1,90 @@ +//---------------------------- rt_1.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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. +// +//---------------------------- rt_1.cc --------------------------- + + +// Show the shape functions of the Raviart-Thomas element on the unit cell + +#include +#include + +#include +#include +#include + +#define PRECISION 5 + + + +template +inline void +plot_shape_functions(const unsigned int degree) +{ + deallog << "FE_RaviartThomas<" << dim << "> (" << degree << ")" + << std::endl; + + FE_RaviartThomas fe_rt(degree); + + const unsigned int div=2; + for (unsigned int mz=0;mz<=((dim>2) ? div : 0) ;++mz) + for (unsigned int my=0;my<=((dim>1) ? div : 0) ;++my) + for (unsigned int mx=0;mx<=div;++mx) + { + const Point p = (dim==2 ? + Point(1.*mx/div, 1.*my/div) : + Point(1.*mx/div, 1.*my/div, 1.*mz/div)); + deallog << "q_point = " << p << std::endl; + + for (unsigned int i=0;i(degree); +// plot_shape_functions<3>(degree); + + return 0; +} + + + diff --git a/tests/fe/rt_2.cc b/tests/fe/rt_2.cc new file mode 100644 index 0000000000..12d9177b24 --- /dev/null +++ b/tests/fe/rt_2.cc @@ -0,0 +1,171 @@ +//---------------------------- rt_2.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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. +// +//---------------------------- rt_2.cc --------------------------- + +// Show the shape functions of the Raviart-Thomas element on a grid +// with only one cell. This cell is rotated, stretched, scaled, etc, +// and on each of these cells each time we evaluate the shape +// functions. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define PRECISION 5 + + +Point<2> stretch_coordinates (const Point<2> p) +{ + return Point<2>(2*p(0), p(1)); +} + + + +Point<2> tilt_coordinates (const Point<2> p) +{ + return Point<2>(p(0)+p(1), p(1)); +} + + +void +transform_grid (Triangulation<2> &tria, + const unsigned int transform) +{ + switch (transform) + { + // first round: take + // original grid + case 0: + break; + + // second round: rotate + // triangulation + case 1: + GridTools::rotate (3.14159265358/2, tria); + break; + + // third round: inflate + // by a factor of 2 + case 2: + GridTools::scale (2, tria); + break; + + // third round: scale + // back, rotate back, + // stretch + case 3: + GridTools::scale (.5, tria); + GridTools::rotate (-3.14159265358/2, tria); + GridTools::transform (&stretch_coordinates, tria); + + break; + + default: + Assert (false, ExcNotImplemented()); + }; +} + + + + +template +void +plot_shape_functions(const unsigned int degree) +{ + FE_RaviartThomas fe_rt(degree); + Triangulation tr; + GridGenerator::hyper_cube(tr, 0., 1.); + + // check the following with a + // number of transformed + // triangulations + for (unsigned int transform=0; transform<4; ++transform) + { + deallog << "GRID TRANSFORMATION " << transform << std::endl; + + transform_grid (tr, transform); + + DoFHandler dof(tr); + typename DoFHandler::cell_iterator c = dof.begin(); + dof.distribute_dofs(fe_rt); + + QTrapez<1> q_trapez; + const unsigned int div=2; + QIterated q(q_trapez, div); + FEValues fe(fe_rt, q, update_values|update_gradients|update_q_points); + fe.reinit(c); + + unsigned int q_point=0; + for (unsigned int mz=0;mz<=((dim>2) ? div : 0) ;++mz) + for (unsigned int my=0;my<=((dim>1) ? div : 0) ;++my) + for (unsigned int mx=0;mx<=div;++mx) + { + deallog << "q_point(" << q_point << ")=" << fe.quadrature_point(q_point) + << std::endl; + + for (unsigned int i=0;i(degree); + + return 0; +} + + + diff --git a/tests/fe/rt_3.cc b/tests/fe/rt_3.cc new file mode 100644 index 0000000000..98676319ce --- /dev/null +++ b/tests/fe/rt_3.cc @@ -0,0 +1,64 @@ +//---------------------------- rt_3.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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. +// +//---------------------------- rt_3.cc --------------------------- + + +// Just output the constraint matrices of the RT element + +#include +#include + +#include +#include + +#define PRECISION 5 + + + +template +void +test(const unsigned int degree) +{ + deallog << "FE_RaviartThomas<" << dim << "> (" << degree << ")" + << std::endl; + + FE_RaviartThomas fe_rt(degree); + const FullMatrix & constraints = fe_rt.constraints(); + + for (unsigned int i=0; i(degree); + + return 0; +} + + + diff --git a/tests/fe/rt_4.cc b/tests/fe/rt_4.cc new file mode 100644 index 0000000000..99fab02035 --- /dev/null +++ b/tests/fe/rt_4.cc @@ -0,0 +1,69 @@ +//---------------------------- rt_4.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003 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. +// +//---------------------------- rt_4.cc --------------------------- + + +// Just output the prolongation matrices of the RT element + +#include +#include + +#include +#include + +#define PRECISION 5 + + + +template +void +test(const unsigned int degree) +{ + deallog << "FE_RaviartThomas<" << dim << "> (" << degree << ")" + << std::endl; + + FE_RaviartThomas fe_rt(degree); + + for (unsigned int c=0; c::children_per_cell; ++c) + { + const FullMatrix & m = fe_rt.prolongate(c); + + for (unsigned int i=0; i(degree); +// test<3>(degree); + + return 0; +} + + + -- 2.39.5