From 487ede46ff3b6a509159fccc5e97af329d2f9b12 Mon Sep 17 00:00:00 2001 From: heister Date: Tue, 25 Oct 2011 20:34:21 +0000 Subject: [PATCH] New: TriaAccessor<>::minimum_vertex_distance(). git-svn-id: https://svn.dealii.org/trunk@24675 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 4 +++ deal.II/include/deal.II/grid/tria_accessor.h | 7 ++++- .../deal.II/grid/tria_accessor.templates.h | 26 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index cec4325f17..240bd820f8 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -48,6 +48,10 @@ enabled due to a missing include file in file

Specific improvements

    +
  1. New: TriaAccessor<>::minimum_vertex_distance(). +
    +(Timo Heister, 2011/10/25) +
  2. 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. diff --git a/deal.II/include/deal.II/grid/tria_accessor.h b/deal.II/include/deal.II/grid/tria_accessor.h index 5d182ff8e8..bba126f20e 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.h +++ b/deal.II/include/deal.II/grid/tria_accessor.h @@ -1351,8 +1351,13 @@ class TriaAccessor : public TriaAccessorBase */ 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 diff --git a/deal.II/include/deal.II/grid/tria_accessor.templates.h b/deal.II/include/deal.II/grid/tria_accessor.templates.h index 967c3c5639..06ab8003ea 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.templates.h +++ b/deal.II/include/deal.II/grid/tria_accessor.templates.h @@ -1912,6 +1912,32 @@ TriaAccessor::diameter () const } + +template +double +TriaAccessor::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::max(); + for (unsigned int i=0;i::vertices_per_cell;++i) + for (unsigned int j=i+1;j::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 Point TriaAccessor::center () const -- 2.39.5