Point<spacedim>
get_new_point(const std::vector<Point<spacedim> > &surrounding_points,
const std::vector<double> &weights) const = 0;
+ /**
+ * Given a point which lies close to the given manifold, it modifies
+ * it and projects it to manifold itself. This function is used in
+ * some mesh smoothing algorithms that try to move around points in
+ * order to improve the mesh quality but need to ensure that points
+ * that were on the manfold remain on the manifold.
+ *
+ * Derived classes do not need to implement this function unless
+ * mesh smoothing algorithms are used with a particular boundary
+ * object. The default implementation of this function calls the
+ * method with the same name, but without surrounding_points.
+ *
+ * This version of the projection function can be overwritten when
+ * only an approximation of the manifold is available, and this
+ * approximation requires surrounding points to be defined.
+ */
+ virtual
+ Point<spacedim> project_to_manifold (const std::vector<Point<spacedim> > &surrounding_points,
+ const Point<spacedim> &candidate) const;
/**
* Given a point which lies close to the given manifold, it modifies
const unsigned int structdim = Iterator::AccessorType::structure_dimension;
const unsigned int spacedim = Iterator::AccessorType::space_dimension;
+ std::vector<Point<spacedim> > vertices(GeometryInfo<structdim>::vertices_per_cell);
+ for(unsigned int i=0; i<vertices.size(); ++i)
+ vertices[i] = object->vertex(i);
// right now we can only deal
// with cells that have been
else
gradient[d]
= ((objective_function (object,
- manifold->project_to_manifold(object_mid_point + h))
+ manifold->project_to_manifold(vertices,
+ object_mid_point + h))
-
objective_function (object,
- manifold->project_to_manifold(object_mid_point - h)))
+ manifold->project_to_manifold(vertices,
+ object_mid_point - h)))
/
eps);
}
gradient;
if (respect_manifold == true)
- object_mid_point = manifold->project_to_manifold(object_mid_point);
+ object_mid_point = manifold->project_to_manifold(vertices,
+ object_mid_point);
// compute current value of the
// objective function
return candidate;
}
+template <int spacedim>
+Point<spacedim>
+Manifold<spacedim>::project_to_manifold (const std::vector<Point<spacedim> > &,
+ const Point<spacedim> &candidate) const
+{
+ return project_to_manifold(candidate);
+}
+
+
template <int spacedim>
void
Manifold<spacedim>::get_normals_at_points(const std::vector<Point<spacedim> > &points,
// distorted cells resulting from refinement
#include "../tests.h"
+#include "my_boundary.h"
#include <deal.II/base/logstream.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/grid/tria.h>
#include <fstream>
-
-template <int dim>
-class MyBoundary : public Manifold<dim>
-{
- virtual Point<dim>
- get_new_point (const std::vector<Point<dim> > &v,
- const std::vector<double> &ws) const
- {
- switch(v.size()) {
- case 2:
- deallog << "Finding point between "
- << v[0] << " and "
- << v[1] << std::endl;
-
- // in 2d, find a point that
- // lies on the opposite side
- // of the quad. in 3d, choose
- // the midpoint of the edge
- if (dim == 2)
- return Point<dim>(0,0.75);
- else
- return (v[0] + v[1]) / 2;
- break;
- default:
- deallog << "Finding point between "
- << v[0] << " and "
- << v[1] << " and "
- << v[2] << " and "
- << v[3] << std::endl;
-
- return Point<dim>(0,0,.75);
- break;
- }
- }
-};
-
-
-
template <int dim>
void check ()
{
#include <deal.II/fe/fe_values.h>
#include <fstream>
-
-
-template <int dim>
-class MyBoundary : public Boundary<dim>
-{
- virtual Point<dim>
- get_new_point_on_line (const typename Triangulation<dim>::line_iterator &line) const
- {
- deallog << "Finding point between "
- << line->vertex(0) << " and "
- << line->vertex(1) << std::endl;
-
- // in 2d, find a point that
- // lies on the opposite side
- // of the quad. in 3d, choose
- // the midpoint of the edge
- if (dim == 2)
- return Point<dim>(0,0.75);
- else
- return (line->vertex(0) + line->vertex(1)) / 2;
- }
-
- virtual Point<dim>
- get_new_point_on_quad (const typename Triangulation<dim>::quad_iterator &quad) const
- {
- deallog << "Finding point between "
- << quad->vertex(0) << " and "
- << quad->vertex(1) << " and "
- << quad->vertex(2) << " and "
- << quad->vertex(3) << std::endl;
-
- return Point<dim>(0,0,.75);
- }
-
- virtual
- Point<dim>
- project_to_surface (const typename Triangulation<dim>::line_iterator &,
- const Point<dim> &p) const
- {
- deallog << "Projecting line point " << p << std::endl;
-
- if (dim == 2)
- return Point<dim>(p[0], 0.75-1.75*std::fabs(p[0]));
- else
- return p;
- }
-
- virtual
- Point<dim>
- project_to_surface (const typename Triangulation<dim>::quad_iterator &,
- const Point<dim> &p) const
- {
- deallog << "Projecting quad point " << p << std::endl;
-
- Assert (dim == 3, ExcInternalError());
-
- return Point<dim>(p[0], p[1],
- 0.75-1.75*std::max(std::fabs(p[0]),
- std::fabs(p[1])));
- }
-
- virtual
- Point<dim>
- project_to_surface (const typename Triangulation<dim>::hex_iterator &,
- const Point<dim> &) const
- {
- Assert (false, ExcInternalError());
- return Point<dim>();
- }
-};
-
-
+#include "my_boundary.h"
template <int dim>
void check ()
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: distorted_cells_04.cc 32209 2014-01-15 00:25:27Z heltai $
+//
+// Copyright (C) 2003 - 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// like _03, but catch the exception and pass it to GridTools::fix_up_distorted_child_cells
+
+#include "../tests.h"
+#include <deal.II/grid/manifold.h>
+
+template <int dim>
+class MyBoundary : public Manifold<dim>
+{
+ virtual Point<dim>
+ get_new_point (const std::vector<Point<dim> > &v,
+ const std::vector<double> &ws) const
+ {
+ switch(v.size()) {
+ case 2:
+ deallog << "Finding point between "
+ << v[0] << " and "
+ << v[1] << std::endl;
+
+ // in 2d, find a point that
+ // lies on the opposite side
+ // of the quad. in 3d, choose
+ // the midpoint of the edge
+ if (dim == 2)
+ return Point<dim>(0,0.75);
+ else
+ return (v[0] + v[1]) / 2;
+ break;
+ default:
+ deallog << "Finding point between "
+ << v[0] << " and "
+ << v[1] << " and "
+ << v[2] << " and "
+ << v[3] << std::endl;
+
+ return Point<dim>(0,0,.75);
+ break;
+ }
+ }
+
+ virtual
+ Point<dim>
+ project_to_manifold (const std::vector<Point<dim> > &v,
+ const Point<dim> &p) const
+ {
+ switch(v.size()) {
+ case 2:
+ {
+ deallog << "Projecting line point " << p << std::endl;
+ if (dim == 2)
+ return Point<dim>(p[0], 0.75-1.75*std::fabs(p[0]));
+ else
+ return p;
+ }
+ break;
+ case 4:
+ {
+ deallog << "Projecting quad point " << p << std::endl;
+
+ Assert (dim == 3, ExcInternalError());
+
+ return Point<dim>(p[0], p[1],
+ 0.75-1.75*std::max(std::fabs(p[0]),
+ std::fabs(p[1])));
+ }
+ break;
+ default:
+ {
+ Assert (false, ExcInternalError());
+ return Point<dim>();
+ }
+ }
+ }
+};
+
+
+
+