From 16e1ea6421bf4213bee25554386cba04cbd169ec Mon Sep 17 00:00:00 2001 From: heltai Date: Wed, 21 Aug 2013 15:59:11 +0000 Subject: [PATCH] Added manifold_lib.cc git-svn-id: https://svn.dealii.org/branches/branch_manifold_id@30375 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-1/step-1.cc | 8 +-- deal.II/include/deal.II/grid/manifold.h | 51 ++++++++++++++++++ deal.II/include/deal.II/grid/manifold_lib.h | 22 ++++++++ deal.II/source/grid/manifold.cc | 25 +++++++++ deal.II/source/grid/manifold_lib.cc | 58 +++++++++++++++++++++ 5 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 deal.II/source/grid/manifold_lib.cc diff --git a/deal.II/examples/step-1/step-1.cc b/deal.II/examples/step-1/step-1.cc index 09599c7935..6019451d59 100644 --- a/deal.II/examples/step-1/step-1.cc +++ b/deal.II/examples/step-1/step-1.cc @@ -73,9 +73,9 @@ void first_grid () // Now we want to write a graphical representation of the mesh to an output // file. The GridOut class of deal.II can do that in a number of different // output formats; here, we choose encapsulated postscript (eps) format: - std::ofstream out ("grid-1.eps"); + std::ofstream out ("grid-1.msh"); GridOut grid_out; - grid_out.write_eps (triangulation, out); + grid_out.write_msh (triangulation, out); } @@ -187,9 +187,9 @@ void second_grid () // Finally, after these five iterations of refinement, we want to again // write the resulting mesh to a file, again in eps format. This works just // as above: - std::ofstream out ("grid-2.eps"); + std::ofstream out ("grid-2.msh"); GridOut grid_out; - grid_out.write_eps (triangulation, out); + grid_out.write_msh (triangulation, out); // At this point, all objects created in this function will be destroyed in diff --git a/deal.II/include/deal.II/grid/manifold.h b/deal.II/include/deal.II/grid/manifold.h index 8354314640..922d7d1cab 100644 --- a/deal.II/include/deal.II/grid/manifold.h +++ b/deal.II/include/deal.II/grid/manifold.h @@ -160,6 +160,57 @@ public: }; +/** + * A chart of dimension dim, which is part of a Manifold. + * This object specializes a Manifold of dimension dim embedded in a + * manifold of dimension spacedim, for which you have an explicit + * pull_back and push_forward transformations. + * + * @ingroup manifold + * + * @author Luca Heltai, 2013 + */ +template +class ManifoldChart: public Manifold +{ +public: + + /** + * Destructor. Does nothing here, but + * needs to be declared to make it + * virtual. + */ + virtual ~ManifoldChart (); + + + /** + * Let the new point be the + * arithmetic mean of the two + * vertices of the line. + * + * Refer to the general + * documentation of this class + * and the documentation of the + * base class for more + * information. + */ + virtual Point + get_new_point(const std::vector > &surrounding_points, + const std::vector &weights) const; + + virtual Point + pull_back(const Point space_point) const = 0; + + virtual Point + push_forward(const Point chart_point) const = 0; + + + private: + FlatManifold sub_manifold; + std::vector > chart_points; +}; + + /* -------------- declaration of explicit specializations ------------- */ diff --git a/deal.II/include/deal.II/grid/manifold_lib.h b/deal.II/include/deal.II/grid/manifold_lib.h index 7bd1cf5e29..2aab365c68 100644 --- a/deal.II/include/deal.II/grid/manifold_lib.h +++ b/deal.II/include/deal.II/grid/manifold_lib.h @@ -22,6 +22,28 @@ #include DEAL_II_NAMESPACE_OPEN + + +/** + * Manifold description for a polar space coordinate system. Given any + * two points in space, tranform them in polar coordinate centered at + * center, compute intermediate points in polar coordinate systems, + * and returns its space representation. + */ +template +class PolarManifold : public FlatManifold +{ + public: + PolarManifold(const Point center = Point()); + + virtual Point + get_new_point (const std::vector > &surrounding_points, + const std::vector &weights) const; + + private: + Point center; +} + // // /** // * Boundary object for the hull of a cylinder. In three dimensions, diff --git a/deal.II/source/grid/manifold.cc b/deal.II/source/grid/manifold.cc index 5135baf965..eff55fa9ce 100644 --- a/deal.II/source/grid/manifold.cc +++ b/deal.II/source/grid/manifold.cc @@ -65,6 +65,31 @@ get_new_point (const std::vector > &surrounding_points, return p; } + +/* -------------------------- ManifoldChart --------------------- */ + +template +ManifoldChart::~ManifoldChart () +{} + + +template +Point +FlatManifold:: +get_new_point (const std::vector > &surrounding_points, + const std::vector &weights) const +{ + Assert(surrounding_points.size() == weights.size(), + ExcDimensionMismatch(surrounding_points.size(), weights.size())); + + Point p; + for(unsigned int i=0; i +#include +#include +#include +#include +#include + +template +Point +PolarManifold::PolarManifold(const Point center): + center(center) +{} + + +template +Point +PolarManifold::get_new_point (const std::vector > &sp, + const std::vector &sw) const +{ + AssertDimension(sp.size(), sw.size()); + + std::vector > sp_(sp.size()); + std::vector sw_(sp.size()); + + + Point middle = StraightBoundary::get_new_point_on_line (line); + + middle -= center; + + double r=0; + if (compute_radius_automatically) + { + const Point vertex_relative = line->vertex(0) - center; + r = std::sqrt(vertex_relative.square()); + } + else + r=radius; + // project to boundary + middle *= r / std::sqrt(middle.square()); + middle += center; + return middle; +} -- 2.39.5