From b7929717c44aa198c9394a10093c884da46ed0e0 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 5 Aug 1998 15:25:34 +0000 Subject: [PATCH] Add a function to calculate the center of a line/quad/... git-svn-id: https://svn.dealii.org/trunk@478 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria_accessor.h | 38 +++++++++++++++++++- deal.II/deal.II/source/grid/tria_accessor.cc | 11 ++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index d0ad841239..f6c4365976 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -447,6 +447,21 @@ class LineAccessor : public TriaAccessor { * length! */ double diameter () const; + + /** + * Return the center of the line. This + * is the average of the two vertices, + * which is the obvious definition for + * straight lines. However, if you use + * higher order mappings from the unit + * cell to the real cell (in more than + * one space dimension), the bounding + * lines may not necessarily be straight. + * In that case ask the finite element + * class for the correct place of the + * midpoint of the line in real space. + */ + Point center () const; private: /** @@ -722,7 +737,28 @@ class QuadAccessor : public TriaAccessor { * distorted. */ double diameter () const; - + + /** + * Return the center of the quad. The + * center of a quad is defined to be + * the average of the four vertices, + * which is also the point where the + * bilinear mapping places the midpoint + * of the unit quad in real space. + * However, this may not be the point + * of the barycenter of the quad. + * + * Also note that if you use + * higher order mappings from the unit + * cell to the real cell (in more than + * two space dimension), the bounding + * quads may not necessarily be straight. + * In that case ask the finite element + * class for the correct place of the + * midpoint of the quad in real space. + */ + Point center () const; + private: /** * Copy operator. This is normally diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 0dbe2fe6ad..a7b274bbaf 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -300,6 +300,13 @@ double LineAccessor::diameter () const { +template +Point LineAccessor::center () const { + return (vertex(1)+vertex(0))/2.; +}; + + + @@ -558,6 +565,10 @@ double QuadAccessor::diameter () const { +template +Point QuadAccessor::center () const { + return (vertex(0)+vertex(1)+vertex(2)+vertex(3))/4.; +}; -- 2.39.5