]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added periodicity getter to ChartManifold
authorLuca Heltai <luca.heltai@sissa.it>
Sun, 27 Mar 2016 18:19:23 +0000 (20:19 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Mon, 11 Apr 2016 07:41:41 +0000 (09:41 +0200)
include/deal.II/grid/manifold.h
include/deal.II/grid/manifold_tools.h
source/grid/manifold.cc
source/grid/manifold_tools.cc
tests/manifold/composition_manifold_04.cc
tests/manifold/composition_manifold_04.with_muparser=true.output

index f2af762e5502ac0cfa389e7c82f6160c3794a9e3..617cd427d4e1571b848b7733ff67464582dc25f6 100644 (file)
@@ -596,6 +596,11 @@ public:
   get_tangent_vector (const Point<spacedim> &x1,
                       const Point<spacedim> &x2) const;
 
+  /**
+   * Return the periodicity of this Manifold.
+   */
+  const Point<spacedim> &get_periodicity() const;
+
 private:
   /**
    * The periodicity of this Manifold. Periodicity affects the way a middle
@@ -848,6 +853,11 @@ public:
   get_tangent_vector (const Point<spacedim> &x1,
                       const Point<spacedim> &x2) const;
 
+  /**
+   * Return the periodicity associated with the submanifold.
+   */
+  const Point<chartdim> &get_periodicity() const;
+
 private:
   /**
    * The sub_manifold object is used to compute the average of the points in
index 21341d3f06385a9fda00fca238794b7401a57fe2..db19df7730835bb3fae3aa08dbfa57075b2a57c4 100644 (file)
@@ -34,7 +34,10 @@ DEAL_II_NAMESPACE_OPEN
  * CompositionManifold.  Take two ChartManifold objects, and make
  * their composition. The CompositionManifold object is a
  * ChartManifold going from the chart of the first ChartManifold to
- * the embedding space of the second ChartManifold.
+ * the embedding space of the second ChartManifold. If the first
+ * ChartManifold is periodic, so is the resulting ChartManifold, with
+ * the same periodicity. Notice however that periodicity on the second
+ * ChartManifold is lost during the composition.
  *
  * This class only works for dim <= chartdim <= intermediate_spacedim
  * <= spacedim. If you try to instantiate anything different, an
index 9bb7241592ad605c61ffb4f2d1453101b88a00a6..ae5e6d1ae04b27b1a527785d3c213801412bc7cb 100644 (file)
@@ -463,6 +463,15 @@ FlatManifold<dim, spacedim>::project_to_manifold (const std::vector<Point<spaced
 
 
 
+template <int dim, int spacedim>
+const Point<spacedim> &
+FlatManifold<dim, spacedim>::get_periodicity() const
+{
+  return periodicity;
+}
+
+
+
 template <int dim, int spacedim>
 Tensor<1,spacedim>
 FlatManifold<dim, spacedim>::get_tangent_vector (const Point<spacedim> &x1,
@@ -552,6 +561,13 @@ get_tangent_vector (const Point<spacedim> &x1,
   return result;
 }
 
+template <int dim, int spacedim, int chartdim>
+const Point<chartdim> &
+ChartManifold<dim,spacedim,chartdim>::
+get_periodicity() const
+{
+  return sub_manifold.get_periodicity();
+}
 
 // explicit instantiations
 #include "manifold.inst"
index 5cb2219fb8642eb87363b98f09e0f7cca1c45c1d..ac98682a5b77a3439a0ef4b8548bef4aaa826b22 100644 (file)
@@ -26,16 +26,22 @@ DEAL_II_NAMESPACE_OPEN
 
 /* -------------------------- CompositionManifold --------------------- */
 
-
-
 template <int dim, int spacedim, int chartdim, int intermediate_dim,
           int dim1, int dim2>
 CompositionManifold<dim,spacedim,chartdim,intermediate_dim,dim1,dim2>::CompositionManifold
 (const ChartManifold<dim1, intermediate_dim, chartdim> &F,
  const ChartManifold<dim2, spacedim, intermediate_dim> &G) :
+  ChartManifold<dim,spacedim,chartdim>(F.get_periodicity()),
   F(&F),
   G(&G)
-{}
+{
+  // We don't know what to do with a periodicity in the second manifold, so
+  // throw an assertion if the second manifold is periodic
+  Assert(G.get_periodicity().norm() == 0.0,
+         ExcMessage("The second manifold cannot be periodic."));
+}
+
+
 
 template <int dim, int spacedim, int chartdim, int intermediate_dim,
           int dim1, int dim2>
@@ -45,6 +51,8 @@ CompositionManifold<dim,spacedim,chartdim,intermediate_dim,dim1,dim2>::pull_back
   return F->pull_back(G->pull_back(space_point));
 }
 
+
+
 template <int dim, int spacedim, int chartdim, int intermediate_dim,
           int dim1, int dim2>
 Point<spacedim>
@@ -54,6 +62,7 @@ CompositionManifold<dim,spacedim,chartdim,intermediate_dim,dim1,dim2>::push_forw
 }
 
 
+
 template <int dim, int spacedim, int chartdim, int intermediate_dim,
           int dim1, int dim2>
 DerivativeForm<1,chartdim,spacedim>
@@ -76,6 +85,7 @@ CompositionManifold<dim,spacedim,chartdim,intermediate_dim,dim1,dim2>::push_forw
 }
 
 
+
 // explicit instantiations
 #include "manifold_tools.inst"
 
index c04f9a7ea346493f4ba45a3e45a1588e37fefdf5..107a5a2d55d64f86f67df53835f8e5fded106955 100644 (file)
@@ -9,7 +9,8 @@
 //---------------------------- composition_manifold ---------------------------
 
 
-// Stress periodicity in CompositionManifold
+// Stress periodicity in CompositionManifold. Compose SphericalManifold with
+// the identity, and make sure periodicity is respected.
 
 #include "../tests.h"
 #include <fstream>
@@ -57,57 +58,47 @@ int main ()
 
   unsigned int n_intermediates = 32;
 
-  for (unsigned int n=0; n<2; ++n)
+  out << "set terminal aqua " << 0 << std::endl
+      << "set size ratio -1" << std::endl
+      << "plot '-' with vectors " << std::endl;
+
+  for (unsigned int v=0; v<sp.size(); ++v)
+    out << center << " "
+        << sp[v] << std::endl;
+
+
+  for (unsigned int i=0; i<n_intermediates+1; ++i)
     {
-      if (n == 1)
-        {
-          sp.push_back(manifold.push_forward(Point<2>(1.0, numbers::PI/4)));
-          sp.push_back(manifold.push_forward(Point<2>(1.0, numbers::PI*3/4)));
-          w.push_back(0);
-          w.push_back(0);
-        }
-      out << "set terminal aqua " << n << std::endl
-          << "set size ratio -1" << std::endl
-          << "plot '-' with vectors " << std::endl;
-
-      for (unsigned int v=0; v<sp.size(); ++v)
-        out << center << " "
-            << sp[v] << std::endl;
-
-
-      for (unsigned int i=0; i<n_intermediates+1; ++i)
-        {
-          w[0] = 1.0-(double)i/((double)n_intermediates);
-          w[1] = 1.0 - w[0];
-
-          Point<spacedim> ip = manifold.get_new_point(Quadrature<spacedim>(sp, w));
-          Tensor<1,spacedim> t1 = manifold.get_tangent_vector(ip, sp[0]);
-          Tensor<1,spacedim> t2 = manifold.get_tangent_vector(ip, sp[1]);
-
-          out << ip << " "
-              << t2 << std::endl;
-        }
-
-      out << "e" << std::endl;
-
-      out << "set terminal aqua " << 2+n << std::endl
-          << "set size ratio -1" << std::endl
-          << "plot '-' w lp " << std::endl;
-
-      for (unsigned int i=0; i<n_intermediates+1; ++i)
-        {
-          w[0] = 1.0-(double)i/((double)n_intermediates);
-          w[1] = 1.0 - w[0];
-
-          Point<spacedim> ip = manifold.
-                               pull_back(manifold.get_new_point(Quadrature<spacedim>(sp, w)));
-
-          ip[0] = w[1];
-
-          out << ip << std::endl;
-        }
-      out << "e" << std::endl;
+      w[0] = 1.0-(double)i/((double)n_intermediates);
+      w[1] = 1.0 - w[0];
+
+      Point<spacedim> ip = manifold.get_new_point(Quadrature<spacedim>(sp, w));
+      Tensor<1,spacedim> t1 = manifold.get_tangent_vector(ip, sp[0]);
+      Tensor<1,spacedim> t2 = manifold.get_tangent_vector(ip, sp[1]);
+
+      out << ip << " "
+          << t2 << std::endl;
+    }
+
+  out << "e" << std::endl;
+
+  out << "set terminal aqua " << 1 << std::endl
+      << "set size ratio -1" << std::endl
+      << "plot '-' w lp " << std::endl;
+
+  for (unsigned int i=0; i<n_intermediates+1; ++i)
+    {
+      w[0] = 1.0-(double)i/((double)n_intermediates);
+      w[1] = 1.0 - w[0];
+
+      Point<spacedim> ip = manifold.
+                           pull_back(manifold.get_new_point(Quadrature<spacedim>(sp, w)));
+
+      ip[0] = w[1];
+
+      out << ip << std::endl;
     }
+  out << "e" << std::endl;
 
   return 0;
 }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fc1f411be930a34ecd41eb7fce3fdb7e57e39efa 100644 (file)
@@ -0,0 +1,77 @@
+
+set terminal aqua 0
+set size ratio -1
+plot '-' with vectors 
+0.00000 0.00000 0.707107 -0.707107
+0.00000 0.00000 0.707107 0.707107
+0.707107 -0.707107 1.11072 1.11072
+0.740951 -0.671559 1.02192 1.12751
+0.773010 -0.634393 0.934221 1.13835
+0.803208 -0.595699 0.847998 1.14339
+0.831470 -0.555570 0.763602 1.14281
+0.857729 -0.514103 0.681371 1.13680
+0.881921 -0.471397 0.601630 1.12557
+0.903989 -0.427555 0.524689 1.10936
+0.923880 -0.382683 0.450838 1.08842
+0.941544 -0.336890 0.380352 1.06301
+0.956940 -0.290285 0.313485 1.03342
+0.970031 -0.242980 0.250472 0.999942
+0.980785 -0.195090 0.191529 0.962884
+0.989177 -0.146730 0.136850 0.922566
+0.995185 -0.0980171 0.0866053 0.879318
+0.998795 -0.0490677 0.0409463 0.833480
+1.00000 -2.44929e-16 1.92367e-16 0.785398
+0.998795 0.0490677 -0.0361291 0.735424
+0.995185 0.0980171 -0.0673597 0.683914
+0.989177 0.146730 -0.0936340 0.631229
+0.980785 0.195090 -0.114918 0.577730
+0.970031 0.242980 -0.131200 0.523779
+0.956940 0.290285 -0.142493 0.469737
+0.941544 0.336890 -0.148833 0.415961
+0.923880 0.382683 -0.150279 0.362807
+0.903989 0.427555 -0.146913 0.310621
+0.881921 0.471397 -0.138838 0.259747
+0.857729 0.514103 -0.126180 0.210518
+0.831470 0.555570 -0.109086 0.163259
+0.803208 0.595699 -0.0877240 0.118282
+0.773010 0.634393 -0.0622814 0.0758901
+0.740951 0.671559 -0.0329651 0.0363714
+0.707107 0.707107 0.00000 0.00000
+e
+set terminal aqua 1
+set size ratio -1
+plot '-' w lp 
+0.00000 5.49779
+0.0312500 5.54687
+0.0625000 5.59596
+0.0937500 5.64505
+0.125000 5.69414
+0.156250 5.74322
+0.187500 5.79231
+0.218750 5.84140
+0.250000 5.89049
+0.281250 5.93957
+0.312500 5.98866
+0.343750 6.03775
+0.375000 6.08684
+0.406250 6.13592
+0.437500 6.18501
+0.468750 6.23410
+0.500000 6.28319
+0.531250 0.0490874
+0.562500 0.0981748
+0.593750 0.147262
+0.625000 0.196350
+0.656250 0.245437
+0.687500 0.294524
+0.718750 0.343612
+0.750000 0.392699
+0.781250 0.441786
+0.812500 0.490874
+0.843750 0.539961
+0.875000 0.589049
+0.906250 0.638136
+0.937500 0.687223
+0.968750 0.736311
+1.00000 0.785398
+e

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.