| 1 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
// vi: set et ts=4 sw=2 sts=2: |
| 3 |
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 4 |
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 5 |
#ifndef DUNE_LOCALFUNCTIONS_LAGRANGE_PQKFACTORY_HH |
| 6 |
#define DUNE_LOCALFUNCTIONS_LAGRANGE_PQKFACTORY_HH |
| 7 |
|
| 8 |
#include <map> |
| 9 |
|
| 10 |
#include <dune/geometry/type.hh> |
| 11 |
|
| 12 |
#include <dune/localfunctions/common/virtualinterface.hh> |
| 13 |
#include <dune/localfunctions/common/virtualwrappers.hh> |
| 14 |
|
| 15 |
#include <dune/localfunctions/lagrange/lagrangecube.hh> |
| 16 |
#include <dune/localfunctions/lagrange/lagrangeprism.hh> |
| 17 |
#include <dune/localfunctions/lagrange/lagrangepyramid.hh> |
| 18 |
#include <dune/localfunctions/lagrange/lagrangesimplex.hh> |
| 19 |
#include <dune/localfunctions/lagrange/p0.hh> |
| 20 |
|
| 21 |
namespace Dune |
| 22 |
{ |
| 23 |
|
| 24 |
/** \brief Factory that only creates dimension specific local finite elements |
| 25 |
* |
| 26 |
* Empty default implementation |
| 27 |
*/ |
| 28 |
template<class D, class R, int d, int k> |
| 29 |
struct DimSpecificPQkLocalFiniteElementFactory |
| 30 |
{ |
| 31 |
typedef typename P0LocalFiniteElement<D,R,d>::Traits::LocalBasisType::Traits T; |
| 32 |
|
| 33 |
//! create finite element for given GeometryType |
| 34 |
static LocalFiniteElementVirtualInterface<T>* create(const GeometryType&) |
| 35 |
{ |
| 36 |
return nullptr; |
| 37 |
} |
| 38 |
}; |
| 39 |
|
| 40 |
/** \brief Factory that only creates dimension specific local finite elements |
| 41 |
* |
| 42 |
* Specialization for dim=3 |
| 43 |
*/ |
| 44 |
template<class D, class R, int k> |
| 45 |
struct DimSpecificPQkLocalFiniteElementFactory<D,R,3,k> |
| 46 |
{ |
| 47 |
typedef typename P0LocalFiniteElement<D,R,3>::Traits::LocalBasisType::Traits T; |
| 48 |
using PrismP1 = LagrangePrismLocalFiniteElement<D,R,1>; |
| 49 |
using PrismP2 = LagrangePrismLocalFiniteElement<D,R,2>; |
| 50 |
using PyramidP1 = LagrangePyramidLocalFiniteElement<D,R,1>; |
| 51 |
using PyramidP2 = LagrangePyramidLocalFiniteElement<D,R,2>; |
| 52 |
|
| 53 |
//! create finite element for given GeometryType |
| 54 |
static LocalFiniteElementVirtualInterface<T>* create(const GeometryType& gt) |
| 55 |
{ |
| 56 |
if ((gt.isPrism())and (k==1)) |
| 57 |
return new LocalFiniteElementVirtualImp<PrismP1>(PrismP1()); |
| 58 |
if ((gt.isPrism())and (k==2)) |
| 59 |
return new LocalFiniteElementVirtualImp<PrismP2>(PrismP2()); |
| 60 |
if ((gt.isPyramid())and (k==1)) |
| 61 |
return new LocalFiniteElementVirtualImp<PyramidP1>(PyramidP1()); |
| 62 |
if ((gt.isPyramid())and (k==2)) |
| 63 |
return new LocalFiniteElementVirtualImp<PyramidP2>(PyramidP2()); |
| 64 |
return nullptr; |
| 65 |
} |
| 66 |
}; |
| 67 |
|
| 68 |
|
| 69 |
/** \brief Factory to create any kind of Pk/Qk like element wrapped for the virtual interface |
| 70 |
* |
| 71 |
*/ |
| 72 |
template<class D, class R, int dim, int k> |
| 73 |
struct PQkLocalFiniteElementFactory |
| 74 |
{ |
| 75 |
typedef typename P0LocalFiniteElement<D,R,dim>::Traits::LocalBasisType::Traits T; |
| 76 |
typedef LocalFiniteElementVirtualInterface<T> FiniteElementType; |
| 77 |
using P0 = P0LocalFiniteElement<D,R,dim>; |
| 78 |
using Pk = LagrangeSimplexLocalFiniteElement<D,R,dim,k>; |
| 79 |
using Qk = LagrangeCubeLocalFiniteElement<D,R,dim,k>; |
| 80 |
|
| 81 |
|
| 82 |
//! create finite element for given GeometryType |
| 83 |
static FiniteElementType* create(const GeometryType& gt) |
| 84 |
{ |
| 85 |
if (k==0) |
| 86 |
return new LocalFiniteElementVirtualImp<P0>(P0(gt)); |
| 87 |
|
| 88 |
if (gt.isSimplex()) |
| 89 |
return new LocalFiniteElementVirtualImp<Pk>(Pk()); |
| 90 |
|
| 91 |
if (gt.isCube()) |
| 92 |
return new LocalFiniteElementVirtualImp<Qk>(Qk()); |
| 93 |
|
| 94 |
return DimSpecificPQkLocalFiniteElementFactory<D,R,dim,k>::create(gt); |
| 95 |
} |
| 96 |
}; |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
#endif |