From 0f9abbd1d784c6a1fa70e5bb484138b1c4e972cc Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sat, 26 Feb 2022 17:26:48 -0500 Subject: [PATCH] add test for invert_cells_with_negative_measure --- tests/grid/grid_invert_02.cc | 79 ++++++++++++++++++++++++++++++++ tests/grid/grid_invert_02.output | 20 ++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/grid/grid_invert_02.cc create mode 100644 tests/grid/grid_invert_02.output diff --git a/tests/grid/grid_invert_02.cc b/tests/grid/grid_invert_02.cc new file mode 100644 index 0000000000..bc126e6f07 --- /dev/null +++ b/tests/grid/grid_invert_02.cc @@ -0,0 +1,79 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2002 - 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 GridTools::invert_cells_with_negative_measure + +/* + vertex layout: + + 1 3 5 + + 0 2 4 + */ + +#include +#include + +#include + +#include "../tests.h" + +void +test() +{ + const static int dim = 2; + std::vector> vertices(6); + vertices[1](1) = 1; + vertices[2](0) = 1; + vertices[3](0) = 1; + vertices[3](1) = 1; + vertices[4](0) = 2; + vertices[5](0) = 2; + vertices[5](1) = 1; + + std::vector> cells(2); + for (const unsigned int i : GeometryInfo::vertex_indices()) + cells[0].vertices[i] = i; + cells[1].vertices[0] = 2; + cells[1].vertices[1] = 4; + cells[1].vertices[2] = 3; + cells[1].vertices[3] = 5; + + SubCellData subcelldata; + const std::size_t n_cells_inverted = + GridTools::invert_cells_with_negative_measure<>(vertices, cells); + + deallog << "We inverted " << n_cells_inverted << " cells." << std::endl; + + Triangulation tria; + tria.create_triangulation_compatibility(vertices, cells, subcelldata); + + std::ostream &logfile = deallog.get_file_stream(); + logfile << "---------------------------------------------" << std::endl + << std::endl + << std::endl; + + GridOut grid_out; + grid_out.set_flags(GridOutFlags::Ucd(true)); + grid_out.write_ucd(tria, logfile); +} + +int +main() +{ + initlog(false, std::ios_base::fmtflags()); + test(); +} diff --git a/tests/grid/grid_invert_02.output b/tests/grid/grid_invert_02.output new file mode 100644 index 0000000000..5ae4fc2608 --- /dev/null +++ b/tests/grid/grid_invert_02.output @@ -0,0 +1,20 @@ + +DEAL::We inverted 1 cells. +--------------------------------------------- + + +# This file was generated by the deal.II library. + + +# +# For a description of the UCD format see the AVS Developer's guide. +# +6 2 0 0 0 +1 0 0 0 +2 0 1 0 +3 1 0 0 +4 1 1 0 +5 2 0 0 +6 2 1 0 +1 0 quad 1 3 2 4 +2 0 quad 3 5 4 6 -- 2.39.5