dune-localfunctions  2.2.0
equidistantpoints.hh
Go to the documentation of this file.
1 #ifndef DUNE_EQUIDISTANTPOINTS_HH
2 #define DUNE_EQUIDISTANTPOINTS_HH
3 
4 #include <vector>
5 
6 #include <dune/common/fvector.hh>
7 #include <dune/common/forloop.hh>
8 #include <dune/geometry/topologyfactory.hh>
9 #include <dune/geometry/genericgeometry/topologytypes.hh>
10 #include <dune/geometry/genericgeometry/subtopologies.hh>
11 
14 
15 namespace Dune
16 {
17 
18  // Internal Forward Declarations
19  // -----------------------------
20 
21  template< class F, unsigned int dim >
22  class EquidistantPointSet;
23 
24  // EquidistantPointSetImpl
25  // ----------------------------
26 
27  template< class Topology, class F >
28  class EquidistantPointSetImpl;
29 
30  template< class F >
31  class EquidistantPointSetImpl< GenericGeometry::Point, F >
32  {
34 
35  typedef GenericGeometry::Point Topology;
36 
37  friend class EquidistantPointSet< F, Topology::dimension >;
38  friend class EquidistantPointSetImpl< GenericGeometry::Prism< Topology >, F >;
39  friend class EquidistantPointSetImpl< GenericGeometry::Pyramid< Topology >, F >;
40 
41  public:
42  typedef F Field;
43 
44  static const unsigned int dimension = Topology::dimension;
45 
46  static unsigned int size ( const unsigned int order )
47  {
48  return 1;
49  }
50 
51  private:
52  template< unsigned int codim, unsigned int dim >
53  static unsigned int setup ( const unsigned int order,
54  unsigned int *count,
56  {
57  assert( codim == 0 );
58  points->localKey_ = LocalKey( 0, 0, count[ 0 ]++ );
59  points->point_ = Field( 0 );
60  return 1;
61  }
62  };
63 
64  template< class BaseTopology, class F >
65  class EquidistantPointSetImpl< GenericGeometry::Prism< BaseTopology >, F >
66  {
67  typedef EquidistantPointSetImpl< GenericGeometry::Prism< BaseTopology >, F > This;
68 
69  typedef GenericGeometry::Prism< BaseTopology > Topology;
70 
71  friend class EquidistantPointSet< F, Topology::dimension >;
72  friend class EquidistantPointSetImpl< GenericGeometry::Prism< Topology >, F >;
73  friend class EquidistantPointSetImpl< GenericGeometry::Pyramid< Topology >, F >;
74 
75  typedef EquidistantPointSetImpl< BaseTopology, F > BaseImpl;
76 
77  public:
78  typedef F Field;
79 
80  static const unsigned int dimension = Topology::dimension;
81 
82  static unsigned int size ( const unsigned int order )
83  {
84  return BaseImpl::size( order ) * (order+1);
85  }
86 
87  // private:
88  template< unsigned int codim, unsigned int dim >
89  static unsigned int setup ( const unsigned int order,
90  unsigned int *count,
92  {
93  unsigned int size = 0;
94  unsigned int numBaseN = 0;
95 
96  if( codim < dimension )
97  {
98  const unsigned int vcodim = (codim < dimension ? codim : dimension-1);
100  for( unsigned int i = 1; i < order; ++i )
101  {
102  const unsigned int n = BaseImpl::template setup< vcodim, dim >( order, count, points );
103  for( unsigned int j = 0; j < n; ++j )
104  {
105  LocalKey &key = points->localKey_;
106  key = LocalKey( key.subEntity(), codim, key.index() );
107  points->point_[ dimension-1 ] = Field( i ) / Field( order );
108  ++points;
109  }
110  size += n;
111  }
112  }
113 
114  if( codim > 0 )
115  {
116  const unsigned int vcodim = (codim > 0 ? codim : 1);
117  const unsigned int numBaseM = GenericGeometry::Size< BaseTopology, vcodim-1 >::value;
118  const unsigned int n = BaseImpl::template setup< vcodim-1, dim >( order, count+numBaseN, points );
119  for( unsigned int j = 0; j < n; ++j )
120  {
121  LocalKey &key = points[ j ].localKey_;
122  key = LocalKey( key.subEntity() + numBaseN, codim, key.index() );
123  points[ j + n ].point_ = points[ j ].point_;
124  points[ j + n ].point_[ dimension-1 ] = Field( 1 );
125  points[ j + n ].localKey_ = LocalKey( key.subEntity() + numBaseM, codim, key.index() );
126  ++count[ key.subEntity() + numBaseM ];
127  }
128  size += 2*n;
129  }
130  return size;
131  }
132  };
133 
134  template< class BaseTopology, class F >
135  class EquidistantPointSetImpl< GenericGeometry::Pyramid< BaseTopology >, F >
136  {
77<) 2an>  return
136  {
Ċibe position of one degree of freedom.">LocalKey &key = points[ j ].indexdelete [] coeff;