From 7bf912ea20f025cf4b0fdeb81ac2615555a28d4e Mon Sep 17 00:00:00 2001 From: Nicola Giuliani Date: Thu, 14 Jan 2021 09:28:19 +0100 Subject: [PATCH] added cell bb tests --- tests/simplex/cell_bounding_boxes_2d.cc | 60 +++++++++++++++++++ ...ng_boxes_2d.with_simplex_support=on.output | 9 +++ tests/simplex/cell_bounding_boxes_3d.cc | 60 +++++++++++++++++++ ...ng_boxes_3d.with_simplex_support=on.output | 25 ++++++++ 4 files changed, 154 insertions(+) create mode 100644 tests/simplex/cell_bounding_boxes_2d.cc create mode 100644 tests/simplex/cell_bounding_boxes_2d.with_simplex_support=on.output create mode 100644 tests/simplex/cell_bounding_boxes_3d.cc create mode 100644 tests/simplex/cell_bounding_boxes_3d.with_simplex_support=on.output diff --git a/tests/simplex/cell_bounding_boxes_2d.cc b/tests/simplex/cell_bounding_boxes_2d.cc new file mode 100644 index 0000000000..182d5dd47d --- /dev/null +++ b/tests/simplex/cell_bounding_boxes_2d.cc @@ -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 +#include +#include +#include + +#include "../tests.h" + + + +template +void +create_simplex_grid(Triangulation &tria_simplex) +{ + tria_simplex.clear(); + Triangulation tria_standard; + GridGenerator::hyper_cube(tria_standard); + GridGenerator::convert_hypercube_to_simplex_mesh(tria_standard, tria_simplex); +} + + +template +void +compute_bounding_boxes(Triangulation &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 index 0000000000..1b2e35c283 --- /dev/null +++ b/tests/simplex/cell_bounding_boxes_2d.with_simplex_support=on.output @@ -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 index 0000000000..227fd9687e --- /dev/null +++ b/tests/simplex/cell_bounding_boxes_3d.cc @@ -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 +#include +#include +#include + +#include "../tests.h" + + + +template +void +create_simplex_grid(Triangulation &tria_simplex) +{ + tria_simplex.clear(); + Triangulation tria_standard; + GridGenerator::hyper_cube(tria_standard); + GridGenerator::convert_hypercube_to_simplex_mesh(tria_standard, tria_simplex); +} + + +template +void +compute_bounding_boxes(Triangulation &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 index 0000000000..56cc394a83 --- /dev/null +++ b/tests/simplex/cell_bounding_boxes_3d.with_simplex_support=on.output @@ -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 -- 2.39.5