Dune Core Modules (2.6.0)

boundaryprojection.hh
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  {
29 
31  virtual CoordinateType operator() (const CoordinateType& global) const = 0;
32  };
33 
34  template < int dimworld >
35  class BoundaryProjectionWrapper
36  : public DuneBoundaryProjection< dimworld >
37  {
38  protected:
39  typedef DuneBoundaryProjection< dimworld > BaseType;
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 
51  ~BoundaryProjectionWrapper () {}
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:
73  typedef typename Base::CoordinateType CoordinateType;
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>
114  struct CircleBoundaryProjection : public DuneBoundaryProjection< dimworld >
115  {
117  typedef FieldVector< double, dimworld> CoordinateType;
118 
120  CircleBoundaryProjection(const double radius = std::sqrt( (double)dimworld ))
121  : radius_( radius ) {}
122 
124  virtual ~CircleBoundaryProjection() {}
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
Base class for grid boundary segments of arbitrary geometry.
Definition: boundaryprojection.hh:67
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition: boundaryprojection.hh:91
BoundarySegmentWrapper(const GeometryType &type, const std::vector< CoordinateType > &vertices, const std::shared_ptr< BoundarySegment > &boundarySegment)
Definition: boundaryprojection.hh:84
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:277
generic geometry implementation based on corner coordinates
Definition: multilineargeometry.hh:179
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:10
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:30
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:24
virtual CoordinateType operator()(const CoordinateType &global) const =0
projection operator projection a global coordinate
virtual ~DuneBoundaryProjection()
destructor
Definition: boundaryprojection.hh:28
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition: boundaryprojection.hh:26
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 1, 22:29, 2024)