]> https://gitweb.dealii.org/ - dealii.git/commitdiff
added cell bb tests 11531/head
authorNicola Giuliani <ngiuliani@sissa.it>
Thu, 14 Jan 2021 08:28:19 +0000 (09:28 +0100)
committerNicola Giuliani <ngiuliani@sissa.it>
Thu, 14 Jan 2021 17:23:53 +0000 (18:23 +0100)
tests/simplex/cell_bounding_boxes_2d.cc [new file with mode: 0644]
tests/simplex/cell_bounding_boxes_2d.with_simplex_support=on.output [new file with mode: 0644]
tests/simplex/cell_bounding_boxes_3d.cc [new file with mode: 0644]
tests/simplex/cell_bounding_boxes_3d.with_simplex_support=on.output [new file with mode: 0644]

diff --git a/tests/simplex/cell_bounding_boxes_2d.cc b/tests/simplex/cell_bounding_boxes_2d.cc
new file mode 100644 (file)
index 0000000..182d5dd
--- /dev/null
@@ -0,0 +1,60 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2021 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 bounding box creation for simplex 2D tria.
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include "../tests.h"
+
+
+
+template <int dim>
+void
+create_simplex_grid(Triangulation<dim> &tria_simplex)
+{
+  tria_simplex.clear();
+  Triangulation<dim> tria_standard;
+  GridGenerator::hyper_cube(tria_standard);
+  GridGenerator::convert_hypercube_to_simplex_mesh(tria_standard, tria_simplex);
+}
+
+
+template <int dim>
+void
+compute_bounding_boxes(Triangulation<dim> &tria)
+{
+  for (const auto cell : tria.active_cell_iterators())
+    {
+      const auto cell_bb = cell->bounding_box();
+      deallog << "Center : " << cell_bb.center()
+              << " , volume : " << cell_bb.volume() << std::endl;
+    }
+}
+
+
+int
+main()
+{
+  initlog();
+  deallog << std::setprecision(5);
+  Triangulation<2> tria;
+  create_simplex_grid(tria);
+  compute_bounding_boxes(tria);
+}
diff --git a/tests/simplex/cell_bounding_boxes_2d.with_simplex_support=on.output b/tests/simplex/cell_bounding_boxes_2d.with_simplex_support=on.output
new file mode 100644 (file)
index 0000000..1b2e35c
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL::Center : 0.25000 0.25000 , volume : 0.25000
+DEAL::Center : 0.25000 0.25000 , volume : 0.25000
+DEAL::Center : 0.75000 0.25000 , volume : 0.25000
+DEAL::Center : 0.75000 0.25000 , volume : 0.25000
+DEAL::Center : 0.25000 0.75000 , volume : 0.25000
+DEAL::Center : 0.25000 0.75000 , volume : 0.25000
+DEAL::Center : 0.75000 0.75000 , volume : 0.25000
+DEAL::Center : 0.75000 0.75000 , volume : 0.25000
diff --git a/tests/simplex/cell_bounding_boxes_3d.cc b/tests/simplex/cell_bounding_boxes_3d.cc
new file mode 100644 (file)
index 0000000..227fd96
--- /dev/null
@@ -0,0 +1,60 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2021 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 bounding box creation for simplex 3D tria.
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include "../tests.h"
+
+
+
+template <int dim>
+void
+create_simplex_grid(Triangulation<dim> &tria_simplex)
+{
+  tria_simplex.clear();
+  Triangulation<dim> tria_standard;
+  GridGenerator::hyper_cube(tria_standard);
+  GridGenerator::convert_hypercube_to_simplex_mesh(tria_standard, tria_simplex);
+}
+
+
+template <int dim>
+void
+compute_bounding_boxes(Triangulation<dim> &tria)
+{
+  for (const auto cell : tria.active_cell_iterators())
+    {
+      const auto cell_bb = cell->bounding_box();
+      deallog << "Center : " << cell_bb.center()
+              << " , volume : " << cell_bb.volume() << std::endl;
+    }
+}
+
+
+int
+main()
+{
+  initlog();
+  deallog << std::setprecision(5);
+  Triangulation<3> tria;
+  create_simplex_grid(tria);
+  compute_bounding_boxes(tria);
+}
diff --git a/tests/simplex/cell_bounding_boxes_3d.with_simplex_support=on.output b/tests/simplex/cell_bounding_boxes_3d.with_simplex_support=on.output
new file mode 100644 (file)
index 0000000..56cc394
--- /dev/null
@@ -0,0 +1,25 @@
+
+DEAL::Center : 0.50000 0.25000 0.25000 , volume : 0.25000
+DEAL::Center : 0.50000 0.75000 0.25000 , volume : 0.25000
+DEAL::Center : 0.50000 0.75000 0.75000 , volume : 0.25000
+DEAL::Center : 0.50000 0.25000 0.75000 , volume : 0.25000
+DEAL::Center : 0.25000 0.50000 0.25000 , volume : 0.25000
+DEAL::Center : 0.25000 0.50000 0.75000 , volume : 0.25000
+DEAL::Center : 0.75000 0.50000 0.75000 , volume : 0.25000
+DEAL::Center : 0.75000 0.50000 0.25000 , volume : 0.25000
+DEAL::Center : 0.25000 0.25000 0.50000 , volume : 0.25000
+DEAL::Center : 0.75000 0.25000 0.50000 , volume : 0.25000
+DEAL::Center : 0.75000 0.75000 0.50000 , volume : 0.25000
+DEAL::Center : 0.25000 0.75000 0.50000 , volume : 0.25000
+DEAL::Center : 0.75000 0.25000 0.50000 , volume : 0.25000
+DEAL::Center : 0.75000 0.75000 0.50000 , volume : 0.25000
+DEAL::Center : 0.25000 0.75000 0.50000 , volume : 0.25000
+DEAL::Center : 0.25000 0.25000 0.50000 , volume : 0.25000
+DEAL::Center : 0.25000 0.25000 0.75000 , volume : 0.12500
+DEAL::Center : 0.75000 0.25000 0.75000 , volume : 0.12500
+DEAL::Center : 0.75000 0.75000 0.75000 , volume : 0.12500
+DEAL::Center : 0.25000 0.75000 0.75000 , volume : 0.12500
+DEAL::Center : 0.75000 0.25000 0.25000 , volume : 0.12500
+DEAL::Center : 0.75000 0.75000 0.25000 , volume : 0.12500
+DEAL::Center : 0.25000 0.75000 0.25000 , volume : 0.12500
+DEAL::Center : 0.25000 0.25000 0.25000 , volume : 0.12500

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.