]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a function to calculate the center of a line/quad/...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 5 Aug 1998 15:25:34 +0000 (15:25 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 5 Aug 1998 15:25:34 +0000 (15:25 +0000)
git-svn-id: https://svn.dealii.org/trunk@478 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria_accessor.h
deal.II/deal.II/source/grid/tria_accessor.cc

index d0ad8412390743d595c7178ac8fdb0c726e59a78..f6c4365976f0e59d6a03f8de1b25bee977ccef37 100644 (file)
@@ -447,6 +447,21 @@ class LineAccessor :  public TriaAccessor<dim> {
                                      * 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<dim> center () const;
     
   private:
                                     /**
@@ -722,7 +737,28 @@ class QuadAccessor :  public TriaAccessor<dim> {
                                      * 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<dim> center () const;
+
   private:
                                     /**
                                      *  Copy operator. This is normally
index 0dbe2fe6ad3d228ffceb31874d22f9c3e70f757e..a7b274bbaffd20b6c6fde37192959e6b05a9a543 100644 (file)
@@ -300,6 +300,13 @@ double LineAccessor<dim>::diameter () const {
 
 
 
+template <int dim>
+Point<dim> LineAccessor<dim>::center () const {
+  return (vertex(1)+vertex(0))/2.;
+};
+
+
+
 
 
 
@@ -558,6 +565,10 @@ double QuadAccessor<dim>::diameter () const {
 
 
 
+template <int dim>
+Point<dim> QuadAccessor<dim>::center () const {
+  return (vertex(0)+vertex(1)+vertex(2)+vertex(3))/4.;
+};
 
 
 

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.