/usr/include/dune/localfunctions/lagrange/pqkfactory.hh is in libdune-localfunctions-dev 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_PQK_FACTORY_HH
#define DUNE_PQK_FACTORY_HH
#include <map>
#include <dune/geometry/type.hh>
#include <dune/localfunctions/common/virtualinterface.hh>
#include <dune/localfunctions/common/virtualwrappers.hh>
#include <dune/localfunctions/lagrange/p0.hh>
#include <dune/localfunctions/lagrange/pk.hh>
#include <dune/localfunctions/lagrange/q1.hh>
#include <dune/localfunctions/lagrange/qk.hh>
#include <dune/localfunctions/lagrange/prismp1.hh>
#include <dune/localfunctions/lagrange/prismp2.hh>
#include <dune/localfunctions/lagrange/pyramidp1.hh>
#include <dune/localfunctions/lagrange/pyramidp2.hh>
namespace Dune
{
/** \brief Factory that only creates dimension specific local finite elements
*
* Empty default implementation
*/
template<class D, class R, int d, int k>
struct DimSpecificPQkLocalFiniteElementFactory
{
typedef typename FixedOrderLocalBasisTraits<typename P0LocalFiniteElement<D,R,d>::Traits::LocalBasisType::Traits,0>::Traits T;
//! create finite element for given GeometryType
static LocalFiniteElementVirtualInterface<T>* create(const GeometryType& gt)
{
return 0;
}
};
/** \brief Factory that only creates dimension specific local finite elements
*
* Specialization for dim=3
*/
template<class D, class R, int k>
struct DimSpecificPQkLocalFiniteElementFactory<D,R,3,k>
{
typedef typename FixedOrderLocalBasisTraits<typename P0LocalFiniteElement<D,R,3>::Traits::LocalBasisType::Traits,0>::Traits T;
typedef PrismP1LocalFiniteElement<D,R> PrismP1;
typedef PrismP2LocalFiniteElement<D,R> PrismP2;
typedef PyramidP1LocalFiniteElement<D,R> PyramidP1;
typedef PyramidP2LocalFiniteElement<D,R> PyramidP2;
//! create finite element for given GeometryType
static LocalFiniteElementVirtualInterface<T>* create(const GeometryType& gt)
{
if ((gt.isPrism())and (k==1))
return new LocalFiniteElementVirtualImp<PrismP1>(PrismP1());
if ((gt.isPrism())and (k==2))
return new LocalFiniteElementVirtualImp<PrismP2>(PrismP2());
if ((gt.isPyramid())and (k==1))
return new LocalFiniteElementVirtualImp<PyramidP1>(PyramidP1());
if ((gt.isPyramid())and (k==2))
return new LocalFiniteElementVirtualImp<PyramidP2>(PyramidP2());
return 0;
}
};
/** \brief Factory to create any kind of Pk/Qk like element wrapped for the virtual interface
*
*/
template<class D, class R, int dim, int k>
struct PQkLocalFiniteElementFactory
{
typedef typename FixedOrderLocalBasisTraits<typename P0LocalFiniteElement<D,R,dim>::Traits::LocalBasisType::Traits,0>::Traits T;
typedef LocalFiniteElementVirtualInterface<T> FiniteElementType;
typedef P0LocalFiniteElement<D,R,dim> P0;
typedef PkLocalFiniteElement<D,R,dim,k> Pk;
typedef QkLocalFiniteElement<D,R,dim,k> Qk;
//! create finite element for given GeometryType
static FiniteElementType* create(const GeometryType& gt)
{
if (k==0)
return new LocalFiniteElementVirtualImp<P0>(P0(gt));
if (gt.isSimplex())
return new LocalFiniteElementVirtualImp<Pk>(Pk());
if (gt.isCube())
return new LocalFiniteElementVirtualImp<Qk>(Qk());
return DimSpecificPQkLocalFiniteElementFactory<D,R,dim,k>::create(gt);
}
};
/** \brief A cache that stores all available Pk/Qk like local finite elements for the given dimension and order
*
* An interface for dealing with different vertex orders is currently missing.
* So you can in general only use this for order=1,2 or with global DG spaces
*
* \tparam D Type used for domain coordinates
* \tparam R Type used for shape function values
* \tparam dim Element dimension
* \tparam k Element order
*/
template<class D, class R, int dim, int k>
class PQkLocalFiniteElementCache
{
protected:
typedef typename FixedOrderLocalBasisTraits<typename P0LocalFiniteElement<D,R,dim>::Traits::LocalBasisType::Traits,0>::Traits T;
typedef LocalFiniteElementVirtualInterface<T> FE;
typedef typename std::map<GeometryType,FE*> FEMap;
public:
/** \brief Type of the finite elements stored in this cache */
typedef FE FiniteElementType;
/** \brief Default constructor */
PQkLocalFiniteElementCache() {}
/** \brief Copy constructor */
PQkLocalFiniteElementCache(const PQkLocalFiniteElementCache& other)
{
typename FEMap::iterator it = other.cache_.begin();
typename FEMap::iterator end = other.cache_.end();
for(; it!=end; ++it)
cache_[it->first] = (it->second)->clone();
}
~PQkLocalFiniteElementCache()
{
typename FEMap::iterator it = cache_.begin();
typename FEMap::iterator end = cache_.end();
for(; it!=end; ++it)
delete it->second;
}
//! Get local finite element for given GeometryType
const FiniteElementType& get(const GeometryType& gt) const
{
typename FEMap::const_iterator it = cache_.find(gt);
if (it==cache_.end())
{
FiniteElementType* fe = PQkLocalFiniteElementFactory<D,R,dim,k>::create(gt);
if (fe==0)
DUNE_THROW(Dune::NotImplemented,"No Pk/Qk like local finite element available for geometry type " << gt << " and order " << k);
cache_[gt] = fe;
return *fe;
}
return *(it->second);
}
protected:
mutable FEMap cache_;
};
}
#endif
|