From: Luca Heltai Date: Thu, 17 Feb 2022 13:06:22 +0000 (+0000) Subject: Make GridGenerator::hyper_ball_balanced() available for GridGenerator::generate_from_... X-Git-Tag: v9.4.0-rc1~465^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13410%2Fhead;p=dealii.git Make GridGenerator::hyper_ball_balanced() available for GridGenerator::generate_from_name_and_argument --- diff --git a/doc/news/changes/minor/20220217LucaHeltai b/doc/news/changes/minor/20220217LucaHeltai new file mode 100644 index 0000000000..59ddabe790 --- /dev/null +++ b/doc/news/changes/minor/20220217LucaHeltai @@ -0,0 +1,3 @@ +New: GridGenerator::generate_from_name_and_argument() now supports also GridGenerator::hyper_ball_balanced() +
+(Luca Heltai, 2022/02/17) diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 1f7187a118..1f7d28dc79 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -3938,6 +3938,15 @@ namespace GridGenerator + template <> + void + hyper_ball_balanced(Triangulation<1> &, const Point<1> &, const double) + { + Assert(false, ExcNotImplemented()); + } + + + template <> void cylinder(Triangulation<1> &, const double, const double) diff --git a/source/grid/grid_generator_from_name.cc b/source/grid/grid_generator_from_name.cc index 8b58ef10b9..7243d0c8a1 100644 --- a/source/grid/grid_generator_from_name.cc +++ b/source/grid/grid_generator_from_name.cc @@ -129,6 +129,9 @@ namespace GridGenerator parse_and_create &, double, bool>(hyper_ball, arguments, tria); + else if (name == "hyper_ball_balanced") + parse_and_create &, double>( + hyper_ball_balanced, arguments, tria); else if (name == "quarter_hyper_ball") parse_and_create &, double>( diff --git a/tests/grid/grid_generator_from_name_and_argument_02.cc b/tests/grid/grid_generator_from_name_and_argument_02.cc new file mode 100644 index 0000000000..e89f9e720b --- /dev/null +++ b/tests/grid/grid_generator_from_name_and_argument_02.cc @@ -0,0 +1,57 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +// Test GridGenerator::generate_from_name_and_arguments. + +#include + +#include +#include +#include + +#include "../tests.h" + +template +void +test(const std::string &name, const std::string &arguments) +{ + Triangulation tria; + + deallog << "Generating Triangulation<" << dim << ", " << spacedim + << "> : " << name << '(' << arguments << ')' << std::endl; + + GridGenerator::generate_from_name_and_arguments(tria, name, arguments); + + GridOut go; + go.write_msh(tria, deallog.get_file_stream()); + + std::ofstream ofile(name + "_" + std::to_string(dim) + "_" + + std::to_string(spacedim) + ".msh"); + go.write_msh(tria, ofile); +} + +int +main() +{ + initlog(); + + test<2, 3>("hyper_sphere", "0,0,0 : 1"); + + test<2, 2>("quarter_hyper_ball", "0,0 : 1"); + test<3, 3>("quarter_hyper_ball", "0,0,0 : 1"); + + test<2, 2>("hyper_ball_balanced", "0,0 : 1"); + test<3, 3>("hyper_ball_balanced", "0,0,0 : 1"); +} diff --git a/tests/grid/grid_generator_from_name_and_argument_02.output b/tests/grid/grid_generator_from_name_and_argument_02.output new file mode 100644 index 0000000000..5119b643ca --- /dev/null +++ b/tests/grid/grid_generator_from_name_and_argument_02.output @@ -0,0 +1,193 @@ + +DEAL::Generating Triangulation<2, 3> : hyper_sphere(0,0,0 : 1) +$NOD +8 +1 -0.577350 -0.577350 -0.577350 +2 0.577350 -0.577350 -0.577350 +3 -0.577350 0.577350 -0.577350 +4 0.577350 0.577350 -0.577350 +5 0.577350 -0.577350 0.577350 +6 0.577350 0.577350 0.577350 +7 -0.577350 -0.577350 0.577350 +8 -0.577350 0.577350 0.577350 +$ENDNOD +$ELM +6 +1 3 0 0 4 1 3 4 2 +2 3 0 0 4 2 4 6 5 +3 3 0 0 4 7 5 6 8 +4 3 0 0 4 1 7 8 3 +5 3 0 0 4 1 2 5 7 +6 3 0 0 4 3 8 6 4 +$ENDELM +DEAL::Generating Triangulation<2, 2> : quarter_hyper_ball(0,0 : 1) +$NOD +7 +1 0.00000 0.00000 0 +2 1.00000 0.00000 0 +3 0.556470 0.00000 0 +4 0.00000 0.556470 0 +5 0.428830 0.428830 0 +6 0.00000 1.00000 0 +7 0.707107 0.707107 0 +$ENDNOD +$ELM +3 +1 3 0 0 4 1 3 5 4 +2 3 0 0 4 2 7 5 3 +3 3 0 0 4 6 4 5 7 +$ENDELM +DEAL::Generating Triangulation<3, 3> : quarter_hyper_ball(0,0,0 : 1) +$NOD +15 +1 0.00000 0.00000 0.00000 +2 1.00000 0.00000 0.00000 +3 0.528000 0.00000 0.00000 +4 0.00000 0.528000 0.00000 +5 0.453300 0.453300 0.00000 +6 0.00000 1.00000 0.00000 +7 0.707107 0.707107 0.00000 +8 0.00000 0.00000 0.528000 +9 0.707107 0.00000 0.707107 +10 0.453300 0.00000 0.453300 +11 0.00000 0.453300 0.453300 +12 0.375200 0.375200 0.375200 +13 0.00000 0.707107 0.707107 +14 0.577350 0.577350 0.577350 +15 0.00000 0.00000 1.00000 +$ENDNOD +$ELM +4 +1 5 0 0 8 1 3 10 8 4 5 12 11 +2 5 0 0 8 2 7 14 9 3 5 12 10 +3 5 0 0 8 6 4 11 13 7 5 12 14 +4 5 0 0 8 8 10 9 15 11 12 14 13 +$ENDELM +DEAL::Generating Triangulation<2, 2> : hyper_ball_balanced(0,0 : 1) +$NOD +17 +1 0.00000 0.00000 0 +2 1.00000 0.00000 0 +3 0.556470 0.00000 0 +4 0.00000 0.556470 0 +5 0.428830 0.428830 0 +6 0.00000 1.00000 0 +7 0.707107 0.707107 0 +8 -0.556470 0.00000 0 +9 -0.428830 0.428830 0 +10 -1.00000 0.00000 0 +11 -0.707107 0.707107 0 +12 0.00000 -0.556470 0 +13 -0.428830 -0.428830 0 +14 0.00000 -1.00000 0 +15 -0.707107 -0.707107 0 +16 0.428830 -0.428830 0 +17 0.707107 -0.707107 0 +$ENDNOD +$ELM +12 +1 3 0 0 4 1 3 5 4 +2 3 0 0 4 2 7 5 3 +3 3 0 0 4 6 4 5 7 +4 3 0 0 4 1 4 9 8 +5 3 0 0 4 6 11 9 4 +6 3 0 0 4 10 8 9 11 +7 3 0 0 4 1 8 13 12 +8 3 0 0 4 10 15 13 8 +9 3 0 0 4 14 12 13 15 +10 3 0 0 4 1 12 16 3 +11 3 0 0 4 14 17 16 12 +12 3 0 0 4 2 3 16 17 +$ENDELM +DEAL::Generating Triangulation<3, 3> : hyper_ball_balanced(0,0,0 : 1) +$NOD +53 +1 0.00000 0.00000 0.00000 +2 1.00000 0.00000 0.00000 +3 0.528000 0.00000 0.00000 +4 0.00000 0.528000 0.00000 +5 0.453300 0.453300 0.00000 +6 0.00000 1.00000 0.00000 +7 0.707107 0.707107 0.00000 +8 0.00000 0.00000 0.528000 +9 0.707107 0.00000 0.707107 +10 0.453300 0.00000 0.453300 +11 0.00000 0.453300 0.453300 +12 0.375200 0.375200 0.375200 +13 0.00000 0.707107 0.707107 +14 0.577350 0.577350 0.577350 +15 0.00000 0.00000 1.00000 +16 -0.528000 0.00000 0.00000 +17 -0.453300 0.453300 0.00000 +18 -1.00000 0.00000 0.00000 +19 -0.707107 0.707107 0.00000 +20 -0.453300 0.00000 0.453300 +21 -0.375200 0.375200 0.375200 +22 -0.707107 0.00000 0.707107 +23 -0.577350 0.577350 0.577350 +24 0.00000 -0.528000 0.00000 +25 -0.453300 -0.453300 0.00000 +26 0.00000 -1.00000 0.00000 +27 -0.707107 -0.707107 0.00000 +28 0.00000 -0.453300 0.453300 +29 -0.375200 -0.375200 0.375200 +30 0.00000 -0.707107 0.707107 +31 -0.577350 -0.577350 0.577350 +32 0.453300 -0.453300 0.00000 +33 0.707107 -0.707107 0.00000 +34 0.375200 -0.375200 0.375200 +35 0.577350 -0.577350 0.577350 +36 0.00000 0.00000 -0.528000 +37 -0.707107 0.00000 -0.707107 +38 -0.453300 0.00000 -0.453300 +39 0.00000 0.453300 -0.453300 +40 -0.375200 0.375200 -0.375200 +41 0.00000 0.707107 -0.707107 +42 -0.577350 0.577350 -0.577350 +43 0.00000 0.00000 -1.00000 +44 0.453300 0.00000 -0.453300 +45 0.375200 0.375200 -0.375200 +46 0.707107 0.00000 -0.707107 +47 0.577350 0.577350 -0.577350 +48 0.00000 -0.453300 -0.453300 +49 0.375200 -0.375200 -0.375200 +50 0.00000 -0.707107 -0.707107 +51 0.577350 -0.577350 -0.577350 +52 -0.375200 -0.375200 -0.375200 +53 -0.577350 -0.577350 -0.577350 +$ENDNOD +$ELM +32 +1 5 0 0 8 1 3 10 8 4 5 12 11 +2 5 0 0 8 2 7 14 9 3 5 12 10 +3 5 0 0 8 6 4 11 13 7 5 12 14 +4 5 0 0 8 15 8 10 9 13 11 12 14 +5 5 0 0 8 1 4 11 8 16 17 21 20 +6 5 0 0 8 6 19 23 13 4 17 21 11 +7 5 0 0 8 18 16 20 22 19 17 21 23 +8 5 0 0 8 15 8 11 13 22 20 21 23 +9 5 0 0 8 1 16 20 8 24 25 29 28 +10 5 0 0 8 18 27 31 22 16 25 29 20 +11 5 0 0 8 26 24 28 30 27 25 29 31 +12 5 0 0 8 15 8 20 22 30 28 29 31 +13 5 0 0 8 1 24 28 8 3 32 34 10 +14 5 0 0 8 26 33 35 30 24 32 34 28 +15 5 0 0 8 2 3 10 9 33 32 34 35 +16 5 0 0 8 15 8 28 30 9 10 34 35 +17 5 0 0 8 1 16 38 36 4 17 40 39 +18 5 0 0 8 18 19 42 37 16 17 40 38 +19 5 0 0 8 6 4 39 41 19 17 40 42 +20 5 0 0 8 43 36 38 37 41 39 40 42 +21 5 0 0 8 1 4 39 36 3 5 45 44 +22 5 0 0 8 6 7 47 41 4 5 45 39 +23 5 0 0 8 2 3 44 46 7 5 45 47 +24 5 0 0 8 43 36 39 41 46 44 45 47 +25 5 0 0 8 1 3 44 36 24 32 49 48 +26 5 0 0 8 2 33 51 46 3 32 49 44 +27 5 0 0 8 26 24 48 50 33 32 49 51 +28 5 0 0 8 43 36 44 46 50 48 49 51 +29 5 0 0 8 1 24 48 36 16 25 52 38 +30 5 0 0 8 26 27 53 50 24 25 52 48 +31 5 0 0 8 18 16 38 37 27 25 52 53 +32 5 0 0 8 43 36 48 50 37 38 52 53 +$ENDELM