]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
GridTools::scale
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 29 Jul 2002 09:07:06 +0000 (09:07 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 29 Jul 2002 09:07:06 +0000 (09:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@6298 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_tools.h
deal.II/deal.II/source/grid/grid_tools.cc
deal.II/doc/news/2002/c-3-4.html

index 7992e0f0b041f69bce69f676a34fe14a570d10dc..d0655de4be4c3cd6149257336fadba11bee35b0c 100644 (file)
@@ -123,11 +123,37 @@ class GridTools
     static
     void rotate (const double      angle,
                 Triangulation<2> &triangulation);
+
+                                    /**
+                                     * Scale the entire triangulation
+                                     * by the given factor. To
+                                     * preserve the orientation of
+                                     * the triangulation, the factor
+                                     * must be positive.
+                                     *
+                                     * This function uses the
+                                     * @ref{transform} function
+                                     * above, so the requirements on
+                                     * the triangulation stated there
+                                     * hold for this function as
+                                     * well.
+                                     */
+    template <int dim>
+    static
+    void scale (const double        scaling_factor,
+               Triangulation<dim> &triangulation);
     
                                     /**
                                      * Exception
                                      */
     DeclException0 (ExcTriangulationHasBeenRefined);
+
+                                    /**
+                                     * Exception
+                                     */
+    DeclException1 (ExcScalingFactorNotPositive,
+                   double,
+                   << "The scaling factor must be positive, but is " << arg1);
 };
 
 
index 2e8c3681ad439d15f31b4851605eea75cc88c488..d6c5df35808c79bc4849ecae35b20fe2dbceca5f 100644 (file)
@@ -115,6 +115,16 @@ namespace
     return Point<2> (std::cos(angle)*p(0) - std::sin(angle) * p(1),
                     std::sin(angle)*p(0) + std::cos(angle) * p(1));
   };
+
+
+
+  template <int dim>
+  inline
+  Point<dim> scale_point (const Point<dim> p,
+                         const double factor)
+  {
+    return p*factor;
+  };
 };
 
 
@@ -143,6 +153,19 @@ GridTools::rotate (const double      angle,
 #endif
 
 
+template <int dim>
+void
+GridTools::scale (const double        scaling_factor,
+                 Triangulation<dim> &triangulation)
+{
+  Assert (scaling_factor>0, ExcScalingFactorNotPositive (scaling_factor));
+  
+  transform (std::bind2nd(std::ptr_fun(&scale_point<dim>),
+                         scaling_factor),
+            triangulation);
+};
+
+
 
 #if deal_II_dimension != 1
 template
@@ -153,3 +176,7 @@ GridTools::diameter<deal_II_dimension> (const Triangulation<deal_II_dimension> &
 template
 void GridTools::shift<deal_II_dimension> (const Point<deal_II_dimension> &,
                                          Triangulation<deal_II_dimension> &);
+
+template
+void GridTools::scale<deal_II_dimension> (const double,
+                                         Triangulation<deal_II_dimension> &);
index bc6e371e8e7d18d34afebc2cd751a7cc2d02cda1..d410b923197e414035caac634f840d42e91aa30f 100644 (file)
@@ -156,7 +156,7 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
   <li> <p> New: The <code class="class">GridTools</code> class now
        offers functions to apply general transformations to all
        vertices of a triangulation, and also more specialized
-       functions that shift and rotate triangulations.
+       functions that shift, scale, and rotate triangulations.
        <br>
        (RH 2002/07/25)
        </p>

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.