From: Luca Heltai Date: Wed, 6 Apr 2016 15:20:23 +0000 (+0200) Subject: Periodicity as Tensor<1,spacedim>. X-Git-Tag: v8.5.0-rc1~1116^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0f24aaed598e5af2bcee3d99cfd7c7903366519;p=dealii.git Periodicity as Tensor<1,spacedim>. --- diff --git a/include/deal.II/grid/manifold.h b/include/deal.II/grid/manifold.h index 617cd427d4..b76e8be958 100644 --- a/include/deal.II/grid/manifold.h +++ b/include/deal.II/grid/manifold.h @@ -529,7 +529,7 @@ public: * guaranteed to lie in the periodicity box plus or minus * tolerance*periodicity.norm(). */ - FlatManifold (const Point &periodicity = Point(), + FlatManifold (const Tensor<1,spacedim> &periodicity = Tensor<1,spacedim>(), const double tolerance=1e-10); /** @@ -599,7 +599,7 @@ public: /** * Return the periodicity of this Manifold. */ - const Point &get_periodicity() const; + const Tensor<1,spacedim> &get_periodicity() const; private: /** @@ -615,12 +615,12 @@ private: * A periodicity 0 along one direction means no periodicity. This is the * default value for all directions. */ - const Point periodicity; + const Tensor<1,spacedim> periodicity; - DeclException4(ExcPeriodicBox, int, Point, Point, double, + DeclException4(ExcPeriodicBox, int, Point, double, double, << "The component number " << arg1 << " of the point [ " << arg2 << " ] is not in the interval [ " << -arg4 - << ", " << arg3[arg4] << "), bailing out."); + << ", " << arg3 << "), bailing out."); /** * Relative tolerance. This tolerance is used to compute distances in double @@ -736,7 +736,7 @@ public: * of (2*pi-eps) and (eps) is not pi, but 2*pi (or zero), since, on the * manifold, these two points are at distance 2*eps and not (2*pi-eps) */ - ChartManifold(const Point &periodicity = Point()); + ChartManifold(const Tensor<1,chartdim> &periodicity = Tensor<1,chartdim>()); /** * Destructor. Does nothing here, but needs to be declared to make it @@ -856,7 +856,7 @@ public: /** * Return the periodicity associated with the submanifold. */ - const Point &get_periodicity() const; + const Tensor<1,chartdim> &get_periodicity() const; private: /** diff --git a/include/deal.II/grid/manifold_lib.h b/include/deal.II/grid/manifold_lib.h index b366d1cc00..6be207102a 100644 --- a/include/deal.II/grid/manifold_lib.h +++ b/include/deal.II/grid/manifold_lib.h @@ -122,7 +122,7 @@ private: * Helper function which returns the periodicity associated with this * coordinate system, according to dim, chartdim, and spacedim. */ - static Point get_periodicity(); + static Tensor<1,spacedim> get_periodicity(); }; @@ -227,7 +227,7 @@ public: */ FunctionManifold(const Function &push_forward_function, const Function &pull_back_function, - const Point periodicity=Point(), + const Tensor<1,chartdim> &periodicity=Tensor<1,chartdim>(), const double tolerance=1e-10); /** @@ -246,7 +246,7 @@ public: */ FunctionManifold(const std::string push_forward_expression, const std::string pull_back_expression, - const Point periodicity=Point(), + const Tensor<1,chartdim> &periodicity=Tensor<1,chartdim>(), const typename FunctionParser::ConstMap = typename FunctionParser::ConstMap(), const std::string chart_vars=FunctionParser::default_variable_names(), const std::string space_vars=FunctionParser::default_variable_names(), diff --git a/source/grid/manifold.cc b/source/grid/manifold.cc index ae5e6d1ae0..bd9174d31f 100644 --- a/source/grid/manifold.cc +++ b/source/grid/manifold.cc @@ -399,7 +399,7 @@ Manifold::get_tangent_vector(const Point &x1, template -FlatManifold::FlatManifold (const Point &periodicity, +FlatManifold::FlatManifold (const Tensor<1,spacedim> &periodicity, const double tolerance) : periodicity(periodicity), @@ -417,16 +417,16 @@ get_new_point (const Quadrature &quad) const const std::vector > &surrounding_points = quad.get_points(); const std::vector &weights = quad.get_weights(); - Point minP = periodicity; + Tensor<1,spacedim> minP = periodicity; for (unsigned int d=0; d 0) for (unsigned int i=0; i= -tolerance*periodicity[d]), - ExcPeriodicBox(d, surrounding_points[i], periodicity, tolerance*periodicity[d])); + Assert( (surrounding_points[i][d] < periodicity[d]+tolerance*periodicity.norm()) || + (surrounding_points[i][d] >= -tolerance*periodicity.norm()), + ExcPeriodicBox(d, surrounding_points[i], periodicity[i], tolerance*periodicity.norm())); } // compute the weighted average point, possibly taking into account periodicity @@ -464,7 +464,7 @@ FlatManifold::project_to_manifold (const std::vector -const Point & +const Tensor<1,spacedim> & FlatManifold::get_periodicity() const { return periodicity; @@ -506,12 +506,13 @@ ChartManifold::~ChartManifold () template -ChartManifold::ChartManifold (const Point &periodicity) +ChartManifold::ChartManifold (const Tensor<1,chartdim> &periodicity) : sub_manifold(periodicity) {} + template Point ChartManifold:: @@ -544,6 +545,7 @@ push_forward_gradient(const Point &) const } + template Tensor<1,spacedim> ChartManifold:: @@ -561,10 +563,11 @@ get_tangent_vector (const Point &x1, return result; } + + template -const Point & -ChartManifold:: -get_periodicity() const +const Tensor<1, chartdim> & +ChartManifold::get_periodicity() const { return sub_manifold.get_periodicity(); } diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index ab23791e94..16ab8980c7 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -32,10 +32,10 @@ SphericalManifold::SphericalManifold(const Point center) template -Point +Tensor<1,spacedim> SphericalManifold::get_periodicity() { - Point periodicity; + Tensor<1,spacedim> periodicity; periodicity[spacedim-1] = 2*numbers::PI; // theta and phi period. return periodicity; } @@ -247,7 +247,7 @@ template FunctionManifold::FunctionManifold (const Function &push_forward_function, const Function &pull_back_function, - const Point periodicity, + const Tensor<1,chartdim> &periodicity, const double tolerance): ChartManifold(periodicity), push_forward_function(&push_forward_function), @@ -263,7 +263,7 @@ template FunctionManifold::FunctionManifold (const std::string push_forward_expression, const std::string pull_back_expression, - const Point periodicity, + const Tensor<1,chartdim> &periodicity, const typename FunctionParser::ConstMap const_map, const std::string chart_vars, const std::string space_vars, diff --git a/tests/manifold/chart_manifold_03.cc b/tests/manifold/chart_manifold_03.cc index dde1cf10f3..219bcc226c 100644 --- a/tests/manifold/chart_manifold_03.cc +++ b/tests/manifold/chart_manifold_03.cc @@ -31,7 +31,7 @@ template class MyFlatManifold : public ChartManifold { public: - MyFlatManifold (const Point &periodicity) + MyFlatManifold (const Tensor<1,spacedim> &periodicity) : ChartManifold (periodicity) {} @@ -72,7 +72,7 @@ void test(unsigned int ref=1) deallog << "Testing dim=" << dim << ", spacedim="<< spacedim << std::endl; - Point periodicity; + Tensor<1,spacedim> periodicity; periodicity[0] = 5.0; MyFlatManifold manifold(periodicity); diff --git a/tests/manifold/chart_manifold_03_embedded.cc b/tests/manifold/chart_manifold_03_embedded.cc index fb46426f1f..df653af9fe 100644 --- a/tests/manifold/chart_manifold_03_embedded.cc +++ b/tests/manifold/chart_manifold_03_embedded.cc @@ -33,7 +33,7 @@ template class MyFlatManifold : public ChartManifold { public: - MyFlatManifold (const Point &periodicity) + MyFlatManifold (const Tensor<1,spacedim+1> &periodicity) : ChartManifold (periodicity) {} @@ -80,7 +80,7 @@ void test(unsigned int ref=1) deallog << "Testing dim=" << dim << ", spacedim="<< spacedim << std::endl; - Point periodicity; + Tensor<1,spacedim+1> periodicity; periodicity[0] = 5.0; MyFlatManifold manifold(periodicity); diff --git a/tests/manifold/chart_manifold_06.cc b/tests/manifold/chart_manifold_06.cc index fcd443268f..487dfabde8 100644 --- a/tests/manifold/chart_manifold_06.cc +++ b/tests/manifold/chart_manifold_06.cc @@ -24,7 +24,7 @@ template class MyFlatManifold : public ChartManifold { public: - MyFlatManifold (const Point &periodicity) + MyFlatManifold (const Tensor<1,spacedim> &periodicity) : ChartManifold(periodicity) {} @@ -67,7 +67,7 @@ void test() << ", spacedim="<< spacedim << std::endl; // make the domain periodic in the first direction with periodicity 1.1 - Point periodicity; + Tensor<1,spacedim> periodicity; periodicity[0] = 1.1; MyFlatManifold manifold(periodicity); diff --git a/tests/manifold/chart_manifold_06_embedded.cc b/tests/manifold/chart_manifold_06_embedded.cc index 9d127b3b29..96a3789d06 100644 --- a/tests/manifold/chart_manifold_06_embedded.cc +++ b/tests/manifold/chart_manifold_06_embedded.cc @@ -26,7 +26,7 @@ template class MyFlatManifold : public ChartManifold { public: - MyFlatManifold (const Point &periodicity) + MyFlatManifold (const Tensor<1,spacedim+1> &periodicity) : ChartManifold(periodicity) {} @@ -74,7 +74,7 @@ void test() << ", spacedim="<< spacedim << std::endl; // make the domain periodic in the first direction with periodicity 1.1 - Point periodicity; + Tensor<1,spacedim+1> periodicity; periodicity[0] = 1.1; MyFlatManifold manifold(periodicity); diff --git a/tests/manifold/chart_manifold_08.cc b/tests/manifold/chart_manifold_08.cc index cbf2574408..3d0ca03838 100644 --- a/tests/manifold/chart_manifold_08.cc +++ b/tests/manifold/chart_manifold_08.cc @@ -19,9 +19,7 @@ #include -Point<3> periodicity (/*r=*/0, - /*phi=*/2*numbers::PI, - /*z=*/0); +Tensor<1,3> periodicity(static_cast >(Point<3>(0,2*numbers::PI,0))); class MyCylinderManifold : public ChartManifold<2,3,3> { diff --git a/tests/manifold/flat_manifold_03.cc b/tests/manifold/flat_manifold_03.cc index 2621541c2a..946142ac56 100644 --- a/tests/manifold/flat_manifold_03.cc +++ b/tests/manifold/flat_manifold_03.cc @@ -31,7 +31,7 @@ void test(unsigned int ref=1) deallog << "Testing dim=" << dim << ", spacedim="<< spacedim << std::endl; - Point periodicity; + Tensor<1,spacedim> periodicity; periodicity[0] = 5.0; FlatManifold manifold(periodicity); diff --git a/tests/manifold/flat_manifold_06.cc b/tests/manifold/flat_manifold_06.cc index 6e7f853169..770552420c 100644 --- a/tests/manifold/flat_manifold_06.cc +++ b/tests/manifold/flat_manifold_06.cc @@ -25,7 +25,7 @@ void test() << ", spacedim="<< spacedim << std::endl; // make the domain periodic in the first direction with periodicity 1.1 - Point periodicity; + Tensor<1,spacedim> periodicity; periodicity[0] = 1.1; FlatManifold manifold(periodicity);