dune-grid 3.0-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
17namespace 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:
41 public:
43 typedef typename BaseType :: CoordinateType CoordinateType;
44
45 // constructor taking other projection
47 : proj_( proje )
48 {}
49
52
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
84 BoundarySegmentWrapper ( const GeometryType &type,
85 const std::vector< CoordinateType > &vertices,
86 const std::shared_ptr< BoundarySegment > &boundarySegment )
87 : faceMapping_( FaceMapping( type, vertices ) ),
88 boundarySegment_( boundarySegment )
89 {}
90
92 {
93 return boundarySegment() ( faceMapping_.local( global ) );
94 }
95
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
Base class for grid boundary segments of arbitrary geometry.
Include standard header files.
Definition agrid.hh:60
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
Definition boundaryprojection.hh:37
BaseType::CoordinateType CoordinateType
type of coordinate vector
Definition boundaryprojection.hh:43
BoundaryProjectionWrapper(const BaseType &proje)
Definition boundaryprojection.hh:46
const BaseType & proj_
Definition boundaryprojection.hh:40
DuneBoundaryProjection< dimworld > BaseType
Definition boundaryprojection.hh:39
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition boundaryprojection.hh:54
~BoundaryProjectionWrapper()
destructor
Definition boundaryprojection.hh:51
Definition boundaryprojection.hh:67
CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition boundaryprojection.hh:91
const BoundarySegment & boundarySegment() const
Definition boundaryprojection.hh:96
BoundarySegmentWrapper(const GeometryType &type, const std::vector< CoordinateType > &vertices, const std::shared_ptr< BoundarySegment > &boundarySegment)
Definition boundaryprojection.hh:84
Dune::BoundarySegment< dim, dimworld > BoundarySegment
Definition boundaryprojection.hh:74
Base::CoordinateType CoordinateType
Definition boundaryprojection.hh:73
Definition boundaryprojection.hh:115
FieldVector< double, dimworld > CoordinateType
type of coordinate vector
Definition boundaryprojection.hh:117
CircleBoundaryProjection(const double radius=std::sqrt((double) dimworld))
constructor taking radius of circle (default = sqrt( dimworld ) )
Definition boundaryprojection.hh:120
virtual CoordinateType operator()(const CoordinateType &global) const
projection operator projection a global coordinate
Definition boundaryprojection.hh:127
virtual ~CircleBoundaryProjection()
destructor
Definition boundaryprojection.hh:124
const double radius_
radius of circ
Definition boundaryprojection.hh:139
Base class for classes implementing geometries of boundary segments.
Definition boundarysegment.hh:30