dune-fem  2.4.1-rc
radialfilter.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_FILTER_RADIALFILTER_HH
2 #define DUNE_FEM_GRIDPART_FILTER_RADIALFILTER_HH
3 
4 // dune-common includes
5 #include <dune/common/fvector.hh>
6 
7 namespace Dune
8 {
9 
10  namespace Fem
11  {
12 
13  // RadialFilter
14  // ------------
15 
19  template < typename ct, int dimw >
21  {
22  public:
24  typedef ct ctype;
25 
27  static const int dimensionworld = dimw;
28 
30  typedef Dune::FieldVector< ct, dimw > GlobalCoordinateType;
31 
33  RadialFilter( const GlobalCoordinateType & center,
34  const ctype radius )
35  : center_( center ),
36  radius_( radius )
37  { }
38 
40  : center_( 0 ),
41  radius_( 0.25 )
42  { }
43 
45  template< class Entity >
46  bool contains ( const Entity & entity ) const
47  {
48  static const int cc = Entity::codimension;
49  if( cc != 0 )
50  DUNE_THROW( InvalidStateException, "RadialFilter::contains only available for codim 0 entities" );
51  ctype dist = (entity.geometry().center() - center_).two_norm();
52  return (dist > radius_);
53  }
54 
56  template< class Intersection >
57  bool interiorIntersection( const Intersection &intersection ) const
58  {
59  typedef typename Intersection::Entity EntityType;
60  const EntityType outside(intersection.outside());
61  return contains( outside );
62  }
63 
65  // which is either it.boundary == true or contains (it.ouside()) == false
66  // so here true is a good choice
67  template < class IntersectionIteratorType >
68  inline bool intersectionBoundary( const IntersectionIteratorType & it ) const
69  {
70  return true;
71  }
73  // which is either it.boundary == true or contains (it.ouside()) == false
74  template < class IntersectionIteratorType >
75  inline int intersectionBoundaryId(const IntersectionIteratorType & it) const
76  {
77  return 1;
78  }
79 
81  template <class IntersectionIteratorType>
82  inline bool intersectionNeighbor( const IntersectionIteratorType & it ) const
83  {
84  return false;
85  }
86 
87  private:
88  const GlobalCoordinateType center_;
89  const ctype radius_;
90 
91  }; // end RadialFilter
92 
93  } // namespace Fem
94 
95 } // namespace Dune
96 
97 #endif // #ifndef DUNE_FEM_GRIDPART_FILTER_RADIALFILTER_HH
98 
RadialFilter()
Definition: radialfilter.hh:39
bool intersectionNeighbor(const IntersectionIteratorType &it) const
if contains() is true then we have an interior entity
Definition: radialfilter.hh:82
Dune::FieldVector< ct, dimw > GlobalCoordinateType
coordinate type
Definition: radialfilter.hh:30
bool contains(const Entity &entity) const
check whether entity center is inside of circle
Definition: radialfilter.hh:46
Definition: coordinate.hh:4
static const int dimensionworld
export dimension
Definition: radialfilter.hh:27
int intersectionBoundaryId(const IntersectionIteratorType &it) const
return what boundary id we have in case of boundary intersection
Definition: radialfilter.hh:75
bool interiorIntersection(const Intersection &intersection) const
default implementation returns contains from neighbor
Definition: radialfilter.hh:57
bool intersectionBoundary(const IntersectionIteratorType &it) const
return what boundary id we have in case of boundary intersection
Definition: radialfilter.hh:68
example implementation; given center x and radius r, filter is characteristic function of clos B_r( x...
Definition: radialfilter.hh:20
RadialFilter(const GlobalCoordinateType &center, const ctype radius)
constructor
Definition: radialfilter.hh:33
ct ctype
export template parameter
Definition: radialfilter.hh:24