]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add test for invert_cells_with_negative_measure 13455/head
authorTimo Heister <timo.heister@gmail.com>
Sat, 26 Feb 2022 22:26:48 +0000 (17:26 -0500)
committerTimo Heister <timo.heister@gmail.com>
Sat, 26 Feb 2022 22:56:37 +0000 (17:56 -0500)
tests/grid/grid_invert_02.cc [new file with mode: 0644]
tests/grid/grid_invert_02.output [new file with mode: 0644]

diff --git a/tests/grid/grid_invert_02.cc b/tests/grid/grid_invert_02.cc
new file mode 100644 (file)
index 0000000..bc126e6
--- /dev/null
@@ -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 <deal.II/grid/grid_out.h>
+#include <deal.II/grid/grid_tools.h>
+
+#include <string>
+
+#include "../tests.h"
+
+void
+test()
+{
+  const static int        dim = 2;
+  std::vector<Point<dim>> 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<CellData<dim>> cells(2);
+  for (const unsigned int i : GeometryInfo<dim>::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<dim> 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 (file)
index 0000000..5ae4fc2
--- /dev/null
@@ -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 

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.