]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Made FlatManifold tolerance relative. 67/head
authorLuca Heltai <luca.heltai@sissa.it>
Thu, 7 Aug 2014 15:12:39 +0000 (17:12 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Thu, 7 Aug 2014 15:12:39 +0000 (17:12 +0200)
include/deal.II/grid/manifold.h
source/grid/manifold.cc

index 6b1b8e387517c9d35ec6e2f8b4fde8490a12a9a5..096702d639c33b981b0766ba0124cbf94816858b 100644 (file)
@@ -259,7 +259,7 @@ public:
    * pi, but 2*pi (or zero), since, on a periodic manifold, these two
    * points are at distance 2*eps and not (2*pi-eps). Special cases
    * are taken into account, to ensure that the behavior is always as
-   * expected. The third argument is used as a tolerance when
+   * expected. The third argument is used as a relative tolerance when
    * computing distances.
    *
    * Periodicity will be intended in the following way: the domain is
@@ -270,8 +270,7 @@ public:
    * compute averages is called, an exception will be thrown if one of
    * the points which you are using for the average lies outside the
    * periodicity box. The return points are garanteed to lie in the
-   * perodicity box plus or minus the tolerance you set as the third
-   * argument.
+   * perodicity box plus or minus tolerance*periodicity.norm().
    */
   FlatManifold (const Point<spacedim> periodicity=Point<spacedim>(),
                 const double tolerance=1e-10);
@@ -312,13 +311,6 @@ public:
   virtual
   Point<spacedim> project_to_manifold (const std::vector<Point<spacedim> > &points,
                                        const Point<spacedim> &candidate) const;
-protected:
-  /**
-   * Tolerance. This tolerance is used to compute distances in double
-   * precision. Anything below this tolerance is considered zero.
-   */
-  const double tolerance;
-
 private:
   /**
    * The periodicity of this Manifold. Periodicity affects the way a
@@ -340,6 +332,12 @@ private:
                  << "The component number " << arg1 << " of the point [ " << arg2
                  << " ]  is not in the interval [ " << -arg4
                  << ", " << arg3[arg4] << "), bailing out.");
+
+  /**
+   * Relative tolerance. This tolerance is used to compute distances
+   * in double precision.
+   */
+  const double tolerance;
 };
 
 
index ccd7e47c647bcb978f5d2f5fd3a0ed7ffe826137..a2b1118a25e2852115b41340026653f3e4bf000a 100644 (file)
@@ -261,8 +261,8 @@ get_new_point_on_hex (const typename Triangulation<3, 3>::hex_iterator &hex) con
 template <int dim, int spacedim>
 FlatManifold<dim,spacedim>::FlatManifold (const Point<spacedim> periodicity,
                                           const double tolerance) :
-  tolerance(tolerance),
-  periodicity(periodicity)
+  periodicity(periodicity),
+  tolerance(tolerance)
 {}
 
 template <int dim, int spacedim>
@@ -277,6 +277,8 @@ get_new_point (const Quadrature<spacedim> &quad) const
   double sum=0;
   for (unsigned int i=0; i<weights.size(); ++i)
     sum+= weights[i];
+  // Here it is correct to use tolerance as an absolute one, since
+  // this should be relative to unity.
   Assert(std::abs(sum-1.0) < tolerance, ExcMessage("Weights should sum to 1!"));
 #endif
 
@@ -291,9 +293,9 @@ get_new_point (const Quadrature<spacedim> &quad) const
         {
           minP[d] = std::min(minP[d], surrounding_points[i][d]);
           if (periodicity[d] > 0)
-            Assert( (surrounding_points[i][d] < periodicity[d]+tolerance) ||
-                    (surrounding_points[i][d] >= -tolerance),
-                    ExcPeriodicBox(d, surrounding_points[i], periodicity, tolerance));
+            Assert( (surrounding_points[i][d] < periodicity[d]+tolerance*periodicity.norm()) ||
+                    (surrounding_points[i][d] >= -tolerance*periodicity.norm()),
+                    ExcPeriodicBox(d, surrounding_points[i], periodicity, tolerance*periodicity.norm()));
         }
 
   for (unsigned int i=0; i<surrounding_points.size(); ++i)

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.