]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make tests more specific.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 4 Jul 2012 12:16:47 +0000 (12:16 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 4 Jul 2012 12:16:47 +0000 (12:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@25677 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/fe_field_function_04.cc
tests/bits/fe_field_function_05.cc

index b54a7fabf7eee4cfa3f5d4cfbb48a404146de808..6d469a7d0f8cda319b7b73fabb1d721b8dd0eb35 100644 (file)
 #include <deal.II/grid/tria_boundary_lib.h>
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/numerics/fe_field_function.h>
+#include <deal.II/numerics/vectors.h>
+
+
+template <int dim>
+class F : public Function<dim>
+{
+  public:
+    virtual double value (const Point<dim> &p,
+                         const unsigned int) const
+      {
+       return p.square();
+      }
+};
 
 
 template<int dim>
@@ -43,6 +56,7 @@ void test()
   dof_handler.distribute_dofs(fe);
 
   Vector<double> solution(dof_handler.n_dofs());
+  VectorTools::interpolate (dof_handler, F<dim>(), solution);
 
   Functions::FEFieldFunction<2> fe_function (dof_handler, solution);
   std::vector<Point<dim> > points;
@@ -68,7 +82,11 @@ void test()
   std::vector<double> m (points.size());
   fe_function.value_list (points, m);
 
-  triangulation.set_boundary (0);
+  for (unsigned int i=0; i<m.size(); ++i)
+    Assert (std::fabs(m[i] - points[i].square())
+           <
+           1e-10 * std::fabs(m[i] + points[i].square()),
+           ExcInternalError());
 
   deallog << "OK" << std::endl;
 }
index d87f45b04aefaa9791fe774f5d1387c83604f8c2..dc9cbc8e26a6bfdc7aa9b556dd4ce35c64f32587 100644 (file)
 #include <deal.II/grid/tria_boundary_lib.h>
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/numerics/fe_field_function.h>
+#include <deal.II/numerics/vectors.h>
+
+
+template <int dim>
+class F : public Function<dim>
+{
+  public:
+    virtual double value (const Point<dim> &p,
+                         const unsigned int) const
+      {
+       return p.square();
+      }
+};
 
 
 template<int dim>
@@ -46,7 +59,12 @@ void test()
   DoFHandler<dim> dof_handler(triangulation);
   dof_handler.distribute_dofs(fe);
 
+                                  // interpolate a quadratic function
+                                  // into the space; this function
+                                  // can be represented exactly, so
+                                  // that we can compare again later
   Vector<double> solution(dof_handler.n_dofs());
+  VectorTools::interpolate (dof_handler, F<dim>(), solution);
 
   Functions::FEFieldFunction<2> fe_function (dof_handler, solution);
   std::vector<Point<dim> > points;
@@ -75,7 +93,11 @@ void test()
   std::vector<double> m (points.size());
   fe_function.value_list (points, m);
 
-  triangulation.set_boundary (0);
+  for (unsigned int i=0; i<m.size(); ++i)
+    Assert (std::fabs(m[i] - points[i].square())
+           <
+           1e-10 * std::fabs(m[i] + points[i].square()),
+           ExcInternalError());
 
   deallog << "OK" << std::endl;
 }

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.