From 1480060f05c0ed879c74a18c6a5476dd674a21c5 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Mon, 24 Feb 2020 15:09:27 -0500 Subject: [PATCH] Add test --- tests/manifold/polar_manifold_09.cc | 76 ++++++++ tests/manifold/polar_manifold_09.output | 241 ++++++++++++++++++++++++ 2 files changed, 317 insertions(+) create mode 100644 tests/manifold/polar_manifold_09.cc create mode 100644 tests/manifold/polar_manifold_09.output diff --git a/tests/manifold/polar_manifold_09.cc b/tests/manifold/polar_manifold_09.cc new file mode 100644 index 0000000000..f4e578824e --- /dev/null +++ b/tests/manifold/polar_manifold_09.cc @@ -0,0 +1,76 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 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. +// +// --------------------------------------------------------------------- + +// Check PolarManifold for normal vector issues. The PolarManifold +// should produce the same normal vector as the SphericalManifold in 2D, +// in particular for points at the same radius. + +#include +#include + +#include +#include + +#include "../tests.h" + + +int +main() +{ + initlog(); + + // Center and radius of the Ball + + const PolarManifold<2, 2> polar_manifold; + const SphericalManifold<2, 2> spherical_manifold; + + Triangulation<2, 2> tria; + GridGenerator::hyper_shell(tria, Point<2>(), .3, .6, 12); + + tria.set_manifold(1, polar_manifold); + + for (typename Triangulation<2, 2>::active_cell_iterator cell = + tria.begin_active(); + cell != tria.end(); + ++cell) + { + cell->set_all_manifold_ids(1); + } + + for (typename Triangulation<2, 2>::active_cell_iterator cell = + tria.begin_active(); + cell != tria.end(); + ++cell) + { + for (unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; ++f) + { + const Point<2> position = cell->face(f)->center(); + const Tensor<1, 2> polar_normal = + polar_manifold.normal_vector(cell->face(f), position); + const Tensor<1, 2> spherical_normal = + spherical_manifold.normal_vector(cell->face(f), position); + deallog << "Position: " << position << std::endl; + deallog << "Polar normal: " << polar_normal << std::endl; + deallog << "Spherical normal: " << spherical_normal << std::endl; + deallog << "Relative difference: " + << (polar_normal - spherical_normal).norm() / + polar_normal.norm() + << std::endl + << std::endl; + } + } + + return 0; +} diff --git a/tests/manifold/polar_manifold_09.output b/tests/manifold/polar_manifold_09.output new file mode 100644 index 0000000000..674d7c796d --- /dev/null +++ b/tests/manifold/polar_manifold_09.output @@ -0,0 +1,241 @@ + +DEAL::Position: 0.450000 0.00000 +DEAL::Polar normal: 0.00000 1.00000 +DEAL::Spherical normal: 0.00000 1.00000 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.389711 0.225000 +DEAL::Polar normal: -0.500000 0.866025 +DEAL::Spherical normal: -0.500000 0.866025 +DEAL::Relative difference: 5.55112e-17 +DEAL:: +DEAL::Position: 0.559808 0.150000 +DEAL::Polar normal: 0.965926 0.258819 +DEAL::Spherical normal: 0.965926 0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.279904 0.0750000 +DEAL::Polar normal: 0.965926 0.258819 +DEAL::Spherical normal: 0.965926 0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.389711 0.225000 +DEAL::Polar normal: -0.500000 0.866025 +DEAL::Spherical normal: -0.500000 0.866025 +DEAL::Relative difference: 5.55112e-17 +DEAL:: +DEAL::Position: 0.225000 0.389711 +DEAL::Polar normal: -0.866025 0.500000 +DEAL::Spherical normal: -0.866025 0.500000 +DEAL::Relative difference: 1.11022e-16 +DEAL:: +DEAL::Position: 0.409808 0.409808 +DEAL::Polar normal: 0.707107 0.707107 +DEAL::Spherical normal: 0.707107 0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.204904 0.204904 +DEAL::Polar normal: 0.707107 0.707107 +DEAL::Spherical normal: 0.707107 0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.225000 0.389711 +DEAL::Polar normal: -0.866025 0.500000 +DEAL::Spherical normal: -0.866025 0.500000 +DEAL::Relative difference: 1.11022e-16 +DEAL:: +DEAL::Position: 2.75546e-17 0.450000 +DEAL::Polar normal: -1.00000 6.12323e-17 +DEAL::Spherical normal: -1.00000 6.12323e-17 +DEAL::Relative difference: 1.23260e-32 +DEAL:: +DEAL::Position: 0.150000 0.559808 +DEAL::Polar normal: 0.258819 0.965926 +DEAL::Spherical normal: 0.258819 0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.0750000 0.279904 +DEAL::Polar normal: 0.258819 0.965926 +DEAL::Spherical normal: 0.258819 0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 2.75546e-17 0.450000 +DEAL::Polar normal: -1.00000 6.12323e-17 +DEAL::Spherical normal: -1.00000 6.12323e-17 +DEAL::Relative difference: 1.23260e-32 +DEAL:: +DEAL::Position: -0.225000 0.389711 +DEAL::Polar normal: -0.866025 -0.500000 +DEAL::Spherical normal: -0.866025 -0.500000 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.150000 0.559808 +DEAL::Polar normal: -0.258819 0.965926 +DEAL::Spherical normal: -0.258819 0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.0750000 0.279904 +DEAL::Polar normal: -0.258819 0.965926 +DEAL::Spherical normal: -0.258819 0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.225000 0.389711 +DEAL::Polar normal: -0.866025 -0.500000 +DEAL::Spherical normal: -0.866025 -0.500000 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.389711 0.225000 +DEAL::Polar normal: -0.500000 -0.866025 +DEAL::Spherical normal: -0.500000 -0.866025 +DEAL::Relative difference: 5.55112e-17 +DEAL:: +DEAL::Position: -0.409808 0.409808 +DEAL::Polar normal: -0.707107 0.707107 +DEAL::Spherical normal: -0.707107 0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.204904 0.204904 +DEAL::Polar normal: -0.707107 0.707107 +DEAL::Spherical normal: -0.707107 0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.389711 0.225000 +DEAL::Polar normal: -0.500000 -0.866025 +DEAL::Spherical normal: -0.500000 -0.866025 +DEAL::Relative difference: 5.55112e-17 +DEAL:: +DEAL::Position: -0.450000 5.51091e-17 +DEAL::Polar normal: -1.22465e-16 -1.00000 +DEAL::Spherical normal: -1.22465e-16 -1.00000 +DEAL::Relative difference: 2.46519e-32 +DEAL:: +DEAL::Position: -0.559808 0.150000 +DEAL::Polar normal: -0.965926 0.258819 +DEAL::Spherical normal: -0.965926 0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.279904 0.0750000 +DEAL::Polar normal: -0.965926 0.258819 +DEAL::Spherical normal: -0.965926 0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.450000 5.51091e-17 +DEAL::Polar normal: -1.22465e-16 -1.00000 +DEAL::Spherical normal: -1.22465e-16 -1.00000 +DEAL::Relative difference: 2.46519e-32 +DEAL:: +DEAL::Position: -0.389711 -0.225000 +DEAL::Polar normal: 0.500000 -0.866025 +DEAL::Spherical normal: 0.500000 -0.866025 +DEAL::Relative difference: 4.00297e-16 +DEAL:: +DEAL::Position: -0.559808 -0.150000 +DEAL::Polar normal: -0.965926 -0.258819 +DEAL::Spherical normal: -0.965926 -0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.279904 -0.0750000 +DEAL::Polar normal: -0.965926 -0.258819 +DEAL::Spherical normal: -0.965926 -0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.389711 -0.225000 +DEAL::Polar normal: 0.500000 -0.866025 +DEAL::Spherical normal: 0.500000 -0.866025 +DEAL::Relative difference: 4.00297e-16 +DEAL:: +DEAL::Position: -0.225000 -0.389711 +DEAL::Polar normal: 0.866025 -0.500000 +DEAL::Spherical normal: 0.866025 -0.500000 +DEAL::Relative difference: 8.95090e-16 +DEAL:: +DEAL::Position: -0.409808 -0.409808 +DEAL::Polar normal: -0.707107 -0.707107 +DEAL::Spherical normal: -0.707107 -0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.204904 -0.204904 +DEAL::Polar normal: -0.707107 -0.707107 +DEAL::Spherical normal: -0.707107 -0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.225000 -0.389711 +DEAL::Polar normal: 0.866025 -0.500000 +DEAL::Spherical normal: 0.866025 -0.500000 +DEAL::Relative difference: 8.95090e-16 +DEAL:: +DEAL::Position: -8.26637e-17 -0.450000 +DEAL::Polar normal: 1.00000 -1.83697e-16 +DEAL::Spherical normal: 1.00000 -1.83697e-16 +DEAL::Relative difference: 2.46519e-32 +DEAL:: +DEAL::Position: -0.150000 -0.559808 +DEAL::Polar normal: -0.258819 -0.965926 +DEAL::Spherical normal: -0.258819 -0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -0.0750000 -0.279904 +DEAL::Polar normal: -0.258819 -0.965926 +DEAL::Spherical normal: -0.258819 -0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: -8.26637e-17 -0.450000 +DEAL::Polar normal: 1.00000 -1.83697e-16 +DEAL::Spherical normal: 1.00000 -1.83697e-16 +DEAL::Relative difference: 2.46519e-32 +DEAL:: +DEAL::Position: 0.225000 -0.389711 +DEAL::Polar normal: 0.866025 0.500000 +DEAL::Spherical normal: 0.866025 0.500000 +DEAL::Relative difference: 1.11022e-16 +DEAL:: +DEAL::Position: 0.150000 -0.559808 +DEAL::Polar normal: 0.258819 -0.965926 +DEAL::Spherical normal: 0.258819 -0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.0750000 -0.279904 +DEAL::Polar normal: 0.258819 -0.965926 +DEAL::Spherical normal: 0.258819 -0.965926 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.225000 -0.389711 +DEAL::Polar normal: 0.866025 0.500000 +DEAL::Spherical normal: 0.866025 0.500000 +DEAL::Relative difference: 1.11022e-16 +DEAL:: +DEAL::Position: 0.389711 -0.225000 +DEAL::Polar normal: 0.500000 0.866025 +DEAL::Spherical normal: 0.500000 0.866025 +DEAL::Relative difference: 1.11022e-16 +DEAL:: +DEAL::Position: 0.409808 -0.409808 +DEAL::Polar normal: 0.707107 -0.707107 +DEAL::Spherical normal: 0.707107 -0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.204904 -0.204904 +DEAL::Polar normal: 0.707107 -0.707107 +DEAL::Spherical normal: 0.707107 -0.707107 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.389711 -0.225000 +DEAL::Polar normal: 0.500000 0.866025 +DEAL::Spherical normal: 0.500000 0.866025 +DEAL::Relative difference: 1.11022e-16 +DEAL:: +DEAL::Position: 0.450000 0.00000 +DEAL::Polar normal: 0.00000 1.00000 +DEAL::Spherical normal: 0.00000 1.00000 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.559808 -0.150000 +DEAL::Polar normal: 0.965926 -0.258819 +DEAL::Spherical normal: 0.965926 -0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: +DEAL::Position: 0.279904 -0.0750000 +DEAL::Polar normal: 0.965926 -0.258819 +DEAL::Spherical normal: 0.965926 -0.258819 +DEAL::Relative difference: 0.00000 +DEAL:: -- 2.39.5