]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a bunch of tests for ChartManifold.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 4 Mar 2016 20:10:39 +0000 (14:10 -0600)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 4 Mar 2016 20:10:39 +0000 (14:10 -0600)
These test tangent directions for the simple case that the pull back
and push forward operations are the identity, or the identity on a
subspace (i.e., a projection).

tests/manifold/chart_manifold_05.cc [new file with mode: 0644]
tests/manifold/chart_manifold_05.output [new file with mode: 0644]
tests/manifold/chart_manifold_05_embedded.cc [new file with mode: 0644]
tests/manifold/chart_manifold_05_embedded.output [new file with mode: 0644]
tests/manifold/chart_manifold_06.cc [new file with mode: 0644]
tests/manifold/chart_manifold_06.output [new file with mode: 0644]
tests/manifold/chart_manifold_06_embedded.cc [new file with mode: 0644]
tests/manifold/chart_manifold_06_embedded.output [new file with mode: 0644]

diff --git a/tests/manifold/chart_manifold_05.cc b/tests/manifold/chart_manifold_05.cc
new file mode 100644 (file)
index 0000000..4e6f86e
--- /dev/null
@@ -0,0 +1,91 @@
+//-------------------------------------------------------------------
+//    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 direction vector of flat manifold without periodicity, where the
+// flat manifold is implemented as a ChartManifold with identity
+// pull-back and push-forward
+
+#include "../tests.h"
+#include <fstream>
+#include <deal.II/base/logstream.h>
+#include <deal.II/grid/manifold.h>
+
+
+template <int dim, int spacedim>
+class MyFlatManifold : public ChartManifold<dim,spacedim,spacedim>
+{
+public:
+  virtual
+  Point<spacedim>
+  pull_back(const Point<spacedim> &space_point) const
+  {
+    return space_point;
+  }
+
+
+  virtual
+  Point<spacedim>
+  push_forward(const Point<spacedim> &chart_point) const
+  {
+    return chart_point;
+  }
+
+  virtual
+  DerivativeForm<1,spacedim,spacedim>
+  push_forward_gradient(const Point<spacedim> &chart_point) const
+  {
+    DerivativeForm<1,spacedim,spacedim> x;
+    for (unsigned int d=0; d<spacedim; ++d)
+      x[d][d] = 1;
+    return x;
+  }
+};
+
+
+
+// Helper function
+template <int dim, int spacedim>
+void test()
+{
+  deallog << "Testing dim=" << dim
+          << ", spacedim="<< spacedim << std::endl;
+
+  MyFlatManifold<dim,spacedim> manifold;
+
+  Point<spacedim> x1, x2;
+  for (unsigned int d=0; d<spacedim; ++d)
+    {
+      x1[d] = 0.1;
+      x2[d] = 0.9;
+    }
+
+  // get the connecting vector between these two points. because we
+  // have no periodicity, this should simply be the vector with
+  // components all equal to 0.8
+  deallog << manifold.get_tangent_vector (x1, x2) << std::endl;
+}
+
+int main ()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  test<1,1>();
+  test<1,2>();
+  test<1,3>();
+  test<2,2>();
+  test<2,3>();
+  test<3,3>();
+
+  return 0;
+}
+
diff --git a/tests/manifold/chart_manifold_05.output b/tests/manifold/chart_manifold_05.output
new file mode 100644 (file)
index 0000000..7795db9
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL::Testing dim=1, spacedim=1
+DEAL::0.800000
+DEAL::Testing dim=1, spacedim=2
+DEAL::0.800000 0.800000
+DEAL::Testing dim=1, spacedim=3
+DEAL::0.800000 0.800000 0.800000
+DEAL::Testing dim=2, spacedim=2
+DEAL::0.800000 0.800000
+DEAL::Testing dim=2, spacedim=3
+DEAL::0.800000 0.800000 0.800000
+DEAL::Testing dim=3, spacedim=3
+DEAL::0.800000 0.800000 0.800000
diff --git a/tests/manifold/chart_manifold_05_embedded.cc b/tests/manifold/chart_manifold_05_embedded.cc
new file mode 100644 (file)
index 0000000..552854f
--- /dev/null
@@ -0,0 +1,96 @@
+//-------------------------------------------------------------------
+//    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 direction vector of flat manifold without periodicity, where the
+// flat manifold is implemented as a ChartManifold with identity
+// pull-back and push-forward
+//
+// make the chart higher dimensional
+
+#include "../tests.h"
+#include <fstream>
+#include <deal.II/base/logstream.h>
+#include <deal.II/grid/manifold.h>
+
+
+template <int dim, int spacedim>
+class MyFlatManifold : public ChartManifold<dim,spacedim,spacedim+1>
+{
+public:
+  virtual
+  Point<spacedim+1>
+  pull_back(const Point<spacedim> &space_point) const
+  {
+    Point<spacedim+1> p;
+    for (unsigned int d=0; d<spacedim; ++d)
+      p[d] = space_point[d];
+    return p;
+  }
+
+
+  virtual
+  Point<spacedim>
+  push_forward(const Point<spacedim+1> &chart_point) const
+  {
+    Point<spacedim> p;
+    for (unsigned int d=0; d<spacedim; ++d)
+      p[d] = chart_point[d];
+    return p;
+  }
+
+  virtual
+  DerivativeForm<1,spacedim+1,spacedim>
+  push_forward_gradient(const Point<spacedim+1> &chart_point) const
+  {
+    DerivativeForm<1,spacedim+1,spacedim> x;
+    for (unsigned int d=0; d<spacedim; ++d)
+      x[d][d] = 1;
+    return x;
+  }
+};
+
+
+
+// Helper function
+template <int dim, int spacedim>
+void test()
+{
+  deallog << "Testing dim=" << dim
+          << ", spacedim="<< spacedim << std::endl;
+
+  MyFlatManifold<dim,spacedim> manifold;
+
+  Point<spacedim> x1, x2;
+  for (unsigned int d=0; d<spacedim; ++d)
+    {
+      x1[d] = 0.1;
+      x2[d] = 0.9;
+    }
+
+  // get the connecting vector between these two points. because we
+  // have no periodicity, this should simply be the vector with
+  // components all equal to 0.8
+  deallog << manifold.get_tangent_vector (x1, x2) << 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>();
+
+  return 0;
+}
+
diff --git a/tests/manifold/chart_manifold_05_embedded.output b/tests/manifold/chart_manifold_05_embedded.output
new file mode 100644 (file)
index 0000000..2eba4fa
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::Testing dim=1, spacedim=1
+DEAL::0.800000
+DEAL::Testing dim=1, spacedim=2
+DEAL::0.800000 0.800000
+DEAL::Testing dim=2, spacedim=2
+DEAL::0.800000 0.800000
diff --git a/tests/manifold/chart_manifold_06.cc b/tests/manifold/chart_manifold_06.cc
new file mode 100644 (file)
index 0000000..fcd4432
--- /dev/null
@@ -0,0 +1,105 @@
+//-------------------------------------------------------------------
+//    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 direction vector of flat manifold with periodicity, where the
+// flat manifold is implemented as a ChartManifold with identity
+// pull-back and push-forward
+
+#include "../tests.h"
+#include <fstream>
+#include <deal.II/base/logstream.h>
+#include <deal.II/grid/manifold.h>
+
+
+
+template <int dim, int spacedim>
+class MyFlatManifold : public ChartManifold<dim,spacedim,spacedim>
+{
+public:
+  MyFlatManifold (const Point<spacedim> &periodicity)
+    :
+    ChartManifold<dim,spacedim,spacedim>(periodicity)
+  {}
+
+
+  virtual
+  Point<spacedim>
+  pull_back(const Point<spacedim> &space_point) const
+  {
+    return space_point;
+  }
+
+
+  virtual
+  Point<spacedim>
+  push_forward(const Point<spacedim> &chart_point) const
+  {
+    return chart_point;
+  }
+
+  virtual
+  DerivativeForm<1,spacedim,spacedim>
+  push_forward_gradient(const Point<spacedim> &chart_point) const
+  {
+    DerivativeForm<1,spacedim,spacedim> x;
+    for (unsigned int d=0; d<spacedim; ++d)
+      x[d][d] = 1;
+    return x;
+  }
+};
+
+
+
+
+// Helper function
+template <int dim, int spacedim>
+void test()
+{
+  deallog << "Testing dim=" << dim
+          << ", spacedim="<< spacedim << std::endl;
+
+  // make the domain periodic in the first direction with periodicity 1.1
+  Point<spacedim> periodicity;
+  periodicity[0] = 1.1;
+  MyFlatManifold<dim,spacedim> manifold(periodicity);
+
+  Point<spacedim> x1, x2;
+  for (unsigned int d=0; d<spacedim; ++d)
+    {
+      x1[d] = 0.1;
+      x2[d] = 0.9;
+    }
+
+  // get the connecting vector between these two points. because we
+  // have no periodicity, this should simply be the vector with
+  // components all equal to 0.8 except for the first, which ought to be -0.3
+  deallog << manifold.get_tangent_vector (x1, x2) << std::endl;
+
+  // then also test the opposite direction
+  deallog << manifold.get_tangent_vector (x2, x1) << std::endl;
+}
+
+int main ()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  test<1,1>();
+  test<1,2>();
+  test<1,3>();
+  test<2,2>();
+  test<2,3>();
+  test<3,3>();
+
+  return 0;
+}
+
diff --git a/tests/manifold/chart_manifold_06.output b/tests/manifold/chart_manifold_06.output
new file mode 100644 (file)
index 0000000..9e77f6a
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::Testing dim=1, spacedim=1
+DEAL::-0.300000
+DEAL::0.300000
+DEAL::Testing dim=1, spacedim=2
+DEAL::-0.300000 0.800000
+DEAL::0.300000 -0.800000
+DEAL::Testing dim=1, spacedim=3
+DEAL::-0.300000 0.800000 0.800000
+DEAL::0.300000 -0.800000 -0.800000
+DEAL::Testing dim=2, spacedim=2
+DEAL::-0.300000 0.800000
+DEAL::0.300000 -0.800000
+DEAL::Testing dim=2, spacedim=3
+DEAL::-0.300000 0.800000 0.800000
+DEAL::0.300000 -0.800000 -0.800000
+DEAL::Testing dim=3, spacedim=3
+DEAL::-0.300000 0.800000 0.800000
+DEAL::0.300000 -0.800000 -0.800000
diff --git a/tests/manifold/chart_manifold_06_embedded.cc b/tests/manifold/chart_manifold_06_embedded.cc
new file mode 100644 (file)
index 0000000..9d127b3
--- /dev/null
@@ -0,0 +1,109 @@
+//-------------------------------------------------------------------
+//    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 direction vector of flat manifold with periodicity, where the
+// flat manifold is implemented as a ChartManifold with identity
+// pull-back and push-forward
+//
+// make the chart higher dimensional
+
+#include "../tests.h"
+#include <fstream>
+#include <deal.II/base/logstream.h>
+#include <deal.II/grid/manifold.h>
+
+
+
+template <int dim, int spacedim>
+class MyFlatManifold : public ChartManifold<dim,spacedim,spacedim+1>
+{
+public:
+  MyFlatManifold (const Point<spacedim+1> &periodicity)
+    :
+    ChartManifold<dim,spacedim,spacedim+1>(periodicity)
+  {}
+
+  virtual
+  Point<spacedim+1>
+  pull_back(const Point<spacedim> &space_point) const
+  {
+    Point<spacedim+1> p;
+    for (unsigned int d=0; d<spacedim; ++d)
+      p[d] = space_point[d];
+    return p;
+  }
+
+
+  virtual
+  Point<spacedim>
+  push_forward(const Point<spacedim+1> &chart_point) const
+  {
+    Point<spacedim> p;
+    for (unsigned int d=0; d<spacedim; ++d)
+      p[d] = chart_point[d];
+    return p;
+  }
+
+  virtual
+  DerivativeForm<1,spacedim+1,spacedim>
+  push_forward_gradient(const Point<spacedim+1> &chart_point) const
+  {
+    DerivativeForm<1,spacedim+1,spacedim> x;
+    for (unsigned int d=0; d<spacedim; ++d)
+      x[d][d] = 1;
+    return x;
+  }
+};
+
+
+
+
+// Helper function
+template <int dim, int spacedim>
+void test()
+{
+  deallog << "Testing dim=" << dim
+          << ", spacedim="<< spacedim << std::endl;
+
+  // make the domain periodic in the first direction with periodicity 1.1
+  Point<spacedim+1> periodicity;
+  periodicity[0] = 1.1;
+  MyFlatManifold<dim,spacedim> manifold(periodicity);
+
+  Point<spacedim> x1, x2;
+  for (unsigned int d=0; d<spacedim; ++d)
+    {
+      x1[d] = 0.1;
+      x2[d] = 0.9;
+    }
+
+  // get the connecting vector between these two points. because we
+  // have no periodicity, this should simply be the vector with
+  // components all equal to 0.8 except for the first, which ought to be -0.3
+  deallog << manifold.get_tangent_vector (x1, x2) << std::endl;
+
+  // then also test the opposite direction
+  deallog << manifold.get_tangent_vector (x2, x1) << 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>();
+
+  return 0;
+}
+
diff --git a/tests/manifold/chart_manifold_06_embedded.output b/tests/manifold/chart_manifold_06_embedded.output
new file mode 100644 (file)
index 0000000..acf0f96
--- /dev/null
@@ -0,0 +1,10 @@
+
+DEAL::Testing dim=1, spacedim=1
+DEAL::-0.300000
+DEAL::0.300000
+DEAL::Testing dim=1, spacedim=2
+DEAL::-0.300000 0.800000
+DEAL::0.300000 -0.800000
+DEAL::Testing dim=2, spacedim=2
+DEAL::-0.300000 0.800000
+DEAL::0.300000 -0.800000

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.