dune-localfunctions  2.3beta2
pqkfactory.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_PQK_FACTORY_HH
4 #define DUNE_PQK_FACTORY_HH
5 
6 #include <map>
7 
8 #include <dune/geometry/type.hh>
9 
12 
21 
22 namespace Dune
23 {
24 
29  template<class D, class R, int d, int k>
31  {
33 
35  static LocalFiniteElementVirtualInterface<T>* create(const GeometryType& gt)
36  {
37  return 0;
38  }
39  };
40 
45  template<class D, class R, int k>
47  {
53 
55  static LocalFiniteElementVirtualInterface<T>* create(const GeometryType& gt)
56  {
57  if ((gt.isPrism())and (k==1))
59  if ((gt.isPrism())and (k==2))
61  if ((gt.isPyramid())and (k==1))
63  if ((gt.isPyramid())and (k==2))
65  return 0;
66  }
67  };
68 
69 
73  template<class D, class R, int dim, int k>
75  {
81 
82 
84  static FiniteElementType* create(const GeometryType& gt)
85  {
86  if (k==0)
87  return new LocalFiniteElementVirtualImp<P0>(P0(gt));
88 
89  if (gt.isSimplex())
91 
92  if (gt.isCube())
94 
96  }
97  };
98 
99 
100 
111  template<class D, class R, int dim, int k>
113  {
114  protected:
117  typedef typename std::map<GeometryType,FE*> FEMap;
118 
119  public:
122 
125 
128  {
129  typename FEMap::iterator it = other.cache_.begin();
130  typename FEMap::iterator end = other.cache_.end();
131  for(; it!=end; ++it)
132  cache_[it->first] = (it->second)->clone();
133  }
134 
136  {
137  typename FEMap::iterator it = cache_.begin();
138  typename FEMap::iterator end = cache_.end();
139  for(; it!=end; ++it)
140  delete it->second;
141  }
142 
144  const FiniteElementType& get(const GeometryType& gt) const
145  {
146  typename FEMap::const_iterator it = cache_.find(gt);
147  if (it==cache_.end())
148  {
150  if (fe==0)
151  DUNE_THROW(Dune::NotImplemented,"No Pk/Qk like local finite element available for geometry type " << gt << " and order " << k);
152 
153  cache_[gt] = fe;
154  return *fe;
155  }
156  return *(it->second);
157  }
158 
159  protected:
160  mutable FEMap cache_;
161 
162  };
163 
164 }
165 
166 #endif