]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test for FEFieldFunction
authorgoll <goll@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 16 Feb 2012 15:18:01 +0000 (15:18 +0000)
committergoll <goll@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 16 Feb 2012 15:18:01 +0000 (15:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@25101 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/fe_field_function_03.cc [new file with mode: 0644]
tests/bits/fe_field_function_03/cmp/generic [new file with mode: 0644]

diff --git a/tests/bits/fe_field_function_03.cc b/tests/bits/fe_field_function_03.cc
new file mode 100644 (file)
index 0000000..834205d
--- /dev/null
@@ -0,0 +1,88 @@
+//-------------------------------------------------------
+//    $Id: fe_field_function_03.cc $
+//    Version: $Name$
+//
+//    Copyright (C) 2005, 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.
+//
+//-------------------------------------------------------
+
+
+// Test the functionality of the laplacian in the FEFieldFunction class. 
+
+#include "../tests.h"
+#include <fstream>
+
+// all include files you need here
+#include <deal.II/numerics/fe_field_function.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/base/function_lib.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/numerics/vectors.h>
+
+template <int dim>
+void test() {
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(9/dim);
+
+  FE_Q<dim> fe(2);
+  DoFHandler<dim> dh(tria);
+
+  dh.distribute_dofs(fe);
+  deallog << "Ndofs :" << dh.n_dofs() << std::endl;
+
+  Functions::CosineFunction<dim> ff;
+
+  Vector<double> v1(dh.n_dofs()), v2(dh.n_dofs());
+
+  VectorTools::interpolate(dh, ff, v1);
+  deallog << "V norm: " << v1.l2_norm() << std::endl;
+
+  Functions::FEFieldFunction<dim, DoFHandler<dim>, Vector<double> >
+    fef(dh, v1);
+
+       //create the origin
+       Point<dim> p;
+       //compute the error of the laplacian in this point
+  deallog << "Value of the laplacian in 0:" << std::endl;
+  deallog << "correct value: " << ff.laplacian(p) <<", approximation: "<< fef.laplacian(p) << std::endl;
+  
+  //now we want to test the list version
+  Point<dim> p1 = Point<dim>::unit_vector(0);
+  p1 = p1 * 0.5;
+  Point<dim> p2 = p1 * 0.5;
+  std::vector<Point<dim> > vec;
+  vec.push_back(p1);
+  vec.push_back(p2);
+  std::vector<double> values_c(2);
+  std::vector<double> values_a(2);
+  
+  //get the laplacians at these two points
+  ff.laplacian_list(vec, values_c);
+  fef.laplacian_list(vec, values_a);
+    deallog << "Value of the laplacian in 0.5*e1 and 0.25 * e1:" << std::endl;
+    deallog << " correct values: " <<values_c[0] << " " << values_c[1]  <<", approximations: "<<values_a[0] << " " << values_a[1] << std::endl;
+}
+
+int main ()
+{
+  std::ofstream logfile("fe_field_function_03/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<1>();
+  test<2>();
+  test<3>();
+
+  return 0;
+}
+
diff --git a/tests/bits/fe_field_function_03/cmp/generic b/tests/bits/fe_field_function_03/cmp/generic
new file mode 100644 (file)
index 0000000..cd95fc4
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::Ndofs :1025
+DEAL::V norm: 22.6385
+DEAL::Value of the laplacian in 0:
+DEAL::correct value: -2.46740, approximation: -2.46743
+DEAL::Value of the laplacian in 0.5*e1 and 0.25 * e1:
+DEAL:: correct values: -1.74472 -2.27958, approximations: -1.74739 -2.28103
+DEAL::Ndofs :1089
+DEAL::V norm: 16.5000
+DEAL::Value of the laplacian in 0:
+DEAL::correct value: -4.93480, approximation: -4.92787
+DEAL::Value of the laplacian in 0.5*e1 and 0.25 * e1:
+DEAL:: correct values: -3.48943 -4.55916, approximations: -3.57012 -4.59908
+DEAL::Ndofs :4913
+DEAL::V norm: 24.7815
+DEAL::Value of the laplacian in 0:
+DEAL::correct value: -7.40220, approximation: -7.36064
+DEAL::Value of the laplacian in 0.5*e1 and 0.25 * e1:
+DEAL:: correct values: -5.23415 -6.83874, approximations: -5.37564 -6.89283

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.