]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix the test. Add output.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 12 Nov 2002 16:32:39 +0000 (16:32 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 12 Nov 2002 16:32:39 +0000 (16:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@6757 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/denis_1.cc
tests/bits/denis_1.checked [new file with mode: 0644]

index 457957c259694a3dd69ba3252f8dfdc4bec5523b..e2371eb9b84da4801f34481d4a6955ea8869d2c3 100644 (file)
 //----------------------------  denis_1.cc  ---------------------------
 
 
-// check for a bug in DerivativeApproximation::approximate_gradient
+// check for something in
+// DerivativeApproximation::approximate_gradient. the original report
+// stated it was a bug, but it was not (see the archives), but since
+// the program is already there let's make use of it.
 //
 // this program is a modified version of one by
 // Denis Danilov <danilovdenis@yandex.ru>, 
 
 
 #include <base/logstream.h>
+#include <base/function.h>
 #include <lac/vector.h>
 #include <grid/tria.h>
 #include <dofs/dof_handler.h>
 #include <grid/grid_generator.h>
 #include <grid/tria_iterator.h>
 #include <dofs/dof_accessor.h>
-#include <numerics/data_out.h>
+#include <numerics/vectors.h>
 #include <fe/fe_q.h>
 #include <numerics/derivative_approximation.h>
 #include <fstream>
 #include <iostream>
 
+
+class F : public Function<2>
+{
+  public:
+    virtual double value (const Point<2> &p, const unsigned int) const
+      {
+        double delta = 0.05;
+        double x, y, r;
+        x = p(0);
+        y = p(1);
+        r = sqrt( x*x + y*y );
+        return 0.5 * ( 1 - tanh( ( r - 0.5 )
+                                 /( 2*M_SQRT2 * delta ) ) ) ;
+      };
+};
+
+
 int main() 
 {
   std::ofstream logfile("denis_1.output");
   deallog.attach(logfile);
   deallog.depth_console(0);
+  logfile.precision (2);
+  logfile.setf(std::ios::fixed);  
 
   Triangulation<2>   triangulation;
   FE_Q<2>            fe(2);
@@ -43,7 +66,6 @@ int main()
   Vector<double>       phi_solution;
   Vector<float>        gradient_phi;
   float                gradient_phi_min, gradient_phi_max;
-  double delta = 0.05;
 
   GridGenerator::hyper_cube(triangulation, 0, 1);
   triangulation.refine_global(5);
@@ -53,22 +75,7 @@ int main()
   DoFHandler<2>::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end();
   
   phi_solution.reinit(dof_handler.n_dofs());
-
-  for(; cell!=endc; ++cell)
-    {
-      for(unsigned int vertex=0;
-          vertex < GeometryInfo<2>::vertices_per_cell;
-          ++vertex)                               
-       {
-         double x, y, r;
-         x = cell->vertex(vertex)(0);
-         y = cell->vertex(vertex)(1);
-         r = sqrt( x*x + y*y );
-         phi_solution( cell->vertex_dof_index(vertex,0) )
-           = 0.5 * ( 1 - tanh( ( r - 0.5 )
-                               /( 2*M_SQRT2 * delta ) ) ) ;
-       }
-    }
+  VectorTools::interpolate (dof_handler, F(), phi_solution);
 
   gradient_phi.reinit(triangulation.n_active_cells());
   DerivativeApproximation::approximate_gradient(dof_handler, phi_solution, gradient_phi);
diff --git a/tests/bits/denis_1.checked b/tests/bits/denis_1.checked
new file mode 100644 (file)
index 0000000..ef87ccd
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::gradient_phi_min: 0.00
+DEAL::gradient_phi_max: 3.50

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.