]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New: TriaAccessor<>::minimum_vertex_distance().
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Oct 2011 20:34:21 +0000 (20:34 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Oct 2011 20:34:21 +0000 (20:34 +0000)
git-svn-id: https://svn.dealii.org/trunk@24675 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/grid/tria_accessor.h
deal.II/include/deal.II/grid/tria_accessor.templates.h

index cec4325f17df3c2886200511bc9ca43b3322a5c3..240bd820f81b655a1e67521502332b1ea645286a 100644 (file)
@@ -48,6 +48,10 @@ enabled due to a missing include file in file
 <h3>Specific improvements</h3>
 
 <ol>
+<li> New: TriaAccessor<>::minimum_vertex_distance().
+<br>
+(Timo Heister, 2011/10/25)
+
 <li> New: TableHandler::print_text now supports not only printing column
 keys above their own column, but also in a separate header, to make it simpler
 for external plotting programs to skip this line.
index 5d182ff8e86e4b42167b2e2e7a411f6790c21939..bba126f20e1af0b0f69c68c77ceb0080b7c453a5 100644 (file)
@@ -1351,8 +1351,13 @@ class TriaAccessor : public TriaAccessorBase<structdim, dim, spacedim>
                                      */
     double extent_in_direction (const unsigned int axis) const;
 
-
                                     /**
+                                     * Returns the minimal distance between
+                                     * any two vertices.
+                                     */
+    double minimum_vertex_distance () const;
+
+                                    /**
                                      * Center of the object. The center of an
                                      * object is defined to be the average of
                                      * the locations of the vertices, which
index 967c3c563982fa8287c14dcb638908b6eb03e122..06ab8003ea36934c5e5e3cd324078a4f68e5e568 100644 (file)
@@ -1912,6 +1912,32 @@ TriaAccessor<structdim, dim, spacedim>::diameter () const
 }
 
 
+
+template <int structdim, int dim, int spacedim>
+double
+TriaAccessor<structdim, dim, spacedim>::minimum_vertex_distance () const
+{
+    switch (structdim)
+    {
+      case 1:
+           return std::sqrt((this->vertex(1)-this->vertex(0)).square());
+      case 2:
+      case 3:
+      {
+       double min = std::numeric_limits<double>::max();
+       for (unsigned int i=0;i<GeometryInfo<structdim>::vertices_per_cell;++i)
+         for (unsigned int j=i+1;j<GeometryInfo<structdim>::vertices_per_cell;++j)
+           min = std::min(min, (this->vertex(i)-this->vertex(j)).square());
+       return std::sqrt(min);
+      }
+      default:
+           Assert (false, ExcNotImplemented());
+           return -1e10;
+    }
+}
+
+
+
 template <int structdim, int dim, int spacedim>
 Point<spacedim>
 TriaAccessor<structdim, dim, spacedim>::center () const

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.