dune-grid  2.6-git
boundaryprojection.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_BOUNDARYPROJECTION_HH
4 #define DUNE_BOUNDARYPROJECTION_HH
5 
6 //- system includes
7 #include <cmath>
8 #include <memory>
9 
10 //- Dune includes
11 #include <dune/common/fvector.hh>
12 
13 #include <dune/geometry/multilineargeometry.hh>
14 
16 
17 namespace Dune
18 {
19 
22  template <int dimworld>
24  {
26  typedef FieldVector< double, dimworld> CoordinateType;
29 
31  virtual CoordinateType operator() (const CoordinateType& global) const = 0;
32  };
33 
34  template < int dimworld >
36  : public DuneBoundaryProjection< dimworld >
37  {
38  protected:
40  const BaseType& proj_;
41  public:
43  typedef typename BaseType :: CoordinateType CoordinateType;
44 
45  // constructor taking other projection
46  BoundaryProjectionWrapper( const BaseType& proje )
47  : proj_( proje )
48  {}
49 
52 
54  CoordinateType operator() (const CoordinateType& global) const
55  {
56  return proj_( global );
57  }
58  };
59 
60  // BoundarySegmentWrapper
61  // ----------------------
62 
64  template< int dim, int dimworld >
66  : public DuneBoundaryProjection< dimworld >
67  {
69 
70  typedef MultiLinearGeometry<typename Base::CoordinateType::value_type,dim-1,dimworld> FaceMapping;
71 
72  public:
75 
85  const std::vector< CoordinateType > &vertices,
86  const std::shared_ptr< BoundarySegment > &boundarySegment )
87  : faceMapping_( FaceMapping( type, vertices ) ),
88  boundarySegment_( boundarySegment )
89  {}
90 
91  CoordinateType operator() ( const CoordinateType &global ) const
92  {
93  return boundarySegment() ( faceMapping_.local( global ) );
94  }
95 
96  const BoundarySegment &boundarySegment () const
97  {
98  return *boundarySegment_;
99  }
100 
101  private:
102  FaceMapping faceMapping_;
103  const std::shared_ptr< BoundarySegment > boundarySegment_;
104  };
105 
106 
107 
109  //
110  // Example of boundary projection projection to a circle
111  //
113  template <int dimworld>
115  {
117  typedef FieldVector< double, dimworld> CoordinateType;
118 
120  CircleBoundaryProjection(const double radius = std::sqrt( (double)dimworld ))
121  : radius_( radius ) {}
122 
125 
127  virtual CoordinateType operator() (const CoordinateType& global) const
128  {
129  CoordinateType prj( global );
130  // get adjustment factor
131  const double factor = radius_ / global.two_norm();
132  // adjust
133  prj *= factor;
134  return prj;
135  }
136 
137  protected:
139  const double radius_;
140  };
141 
142 } // end namespace
143 
144 #endif // #ifndef DUNE_BOUNDARYPROJECTION_HH
Include standard header files.
Definition: agrid.hh:58
const double radius_
radius of circ
Definition: boundaryprojection.hh:139
Base class for grid boundary segments of arbitrary geometry.
Definition: boundaryprojection.hh:114
BoundaryProjectionWrapper(const BaseType &proje)
Definition: boundaryprojection.hh:46
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:26
BaseType ::CoordinateType CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:43
Definition: boundaryprojection.hh:65
const BoundarySegment & boundarySegment() const
Definition: boundaryprojection.hh:96
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:117
virtual CoordinateType operator()(const CoordinateType &global) const =0
projection operator projection a global coordinate
Base::CoordinateType CoordinateType
Definition: boundaryprojection.hh:73
virtual ~CircleBoundaryProjection()
destructor
Definition: boundaryprojection.hh:124
DuneBoundaryProjection< dimworld > BaseType
Definition: boundaryprojection.hh:39
const BaseType & proj_
Definition: boundaryprojection.hh:40
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:178
BoundarySegmentWrapper(const GeometryType &type, const std::vector< CoordinateType > &vertices, const std::shared_ptr< BoundarySegment > &boundarySegment)
Definition: boundaryprojection.hh:84
Definition: boundaryprojection.hh:35
virtual ~DuneBoundaryProjection()
destructor
Definition: boundaryprojection.hh:28
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:23
CircleBoundaryProjection(const double radius=std::sqrt((double) dimworld))
constructor taking radius of circle (default = sqrt( dimworld ) )
Definition: boundaryprojection.hh:120
Dune::BoundarySegment< dim, dimworld > BoundarySegment
Definition: boundaryprojection.hh:74
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:29
~BoundaryProjectionWrapper()
destructor
Definition: boundaryprojection.hh:51