From eee752025a35e40214899553e62a949771c3ff6d Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Mon, 19 Sep 2016 13:31:15 +0000 Subject: [PATCH] Added minimal test for projection manifold. --- tests/manifold/projection_manifold_01.cc | 75 ++++++++++++++++++++ tests/manifold/projection_manifold_01.output | 16 +++++ 2 files changed, 91 insertions(+) create mode 100644 tests/manifold/projection_manifold_01.cc create mode 100644 tests/manifold/projection_manifold_01.output diff --git a/tests/manifold/projection_manifold_01.cc b/tests/manifold/projection_manifold_01.cc new file mode 100644 index 0000000000..88c8635310 --- /dev/null +++ b/tests/manifold/projection_manifold_01.cc @@ -0,0 +1,75 @@ +//------------------------------------------------------------------- +// Copyright (C) 2016 by the deal.II authors. +// +// This file is subject to LGPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//------------------------------------------------------------------- + +// Test that a Manifold with projection only works + +#include "../tests.h" +#include +#include + + +// all include files you need here +#include +#include +#include +#include +#include +#include + +template +class MyManifold : public Manifold +{ +public: + Point + project_to_manifold (const std::vector > &vertices, + const Point &candidate) const + { + // Shift the y coordinate to 4*x*(1-x) + Point p = candidate; + if (spacedim > 1) + p[1] = 4*p[0]*(1-p[0]); + return p; + } +}; + +// Helper function +template +void test(unsigned int ref=1) +{ + deallog << "Testing dim=" << dim + << ", spacedim="<< spacedim << std::endl; + MyManifold manifold; + + // Test that we get the right thing with two simple points. + Point p0, p1; + p1[0] = 1.0; + + Point p2 = manifold.get_intermediate_point(p0,p1,.5); + deallog << "p2(0.5): " << p2 << std::endl; + + p2 = manifold.get_intermediate_point(p0,p1,.2); + deallog << "p2(0.2): " << p2 << std::endl; +} + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + test<1,1>(); + test<1,2>(); + test<2,2>(); + test<2,3>(); + test<3,3>(); + + return 0; +} + diff --git a/tests/manifold/projection_manifold_01.output b/tests/manifold/projection_manifold_01.output new file mode 100644 index 0000000000..358d988667 --- /dev/null +++ b/tests/manifold/projection_manifold_01.output @@ -0,0 +1,16 @@ + +DEAL::Testing dim=1, spacedim=1 +DEAL::p2(0.5): 0.500000 +DEAL::p2(0.2): 0.200000 +DEAL::Testing dim=1, spacedim=2 +DEAL::p2(0.5): 0.500000 1.00000 +DEAL::p2(0.2): 0.200000 0.640000 +DEAL::Testing dim=2, spacedim=2 +DEAL::p2(0.5): 0.500000 1.00000 +DEAL::p2(0.2): 0.200000 0.640000 +DEAL::Testing dim=2, spacedim=3 +DEAL::p2(0.5): 0.500000 1.00000 0.00000 +DEAL::p2(0.2): 0.200000 0.640000 0.00000 +DEAL::Testing dim=3, spacedim=3 +DEAL::p2(0.5): 0.500000 1.00000 0.00000 +DEAL::p2(0.2): 0.200000 0.640000 0.00000 -- 2.39.5