From f7fc7ecec5a0e0484e20dfd8c7c17f29efdc840c Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Tue, 7 Apr 2020 18:19:23 +0200 Subject: [PATCH] Test case --- tests/grid/grid_hyper_shell_07.cc | 78 +++++++++++++++++++++++++++ tests/grid/grid_hyper_shell_07.output | 56 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 tests/grid/grid_hyper_shell_07.cc create mode 100644 tests/grid/grid_hyper_shell_07.output diff --git a/tests/grid/grid_hyper_shell_07.cc b/tests/grid/grid_hyper_shell_07.cc new file mode 100644 index 0000000000..15d57230d0 --- /dev/null +++ b/tests/grid/grid_hyper_shell_07.cc @@ -0,0 +1,78 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 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 the various cell variants of GridGenerator::hyper_shell in 3d + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "../tests.h" + +template +void +check(double r1, double r2, unsigned int n) +{ + Point center; + Triangulation tria(Triangulation::none); + GridGenerator::hyper_shell(tria, center, r1, r2, n); + + deallog << "Number of cells: " << tria.n_cells() << std::endl; + + unsigned int n_r1 = 0; + unsigned int n_r2 = 0; + unsigned int n_other_radius = 0; + + // ensure that all vertices of the mesh are either at r1 or at r2 + for (const auto v : tria.get_vertices()) + if (std::abs(v.norm_square() - r1 * r1) < 1e-12) + ++n_r1; + else if (std::abs(v.norm_square() - r2 * r2) < 1e-12) + ++n_r2; + else + ++n_other_radius; + + deallog << "Number of vertices at inner radius: " << n_r1 << std::endl; + deallog << "Number of vertices at outer radius: " << n_r2 << std::endl; + deallog << "Number of vertices at other radius: " << n_other_radius + << std::endl; + deallog << std::endl; +} + + +int +main() +{ + initlog(); + + check<3>(.8, 1, 6); + check<3>(.8, 1, 12); + check<3>(.8, 1, 24); + check<3>(.8, 1, 48); + check<3>(.8, 1, 96); + check<3>(.8, 1, 192); + check<3>(.8, 1, 384); + check<3>(.8, 1, 768); + check<3>(.8, 1, 1536); + check<3>(.8, 1, 3072); + check<3>(.8, 1, 6144); +} diff --git a/tests/grid/grid_hyper_shell_07.output b/tests/grid/grid_hyper_shell_07.output new file mode 100644 index 0000000000..437b35def0 --- /dev/null +++ b/tests/grid/grid_hyper_shell_07.output @@ -0,0 +1,56 @@ + +DEAL::Number of cells: 6 +DEAL::Number of vertices at inner radius: 8 +DEAL::Number of vertices at outer radius: 8 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 12 +DEAL::Number of vertices at inner radius: 14 +DEAL::Number of vertices at outer radius: 14 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 24 +DEAL::Number of vertices at inner radius: 26 +DEAL::Number of vertices at outer radius: 26 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 48 +DEAL::Number of vertices at inner radius: 50 +DEAL::Number of vertices at outer radius: 50 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 96 +DEAL::Number of vertices at inner radius: 50 +DEAL::Number of vertices at outer radius: 50 +DEAL::Number of vertices at other radius: 50 +DEAL:: +DEAL::Number of cells: 192 +DEAL::Number of vertices at inner radius: 194 +DEAL::Number of vertices at outer radius: 194 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 384 +DEAL::Number of vertices at inner radius: 386 +DEAL::Number of vertices at outer radius: 386 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 768 +DEAL::Number of vertices at inner radius: 770 +DEAL::Number of vertices at outer radius: 770 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 1536 +DEAL::Number of vertices at inner radius: 1538 +DEAL::Number of vertices at outer radius: 1538 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 3072 +DEAL::Number of vertices at inner radius: 3074 +DEAL::Number of vertices at outer radius: 3074 +DEAL::Number of vertices at other radius: 0 +DEAL:: +DEAL::Number of cells: 6144 +DEAL::Number of vertices at inner radius: 6146 +DEAL::Number of vertices at outer radius: 6146 +DEAL::Number of vertices at other radius: 0 +DEAL:: -- 2.39.5