Reference documentation for deal.II version 9.0.0
manifold_lib.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2018 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_manifold_lib_h
17 #define dealii_manifold_lib_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/grid/manifold.h>
22 #include <deal.II/base/function.h>
23 #include <deal.II/base/function_parser.h>
24 
25 #include <boost/container/small_vector.hpp>
26 
27 DEAL_II_NAMESPACE_OPEN
28 
60 template <int dim, int spacedim = dim>
61 class PolarManifold : public ChartManifold<dim, spacedim, spacedim>
62 {
63 public:
73 
77  virtual std::unique_ptr<Manifold<dim,spacedim> > clone() const override;
78 
84  virtual Point<spacedim>
85  pull_back(const Point<spacedim> &space_point) const override;
86 
92  virtual Point<spacedim>
93  push_forward(const Point<spacedim> &chart_point) const override;
94 
107  virtual
109  push_forward_gradient(const Point<spacedim> &chart_point) const override;
110 
115 private:
116 
122 };
123 
124 
125 
219 template <int dim, int spacedim = dim>
220 class SphericalManifold : public Manifold<dim, spacedim>
221 {
222 public:
227 
231  virtual std::unique_ptr<Manifold<dim,spacedim> > clone() const override;
232 
240  virtual
243  const Point<spacedim> &p2,
244  const double w) const override;
245 
250  virtual
253  const Point<spacedim> &x2) const override;
254 
258  virtual
261  const Point<spacedim> &p) const override;
262 
266  virtual
267  void
269  typename Manifold<dim, spacedim>::FaceVertexNormals &face_vertex_normals) const override;
270 
285  virtual
286  void
287  get_new_points (const ArrayView<const Point<spacedim>> &surrounding_points,
288  const Table<2,double> &weights,
289  ArrayView<Point<spacedim>> new_points) const override;
290 
295  virtual
297  get_new_point (const ArrayView<const Point<spacedim>> &vertices,
298  const ArrayView<const double> &weights) const override;
299 
304 
305 private:
312  std::pair<double, Tensor<1,spacedim> >
313  guess_new_point(const ArrayView<const Tensor<1,spacedim>> &directions,
314  const ArrayView<const double> &distances,
315  const ArrayView<const double> &weights) const;
316 
332  get_new_point (const ArrayView<const Tensor<1,spacedim>> &directions,
333  const ArrayView<const double> &distances,
334  const ArrayView<const double> &weights,
335  const Point<spacedim> &candidate_point) const;
336 
350  virtual
351  void
352  get_new_points (const ArrayView<const Point<spacedim>> &surrounding_points,
353  const ArrayView<const double> &weights,
354  ArrayView<Point<spacedim>> new_points) const;
355 
360 };
361 
377 template <int dim, int spacedim = dim>
378 class CylindricalManifold : public ChartManifold<dim,spacedim,3>
379 {
380 public:
387  CylindricalManifold (const unsigned int axis = 0,
388  const double tolerance = 1e-10);
389 
399  const double tolerance = 1e-10);
400 
404  virtual std::unique_ptr<Manifold<dim,spacedim> > clone() const override;
405 
410  virtual Point<3>
411  pull_back(const Point<spacedim> &space_point) const override;
412 
419  virtual Point<spacedim>
420  push_forward(const Point<3> &chart_point) const override;
421 
429  push_forward_gradient(const Point<3> &chart_point) const override;
430 
435  virtual Point<spacedim>
436  get_new_point (const ArrayView<const Point<spacedim>> &surrounding_points,
437  const ArrayView<const double> &weights) const override;
438 
439 protected:
444 
449 
454 
455 private:
459  double tolerance;
460 
461 };
462 
463 
464 
481 template <int dim, int spacedim=dim, int chartdim=dim>
482 class FunctionManifold : public ChartManifold<dim, spacedim, chartdim>
483 {
484 public:
496  const Tensor<1,chartdim> &periodicity=Tensor<1,chartdim>(),
497  const double tolerance=1e-10);
498 
513  FunctionManifold(const std::string push_forward_expression,
514  const std::string pull_back_expression,
515  const Tensor<1,chartdim> &periodicity=Tensor<1,chartdim>(),
519  const double tolerance=1e-10,
520  const double h=1e-8);
521 
525  virtual ~FunctionManifold() override;
526 
530  virtual std::unique_ptr<Manifold<dim,spacedim> > clone() const override;
531 
537  virtual Point<spacedim>
538  push_forward(const Point<chartdim> &chart_point) const override;
539 
560  virtual
562  push_forward_gradient(const Point<chartdim> &chart_point) const override;
563 
569  virtual Point<chartdim>
570  pull_back(const Point<spacedim> &space_point) const override;
571 
572 private:
577 
583 
589 
595  const double tolerance;
596 
604  const bool owns_pointers;
605 
609  const std::string push_forward_expression;
610 
614  const std::string pull_back_expression;
615 
619  const std::string chart_vars;
620 
624  const std::string space_vars;
625 
630 };
631 
632 
633 
648 template <int dim>
649 class TorusManifold : public ChartManifold<dim,3,3>
650 {
651 public:
652  static const int chartdim = 3;
653  static const int spacedim = 3;
654 
660  TorusManifold (const double R, const double r);
661 
665  virtual std::unique_ptr<Manifold<dim, 3> > clone() const override;
666 
670  virtual Point<3>
671  pull_back(const Point<3> &p) const override;
672 
676  virtual Point<3>
677  push_forward(const Point<3> &chart_point) const override;
678 
682  virtual
684  push_forward_gradient(const Point<3> &chart_point) const override;
685 
686 private:
687  double r, R;
688 };
689 
690 
691 
825 template <int dim, int spacedim=dim>
826 class TransfiniteInterpolationManifold : public Manifold<dim,spacedim>
827 {
828 public:
833 
837  virtual ~TransfiniteInterpolationManifold() override;
838 
842  virtual std::unique_ptr<Manifold<dim,spacedim> > clone() const override;
843 
857 
873  virtual
875  get_new_point (const ArrayView<const Point<spacedim>> &surrounding_points,
876  const ArrayView<const double> &weights) const override;
877 
897  virtual
898  void
899  get_new_points (const ArrayView<const Point<spacedim>> &surrounding_points,
900  const Table<2,double> &weights,
901  ArrayView<Point<spacedim>> new_points) const override;
902 
903 private:
915  std::array<unsigned int, 20>
916  get_possible_cells_around_points(const ArrayView<const Point<spacedim>> &surrounding_points) const;
917 
926  compute_chart_points(const ArrayView<const Point<spacedim>> &surrounding_points,
927  ArrayView<Point<dim>> chart_points) const;
928 
945  Point<dim>
947  const Point<spacedim> &p,
948  const Point<dim> &initial_guess) const;
949 
963  const Point<dim> &chart_point) const;
964 
978  const Point<dim> &chart_point,
979  const Point<spacedim> &pushed_forward_chart_point) const;
980 
985 
991 
997  std::vector<bool> coarse_cell_is_flat;
998 
1004 
1009  boost::signals2::connection clear_signal;
1010 };
1011 
1012 DEAL_II_NAMESPACE_CLOSE
1013 
1014 #endif
DerivativeForm< 1, dim, spacedim > push_forward_gradient(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &chart_point, const Point< spacedim > &pushed_forward_chart_point) const
FlatManifold< dim > chart_manifold
Triangulation< dim, spacedim >::cell_iterator compute_chart_points(const ArrayView< const Point< spacedim >> &surrounding_points, ArrayView< Point< dim >> chart_points) const
const double tolerance
Definition: manifold_lib.h:595
virtual Point< spacedim > push_forward(const Point< 3 > &chart_point) const override
SmartPointer< const Function< chartdim >, FunctionManifold< dim, spacedim, chartdim > > push_forward_function
Definition: manifold_lib.h:582
FunctionManifold(const Function< chartdim > &push_forward_function, const Function< spacedim > &pull_back_function, const Tensor< 1, chartdim > &periodicity=Tensor< 1, chartdim >(), const double tolerance=1e-10)
static Tensor< 1, spacedim > get_periodicity()
std::array< unsigned int, 20 > get_possible_cells_around_points(const ArrayView< const Point< spacedim >> &surrounding_points) const
virtual Point< spacedim > get_new_point(const ArrayView< const Point< spacedim >> &surrounding_points, const ArrayView< const double > &weights) const override
const Point< spacedim > point_on_axis
Definition: manifold_lib.h:453
std::vector< bool > coarse_cell_is_flat
Definition: manifold_lib.h:997
virtual std::unique_ptr< Manifold< dim, 3 > > clone() const override
virtual void get_new_points(const ArrayView< const Point< spacedim >> &surrounding_points, const Table< 2, double > &weights, ArrayView< Point< spacedim >> new_points) const override
const double finite_difference_step
Definition: manifold_lib.h:629
const std::string pull_back_expression
Definition: manifold_lib.h:614
virtual DerivativeForm< 1, 3, 3 > push_forward_gradient(const Point< 3 > &chart_point) const override
SmartPointer< const Function< spacedim >, FunctionManifold< dim, spacedim, chartdim > > pull_back_function
Definition: manifold_lib.h:588
virtual Point< spacedim > get_new_point(const ArrayView< const Point< spacedim >> &vertices, const ArrayView< const double > &weights) const override
virtual Point< 3 > pull_back(const Point< 3 > &p) const override
const Tensor< 1, spacedim > direction
Definition: manifold_lib.h:448
TorusManifold(const double R, const double r)
void initialize(const Triangulation< dim, spacedim > &triangulation)
virtual std::unique_ptr< Manifold< dim, spacedim > > clone() const override
const Point< spacedim > center
Definition: manifold_lib.h:114
virtual Point< 3 > push_forward(const Point< 3 > &chart_point) const override
virtual DerivativeForm< 1, 3, spacedim > push_forward_gradient(const Point< 3 > &chart_point) const override
CylindricalManifold(const unsigned int axis=0, const double tolerance=1e-10)
virtual std::unique_ptr< Manifold< dim, spacedim > > clone() const override
PolarManifold(const Point< spacedim > center=Point< spacedim >())
const PolarManifold< spacedim > polar_manifold
Definition: manifold_lib.h:359
virtual ~FunctionManifold() override
const std::string chart_vars
Definition: manifold_lib.h:619
virtual Point< chartdim > pull_back(const Point< spacedim > &space_point) const override
virtual Point< 3 > pull_back(const Point< spacedim > &space_point) const override
virtual Tensor< 1, spacedim > get_tangent_vector(const Point< spacedim > &x1, const Point< spacedim > &x2) const override
Point< spacedim > push_forward(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &chart_point) const
virtual Point< spacedim > push_forward(const Point< spacedim > &chart_point) const override
virtual Point< spacedim > get_new_point(const ArrayView< const Point< spacedim >> &surrounding_points, const ArrayView< const double > &weights) const override
virtual std::unique_ptr< Manifold< dim, spacedim > > clone() const override
virtual void get_normals_at_vertices(const typename Triangulation< dim, spacedim >::face_iterator &face, typename Manifold< dim, spacedim >::FaceVertexNormals &face_vertex_normals) const override
const Point< spacedim > center
Definition: manifold_lib.h:303
virtual void get_new_points(const ArrayView< const Point< spacedim >> &surrounding_points, const Table< 2, double > &weights, ArrayView< Point< spacedim >> new_points) const override
virtual ~TransfiniteInterpolationManifold() override
virtual Point< spacedim > push_forward(const Point< chartdim > &chart_point) const override
virtual Point< spacedim > pull_back(const Point< spacedim > &space_point) const override
virtual DerivativeForm< 1, chartdim, spacedim > push_forward_gradient(const Point< chartdim > &chart_point) const override
const Tensor< 1, spacedim > normal_direction
Definition: manifold_lib.h:443
const std::string space_vars
Definition: manifold_lib.h:624
Point< dim > pull_back(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p, const Point< dim > &initial_guess) const
const Triangulation< dim, spacedim > * triangulation
Definition: manifold_lib.h:984
const std::string push_forward_expression
Definition: manifold_lib.h:609
std::pair< double, Tensor< 1, spacedim > > guess_new_point(const ArrayView< const Tensor< 1, spacedim >> &directions, const ArrayView< const double > &distances, const ArrayView< const double > &weights) const
const FunctionParser< spacedim >::ConstMap const_map
Definition: manifold_lib.h:576
boost::signals2::connection clear_signal
virtual std::unique_ptr< Manifold< dim, spacedim > > clone() const override
const bool owns_pointers
Definition: manifold_lib.h:604
SphericalManifold(const Point< spacedim > center=Point< spacedim >())
virtual Point< spacedim > get_intermediate_point(const Point< spacedim > &p1, const Point< spacedim > &p2, const double w) const override
virtual std::unique_ptr< Manifold< dim, spacedim > > clone() const override
virtual DerivativeForm< 1, spacedim, spacedim > push_forward_gradient(const Point< spacedim > &chart_point) const override
virtual Tensor< 1, spacedim > normal_vector(const typename Triangulation< dim, spacedim >::face_iterator &face, const Point< spacedim > &p) const override