]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add new test case
authorNiklas Fehn <fehn@lnm.mw.tum.de>
Wed, 16 Oct 2019 16:16:38 +0000 (18:16 +0200)
committerNiklas Fehn <fehn@lnm.mw.tum.de>
Wed, 16 Oct 2019 16:16:38 +0000 (18:16 +0200)
tests/grid/grid_generator_open_torus.cc [new file with mode: 0644]
tests/grid/grid_generator_open_torus.output [new file with mode: 0644]

diff --git a/tests/grid/grid_generator_open_torus.cc b/tests/grid/grid_generator_open_torus.cc
new file mode 100644 (file)
index 0000000..4f7a0dd
--- /dev/null
@@ -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 <deal.II/base/exceptions.h>
+#include <deal.II/base/mpi.h>
+#include <deal.II/base/partitioner.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/distributed/tria.h>
+
+#include <deal.II/fe/mapping_q_generic.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
+
+#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 (file)
index 0000000..5c32d71
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::N_active_cells_full = 45
+DEAL::N_active_cells_open = 15
+DEAL::| AR_full - AR_open | = 0.000000e+00

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.