dune-localfunctions  2.2.1
pqkfactory.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil -*-
2 // vi: set ts=4 sw=2 et 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  {
50 
52  static LocalFiniteElementVirtualInterface<T>* create(const GeometryType& gt)
53  {
54  if ((gt.isCube()) and (k==2))
56  return 0;
57  }
58  };
59 
64  template<class D, class R, int k>
66  {
72 
74  static LocalFiniteElementVirtualInterface<T>* create(const GeometryType& gt)
75  {
76  if ((gt.isPrism()) and (k==1))
78  if ((gt.isPrism()) and (k==2))
80  if ((gt.isPyramid()) and (k==1))
82  if ((gt.isPyramid()) and (k==2))
84  return 0;
85  }
86  };
87 
88 
92  template<class D, class R, int dim, int k>
94  {
100 
101 
103  static FiniteElementType* create(const GeometryType& gt)
104  {
105  if (k==0)
106  return new LocalFiniteElementVirtualImp<P0>(P0(gt));
107 
108  if (gt.isSimplex())
109  return new LocalFiniteElementVirtualImp<Pk>(Pk());
110 
111  if ((gt.isCube()) and (k==1))
112  return new LocalFiniteElementVirtualImp<Q1>(Q1());
113 
115  }
116  };
117 
118 
119 
130  template<class D, class R, int dim, int k>
132  {
133  protected:
136  typedef typename std::map<GeometryType,FE*> FEMap;
137 
138  public:
141 
144 
147  {
148  typename FEMap::iterator it = other.cache_.begin();
149  typename FEMap::iterator end = other.cache_.end();
150  for(; it!=end; ++it)
151  cache_[it->first] = (it->second)->clone();
152  }
153 
155  {
156  typename FEMap::iterator it = cache_.begin();
157  typename FEMap::iterator end = cache_.end();
158  for(; it!=end; ++it)
159  delete it->second;
160  }
161 
163  const FiniteElementType& get(const GeometryType& gt) const
164  {
165  typename FEMap::const_iterator it = cache_.find(gt);
166  if (it==cache_.end())
167  {
169  if (fe==0)
170  DUNE_THROW(Dune::NotImplemented,"No Pk/Qk like local finite element available for geometry type " << gt << " and order " << k);
171 
172  cache_[gt] = fe;
173  return *fe;
174  }
175  return *(it->second);
176  }
177 
178  protected:
179  mutable FEMap cache_;
180 
181  };
182 
183 }
184 
185 #endif