From: Luca Heltai Date: Sun, 27 Mar 2016 18:19:23 +0000 (+0200) Subject: Added periodicity getter to ChartManifold X-Git-Tag: v8.5.0-rc1~1116^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=921f346b66cdc56b0407e14189c4319148373e8b;p=dealii.git Added periodicity getter to ChartManifold --- diff --git a/include/deal.II/grid/manifold.h b/include/deal.II/grid/manifold.h index f2af762e55..617cd427d4 100644 --- a/include/deal.II/grid/manifold.h +++ b/include/deal.II/grid/manifold.h @@ -596,6 +596,11 @@ public: get_tangent_vector (const Point &x1, const Point &x2) const; + /** + * Return the periodicity of this Manifold. + */ + const Point &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 &x1, const Point &x2) const; + /** + * Return the periodicity associated with the submanifold. + */ + const Point &get_periodicity() const; + private: /** * The sub_manifold object is used to compute the average of the points in diff --git a/include/deal.II/grid/manifold_tools.h b/include/deal.II/grid/manifold_tools.h index 21341d3f06..db19df7730 100644 --- a/include/deal.II/grid/manifold_tools.h +++ b/include/deal.II/grid/manifold_tools.h @@ -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 diff --git a/source/grid/manifold.cc b/source/grid/manifold.cc index 9bb7241592..ae5e6d1ae0 100644 --- a/source/grid/manifold.cc +++ b/source/grid/manifold.cc @@ -463,6 +463,15 @@ FlatManifold::project_to_manifold (const std::vector +const Point & +FlatManifold::get_periodicity() const +{ + return periodicity; +} + + + template Tensor<1,spacedim> FlatManifold::get_tangent_vector (const Point &x1, @@ -552,6 +561,13 @@ get_tangent_vector (const Point &x1, return result; } +template +const Point & +ChartManifold:: +get_periodicity() const +{ + return sub_manifold.get_periodicity(); +} // explicit instantiations #include "manifold.inst" diff --git a/source/grid/manifold_tools.cc b/source/grid/manifold_tools.cc index 5cb2219fb8..ac98682a5b 100644 --- a/source/grid/manifold_tools.cc +++ b/source/grid/manifold_tools.cc @@ -26,16 +26,22 @@ DEAL_II_NAMESPACE_OPEN /* -------------------------- CompositionManifold --------------------- */ - - template CompositionManifold::CompositionManifold (const ChartManifold &F, const ChartManifold &G) : + ChartManifold(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 @@ -45,6 +51,8 @@ CompositionManifold::pull_back return F->pull_back(G->pull_back(space_point)); } + + template Point @@ -54,6 +62,7 @@ CompositionManifold::push_forw } + template DerivativeForm<1,chartdim,spacedim> @@ -76,6 +85,7 @@ CompositionManifold::push_forw } + // explicit instantiations #include "manifold_tools.inst" diff --git a/tests/manifold/composition_manifold_04.cc b/tests/manifold/composition_manifold_04.cc index c04f9a7ea3..107a5a2d55 100644 --- a/tests/manifold/composition_manifold_04.cc +++ b/tests/manifold/composition_manifold_04.cc @@ -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 @@ -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(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 ip = manifold.get_new_point(Quadrature(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 ip = manifold. - pull_back(manifold.get_new_point(Quadrature(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 ip = manifold.get_new_point(Quadrature(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 ip = manifold. + pull_back(manifold.get_new_point(Quadrature(sp, w))); + + ip[0] = w[1]; + + out << ip << std::endl; } + out << "e" << std::endl; return 0; } diff --git a/tests/manifold/composition_manifold_04.with_muparser=true.output b/tests/manifold/composition_manifold_04.with_muparser=true.output index e69de29bb2..fc1f411be9 100644 --- a/tests/manifold/composition_manifold_04.with_muparser=true.output +++ b/tests/manifold/composition_manifold_04.with_muparser=true.output @@ -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