]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Test that compare the kelly estimator for the same mesh, when consider
authorpauletti <pauletti@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 1 Mar 2012 20:48:38 +0000 (20:48 +0000)
committerpauletti <pauletti@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 1 Mar 2012 20:48:38 +0000 (20:48 +0000)
as codim 0 or as codim 1

git-svn-id: https://svn.dealii.org/trunk@25196 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/error_estimator_01.cc [new file with mode: 0644]
tests/deal.II/error_estimator_01/cmp/generic [new file with mode: 0644]

diff --git a/tests/deal.II/error_estimator_01.cc b/tests/deal.II/error_estimator_01.cc
new file mode 100644 (file)
index 0000000..d40790b
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  error_estimator_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2000, 2001, 2003, 2004, 2007, 2010 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.
+//
+//----------------------------  error_estimator_01.cc  ---------------------------
+
+
+/* Compare the kelly estimator for the same square but in codimension 0 and the other in codimension 1,
+   Both should return the same estimator */
+
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/function_lib.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/mapping_q.h>
+#include <deal.II/numerics/vectors.h>
+#include <deal.II/numerics/error_estimator.h>
+
+#include <fstream>
+
+template <int dim, int spacedim>
+void
+check ()
+{
+  Functions::CosineFunction<spacedim> function;
+  Triangulation<dim,spacedim> tr;
+  
+  GridGenerator::hyper_cube(tr, -1,1);
+
+  tr.refine_global (1);
+  tr.begin_active()->set_refine_flag ();
+  tr.execute_coarsening_and_refinement ();
+  
+  FE_Q<dim,spacedim> element(3);
+  DoFHandler<dim,spacedim> dof(tr);
+  dof.distribute_dofs(element);
+
+  MappingQ<dim,spacedim> mapping(3);
+  QGauss<dim-1> q_face(4);
+
+  std::map<unsigned char,const Function<spacedim>*> neumann_bc;
+  neumann_bc[0] = &function;
+  
+  Vector<double> v (dof.n_dofs());
+  VectorTools::interpolate (mapping, dof, function, v);
+
+  Vector<float> error (tr.n_active_cells());
+
+  KellyErrorEstimator<dim,spacedim>::estimate (mapping, dof, q_face, neumann_bc,
+                                              v, error);
+
+  deallog << "Estimated error:" << std::endl;
+  for (unsigned int i=0; i<error.size(); ++i)
+    deallog << error(i)*100 << std::endl;
+}
+
+
+int main ()
+{
+  std::ofstream logfile ("error_estimator_01/output");
+  deallog << std::setprecision (2);
+  deallog << std::fixed;  
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+
+  deallog.push ("2d_2");
+  check<2,2> ();
+  deallog.pop ();
+  deallog.push ("2d_3");
+  check<2,3> ();
+  deallog.pop ();
+}
diff --git a/tests/deal.II/error_estimator_01/cmp/generic b/tests/deal.II/error_estimator_01/cmp/generic
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+

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.