dune-localfunctions  2.4
dualpq1factory.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_LOCALFUNCTIONS_DUAL_P1_Q1_FACTORY_HH
4 #define DUNE_LOCALFUNCTIONS_DUAL_P1_Q1_FACTORY_HH
5 
6 #include <map>
7 
10 
12 
13 namespace Dune {
14 
15 template<class D, class R, int dim>
17 {
18 protected:
23  typedef std::map<Dune::GeometryType,FE*> FEMap;
24 
25 public:
27  typedef FE FiniteElementType;
28 
30  {
31  typename FEMap::iterator it = cache_.begin();
32  typename FEMap::iterator end = cache_.end();
33  for(; it!=end; ++it)
34  delete it->second;
35  }
36 
38  static FE* create(const Dune::GeometryType& gt)
39  {
40  if (gt.isSimplex())
42  if (gt.isCube())
44  return 0;
45  }
46 
48  const FiniteElementType& get(const Dune::GeometryType& gt) const
49  {
50  typename FEMap::const_iterator it = cache_.find(gt);
51  if (it==cache_.end())
52  {
53  FiniteElementType* fe = create(gt);
54 
55  if (fe==0)
56  DUNE_THROW(Dune::NotImplemented,"No Dual P/Q1 like local finite element available for geometry type " << gt);
57 
58  cache_[gt] = fe;
59  return *fe;
60  }
61  return *(it->second);
62  }
63 
64 protected:
65  mutable FEMap cache_;
66 };
67 
68 } // namespace Dune
69 
70 #endif // DUNE_LOCALFUNCTIONS_DUAL_P1_Q1_FACTORY_HH
FEMap cache_
Definition: dualpq1factory.hh:65
virtual base class for local finite elements with functions
Definition: virtualinterface.hh:381
Dune::DualQ1LocalFiniteElement< D, R, dim > DualQ1
Definition: dualpq1factory.hh:20
static FE * create(const Dune::GeometryType &gt)
create finite element for given GeometryType
Definition: dualpq1factory.hh:38
Dune::FixedOrderLocalBasisTraits< typename DualP1::Traits::LocalBasisType::Traits, 0 >::Traits T
Definition: dualpq1factory.hh:21
class for wrapping a finite element using the virtual interface
Definition: virtualwrappers.hh:19
~DualPQ1LocalFiniteElementCache()
Definition: dualpq1factory.hh:29
Dune::DualP1LocalFiniteElement< D, R, dim > DualP1
Definition: dualpq1factory.hh:19
The local dual p1 finite element on simplices.
Definition: dualp1.hh:22
The local dual Q1 finite element on cubes.
Definition: dualq1.hh:28
std::map< Dune::GeometryType, FE * > FEMap
Definition: dualpq1factory.hh:23
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:37
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:14
Dune::LocalFiniteElementVirtualInterface< T > FE
Definition: dualpq1factory.hh:22
Definition: dualpq1factory.hh:16
FE FiniteElementType
Type of the finite elements stored in this cache.
Definition: dualpq1factory.hh:27