]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Added back default computation of normals for FlatManifolds
authorheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Jan 2014 22:55:08 +0000 (22:55 +0000)
committerheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 15 Jan 2014 22:55:08 +0000 (22:55 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_manifold_id@32223 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/grid/tria.h
deal.II/include/deal.II/grid/tria_boundary.h
deal.II/source/fe/mapping_c1.cc
deal.II/source/grid/tria.cc
deal.II/source/grid/tria_boundary.cc

index b577b3cfd1845dfd60012c9584f812fcfdfe9aaf..5eea08a8bc9268f061c8cba31e1957675235553f 100644 (file)
@@ -42,6 +42,7 @@ DEAL_II_NAMESPACE_OPEN
 
 template <int spacedim> class Manifold;
 template <int spacedim> class FlatManifold;
+template <int dim, int spacedim> class StraightBoundary;
 
 template <int, int, int> class TriaAccessor;
 template <int spacedim> class TriaAccessor<0,1,spacedim>;
@@ -1240,6 +1241,14 @@ public:
    */
   static const FlatManifold<spacedim> flat_manifold;
 
+  /**
+   * Default boundary object. This is used
+   * for those objects for which no
+   * boundary description has been explicitly
+   * set using set_manifold().
+   */
+
+    static const StraightBoundary<dim,spacedim> straight_boundary;
 
   /**
    * Declare some symbolic names
index b80a2bcd2fdc619e5b416eb41e94549fb4fba4cc..a2374e777a477ae921e711077ba95bf7bead1773 100644 (file)
@@ -128,11 +128,11 @@ public:
  *   polygon/polyhedron defined by the boundary of the initial coarse
  *   triangulation.
  *
- *   @deprecated The functionality of this class is equivalent, but
- *   less general, to that of FlatManifold<spacedim>. Please use
- *   FlatManifold<spacedim> instead of this
- *   class. StraightBoundary<dim,spacedim> will be removed in future
- *   releases.
+ *   The functionality of this class is equivalent, in most aspects,
+ *   to that of FlatManifold<spacedim>. The only difference between
+ *   this class and the FlatManifold<spacedim> class is that for this
+ *   class the normal is well defined, and therefore there exist the
+ *   specialized method which computes it.
  *   
  *   @ingroup boundary
  *
@@ -140,13 +140,23 @@ public:
  *   Heltai 2013, 2014
  */
 template <int dim, int spacedim=dim>
-class StraightBoundary : public Boundary<dim,spacedim>
+class StraightBoundary : public FlatManifold<spacedim>
 {
 public:
   /**
    * Default constructor. Some compilers require this for some reasons.
    */
   StraightBoundary ();
+
+  /**
+    * Given a vector of points, return the normals to the Manifold in
+    * those points. Input arguments must be of the same size. 
+    */
+    virtual
+    void get_normals_at_points(std::vector<Point<spacedim> > &normals,
+                              const std::vector<Point<spacedim> > &points) const;
+    
+    
 } DEAL_II_DEPRECATED;
 
 DEAL_II_NAMESPACE_CLOSE
index 3196ececa509209996090c73abc82a70c6d0f315..9097bb47fde3e268067702cf44f0595c9d7e1ec0 100644 (file)
@@ -67,11 +67,8 @@ MappingC1<2>::add_line_support_points (const Triangulation<2>::cell_iterator &ce
         {
           // first get the normal vectors at the two vertices of this line
           // from the boundary description
-          const Manifold<dim> &boundary
-            = line->get_boundary();
-         
          std::vector<Point<dim> > face_vertex_normals(2);
-          boundary.get_normals_at_points (face_vertex_normals, points);
+          line->get_boundary().get_normals_at_points (face_vertex_normals, points);
 
           // then transform them into interpolation points for a cubic
           // polynomial
index aaae9a3da47cdb55078ef3e26d28a7155436f74d..f363e7c15fd974e51b75233aee08852b1f2dc235 100644 (file)
@@ -27,6 +27,7 @@
 #include <deal.II/grid/tria_accessor.h>
 #include <deal.II/grid/tria_iterator.h>
 #include <deal.II/grid/manifold.h>
+#include <deal.II/grid/tria_boundary.h>
 #include <deal.II/grid/grid_tools.h>
 #include <deal.II/grid/magic_numbers.h>
 #include <deal.II/fe/mapping_q1.h>
@@ -9547,6 +9548,9 @@ template <int dim, int spacedim>
 const FlatManifold<spacedim>
 Triangulation<dim, spacedim>::flat_manifold = FlatManifold<spacedim>();
 
+template <int dim, int spacedim>
+const StraightBoundary<dim,spacedim>
+Triangulation<dim, spacedim>::straight_boundary = StraightBoundary<dim,spacedim>();
 
 template <int dim, int spacedim>
 const unsigned int
@@ -9714,7 +9718,7 @@ Triangulation<dim, spacedim>::get_boundary (const types::manifold_id m_number) c
       //if we have not found an entry
       //connected with number, we return
       //straight_boundary
-      return flat_manifold;
+      return straight_boundary;
     }
 }
 
@@ -9723,8 +9727,8 @@ template <int dim, int spacedim>
 const Manifold<spacedim> &
 Triangulation<dim, spacedim>::get_manifold (const types::manifold_id m_number) const
 {
-                                  //look, if there is a boundary stored at
-                                  //boundary_id number.
+                                  //look, if there is a manifold stored at
+                                  //manifold_id number.
   typename std::map<types::manifold_id, SmartPointer<const Manifold<spacedim>, Triangulation<dim, spacedim> > >::const_iterator it
     = manifold.find(m_number);
 
@@ -9737,8 +9741,8 @@ Triangulation<dim, spacedim>::get_manifold (const types::manifold_id m_number) c
     {
       //if we have not found an entry
       //connected with number, we return
-      //flat_manifold
-      return flat_manifold;
+      //straight_boundary
+      return straight_boundary;
     }
 }
 
index 3ed27b97b237b8735c81da5a26644db8a937b04c..d0668604142f2828ffc431807ca34e2084da35e4 100644 (file)
@@ -13,7 +13,8 @@
 // the top level of the deal.II distribution.
 //
 // ---------------------------------------------------------------------
-
+  
+#include <deal.II/base/tensor.h>
 #include <deal.II/grid/tria_boundary.h>
 DEAL_II_NAMESPACE_OPEN
 
@@ -31,6 +32,65 @@ template <int dim, int spacedim>
 StraightBoundary<dim, spacedim>::StraightBoundary ()
 {}
 
+template <int dim, int spacedim>
+void
+StraightBoundary<dim, spacedim>::get_normals_at_points(std::vector<Point<spacedim> > &normals,
+                                                      const std::vector<Point<spacedim> > &points) const
+{
+  AssertDimension(normals.size(), points.size());
+  switch(dim)
+    {
+      case 1:
+           Assert(false, ExcNotImplemented());
+           break;
+      case 2:
+      {
+       Assert(points.size() >= 2, ExcMessage("At least two points!"));
+       for(unsigned int i=0; i<points.size(); ++i)
+         {
+           Point<spacedim> t = points[1]-points[0];
+           Point<spacedim> n; n[0] = t[1]; n[1] = -t[0];
+           normals[i] = n;
+         }
+      }
+      break;
+      case 3:
+      {
+       AssertDimension(points.size(), 4);
+       
+       const unsigned int vertices_per_face = GeometryInfo<3>::vertices_per_face;
+       static const unsigned int neighboring_vertices[4][2]=
+         { {1,2},{3,0},{0,3},{2,1}};
+       for (unsigned int vertex=0; vertex<vertices_per_face; ++vertex)
+         {
+                                            // first define the two tangent
+                                            // vectors at the vertex by
+                                            // using the two lines
+                                            // radiating away from this
+                                            // vertex
+           const Tensor<1,spacedim> tangents[2]
+             = { points[neighboring_vertices[vertex][0]]
+                 - points[vertex],
+                 points[neighboring_vertices[vertex][1]]
+                 - points[vertex] };
+           
+                                            // then compute the normal by
+                                            // taking the cross
+                                            // product. since the normal is
+                                            // not required to be
+                                            // normalized, no problem here
+           cross_product (normals[vertex],
+                          tangents[0], tangents[1]);
+         };
+      }
+      break;
+      default:
+           Assert(false, ExcNotImplemented());
+           break;
+    }
+}
+
+
 // explicit instantiations
 #include "tria_boundary.inst"
 

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.