]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test case. 5559/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 1 Dec 2017 08:42:33 +0000 (09:42 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 1 Dec 2017 08:44:09 +0000 (09:44 +0100)
tests/mappings/mapping_real_to_unit_q1_singular_02.cc [new file with mode: 0644]
tests/mappings/mapping_real_to_unit_q1_singular_02.output [new file with mode: 0644]

diff --git a/tests/mappings/mapping_real_to_unit_q1_singular_02.cc b/tests/mappings/mapping_real_to_unit_q1_singular_02.cc
new file mode 100644 (file)
index 0000000..d7fb721
--- /dev/null
@@ -0,0 +1,75 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check that MappingQ1::transform_real_to_unit_cell can handle the case of a
+// point which is close to a Cartesian mesh except for roundoff, which used to
+// create divisions by zero in an earlier implementation
+
+#include "../tests.h"
+
+#include <deal.II/base/utilities.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/fe/mapping_q1.h>
+
+
+void test_real_to_unit_cell()
+{
+  const unsigned int dim = 2;
+
+  Triangulation<dim>   triangulation;
+
+  std::vector<Point<dim> > points ({{
+      Point<dim>(-0.29999999999999999, -0.29999999999999999),
+      Point<dim>(-0.050000000000000003, -0.29999999999999999),
+      Point<dim>(-0.29999999999999999, -0.050000000000000003),
+      Point<dim>(-0.049999999999999989, -0.050000000000000003)
+    }
+  });
+  std::vector<CellData<dim> > cells(1);
+  cells[0].vertices[0] = 0;
+  cells[0].vertices[1] = 1;
+  cells[0].vertices[2] = 2;
+  cells[0].vertices[3] = 3;
+  cells[0].material_id = 0;
+  triangulation.create_triangulation (points, cells, SubCellData());
+
+  Point<dim> point(-0.29999999999999999, -0.29999999999999999);
+  MappingQGeneric<dim> mapping(1);
+
+  try
+    {
+      mapping.transform_real_to_unit_cell(triangulation.begin(), point);
+    }
+  catch (typename Mapping<dim>::ExcTransformationFailed)
+    {
+      deallog << "Transformation for point " << point << " on cell with "
+              << "center " << triangulation.begin()->center() << " is not invertible" << std::endl;
+    }
+  deallog << "OK" << std::endl;
+}
+
+
+int
+main()
+{
+  initlog();
+
+  test_real_to_unit_cell();
+
+  return 0;
+}
diff --git a/tests/mappings/mapping_real_to_unit_q1_singular_02.output b/tests/mappings/mapping_real_to_unit_q1_singular_02.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

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.