Reference documentation for deal.II version 8.5.1
manifold.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2017 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__tria_manifold_h
17 #define dealii__tria_manifold_h
18 
19 
20 /*---------------------------- manifold.h ---------------------------*/
21 
22 #include <deal.II/base/config.h>
23 #include <deal.II/base/subscriptor.h>
24 #include <deal.II/base/quadrature_lib.h>
25 #include <deal.II/base/thread_management.h>
26 #include <deal.II/base/point.h>
27 #include <deal.II/base/derivative_form.h>
28 #include <deal.II/grid/tria.h>
29 
30 DEAL_II_NAMESPACE_OPEN
31 
32 // forward declaration
33 template <int, typename> class Table;
34 
39 namespace Manifolds
40 {
82  template <typename MeshIteratorType>
84  get_default_quadrature(const MeshIteratorType &iterator,
85  const bool with_laplace = false) DEAL_II_DEPRECATED;
86 
128  template <typename MeshIteratorType>
129  std::pair<std::vector<Point<MeshIteratorType::AccessorType::space_dimension> >,
130  std::vector<double> >
131  get_default_points_and_weights(const MeshIteratorType &iterator,
132  const bool with_laplace = false);
133 }
134 
135 
299 template <int dim, int spacedim=dim>
300 class Manifold : public Subscriptor
301 {
302 public:
303 
304  // explicitly check for sensible template arguments
305 #ifdef DEAL_II_WITH_CXX11
306  static_assert (dim<=spacedim,
307  "The dimension <dim> of a Manifold must be less than or "
308  "equal to the space dimension <spacedim> in which it lives.");
309 #endif
310 
311 
324 
325 
330  virtual ~Manifold ();
331 
335 
354  virtual
357  const Point<spacedim> &p2,
358  const double w) const;
359 
377  virtual
379  get_new_point (const Quadrature<spacedim> &quad) const DEAL_II_DEPRECATED;
380 
397  virtual
399  get_new_point (const std::vector<Point<spacedim> > &surrounding_points,
400  const std::vector<double> &weights) const;
401 
425  virtual
426  void
427  add_new_points (const std::vector<Point<spacedim> > &surrounding_points,
428  const Table<2,double> &weights,
429  std::vector<Point<spacedim> > &new_points) const;
430 
444  virtual
445  Point<spacedim> project_to_manifold (const std::vector<Point<spacedim> > &surrounding_points,
446  const Point<spacedim> &candidate) const;
447 
461  virtual
463  get_new_point_on_line (const typename Triangulation<dim,spacedim>::line_iterator &line) const;
464 
482  virtual
484  get_new_point_on_quad (const typename Triangulation<dim,spacedim>::quad_iterator &quad) const;
485 
504  virtual
506  get_new_point_on_hex (const typename Triangulation<dim,spacedim>::hex_iterator &hex) const;
507 
508 
517 
518 
527 
529 
533 
569  virtual
572  const Point<spacedim> &x2) const;
573 
575 
579 
634  virtual
637  const Point<spacedim> &p) const;
638 
653  virtual
654  void
656  FaceVertexNormals &face_vertex_normals) const;
657 
659 };
660 
661 
673 template <int dim, int spacedim=dim>
674 class FlatManifold : public Manifold<dim, spacedim>
675 {
676 public:
705  const double tolerance=1e-10);
706 
728  virtual
730  get_new_point(const Quadrature<spacedim> &quad) const DEAL_II_DEPRECATED;
731 
753  virtual
755  get_new_point(const std::vector<Point<spacedim> > &surrounding_points,
756  const std::vector<double> &weights) const;
757 
771  virtual
772  void
773  add_new_points (const std::vector<Point<spacedim> > &surrounding_points,
774  const Table<2,double> &weights,
775  std::vector<Point<spacedim> > &new_points) const;
776 
784  virtual
786  project_to_manifold (const std::vector<Point<spacedim> > &points,
787  const Point<spacedim> &candidate) const;
788 
810  virtual
813  const Point<spacedim> &x2) const;
814 
818  const Tensor<1,spacedim> &get_periodicity() const;
819 
820 private:
835 
837  << "The component number " << arg1 << " of the point [ " << arg2
838  << " ] is not in the interval [ 0, " << arg3 << "), bailing out.");
839 
844  const double tolerance;
845 };
846 
847 
936 template <int dim, int spacedim=dim, int chartdim=dim>
937 class ChartManifold : public Manifold<dim,spacedim>
938 {
939 public:
940  // explicitly check for sensible template arguments
941 #ifdef DEAL_II_WITH_CXX11
942  static_assert (dim<=spacedim,
943  "The dimension <dim> of a ChartManifold must be less than or "
944  "equal to the space dimension <spacedim> in which it lives.");
945 #endif
946 
961  ChartManifold(const Tensor<1,chartdim> &periodicity = Tensor<1,chartdim>());
962 
967  virtual ~ChartManifold ();
968 
969 
974  virtual
976  get_new_point(const Quadrature<spacedim> &quad) const DEAL_II_DEPRECATED;
977 
982  virtual
984  get_new_point(const std::vector<Point<spacedim> > &surrounding_points,
985  const std::vector<double> &weights) const;
986 
1011  virtual
1012  void
1013  add_new_points (const std::vector<Point<spacedim> > &surrounding_points,
1014  const Table<2,double> &weights,
1015  std::vector<Point<spacedim> > &new_points) const;
1016 
1023  virtual
1025  pull_back(const Point<spacedim> &space_point) const = 0;
1026 
1033  virtual
1035  push_forward(const Point<chartdim> &chart_point) const = 0;
1036 
1053  virtual
1055  push_forward_gradient(const Point<chartdim> &chart_point) const;
1056 
1112  virtual
1115  const Point<spacedim> &x2) const;
1116 
1120  const Tensor<1,chartdim> &get_periodicity() const;
1121 
1122 private:
1135 };
1136 
1137 
1138 
1139 
1140 /* -------------- declaration of explicit specializations ------------- */
1141 
1142 #ifndef DOXYGEN
1143 
1144 template <>
1145 Point<1>
1148 
1149 template <>
1150 Point<2>
1153 
1154 
1155 template <>
1156 Point<3>
1159 
1160 
1161 template <>
1162 Point<1>
1164 get_new_point_on_quad (const Triangulation<1,1>::quad_iterator &) const;
1165 
1166 template <>
1167 Point<2>
1169 get_new_point_on_quad (const Triangulation<1,2>::quad_iterator &) const;
1170 
1171 
1172 template <>
1173 Point<3>
1175 get_new_point_on_quad (const Triangulation<1,3>::quad_iterator &) const;
1176 
1177 
1178 template <>
1179 Point<3>
1181 get_new_point_on_hex (const Triangulation<3,3>::hex_iterator &) const;
1182 
1183 /*---Templated functions---*/
1184 
1185 namespace Manifolds
1186 {
1187  template <typename MeshIteratorType>
1189  get_default_quadrature(const MeshIteratorType &iterator,
1190  const bool with_laplace)
1191  {
1192  const std::pair<std::vector<Point<MeshIteratorType::AccessorType::space_dimension> >,
1193  std::vector<double> > points_and_weights = get_default_points_and_weights(iterator,
1194  with_laplace);
1195  return Quadrature<MeshIteratorType::AccessorType::space_dimension>(points_and_weights.first,
1196  points_and_weights.second);
1197  }
1198 
1199  template <typename MeshIteratorType>
1200  std::pair<std::vector<Point<MeshIteratorType::AccessorType::space_dimension> >,
1201  std::vector<double> >
1202  get_default_points_and_weights(const MeshIteratorType &iterator,
1203  const bool with_laplace)
1204  {
1205  const int spacedim = MeshIteratorType::AccessorType::space_dimension;
1206  const int dim = MeshIteratorType::AccessorType::structure_dimension;
1207 
1208  std::pair<std::vector<Point<spacedim> >,
1209  std::vector<double> > points_weights;
1210 
1211 
1212  // note that the exact weights are chosen such as to minimize the
1213  // distortion of the four new quads from the optimal shape; their
1214  // derivation and values is copied over from the
1215  // @p{MappingQ::set_laplace_on_vector} function
1216  switch (dim)
1217  {
1218  case 1:
1219  points_weights.first.resize(2);
1220  points_weights.second.resize(2);
1221  points_weights.first[0] = iterator->vertex(0);
1222  points_weights.second[0] = .5;
1223  points_weights.first[1] = iterator->vertex(1);
1224  points_weights.second[1] = .5;
1225  break;
1226  case 2:
1227  points_weights.first.resize(8);
1228  points_weights.second.resize(8);
1229 
1230  for (unsigned int i=0; i<4; ++i)
1231  {
1232  points_weights.first[i] = iterator->vertex(i);
1233  points_weights.first[4+i] = ( iterator->line(i)->has_children() ?
1234  iterator->line(i)->child(0)->vertex(1) :
1235  iterator->line(i)->get_manifold().get_new_point_on_line(iterator->line(i)) );
1236  }
1237 
1238  if (with_laplace)
1239  {
1240  std::fill(points_weights.second.begin(), points_weights.second.begin()+4, 1.0/16.0);
1241  std::fill(points_weights.second.begin()+4, points_weights.second.end(), 3.0/16.0);
1242  }
1243  else
1244  std::fill(points_weights.second.begin(), points_weights.second.end(), 1.0/8.0);
1245  break;
1246  case 3:
1247  {
1249  = static_cast<TriaIterator<TriaAccessor<3, 3, 3> > >(iterator);
1250  const unsigned int np =
1254  points_weights.first.resize(np);
1255  points_weights.second.resize(np);
1256  std::vector<Point<3> > *sp3 = reinterpret_cast<std::vector<Point<3> > *>(&points_weights.first);
1257 
1258  unsigned int j=0;
1259 
1260  // note that the exact weights are chosen such as to minimize the
1261  // distortion of the eight new hexes from the optimal shape; their
1262  // derivation and values is copied over from the
1263  // @p{MappingQ::set_laplace_on_vector} function
1264  for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i, ++j)
1265  {
1266  (*sp3)[j] = hex->vertex(i);
1267  points_weights.second[j] = 1.0/128.0;
1268  }
1269  for (unsigned int i=0; i<GeometryInfo<dim>::lines_per_cell; ++i, ++j)
1270  {
1271  (*sp3)[j] = (hex->line(i)->has_children() ?
1272  hex->line(i)->child(0)->vertex(1) :
1273  hex->line(i)->get_manifold().get_new_point_on_line(hex->line(i)));
1274  points_weights.second[j] = 7.0/192.0;
1275  }
1276  for (unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i, ++j)
1277  {
1278  (*sp3)[j] = (hex->quad(i)->has_children() ?
1279  hex->quad(i)->isotropic_child(0)->vertex(3) :
1280  hex->quad(i)->get_manifold().get_new_point_on_quad(hex->quad(i)));
1281  points_weights.second[j] = 1.0/12.0;
1282  }
1283  // Overwrite the weights with 1/np if we don't want to use
1284  // laplace vectors.
1285  if (with_laplace == false)
1286  std::fill(points_weights.second.begin(), points_weights.second.end(), 1.0/np);
1287  }
1288  break;
1289  default:
1290  Assert(false, ExcInternalError());
1291  break;
1292  }
1293  return points_weights;
1294  }
1295 }
1296 
1297 #endif // DOXYGEN
1298 
1299 DEAL_II_NAMESPACE_CLOSE
1300 
1301 #endif
virtual void add_new_points(const std::vector< Point< spacedim > > &surrounding_points, const Table< 2, double > &weights, std::vector< Point< spacedim > > &new_points) const
Definition: manifold.cc:622
const Tensor< 1, spacedim > periodicity
Definition: manifold.h:834
FlatManifold(const Tensor< 1, spacedim > &periodicity=Tensor< 1, spacedim >(), const double tolerance=1e-10)
Definition: manifold.cc:545
virtual Tensor< 1, spacedim > get_tangent_vector(const Point< spacedim > &x1, const Point< spacedim > &x2) const
Definition: manifold.cc:709
const FlatManifold< chartdim, chartdim > sub_manifold
Definition: manifold.h:1134
const Tensor< 1, spacedim > & get_periodicity() const
Definition: manifold.cc:700
virtual Point< spacedim > get_new_point_on_hex(const typename Triangulation< dim, spacedim >::hex_iterator &hex) const
Definition: manifold.cc:503
std::pair< std::vector< Point< MeshIteratorType::AccessorType::space_dimension > >, std::vector< double > > get_default_points_and_weights(const MeshIteratorType &iterator, const bool with_laplace=false)
Quadrature< MeshIteratorType::AccessorType::space_dimension > get_default_quadrature(const MeshIteratorType &iterator, const bool with_laplace=false) 1
virtual Point< spacedim > get_new_point(const Quadrature< spacedim > &quad) const 1
Definition: manifold.cc:86
virtual Point< spacedim > get_new_point_on_line(const typename Triangulation< dim, spacedim >::line_iterator &line) const
Definition: manifold.cc:375
virtual Point< spacedim > project_to_manifold(const std::vector< Point< spacedim > > &points, const Point< spacedim > &candidate) const
Definition: manifold.cc:690
virtual Tensor< 1, spacedim > get_tangent_vector(const Point< spacedim > &x1, const Point< spacedim > &x2) const
Definition: manifold.cc:524
virtual DerivativeForm< 1, chartdim, spacedim > push_forward_gradient(const Point< chartdim > &chart_point) const
Definition: manifold.cc:805
virtual void add_new_points(const std::vector< Point< spacedim > > &surrounding_points, const Table< 2, double > &weights, std::vector< Point< spacedim > > &new_points) const
Definition: manifold.cc:779
#define Assert(cond, exc)
Definition: exceptions.h:313
virtual Point< spacedim > project_to_manifold(const std::vector< Point< spacedim > > &surrounding_points, const Point< spacedim > &candidate) const
Definition: manifold.cc:59
static ::ExceptionBase & ExcPeriodicBox(int arg1, Point< spacedim > arg2, double arg3)
Tensor< 1, spacedim > FaceVertexNormals[GeometryInfo< dim >::vertices_per_face]
Definition: manifold.h:308
virtual Point< spacedim > get_new_point(const Quadrature< spacedim > &quad) const 1
Definition: manifold.cc:751
const Tensor< 1, chartdim > & get_periodicity() const
Definition: manifold.cc:846
const double tolerance
Definition: manifold.h:844
virtual Point< spacedim > get_intermediate_point(const Point< spacedim > &p1, const Point< spacedim > &p2, const double w) const
Definition: manifold.cc:71
virtual Tensor< 1, spacedim > get_tangent_vector(const Point< spacedim > &x1, const Point< spacedim > &x2) const
Definition: manifold.cc:818
virtual void add_new_points(const std::vector< Point< spacedim > > &surrounding_points, const Table< 2, double > &weights, std::vector< Point< spacedim > > &new_points) const
Definition: manifold.cc:157
virtual Point< spacedim > get_new_point(const Quadrature< spacedim > &quad) const 1
Definition: manifold.cc:557
virtual ~Manifold()
Definition: manifold.cc:51
virtual Point< spacedim > get_new_point_on_quad(const typename Triangulation< dim, spacedim >::quad_iterator &quad) const
Definition: manifold.cc:386
virtual Point< spacedim > push_forward(const Point< chartdim > &chart_point) const =0
Definition: table.h:33
virtual Tensor< 1, spacedim > normal_vector(const typename Triangulation< dim, spacedim >::face_iterator &face, const Point< spacedim > &p) const
Definition: manifold.cc:295
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:588
virtual ~ChartManifold()
Definition: manifold.cc:735
ChartManifold(const Tensor< 1, chartdim > &periodicity=Tensor< 1, chartdim >())
Definition: manifold.cc:741
Point< spacedim > get_new_point_on_face(const typename Triangulation< dim, spacedim >::face_iterator &face) const
Definition: manifold.cc:397
virtual void get_normals_at_vertices(const typename Triangulation< dim, spacedim >::face_iterator &face, FaceVertexNormals &face_vertex_normals) const
Definition: manifold.cc:360
virtual Point< chartdim > pull_back(const Point< spacedim > &space_point) const =0
static ::ExceptionBase & ExcInternalError()
Point< spacedim > get_new_point_on_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
Definition: manifold.cc:417