From: Niklas Fehn Date: Thu, 26 Mar 2020 13:10:52 +0000 (+0100) Subject: add functions to support dim-independent programming X-Git-Tag: v9.2.0-rc1~295^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9739%2Fhead;p=dealii.git add functions to support dim-independent programming --- diff --git a/include/deal.II/grid/grid_generator.h b/include/deal.II/grid/grid_generator.h index a9cf8ac42c..7f12c87cb8 100644 --- a/include/deal.II/grid/grid_generator.h +++ b/include/deal.II/grid/grid_generator.h @@ -1755,6 +1755,22 @@ namespace GridGenerator const bool copy_manifold_ids = false, const std::vector &manifold_priorities = {}); + /** + * Overload of extrude_triangulation() to allow dimension independent + * code to compile. This function throws an error when called, as + * extrude_triangulation() is only implemented to extrude a dim=2 to a dim=3 + * Triangulation. + */ + void + extrude_triangulation( + const Triangulation<2, 2> & input, + const unsigned int n_slices, + const double height, + Triangulation<2, 2> & result, + const bool copy_manifold_ids = false, + const std::vector &manifold_priorities = {}); + + /** * Overload of the previous function. Take a 2d Triangulation that is being * extruded. Differing from the previous function taking height and number of @@ -1783,6 +1799,21 @@ namespace GridGenerator const bool copy_manifold_ids = false, const std::vector &manifold_priorities = {}); + /** + * Overload of extrude_triangulation() to allow dimension independent + * code to compile. This function throws an error when called, as + * extrude_triangulation() is only implemented to extrude a dim=2 to a dim=3 + * Triangulation. + */ + void + extrude_triangulation( + const Triangulation<2, 2> & input, + const std::vector & slice_coordinates, + Triangulation<2, 2> & result, + const bool copy_manifold_ids = false, + const std::vector &manifold_priorities = {}); + + /** * Given an input triangulation @p in_tria, this function makes a new flat diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 4369210a60..77a1b5e2eb 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -453,9 +453,12 @@ namespace GridTools * given angle (given in radians, rather than degrees). This function uses * the transform() function above, so the requirements on the triangulation * stated there hold for this function as well. + * + * @note This function is only supported for dim=2. */ + template void - rotate(const double angle, Triangulation<2> &triangulation); + rotate(const double angle, Triangulation &triangulation); /** * Rotate all vertices of the given @p triangulation in counter-clockwise diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index ca7eaed285..323a698c11 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -6196,6 +6196,30 @@ namespace GridGenerator + void + extrude_triangulation( + const Triangulation<2, 2> & input, + const unsigned int n_slices, + const double height, + Triangulation<2, 2> & result, + const bool copy_manifold_ids, + const std::vector &manifold_priorities) + { + (void)input; + (void)n_slices; + (void)height; + (void)result; + (void)copy_manifold_ids; + (void)manifold_priorities; + + AssertThrow(false, + ExcMessage( + "GridTools::extrude_triangulation() is only available " + "for Triangulation<3, 3> as output triangulation.")); + } + + + void extrude_triangulation( const Triangulation<2, 2> & input, @@ -6425,6 +6449,29 @@ namespace GridGenerator } + + void + extrude_triangulation( + const Triangulation<2, 2> & input, + const std::vector & slice_coordinates, + Triangulation<2, 2> & result, + const bool copy_manifold_ids, + const std::vector &manifold_priorities) + { + (void)input; + (void)slice_coordinates; + (void)result; + (void)copy_manifold_ids; + (void)manifold_priorities; + + AssertThrow(false, + ExcMessage( + "GridTools::extrude_triangulation() is only available " + "for Triangulation<3, 3> as output triangulation.")); + } + + + template <> void hyper_cube_with_cylindrical_hole(Triangulation<1> &, const double, diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 4a4cee06be..f237ec2928 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -1068,13 +1068,25 @@ namespace GridTools } - + 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.")); + } + + template void rotate(const double angle,