]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Test r24829 with SolutionTransfer for FE_Nothing.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 15 Dec 2011 19:59:25 +0000 (19:59 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 15 Dec 2011 19:59:25 +0000 (19:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@24831 0785d39b-7218-0410-832d-ea1e28bc413d

tests/hp/fe_nothing_17.cc [new file with mode: 0644]
tests/hp/fe_nothing_17/cmp/generic [new file with mode: 0644]

diff --git a/tests/hp/fe_nothing_17.cc b/tests/hp/fe_nothing_17.cc
new file mode 100644 (file)
index 0000000..215853a
--- /dev/null
@@ -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 <deal.II/base/function.h>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/vector.h>
+
+#include <deal.II/grid/tria.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_refinement.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/numerics/solution_transfer.h>
+#include <deal.II/fe/fe_nothing.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+template<int dim>
+class MyFunction : public Function<dim>
+{
+  public:
+    MyFunction () : Function<dim>(2) {};
+
+    virtual double value (const Point<dim>   &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 <int dim>
+void transfer(std::ostream &out)
+{
+  MyFunction<dim> function;
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(5-dim);
+
+  FESystem<dim> fe(FE_Q<dim> (1), 1,
+                  FE_Nothing<dim>(), 1);
+  DoFHandler<dim> dof_handler(tria);
+
+  Vector<double> solution;
+  ConstraintMatrix cm;
+  cm.close();
+
+  dof_handler.distribute_dofs (fe);
+  solution.reinit(dof_handler.n_dofs());
+
+  for (unsigned int i=0; i<solution.size(); ++i)
+    solution(i) = i;
+
+  SolutionTransfer<dim> soltrans(dof_handler);
+
+                                  // test a): pure refinement
+  typename Triangulation<dim>::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<double> 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<double> 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 (file)
index 0000000..6009dee
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::   1D solution transfer
+DEAL::OK
+DEAL::   2D solution transfer
+DEAL::OK
+DEAL::   3D solution transfer
+DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.