dune-fem 2.8.0
Loading...
Searching...
No Matches
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#include <dune/common/fvector.hh>
5
6namespace Dune
7{
8
9 namespace Fem
10 {
11
12 // RadialFilter
13 // ------------
14
17 template < typename ct, int dimw >
19 {
20 public:
22 typedef ct ctype;
23
25 static constexpr int dimensionworld = dimw;
26
28 typedef Dune::FieldVector< ct, dimw > GlobalCoordinateType;
29
32 ctype radius = 0.25)
33 : center_( center ),
34 radius_( radius )
35 { }
36
38 template< class Entity >
39 bool contains ( const Entity & entity ) const
40 {
41 constexpr int cc = Entity::codimension;
42 if( cc != 0 )
43 DUNE_THROW( InvalidStateException, "RadialFilter::contains only available for codim 0 entities" );
44 ctype dist = (entity.geometry().center() - center_).two_norm();
45 return (dist > radius_);
46 }
47
49 template< class Intersection >
50 bool interiorIntersection( const Intersection &intersection ) const
51 {
52 return contains( intersection.outside() );
53 }
54
56 // which is either it.boundary == true or contains (it.ouside()) == false
57 // so here true is a good choice
58 template < class Intersection >
59 bool intersectionBoundary( const Intersection & ) const
60 {
61 return true;
62 }
64 // which is either it.boundary == true or contains (it.ouside()) == false
65 template < class Intersection >
66 int intersectionBoundaryId(const Intersection & ) const
67 {
68 return 1;
69 }
70
72 template <class Intersection>
73 bool intersectionNeighbor( const Intersection & ) const
74 {
75 return false;
76 }
77
78 private:
79 const GlobalCoordinateType center_;
80 const ctype radius_;
81
82 }; // end RadialFilter
83
84 } // namespace Fem
85
86} // namespace Dune
87
88#endif // #ifndef DUNE_FEM_GRIDPART_FILTER_RADIALFILTER_HH
89
Definition: bindguard.hh:11
given center x and radius r, filter is characteristic function of clos B_r( x )
Definition: radialfilter.hh:19
static constexpr int dimensionworld
export dimension
Definition: radialfilter.hh:25
bool intersectionBoundary(const Intersection &) const
return what boundary id we have in case of boundary intersection
Definition: radialfilter.hh:59
RadialFilter(const GlobalCoordinateType &center=GlobalCoordinateType(0), ctype radius=0.25)
constructor
Definition: radialfilter.hh:31
int intersectionBoundaryId(const Intersection &) const
return what boundary id we have in case of boundary intersection
Definition: radialfilter.hh:66
Dune::FieldVector< ct, dimw > GlobalCoordinateType
coordinate type
Definition: radialfilter.hh:28
ct ctype
export template parameter
Definition: radialfilter.hh:22
bool contains(const Entity &entity) const
check whether entity center is inside of circle
Definition: radialfilter.hh:39
bool intersectionNeighbor(const Intersection &) const
if contains() is true then we have an interior entity
Definition: radialfilter.hh:73
bool interiorIntersection(const Intersection &intersection) const
default implementation returns contains from neighbor
Definition: radialfilter.hh:50