]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Patch from James Avery: TriaAccessor::extent_in_direction.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 May 2010 03:47:29 +0000 (03:47 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 May 2010 03:47:29 +0000 (03:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@21113 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria_accessor.h
deal.II/deal.II/source/grid/tria_accessor.cc
deal.II/doc/news/changes.h

index 705777b361ef305ec0ee15e4213a9c571847cea3..a900482b44e87dc4bc445f7442924ba0a70037c2 100644 (file)
@@ -1243,6 +1243,24 @@ class TriaAccessor : public TriaAccessorBase<structdim, dim, spacedim>
                                      */
     double diameter () const;
 
+                                    /** 
+                                     * Length of an object in the direction
+                                     * of the given axis, specified in the
+                                     * local coordinate system. See the
+                                     * documentation of GeometryInfo for the
+                                     * meaning and enumeration of the local
+                                     * axes.
+                                     *
+                                     * Note that the "length" of an object
+                                     * can be interpreted in a variety of
+                                     * ways. Here, we choose it as the
+                                     * maximal length of any of the edges of
+                                     * the object that are parallel to the
+                                     * chosen axis on the reference cell.
+                                     */
+    double extent_in_direction (const unsigned int axis) const;
+
+
                                     /**
                                      * Center of the object. The center of an
                                      * object is defined to be the average of
@@ -1255,6 +1273,8 @@ class TriaAccessor : public TriaAccessorBase<structdim, dim, spacedim>
                                      * object if higher order mappings are
                                      * used.
                                      */
+
+
     Point<spacedim> center () const;
 
                                     /**
index 4f6ab581b570038b56cfb3062b8fdd27650830d0..9458c3ec369cb457f71a12669bed55af019cd879 100644 (file)
@@ -1013,6 +1013,56 @@ measure () const
 }
 
 
+#if deal_II_dimension == 1
+
+template <>
+double TriaAccessor<1,1,1>::extent_in_direction(const unsigned int axis) const
+{
+  Assert (axis == 0, ExcIndexRange (axis, 0, 1));  
+
+  return this->diameter();
+}
+
+#elsif deal_II_dimension == 2
+
+template <>
+double TriaAccessor<2,2,2>::extent_in_direction(const unsigned int axis) const
+{
+  const unsigned int lines[2][2] = {{2,3}, /// Lines along x-axis, see GeometryInfo
+                                   {0,1}};/// Lines along y-axis
+
+  Assert (axis < 2, ExcIndexRange (axis, 0, 2));
+  
+  return std::max(this->line(lines[axis][0])->diameter(),
+                 this->line(lines[axis][1])->diameter());
+}
+
+#elsif deal_II_dimension == 3
+
+template <>
+double TriaAccessor<3,3,3>::extent_in_direction(const unsigned int axis) const
+{
+  const unsigned int lines[3][4] = {{2,3,6,7},    /// Lines along x-axis, see GeometryInfo
+                                   {0,1,4,5},    /// Lines along y-axis
+                                   {8,9,10,11}}; /// Lines along z-axis
+  
+  Assert (axis < 3, ExcIndexRange (axis, 0, 3));
+
+  double lengths[4] = { this->line(lines[axis][0])->diameter(),
+                       this->line(lines[axis][1])->diameter(),
+                       this->line(lines[axis][2])->diameter(),
+                       this->line(lines[axis][3])->diameter() };
+
+  return std::max(std::max(lengths[0], lengths[1]),
+                 std::max(lengths[2], lengths[3]));
+}
+
+#else
+
+// Not implemented for higher dimensions
+
+#endif
+
 
 /*------------------------ Functions: CellAccessor<1> -----------------------*/
 
index 607fa3ac4a70f7f03d938b88f4b3649b3d4368fc..c2e85013b5ee102dec9a716ff6829fb8e3f18cfc 100644 (file)
@@ -629,9 +629,15 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+  <li>
+  <p>New: TriaAccessor::extent_in_direction() returns the length
+  of an object in a given direction.
+  <br>
+  (James Avery 2010/05/10)
+  </p></li>
+
   <li>
   <p>New: There is a new function DoFTools::extract_dofs_with_support_on_boundary().
-  fixed.
   <br>
   (WB 2010/05/07)
   </p></li>

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.