--- /dev/null
+Improved: The function GridTools::rotate()
+can now also handle Triangulation objects with
+dim=1 and spacedim=2.
+<br>
+(Peter Munch, 2022/12/08)
* stated there hold for this function as well; in particular,
* this is true about the discussion about manifolds.
*
- * @note This function is only supported for dim=2.
+ * @note This function is only supported for spacedim=2.
*/
- template <int dim>
+ template <int dim, int spacedim>
void
- rotate(const double angle, Triangulation<dim> &triangulation);
+ rotate(const double angle, Triangulation<dim, spacedim> &triangulation);
/**
* Rotate all vertices of the given @p triangulation in counter-clockwise
};
+ // Transformation to rotate around one of the cartesian z-axis in 2D.
+ class Rotate2d
+ {
+ public:
+ explicit Rotate2d(const double angle)
+ : rotation_matrix(
+ Physics::Transformations::Rotations::rotation_matrix_2d(angle))
+ {}
+ Point<2>
+ operator()(const Point<2> &p) const
+ {
+ return static_cast<Point<2>>(rotation_matrix * p);
+ }
+
+ private:
+ const Tensor<2, 2, double> rotation_matrix;
+ };
+
+
// Transformation to rotate around one of the cartesian axes.
class Rotate3d
{
}
+
+ template <int dim, int spacedim>
+ void
+ rotate(const double angle, Triangulation<dim, spacedim> &triangulation)
+ {
+ (void)angle;
+ (void)triangulation;
+
+ AssertThrow(false,
+ ExcMessage(
+ "GridTools::rotate() is only available for spacedim = 2."));
+ }
+
+
+
+ template <>
+ void
+ rotate(const double angle, Triangulation<1, 2> &triangulation)
+ {
+ transform(internal::Rotate2d(angle), triangulation);
+ }
+
+
+
+ template <>
+ void
+ rotate(const double angle, Triangulation<2, 2> &triangulation)
+ {
+ transform(internal::Rotate2d(angle), triangulation);
+ }
+
+
template <int dim>
void
rotate(const Tensor<1, 3, double> &axis,
const double,
Triangulation<deal_II_dimension, deal_II_space_dimension> &);
+# if deal_II_space_dimension != 2
+ template void
+ rotate<deal_II_dimension, deal_II_space_dimension>(
+ const double,
+ Triangulation<deal_II_dimension, deal_II_space_dimension> &);
+# endif
+
# if deal_II_space_dimension == 3
template void
rotate<deal_II_dimension>(
return (t34 + t64 + t95 + t125 + t156 + t181 + t207 + t228) / 12.;
}
-
-
-
- namespace
- {
- // the following class is only needed in 2d, so avoid trouble with compilers
- // warning otherwise
- class Rotate2d
- {
- public:
- explicit Rotate2d(const double angle)
- : rotation_matrix(
- Physics::Transformations::Rotations::rotation_matrix_2d(angle))
- {}
- Point<2>
- operator()(const Point<2> &p) const
- {
- return static_cast<Point<2>>(rotation_matrix * p);
- }
-
- private:
- const Tensor<2, 2, double> rotation_matrix;
- };
- } // namespace
-
-
-
- template <>
- void
- rotate(const double angle, Triangulation<2> &triangulation)
- {
- transform(Rotate2d(angle), triangulation);
- }
-
-
-
- template <>
- void
- rotate(const double angle, Triangulation<3> &triangulation)
- {
- (void)angle;
- (void)triangulation;
-
- AssertThrow(
- false, ExcMessage("GridTools::rotate() is not available for dim = 3."));
- }
} /* namespace GridTools */
DEAL_II_NAMESPACE_CLOSE
void
test();
+template <>
+void
+test<1, 2>()
+{
+ const int dim = 1;
+ const int spacedim = 2;
+ Triangulation<dim, spacedim> tria;
+ GridGenerator::hyper_sphere<spacedim>(tria);
+
+ // GridOut().write_gnuplot (tria, deallog.get_file_stream());
+ GridTools::rotate(numbers::PI / 3.0, tria);
+ GridOut().write_gnuplot(tria, deallog.get_file_stream());
+}
+
template <>
void
test<2, 2>()
{
initlog();
+ test<1, 2>();
test<2, 2>();
test<1, 3>();
test<2, 3>();
+0.965926 0.258819 0 0
+0.258819 -0.965926 0 0
+
+
+0.258819 -0.965926 0 0
+-0.965926 -0.258819 0 0
+
+
+-0.258819 0.965926 0 0
+0.965926 0.258819 0 0
+
+
+-0.965926 -0.258819 0 0
+-0.258819 0.965926 0 0
+
+
0.00000 0.00000 0 0
1.00000 1.73205 0 0
0.407180 2.30526 0 0