From 38d757306e87fc15e8819be1370d96e68668f278 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Tue, 5 Mar 2019 18:41:39 +0100 Subject: [PATCH] Add test for cylindrical manifold --- tests/manifold/cylindrical_manifold_03.cc | 75 +++++++++++++++++++ tests/manifold/cylindrical_manifold_03.output | 4 + 2 files changed, 79 insertions(+) create mode 100644 tests/manifold/cylindrical_manifold_03.cc create mode 100644 tests/manifold/cylindrical_manifold_03.output diff --git a/tests/manifold/cylindrical_manifold_03.cc b/tests/manifold/cylindrical_manifold_03.cc new file mode 100644 index 0000000000..ec2994904b --- /dev/null +++ b/tests/manifold/cylindrical_manifold_03.cc @@ -0,0 +1,75 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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 cylindrical manifold for the mid point axis of a cylinder + +#include "../tests.h" + + +// all include files you need here +#include + + + +int +main() +{ + initlog(); + deallog << std::setprecision(10); + + Tensor<1, 3> axis({0.0, 0.0, 1.0}); + const Point<3> origin(1.0, 2.0, 3.0); + + // the larger the tolerance value, the more likely we identify the mid point + const double tolerance = 1e-6; + + const CylindricalManifold<3> cylinder(axis, origin, tolerance); + + // take two points symmetric about cylinder axis + const double offset = 1.0; + std::vector> surrounding_points_vector( + {Point<3>(origin[0] + offset, origin[1], origin[2]), + Point<3>(origin[0] - offset, origin[1], origin[2])}); + const ArrayView> surrounding_points = + make_array_view(surrounding_points_vector); + const std::vector weights_vector({0.5, 0.5}); + const ArrayView weights = make_array_view(weights_vector); + + deallog << "New point is at " + << cylinder.get_new_point(surrounding_points, weights) + << " and it should be " << origin << std::endl; + + surrounding_points_vector[0][2] = -1; + surrounding_points_vector[1][2] = -1; + + deallog << "New point is at " + << cylinder.get_new_point(surrounding_points, weights) + << " and it should be " << Point<3>(origin[0], origin[1], -1.0) + << std::endl; + + axis[0] = 0.3; + axis[1] = 0.6; + axis[2] = 0.8; + + surrounding_points_vector[0][2] = origin[2]; + surrounding_points_vector[1][2] = origin[2]; + + const CylindricalManifold<3> second_cylinder(axis, origin, tolerance); + deallog << "New point is at " + << second_cylinder.get_new_point(surrounding_points, weights) + << " and it should be " << origin << std::endl; + + return 0; +} diff --git a/tests/manifold/cylindrical_manifold_03.output b/tests/manifold/cylindrical_manifold_03.output new file mode 100644 index 0000000000..87c17c1da5 --- /dev/null +++ b/tests/manifold/cylindrical_manifold_03.output @@ -0,0 +1,4 @@ + +DEAL::New point is at 1.000000000 2.000000000 3.000000000 and it should be 1.000000000 2.000000000 3.000000000 +DEAL::New point is at 1.000000000 2.000000000 -1.000000000 and it should be 1.000000000 2.000000000 -1.000000000 +DEAL::New point is at 1.000000000 2.000000000 3.000000000 and it should be 1.000000000 2.000000000 3.000000000 -- 2.39.5