From: wolf Date: Mon, 9 Jun 2003 15:59:07 +0000 (+0000) Subject: Add RT tests. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1ef09f591af115b3ea6bb4de721d556379bf7e0;p=dealii-svn.git Add RT tests. git-svn-id: https://svn.dealii.org/trunk@7771 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/fe/Makefile b/tests/fe/Makefile index 16b2535e5b..2ba9d037c3 100644 --- a/tests/fe/Makefile +++ b/tests/fe/Makefile @@ -45,6 +45,8 @@ rt_1.exe : rt_1.g.$(OBJEXT) $(libraries) rt_2.exe : rt_2.g.$(OBJEXT) $(libraries) rt_3.exe : rt_3.g.$(OBJEXT) $(libraries) rt_4.exe : rt_4.g.$(OBJEXT) $(libraries) +rt_5.exe : rt_5.g.$(OBJEXT) $(libraries) +rt_6.exe : rt_6.g.$(OBJEXT) $(libraries) system_1.exe : system_1.g.$(OBJEXT) $(libraries) shapes.exe : shapes.g.$(OBJEXT) $(libraries) transfer.exe : transfer.g.$(OBJEXT) $(libraries) diff --git a/tests/fe/rt_5.cc b/tests/fe/rt_5.cc new file mode 100644 index 0000000000..d4c9ff7ca0 --- /dev/null +++ b/tests/fe/rt_5.cc @@ -0,0 +1,69 @@ +//---------------------------- rt_5.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_5.cc --------------------------- + + +// Just output the restriction 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.restrict(c); + + for (unsigned int i=0; i(degree); +// test<3>(degree); + + return 0; +} + + + diff --git a/tests/fe/rt_6.cc b/tests/fe/rt_6.cc new file mode 100644 index 0000000000..0abac9a351 --- /dev/null +++ b/tests/fe/rt_6.cc @@ -0,0 +1,174 @@ +//---------------------------- rt_6.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_6.cc --------------------------- + +// adaptation of up_and_down for RT elements + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define PRECISION 4 + + +template +Point transform (const Point p) +{ + switch (dim) + { + case 1: + return p; + case 2: + return Point(p(0)*(1+p(1)), p(1)*(1+p(0))); + case 3: + return Point(p(0)*(1+p(1))*(1+p(2)), + p(1)*(1+p(0))*(1+p(2)), + p(2)*(1+p(0))*(1+p(1))); + default: + Assert (false, ExcNotImplemented()); + return Point(); + }; +} + + +template +void check_element (const Triangulation &tr, + const FiniteElement &fe) +{ + DoFHandler dof_handler(tr); + dof_handler.distribute_dofs (fe); + + // create a mostly arbitrary + // function plus a trend on this + // grid + Vector tmp(dof_handler.n_dofs()); + for (unsigned int i=0; i x(tmp.size()); + Vector v(fe.dofs_per_cell); + for (typename DoFHandler::cell_iterator cell=dof_handler.begin(); + cell!=dof_handler.end(); ++cell) + if (cell->has_children() && + cell->child(0)->active()) + { + // first make sure that what + // we do is reasonable. for + // this, _all_ children have + // to be active, not only + // some of them + for (unsigned int c=0; c::children_per_cell; ++c) + Assert (cell->child(c)->active(), ExcInternalError()); + + // then restrict and prolong + cell->get_interpolated_dof_values (tmp, v); + cell->set_dof_values_by_interpolation (v, x); + }; + + // now x is a function on the fine + // grid that is representable on + // the coarse grid. so another + // cycle should not alter it any + // more: + Vector x2(x.size()); + for (typename DoFHandler::cell_iterator cell=dof_handler.begin(); + cell!=dof_handler.end(); ++cell) + if (cell->has_children() && + cell->child(0)->active()) + { + cell->get_interpolated_dof_values (x, v); + cell->set_dof_values_by_interpolation (v, x2); + }; + + // then check that this is so: + x2 -= x; + const double relative_residual = (x2.l2_norm() / x.l2_norm()); + + const double threshold = 1e-6; + deallog << ", dofs_per_cell=" << fe.dofs_per_cell + << "; relative residual: " + << (relative_residual +void test () +{ + // make a coarse triangulation as a + // hypercube. if in more than 1d, + // distort it so that it is no more + // an affine image of the + // hypercube, to make things more + // difficult. then refine it twice + Triangulation tr; + GridGenerator::hyper_cube(tr, 0., 1.); + Point (*p) (Point) = &transform; + GridTools::transform (p, tr); + tr.refine_global (2); + + // now for a list of finite + // elements, for which we want to + // test. we happily waste tons of + // memory here, but who cares... + const FiniteElement *fe_list[] + = + { + new FE_RaviartThomas(0), + new FE_RaviartThomas(1) + }; + + for (unsigned int i=0; i(); + + return 0; +} + + +