From: Martin Kronbichler Date: Sat, 2 Dec 2017 10:04:25 +0000 (+0100) Subject: Add two manifold tests for normal vectors. X-Git-Tag: v9.0.0-rc1~691^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6a2a089a002017ab2e8c8418ae4b6a510657990;p=dealii.git Add two manifold tests for normal vectors. --- diff --git a/tests/manifold/spherical_manifold_09.cc b/tests/manifold/spherical_manifold_09.cc new file mode 100644 index 0000000000..0f752934b1 --- /dev/null +++ b/tests/manifold/spherical_manifold_09.cc @@ -0,0 +1,93 @@ +// --------------------------------------------------------------------- +// +// 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 SphericalManifold::normal_vector on a set of points of a +// hypersphere mesh + +#include "../tests.h" +#include +#include +#include +#include + +using namespace dealii; + +int +main() +{ + initlog(); + deallog << std::setprecision(3); + + constexpr unsigned int dim = 3; + SphericalManifold<3> spherical; + + Triangulation tria; + GridGenerator::hyper_shell(tria, Point(), 0.5, 1., 96, true); + tria.set_all_manifold_ids(0); + tria.set_manifold(0, spherical); + + for (auto cell : tria.active_cell_iterators()) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->at_boundary(f)) + { + if (std::abs(cell->face(f)->vertex(1).norm()-1.) < 1e-12) + { + // at outer boundary, the normal should point outwards and be + // aligned with the point down to roundoff. Check this for the + // second face vertex as well as the center. + deallog << "Outer normal correctness (should be 0): " + << (1.0 - cell->face(f)->vertex(1) * + spherical.normal_vector(cell->face(f), cell->face(f)->vertex(1))) + << " " + << (1.0 - cell->face(f)->center(/*respect_manifold=*/true) * + spherical.normal_vector(cell->face(f), cell->face(f)->center(true))) + << std::endl; + } + else if (std::abs(cell->face(f)->vertex(1).norm()-0.5) < 1e-12) + { + // at inner boundary, the normal should point inwards and be + // aligned with the point down to roundoff. Check this for the + // second face vertex as well as the center. + deallog << "Inner normal correctness (should be 0): " + << (0.5 - cell->face(f)->vertex(1) * + spherical.normal_vector(cell->face(f), cell->face(f)->vertex(1))) + << " " + << (0.5 - cell->face(f)->center(/*respect_manifold=*/true) * + spherical.normal_vector(cell->face(f), cell->face(f)->center(true))) + << std::endl; + } + } + for (auto cell : tria.active_cell_iterators()) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->at_boundary(f)) + { + // the first choice will contain perturbations in the normal because + // the center without respecting the manifold is not on the face to + // which the algorithm computes its points. As an alternative, we + // adjust the point to lie on the same radius as the vertex points + // by a weighting where the normal should again be perfectly aligned + // with the point itself. + deallog << "Approximate normal in " + << cell->face(f)->center(false) << ": " + << spherical.normal_vector(cell->face(f), cell->face(f)->center(false)) + << ", adjusted: " + << spherical.normal_vector(cell->face(f), + cell->face(f)->center(false)/cell->face(f)->center(false).norm() + *cell->face(f)->vertex(1).norm()) + << std::endl; + } + + return 0; +} diff --git a/tests/manifold/spherical_manifold_09.output b/tests/manifold/spherical_manifold_09.output new file mode 100644 index 0000000000..454a47f46a --- /dev/null +++ b/tests/manifold/spherical_manifold_09.output @@ -0,0 +1,193 @@ + +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 0.00 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 0.00 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 2.22e-16 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 5.55e-17 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 1.11e-16 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 0.00 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 0.00 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 2.22e-16 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 5.55e-17 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 1.11e-16 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): -1.11e-16 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 5.55e-17 -1.11e-16 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): -2.22e-16 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 1.11e-16 -2.22e-16 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Inner normal correctness (should be 0): 5.55e-17 0.00 +DEAL::Inner normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Outer normal correctness (should be 0): 1.11e-16 0.00 +DEAL::Outer normal correctness (should be 0): 0.00 0.00 +DEAL::Approximate normal in -0.170 -0.435 0.00: -0.519 -0.833 -0.193, adjusted: -0.363 -0.932 -2.53e-17 +DEAL::Approximate normal in -0.312 -0.312 0.153: -0.801 -0.592 0.0902, adjusted: -0.668 -0.668 0.328 +DEAL::Approximate normal in -0.312 -0.312 -0.153: -0.801 -0.592 -0.0902, adjusted: -0.668 -0.668 -0.328 +DEAL::Approximate normal in -0.435 -0.170 0.00: -0.833 -0.519 -0.193, adjusted: -0.932 -0.363 -1.58e-16 +DEAL::Approximate normal in -0.339 -0.871 0.00: -0.519 -0.833 -0.193, adjusted: -0.363 -0.932 -2.53e-17 +DEAL::Approximate normal in -0.624 -0.624 0.307: -0.801 -0.592 0.0902, adjusted: -0.668 -0.668 0.328 +DEAL::Approximate normal in -0.624 -0.624 -0.307: -0.801 -0.592 -0.0902, adjusted: -0.668 -0.668 -0.328 +DEAL::Approximate normal in -0.871 -0.339 0.00: -0.833 -0.519 -0.193, adjusted: -0.932 -0.363 -1.58e-16 +DEAL::Approximate normal in -0.312 -0.153 0.312: -0.801 -0.0902 0.592, adjusted: -0.668 -0.328 0.668 +DEAL::Approximate normal in -0.170 -6.94e-18 0.435: -0.519 0.193 0.833, adjusted: -0.363 -1.87e-16 0.932 +DEAL::Approximate normal in -0.435 -6.94e-18 0.170: -0.833 0.193 0.519, adjusted: -0.932 1.58e-16 0.363 +DEAL::Approximate normal in -0.312 0.153 0.312: -0.801 0.0902 0.592, adjusted: -0.668 0.328 0.668 +DEAL::Approximate normal in -0.624 -0.307 0.624: -0.801 -0.0902 0.592, adjusted: -0.668 -0.328 0.668 +DEAL::Approximate normal in -0.339 -1.39e-17 0.871: -0.519 0.193 0.833, adjusted: -0.363 -1.87e-16 0.932 +DEAL::Approximate normal in -0.871 -1.39e-17 0.339: -0.833 0.193 0.519, adjusted: -0.932 1.58e-16 0.363 +DEAL::Approximate normal in -0.624 0.307 0.624: -0.801 0.0902 0.592, adjusted: -0.668 0.328 0.668 +DEAL::Approximate normal in 0.00 -0.435 0.170: -0.193 -0.833 0.519, adjusted: -2.53e-17 -0.932 0.363 +DEAL::Approximate normal in 0.153 -0.312 0.312: 0.0902 -0.592 0.801, adjusted: 0.328 -0.668 0.668 +DEAL::Approximate normal in -0.153 -0.312 0.312: -0.0902 -0.592 0.801, adjusted: -0.328 -0.668 0.668 +DEAL::Approximate normal in 0.00 -0.170 0.435: -0.193 -0.519 0.833, adjusted: -1.58e-16 -0.363 0.932 +DEAL::Approximate normal in 0.00 -0.871 0.339: -0.193 -0.833 0.519, adjusted: -2.53e-17 -0.932 0.363 +DEAL::Approximate normal in 0.307 -0.624 0.624: 0.0902 -0.592 0.801, adjusted: 0.328 -0.668 0.668 +DEAL::Approximate normal in -0.307 -0.624 0.624: -0.0902 -0.592 0.801, adjusted: -0.328 -0.668 0.668 +DEAL::Approximate normal in 0.00 -0.339 0.871: -0.193 -0.519 0.833, adjusted: -1.58e-16 -0.363 0.932 +DEAL::Approximate normal in 0.312 -0.312 -0.153: 0.592 -0.801 -0.0902, adjusted: 0.668 -0.668 -0.328 +DEAL::Approximate normal in 0.435 -0.170 -6.94e-18: 0.833 -0.519 0.193, adjusted: 0.932 -0.363 -1.87e-16 +DEAL::Approximate normal in 0.170 -0.435 -6.94e-18: 0.519 -0.833 0.193, adjusted: 0.363 -0.932 1.58e-16 +DEAL::Approximate normal in 0.312 -0.312 0.153: 0.592 -0.801 0.0902, adjusted: 0.668 -0.668 0.328 +DEAL::Approximate normal in 0.624 -0.624 -0.307: 0.592 -0.801 -0.0902, adjusted: 0.668 -0.668 -0.328 +DEAL::Approximate normal in 0.871 -0.339 -1.39e-17: 0.833 -0.519 0.193, adjusted: 0.932 -0.363 -1.87e-16 +DEAL::Approximate normal in 0.339 -0.871 -1.39e-17: 0.519 -0.833 0.193, adjusted: 0.363 -0.932 1.58e-16 +DEAL::Approximate normal in 0.624 -0.624 0.307: 0.592 -0.801 0.0902, adjusted: 0.668 -0.668 0.328 +DEAL::Approximate normal in 0.435 0.00 0.170: 0.833 -0.193 0.519, adjusted: 0.932 -2.53e-17 0.363 +DEAL::Approximate normal in 0.312 0.153 0.312: 0.592 0.0902 0.801, adjusted: 0.668 0.328 0.668 +DEAL::Approximate normal in 0.312 -0.153 0.312: 0.592 -0.0902 0.801, adjusted: 0.668 -0.328 0.668 +DEAL::Approximate normal in 0.170 0.00 0.435: 0.519 -0.193 0.833, adjusted: 0.363 -1.58e-16 0.932 +DEAL::Approximate normal in 0.871 0.00 0.339: 0.833 -0.193 0.519, adjusted: 0.932 -2.53e-17 0.363 +DEAL::Approximate normal in 0.624 0.307 0.624: 0.592 0.0902 0.801, adjusted: 0.668 0.328 0.668 +DEAL::Approximate normal in 0.624 -0.307 0.624: 0.592 -0.0902 0.801, adjusted: 0.668 -0.328 0.668 +DEAL::Approximate normal in 0.339 0.00 0.871: 0.519 -0.193 0.833, adjusted: 0.363 -1.58e-16 0.932 +DEAL::Approximate normal in 0.153 0.312 0.312: 0.0902 0.592 0.801, adjusted: 0.328 0.668 0.668 +DEAL::Approximate normal in 6.94e-18 0.435 0.170: -0.193 0.833 0.519, adjusted: 1.87e-16 0.932 0.363 +DEAL::Approximate normal in 6.94e-18 0.170 0.435: -0.193 0.519 0.833, adjusted: -1.58e-16 0.363 0.932 +DEAL::Approximate normal in -0.153 0.312 0.312: -0.0902 0.592 0.801, adjusted: -0.328 0.668 0.668 +DEAL::Approximate normal in 0.307 0.624 0.624: 0.0902 0.592 0.801, adjusted: 0.328 0.668 0.668 +DEAL::Approximate normal in 1.39e-17 0.871 0.339: -0.193 0.833 0.519, adjusted: 1.87e-16 0.932 0.363 +DEAL::Approximate normal in 1.39e-17 0.339 0.871: -0.193 0.519 0.833, adjusted: -1.58e-16 0.363 0.932 +DEAL::Approximate normal in -0.307 0.624 0.624: -0.0902 0.592 0.801, adjusted: -0.328 0.668 0.668 +DEAL::Approximate normal in 0.435 0.170 0.00: 0.833 0.519 0.193, adjusted: 0.932 0.363 2.53e-17 +DEAL::Approximate normal in 0.312 0.312 -0.153: 0.592 0.801 -0.0902, adjusted: 0.668 0.668 -0.328 +DEAL::Approximate normal in 0.312 0.312 0.153: 0.592 0.801 0.0902, adjusted: 0.668 0.668 0.328 +DEAL::Approximate normal in 0.170 0.435 0.00: 0.519 0.833 0.193, adjusted: 0.363 0.932 1.58e-16 +DEAL::Approximate normal in 0.871 0.339 0.00: 0.833 0.519 0.193, adjusted: 0.932 0.363 2.53e-17 +DEAL::Approximate normal in 0.624 0.624 -0.307: 0.592 0.801 -0.0902, adjusted: 0.668 0.668 -0.328 +DEAL::Approximate normal in 0.624 0.624 0.307: 0.592 0.801 0.0902, adjusted: 0.668 0.668 0.328 +DEAL::Approximate normal in 0.339 0.871 0.00: 0.519 0.833 0.193, adjusted: 0.363 0.932 1.58e-16 +DEAL::Approximate normal in 0.312 -0.153 -0.312: 0.801 -0.0902 -0.592, adjusted: 0.668 -0.328 -0.668 +DEAL::Approximate normal in 0.170 -6.94e-18 -0.435: 0.519 0.193 -0.833, adjusted: 0.363 -1.87e-16 -0.932 +DEAL::Approximate normal in 0.435 -6.94e-18 -0.170: 0.833 0.193 -0.519, adjusted: 0.932 1.58e-16 -0.363 +DEAL::Approximate normal in 0.312 0.153 -0.312: 0.801 0.0902 -0.592, adjusted: 0.668 0.328 -0.668 +DEAL::Approximate normal in 0.624 -0.307 -0.624: 0.801 -0.0902 -0.592, adjusted: 0.668 -0.328 -0.668 +DEAL::Approximate normal in 0.339 -1.39e-17 -0.871: 0.519 0.193 -0.833, adjusted: 0.363 -1.87e-16 -0.932 +DEAL::Approximate normal in 0.871 -1.39e-17 -0.339: 0.833 0.193 -0.519, adjusted: 0.932 1.58e-16 -0.363 +DEAL::Approximate normal in 0.624 0.307 -0.624: 0.801 0.0902 -0.592, adjusted: 0.668 0.328 -0.668 +DEAL::Approximate normal in 0.00 0.170 -0.435: 0.193 0.519 -0.833, adjusted: 4.18e-16 0.363 -0.932 +DEAL::Approximate normal in -0.153 0.312 -0.312: -0.0902 0.801 -0.592, adjusted: -0.328 0.668 -0.668 +DEAL::Approximate normal in 0.153 0.312 -0.312: 0.0902 0.801 -0.592, adjusted: 0.328 0.668 -0.668 +DEAL::Approximate normal in 0.00 0.435 -0.170: 0.193 0.833 -0.519, adjusted: 1.58e-16 0.932 -0.363 +DEAL::Approximate normal in 0.00 0.339 -0.871: 0.193 0.519 -0.833, adjusted: 4.18e-16 0.363 -0.932 +DEAL::Approximate normal in -0.307 0.624 -0.624: -0.0902 0.801 -0.592, adjusted: -0.328 0.668 -0.668 +DEAL::Approximate normal in 0.307 0.624 -0.624: 0.0902 0.801 -0.592, adjusted: 0.328 0.668 -0.668 +DEAL::Approximate normal in 0.00 0.871 -0.339: 0.193 0.833 -0.519, adjusted: 1.58e-16 0.932 -0.363 +DEAL::Approximate normal in -0.312 0.312 -0.153: -0.592 0.801 -0.0902, adjusted: -0.668 0.668 -0.328 +DEAL::Approximate normal in -0.435 0.170 -6.94e-18: -0.833 0.519 0.193, adjusted: -0.932 0.363 -1.87e-16 +DEAL::Approximate normal in -0.170 0.435 -6.94e-18: -0.519 0.833 0.193, adjusted: -0.363 0.932 1.58e-16 +DEAL::Approximate normal in -0.312 0.312 0.153: -0.592 0.801 0.0902, adjusted: -0.668 0.668 0.328 +DEAL::Approximate normal in -0.624 0.624 -0.307: -0.592 0.801 -0.0902, adjusted: -0.668 0.668 -0.328 +DEAL::Approximate normal in -0.871 0.339 -1.39e-17: -0.833 0.519 0.193, adjusted: -0.932 0.363 -1.87e-16 +DEAL::Approximate normal in -0.339 0.871 -1.39e-17: -0.519 0.833 0.193, adjusted: -0.363 0.932 1.58e-16 +DEAL::Approximate normal in -0.624 0.624 0.307: -0.592 0.801 0.0902, adjusted: -0.668 0.668 0.328 +DEAL::Approximate normal in -0.170 0.00 -0.435: -0.519 0.193 -0.833, adjusted: -0.363 4.18e-16 -0.932 +DEAL::Approximate normal in -0.312 -0.153 -0.312: -0.801 -0.0902 -0.592, adjusted: -0.668 -0.328 -0.668 +DEAL::Approximate normal in -0.312 0.153 -0.312: -0.801 0.0902 -0.592, adjusted: -0.668 0.328 -0.668 +DEAL::Approximate normal in -0.435 0.00 -0.170: -0.833 0.193 -0.519, adjusted: -0.932 1.58e-16 -0.363 +DEAL::Approximate normal in -0.339 0.00 -0.871: -0.519 0.193 -0.833, adjusted: -0.363 4.18e-16 -0.932 +DEAL::Approximate normal in -0.624 -0.307 -0.624: -0.801 -0.0902 -0.592, adjusted: -0.668 -0.328 -0.668 +DEAL::Approximate normal in -0.624 0.307 -0.624: -0.801 0.0902 -0.592, adjusted: -0.668 0.328 -0.668 +DEAL::Approximate normal in -0.871 0.00 -0.339: -0.833 0.193 -0.519, adjusted: -0.932 1.58e-16 -0.363 +DEAL::Approximate normal in 0.153 -0.312 -0.312: 0.0902 -0.592 -0.801, adjusted: 0.328 -0.668 -0.668 +DEAL::Approximate normal in 6.94e-18 -0.435 -0.170: -0.193 -0.833 -0.519, adjusted: 1.87e-16 -0.932 -0.363 +DEAL::Approximate normal in 6.94e-18 -0.170 -0.435: -0.193 -0.519 -0.833, adjusted: -1.58e-16 -0.363 -0.932 +DEAL::Approximate normal in -0.153 -0.312 -0.312: -0.0902 -0.592 -0.801, adjusted: -0.328 -0.668 -0.668 +DEAL::Approximate normal in 0.307 -0.624 -0.624: 0.0902 -0.592 -0.801, adjusted: 0.328 -0.668 -0.668 +DEAL::Approximate normal in 1.39e-17 -0.871 -0.339: -0.193 -0.833 -0.519, adjusted: 1.87e-16 -0.932 -0.363 +DEAL::Approximate normal in 1.39e-17 -0.339 -0.871: -0.193 -0.519 -0.833, adjusted: -1.58e-16 -0.363 -0.932 +DEAL::Approximate normal in -0.307 -0.624 -0.624: -0.0902 -0.592 -0.801, adjusted: -0.328 -0.668 -0.668 diff --git a/tests/manifold/spherical_manifold_10.cc b/tests/manifold/spherical_manifold_10.cc new file mode 100644 index 0000000000..911b73c075 --- /dev/null +++ b/tests/manifold/spherical_manifold_10.cc @@ -0,0 +1,74 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + +// Compare SphericalManifold::normal_vector with the result of +// FEFaceValues::normal_vector. Those should give very similar results, but an +// old implementation in the manifold gave wrong points + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace dealii; + +int +main() +{ + initlog(); + deallog << std::setprecision(8); + + constexpr unsigned int dim = 3; + SphericalManifold<3> spherical; + + Triangulation tria; + GridGenerator::hyper_shell(tria, Point(), 0.5, 1., 96, true); + tria.set_all_manifold_ids(0); + tria.set_manifold(0, spherical); + + MappingQGeneric mapping(4); + QGaussLobatto quadrature(4); + FE_Nothing dummy; + FEFaceValues fe_values(mapping, dummy, quadrature, + update_normal_vectors | update_quadrature_points); + + for (auto cell : tria.active_cell_iterators()) + for (unsigned int f=0; f::faces_per_cell; ++f) + { + fe_values.reinit(cell, f); + + // all points should coincide to an accuracy of at least 1e-8 (note + // that we use a 4-th degree mapping, so its accuracy on the 96 cell + // version of the sphere should but be enough) + const double tolerance = 1e-8; + for (unsigned int q=0; q normal_manifold = + spherical.normal_vector(cell->face(f), fe_values.quadrature_point(q)); + const Tensor<1,dim> normal_feval = fe_values.normal_vector(q); + if (std::abs(1.0 - std::abs(normal_manifold * normal_feval)) > tolerance) + deallog << "Error in point " << fe_values.quadrature_point(q) << ": " + << "FEFaceValues says " << normal_feval << " but manifold says " + << normal_manifold << std::endl; + } + } + deallog << "OK" << std::endl; + + return 0; +} diff --git a/tests/manifold/spherical_manifold_10.output b/tests/manifold/spherical_manifold_10.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/manifold/spherical_manifold_10.output @@ -0,0 +1,2 @@ + +DEAL::OK