// 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);
}
// 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
};
+/**
+ * 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 ------------- */
#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,
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"
--- /dev/null
+// ---------------------------------------------------------------------
+// $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;
+}