Reference documentation for deal.II version 8.4.2
manifold.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2015 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/grid/tria.h>
28 
29 DEAL_II_NAMESPACE_OPEN
30 
31 template <int dim, int space_dim> class Triangulation;
32 
33 
38 namespace Manifolds
39 {
47  template <typename OBJECT>
49  get_default_quadrature(const OBJECT &obj, bool with_laplace = false);
50 }
51 
52 
82 template <int dim, int spacedim=dim>
83 class Manifold : public Subscriptor
84 {
85 public:
86 
87 
92  virtual ~Manifold ();
93 
104  virtual
106  get_new_point(const Quadrature<spacedim> &quad) const;
107 
121  virtual
122  Point<spacedim> project_to_manifold (const std::vector<Point<spacedim> > &surrounding_points,
123  const Point<spacedim> &candidate) const;
124 
138  virtual
140  get_new_point_on_line (const typename Triangulation<dim,spacedim>::line_iterator &line) const;
141 
159  virtual
161  get_new_point_on_quad (const typename Triangulation<dim,spacedim>::quad_iterator &quad) const;
162 
181  virtual
183  get_new_point_on_hex (const typename Triangulation<dim,spacedim>::hex_iterator &hex) const;
184 
185 
193  get_new_point_on_face (const typename Triangulation<dim,spacedim>::face_iterator &face) const;
194 
195 
203  get_new_point_on_cell (const typename Triangulation<dim,spacedim>::cell_iterator &cell) const;
204 };
205 
206 
218 template <int dim, int spacedim=dim>
219 class FlatManifold: public Manifold<dim, spacedim>
220 {
221 public:
249  FlatManifold (const Point<spacedim> periodicity=Point<spacedim>(),
250  const double tolerance=1e-10);
251 
273  virtual Point<spacedim>
274  get_new_point(const Quadrature<spacedim> &quad) const;
275 
276 
284  virtual
285  Point<spacedim> project_to_manifold (const std::vector<Point<spacedim> > &points,
286  const Point<spacedim> &candidate) const;
287 private:
302 
303  DeclException4(ExcPeriodicBox, int, Point<spacedim>, Point<spacedim>, double,
304  << "The component number " << arg1 << " of the point [ " << arg2
305  << " ] is not in the interval [ " << -arg4
306  << ", " << arg3[arg4] << "), bailing out.");
307 
312  const double tolerance;
313 };
314 
315 
376 template <int dim, int spacedim=dim, int chartdim=dim>
377 class ChartManifold: public Manifold<dim,spacedim>
378 {
379 public:
394  ChartManifold(const Point<chartdim> periodicity=Point<chartdim>());
395 
400  virtual ~ChartManifold ();
401 
402 
407  virtual Point<spacedim>
408  get_new_point(const Quadrature<spacedim> &quad) const;
409 
416  virtual Point<chartdim>
417  pull_back(const Point<spacedim> &space_point) const = 0;
418 
425  virtual Point<spacedim>
426  push_forward(const Point<chartdim> &chart_point) const = 0;
427 
428 private:
434 };
435 
436 
437 
438 
439 /* -------------- declaration of explicit specializations ------------- */
440 
441 #ifndef DOXYGEN
442 
443 template <>
444 Point<1>
447 
448 template <>
449 Point<2>
452 
453 
454 template <>
455 Point<3>
458 
459 
460 template <>
461 Point<1>
463 get_new_point_on_quad (const Triangulation<1,1>::quad_iterator &) const;
464 
465 template <>
466 Point<2>
468 get_new_point_on_quad (const Triangulation<1,2>::quad_iterator &) const;
469 
470 
471 template <>
472 Point<3>
474 get_new_point_on_quad (const Triangulation<1,3>::quad_iterator &) const;
475 
476 
477 template <>
478 Point<3>
480 get_new_point_on_hex (const Triangulation<3,3>::hex_iterator &) const;
481 
482 /*---Templated functions---*/
483 
484 namespace Manifolds
485 {
486 
487  template <typename OBJECT>
489  get_default_quadrature(const OBJECT &obj, bool with_laplace)
490  {
491  const int spacedim = OBJECT::AccessorType::space_dimension;
492  const int dim = OBJECT::AccessorType::structure_dimension;
493 
494  std::vector<Point<spacedim> > sp;
495  std::vector<double> wp;
496 
497 
498  // note that the exact weights are chosen such as to minimize the
499  // distortion of the four new quads from the optimal shape; their
500  // derivation and values is copied over from the
501  // @p{MappingQ::set_laplace_on_vector} function
502  switch (dim)
503  {
504  case 1:
505  sp.resize(2);
506  wp.resize(2);
507  sp[0] = obj->vertex(0);
508  wp[0] = .5;
509  sp[1] = obj->vertex(1);
510  wp[1] = .5;
511  break;
512  case 2:
513  sp.resize(8);
514  wp.resize(8);
515 
516  for (unsigned int i=0; i<4; ++i)
517  {
518  sp[i] = obj->vertex(i);
519  sp[4+i] = ( obj->line(i)->has_children() ?
520  obj->line(i)->child(0)->vertex(1) :
521  obj->line(i)->get_manifold().get_new_point_on_line(obj->line(i)) );
522  }
523 
524  if (with_laplace)
525  {
526  std::fill(wp.begin(), wp.begin()+4, 1.0/16.0);
527  std::fill(wp.begin()+4, wp.end(), 3.0/16.0);
528  }
529  else
530  std::fill(wp.begin(), wp.end(), 1.0/8.0);
531  break;
532  case 3:
533  {
535  = static_cast<TriaIterator<TriaAccessor<3, 3, 3> > >(obj);
536  const unsigned int np =
540  sp.resize(np);
541  wp.resize(np);
542  std::vector<Point<3> > *sp3 = reinterpret_cast<std::vector<Point<3> > *>(&sp);
543 
544  unsigned int j=0;
545 
546  // note that the exact weights are chosen such as to minimize the
547  // distortion of the eight new hexes from the optimal shape; their
548  // derivation and values is copied over from the
549  // @p{MappingQ::set_laplace_on_vector} function
550  for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i, ++j)
551  {
552  (*sp3)[j] = hex->vertex(i);
553  wp[j] = 1.0/128.0;
554  }
555  for (unsigned int i=0; i<GeometryInfo<dim>::lines_per_cell; ++i, ++j)
556  {
557  (*sp3)[j] = (hex->line(i)->has_children() ?
558  hex->line(i)->child(0)->vertex(1) :
559  hex->line(i)->get_manifold().get_new_point_on_line(hex->line(i)));
560  wp[j] = 7.0/192.0;
561  }
562  for (unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i, ++j)
563  {
564  (*sp3)[j] = (hex->quad(i)->has_children() ?
565  hex->quad(i)->isotropic_child(0)->vertex(3) :
566  hex->quad(i)->get_manifold().get_new_point_on_quad(hex->quad(i)));
567  wp[j] = 1.0/12.0;
568  }
569  // Overwrite the weights with 1/np if we don't want to use
570  // laplace vectors.
571  if (with_laplace == false)
572  std::fill(wp.begin(), wp.end(), 1.0/np);
573  }
574  break;
575  default:
576  Assert(false, ExcInternalError());
577  break;
578  }
579  return Quadrature<spacedim>(sp,wp);
580  }
581 }
582 
583 #endif // DOXYGEN
584 
585 DEAL_II_NAMESPACE_CLOSE
586 
587 #endif
Quadrature< OBJECT::AccessorType::space_dimension > get_default_quadrature(const OBJECT &obj, bool with_laplace=false)
virtual Point< spacedim > get_new_point_on_hex(const typename Triangulation< dim, spacedim >::hex_iterator &hex) const
Definition: manifold.cc:192
const FlatManifold< dim, chartdim > sub_manifold
Definition: manifold.h:433
#define Assert(cond, exc)
Definition: exceptions.h:294
const double tolerance
Definition: manifold.h:312
const Point< spacedim > periodicity
Definition: manifold.h:301
virtual Point< spacedim > get_new_point_on_quad(const typename Triangulation< dim, spacedim >::quad_iterator &quad) const
Definition: manifold.cc:85
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:572
Point< spacedim > get_new_point_on_face(const typename Triangulation< dim, spacedim >::face_iterator &face) const
Definition: manifold.cc:94