]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Take floating point round-off into consideration.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 14 Nov 2002 22:10:30 +0000 (22:10 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 14 Nov 2002 22:10:30 +0000 (22:10 +0000)
git-svn-id: https://svn.dealii.org/trunk@6766 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-14/step-14.cc

index 6569c4c5322e91fa429febf7705048fbaaf8a170..38e96efc4feed9ca9a8b722e6116274e15c567de 100644 (file)
@@ -144,7 +144,9 @@ namespace Evaluation
       for (unsigned int vertex=0;
           vertex<GeometryInfo<dim>::vertices_per_cell;
           ++vertex)
-       if (cell->vertex(vertex) == evaluation_point)
+       if (cell->vertex(vertex).distance (evaluation_point)
+           <
+           cell->diameter() * 1e-8)
          {
            point_value = solution(cell->vertex_dof_index(vertex,0));
 
@@ -1936,7 +1938,10 @@ namespace DualFunctional
 
                                     // ...then loop over cells and
                                     // find the evaluation point
-                                    // among the vertices:
+                                    // among the vertices (or very
+                                    // close to a vertex, which may
+                                    // happen due to floating point
+                                    // round-off):
     typename DoFHandler<dim>::active_cell_iterator
       cell = dof_handler.begin_active(),
       endc = dof_handler.end();
@@ -1944,7 +1949,8 @@ namespace DualFunctional
       for (unsigned int vertex=0;
           vertex<GeometryInfo<dim>::vertices_per_cell;
           ++vertex)
-       if (cell->vertex(vertex) == evaluation_point)
+       if (cell->vertex(vertex).distance(evaluation_point)
+           < cell->diameter()*1e-8)
          {
                                             // Ok, found, so set
                                             // corresponding entry,

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.