From: Niklas Fehn Date: Wed, 16 Oct 2019 16:16:38 +0000 (+0200) Subject: add new test case X-Git-Tag: v9.2.0-rc1~975^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=deabb051e6caa40401e5d5f274aaa4ac1eb377ed;p=dealii.git add new test case --- diff --git a/tests/grid/grid_generator_open_torus.cc b/tests/grid/grid_generator_open_torus.cc new file mode 100644 index 0000000000..4f7a0dd87e --- /dev/null +++ b/tests/grid/grid_generator_open_torus.cc @@ -0,0 +1,107 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + +// Short test to validate GridGenerator::torus<3,3>() with angle < 2*pi +// To test that the grid and the manifolds are generated correctly for +// open torus, we compare the aspect ratio of a full torus and an open +// torus for meshes with the same number of elements per arc length. + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#include "../tests.h" + +using namespace dealii; + +void +test() +{ + Triangulation<3> tria; + unsigned int const n_cells_toroidal = 9; + double const angle = 2.0 * numbers::PI; + double const R = 3., r = 1.; + GridGenerator::torus(tria, R, r, n_cells_toroidal, angle); + + Triangulation<3> tria_open; + unsigned int const factor = 3; + GridGenerator::torus( + tria_open, R, r, n_cells_toroidal / factor, angle / (double)factor); + + MappingQGeneric<3> const mapping(3); + QGauss<3> const gauss(4); + + double const ar_full_torus = + GridTools::compute_maximum_aspect_ratio(tria, mapping, gauss); + double const ar_open_torus = + GridTools::compute_maximum_aspect_ratio(tria_open, mapping, gauss); + + deallog << "N_active_cells_full = " << tria.n_global_active_cells() + << std::endl; + deallog << "N_active_cells_open = " << tria_open.n_global_active_cells() + << std::endl; + deallog << "| AR_full - AR_open | = " + << std::abs(ar_full_torus - ar_open_torus) << std::endl; +} + +int +main(int argc, char **argv) +{ + initlog(); + deallog << std::scientific << std::setprecision(6); + + try + { + Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1); + + test(); + } + catch (std::exception &exc) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + } + catch (...) + { + std::cerr << std::endl + << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + } + + return 0; +} diff --git a/tests/grid/grid_generator_open_torus.output b/tests/grid/grid_generator_open_torus.output new file mode 100644 index 0000000000..5c32d714a8 --- /dev/null +++ b/tests/grid/grid_generator_open_torus.output @@ -0,0 +1,4 @@ + +DEAL::N_active_cells_full = 45 +DEAL::N_active_cells_open = 15 +DEAL::| AR_full - AR_open | = 0.000000e+00