]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added minimal test for projection manifold.
authorLuca Heltai <luca.heltai@sissa.it>
Mon, 19 Sep 2016 13:31:15 +0000 (13:31 +0000)
committerLuca Heltai <luca.heltai@sissa.it>
Mon, 19 Sep 2016 13:40:00 +0000 (13:40 +0000)
tests/manifold/projection_manifold_01.cc [new file with mode: 0644]
tests/manifold/projection_manifold_01.output [new file with mode: 0644]

diff --git a/tests/manifold/projection_manifold_01.cc b/tests/manifold/projection_manifold_01.cc
new file mode 100644 (file)
index 0000000..88c8635
--- /dev/null
@@ -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 <fstream>
+#include <deal.II/base/logstream.h>
+
+
+// all include files you need here
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria_boundary_lib.h>
+#include <deal.II/grid/grid_out.h>
+
+template <int dim, int spacedim>
+class MyManifold : public Manifold<dim, spacedim>
+{
+public:
+  Point<spacedim>
+  project_to_manifold (const std::vector<Point<spacedim> > &vertices,
+                       const Point<spacedim> &candidate) const
+  {
+    // Shift the y coordinate to 4*x*(1-x)
+    Point<spacedim> p = candidate;
+    if (spacedim > 1)
+      p[1] = 4*p[0]*(1-p[0]);
+    return p;
+  }
+};
+
+// Helper function
+template <int dim, int spacedim>
+void test(unsigned int ref=1)
+{
+  deallog << "Testing dim=" << dim
+          << ", spacedim="<< spacedim << std::endl;
+  MyManifold<dim,spacedim> manifold;
+
+  // Test that we get the right thing with two simple points.
+  Point<spacedim> p0, p1;
+  p1[0] = 1.0;
+
+  Point<spacedim> 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 (file)
index 0000000..358d988
--- /dev/null
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.