]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Added manifold_lib.cc
authorheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 21 Aug 2013 15:59:11 +0000 (15:59 +0000)
committerheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 21 Aug 2013 15:59:11 +0000 (15:59 +0000)
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
deal.II/include/deal.II/grid/manifold.h
deal.II/include/deal.II/grid/manifold_lib.h
deal.II/source/grid/manifold.cc
deal.II/source/grid/manifold_lib.cc [new file with mode: 0644]

index 09599c7935cfe09ca8a4a3096cd04aa67db8b250..6019451d593b0d8de5b1bb35e04684a332ca8a43 100644 (file)
@@ -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
index 83543146403deb44e4b57bc88adb8df8f357b81c..922d7d1cab1cf23666c9d59e614884f8d415b5e0 100644 (file)
@@ -160,6 +160,57 @@ public:
 };
 
 
+/**
+ *   A chart of dimension dim, which is part of a Manifold<spacedim>.
+ *   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 <int dim, int spacedim>
+class ManifoldChart: public Manifold<spacedim>
+{
+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<spacedim>
+    get_new_point(const std::vector<Point<spacedim> > &surrounding_points,
+                 const std::vector<double> &weights) const;
+
+    virtual Point<dim>
+    pull_back(const Point<spacedim> space_point) const = 0;
+
+    virtual Point<spacedim>
+    push_forward(const Point<dim> chart_point) const = 0;
+    
+
+  private:
+    FlatManifold<dim> sub_manifold;
+    std::vector<Point<dim> > chart_points;
+};
+
+
 
 /* -------------- declaration of explicit specializations ------------- */
 
index 7bd1cf5e2973d2d318211161cf26c59023ccde68..2aab365c689708cffcb9770db5ddb47b19c71002 100644 (file)
 #include <deal.II/grid/manifold.h>
 
 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 <int spacedim>
+class PolarManifold : public FlatManifold<spacedim> 
+{
+  public:
+    PolarManifold(const Point<spacedim> center = Point<spacedim>());
+
+    virtual Point<spacedim>
+    get_new_point (const std::vector<Point<spacedim> > &surrounding_points,
+                  const std::vector<double> &weights) const;
+
+  private:
+    Point<spacedim> center;
+}
+
 //  
 //  /**
 //   * Boundary object for the hull of a cylinder.  In three dimensions,
index 5135baf965fe2bf303429e1d12c1ab40a7a8c621..eff55fa9ce56218b40e34a1e202844d21ceff492 100644 (file)
@@ -65,6 +65,31 @@ get_new_point (const std::vector<Point<spacedim> > &surrounding_points,
   return p;
 }
 
+
+/* -------------------------- ManifoldChart --------------------- */
+
+template <int spacedim>
+ManifoldChart<spacedim>::~ManifoldChart ()
+{}
+
+
+template <int spacedim>
+Point<spacedim>
+FlatManifold<spacedim>::
+get_new_point (const std::vector<Point<spacedim> > &surrounding_points,
+              const std::vector<double> &weights) const
+{
+  Assert(surrounding_points.size() == weights.size(),
+        ExcDimensionMismatch(surrounding_points.size(), weights.size()));
+  
+  Point<spacedim> p;
+  for(unsigned int i=0; i<surrounding_points.size(); ++i)
+    p += surrounding_points[i]*weights[i];
+  
+  return p;
+}
+
+
 // explicit instantiations
 #include "manifold.inst"
 
diff --git a/deal.II/source/grid/manifold_lib.cc b/deal.II/source/grid/manifold_lib.cc
new file mode 100644 (file)
index 0000000..16c8f61
--- /dev/null
@@ -0,0 +1,58 @@
+// ---------------------------------------------------------------------
+// $Id: manifold_lib.cc 30130 2013-07-23 13:01:18Z heltai $
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/grid/manifold_lib.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/base/tensor.h>
+#include <cmath>
+
+template <int spacedim>
+Point<spacedim>
+PolarManifold<spacedim>::PolarManifold(const Point<spacedim> center):
+  center(center)
+{}
+
+
+template <int spacedim>
+Point<spacedim>
+PolarManifold<spacedim>::get_new_point (const std::vector<Point<spacedim> > &sp,
+                                       const std::vector<double> &sw) const
+{
+  AssertDimension(sp.size(), sw.size());
+  
+  std::vector<Point<spacedim> > sp_(sp.size());
+  std::vector<double> sw_(sp.size());
+  
+  
+  Point<spacedim> middle = StraightBoundary<dim,spacedim>::get_new_point_on_line (line);
+
+  middle -= center;
+
+  double r=0;
+  if (compute_radius_automatically)
+    {
+      const Point<spacedim> 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;
+}

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.