From: bangerth Date: Thu, 15 Dec 2011 19:59:25 +0000 (+0000) Subject: Test r24829 with SolutionTransfer for FE_Nothing. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcc2d4e9d389a04263d9cbd241e0624f529e4e06;p=dealii-svn.git Test r24829 with SolutionTransfer for FE_Nothing. git-svn-id: https://svn.dealii.org/trunk@24831 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/hp/fe_nothing_17.cc b/tests/hp/fe_nothing_17.cc new file mode 100644 index 0000000000..215853a627 --- /dev/null +++ b/tests/hp/fe_nothing_17.cc @@ -0,0 +1,139 @@ +//---------------------------- fe_nothing_17.cc --------------------------- +// fe_data_test.cc,v 1.14 2003/11/28 11:52:35 guido Exp +// Version: +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2011 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. +// +//---------------------------- fe_nothing_17.cc --------------------------- + + +// test that SolutionTransfer works with FE_Nothing. This was broken +// before r24829, resulting in an exception. + +#include "../tests.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +template +class MyFunction : public Function +{ + public: + MyFunction () : Function(2) {}; + + virtual double value (const Point &p, + const unsigned int) const + { double f=sin(p[0]*4); + if (dim>1) + f*=cos(p[1]*4); + if (dim>2) + f*=exp(p[2]*4); + return f; + }; +}; + + +template +void transfer(std::ostream &out) +{ + MyFunction function; + Triangulation tria; + GridGenerator::hyper_cube(tria); + tria.refine_global(5-dim); + + FESystem fe(FE_Q (1), 1, + FE_Nothing(), 1); + DoFHandler dof_handler(tria); + + Vector solution; + ConstraintMatrix cm; + cm.close(); + + dof_handler.distribute_dofs (fe); + solution.reinit(dof_handler.n_dofs()); + + for (unsigned int i=0; i soltrans(dof_handler); + + // test a): pure refinement + typename Triangulation::active_cell_iterator cell=tria.begin_active(), + endc=tria.end(); + ++cell; + ++cell; + for (; cell!=endc; ++cell) + cell->set_refine_flag(); + + tria.prepare_coarsening_and_refinement(); + soltrans.prepare_for_pure_refinement(); + tria.execute_coarsening_and_refinement(); + dof_handler.distribute_dofs (fe); + + Vector tmp_q (dof_handler.n_dofs()); + soltrans.refine_interpolate(solution, tmp_q); + solution.reinit (dof_handler.n_dofs()); + solution = tmp_q; + + // test b): with coarsening + soltrans.clear(); + + cell=tria.begin_active(tria.n_levels()-1); + endc=tria.end(tria.n_levels()-1); + cell->set_refine_flag(); + ++cell; + for (; cell!=endc; ++cell) + cell->set_coarsen_flag(); + Vector old_solution=solution; + tria.prepare_coarsening_and_refinement(); + soltrans.prepare_for_coarsening_and_refinement(old_solution); + tria.execute_coarsening_and_refinement(); + dof_handler.distribute_dofs (fe); + solution.reinit(dof_handler.n_dofs()); + soltrans.interpolate(old_solution, solution); + + deallog << "OK" << std::endl; +} + + +int main() +{ + std::ofstream logfile("fe_nothing_17/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog << " 1D solution transfer" << std::endl; + transfer<1>(logfile); + + deallog << " 2D solution transfer" << std::endl; + transfer<2>(logfile); + + deallog << " 3D solution transfer" << std::endl; + transfer<3>(logfile); +} + + + diff --git a/tests/hp/fe_nothing_17/cmp/generic b/tests/hp/fe_nothing_17/cmp/generic new file mode 100644 index 0000000000..6009dee06e --- /dev/null +++ b/tests/hp/fe_nothing_17/cmp/generic @@ -0,0 +1,7 @@ + +DEAL:: 1D solution transfer +DEAL::OK +DEAL:: 2D solution transfer +DEAL::OK +DEAL:: 3D solution transfer +DEAL::OK