From 88bebfc3c16daf3b92968b57f17ede735086b7d6 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 1 Dec 2017 09:42:33 +0100 Subject: [PATCH] Add test case. --- .../mapping_real_to_unit_q1_singular_02.cc | 75 +++++++++++++++++++ ...mapping_real_to_unit_q1_singular_02.output | 2 + 2 files changed, 77 insertions(+) create mode 100644 tests/mappings/mapping_real_to_unit_q1_singular_02.cc create mode 100644 tests/mappings/mapping_real_to_unit_q1_singular_02.output 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 index 0000000000..d7fb72116b --- /dev/null +++ b/tests/mappings/mapping_real_to_unit_q1_singular_02.cc @@ -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 +#include +#include +#include + + +void test_real_to_unit_cell() +{ + const unsigned int dim = 2; + + Triangulation triangulation; + + std::vector > points ({{ + Point(-0.29999999999999999, -0.29999999999999999), + Point(-0.050000000000000003, -0.29999999999999999), + Point(-0.29999999999999999, -0.050000000000000003), + Point(-0.049999999999999989, -0.050000000000000003) + } + }); + std::vector > 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 point(-0.29999999999999999, -0.29999999999999999); + MappingQGeneric mapping(1); + + try + { + mapping.transform_real_to_unit_cell(triangulation.begin(), point); + } + catch (typename Mapping::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 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/mappings/mapping_real_to_unit_q1_singular_02.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5