From 32d76ad71e3113ba9d84ce448065065fe3bbfdeb Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 29 Jul 2002 09:07:06 +0000 Subject: [PATCH] GridTools::scale git-svn-id: https://svn.dealii.org/trunk@6298 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/grid_tools.h | 26 ++++++++++++++++++++++ deal.II/deal.II/source/grid/grid_tools.cc | 27 +++++++++++++++++++++++ deal.II/doc/news/2002/c-3-4.html | 2 +- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/deal.II/deal.II/include/grid/grid_tools.h b/deal.II/deal.II/include/grid/grid_tools.h index 7992e0f0b0..d0655de4be 100644 --- a/deal.II/deal.II/include/grid/grid_tools.h +++ b/deal.II/deal.II/include/grid/grid_tools.h @@ -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 + static + void scale (const double scaling_factor, + Triangulation &triangulation); /** * Exception */ DeclException0 (ExcTriangulationHasBeenRefined); + + /** + * Exception + */ + DeclException1 (ExcScalingFactorNotPositive, + double, + << "The scaling factor must be positive, but is " << arg1); }; diff --git a/deal.II/deal.II/source/grid/grid_tools.cc b/deal.II/deal.II/source/grid/grid_tools.cc index 2e8c3681ad..d6c5df3580 100644 --- a/deal.II/deal.II/source/grid/grid_tools.cc +++ b/deal.II/deal.II/source/grid/grid_tools.cc @@ -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 + inline + Point scale_point (const Point p, + const double factor) + { + return p*factor; + }; }; @@ -143,6 +153,19 @@ GridTools::rotate (const double angle, #endif +template +void +GridTools::scale (const double scaling_factor, + Triangulation &triangulation) +{ + Assert (scaling_factor>0, ExcScalingFactorNotPositive (scaling_factor)); + + transform (std::bind2nd(std::ptr_fun(&scale_point), + scaling_factor), + triangulation); +}; + + #if deal_II_dimension != 1 template @@ -153,3 +176,7 @@ GridTools::diameter (const Triangulation & template void GridTools::shift (const Point &, Triangulation &); + +template +void GridTools::scale (const double, + Triangulation &); diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index bc6e371e8e..d410b92319 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -156,7 +156,7 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
  • New: The GridTools 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.
    (RH 2002/07/25)

    -- 2.39.5