| 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_LAGRANGELFECACHE_HH |
| 6 |
#define DUNE_LOCALFUNCTIONS_LAGRANGE_LAGRANGELFECACHE_HH |
| 7 |
|
| 8 |
#include <tuple> |
| 9 |
#include <utility> |
| 10 |
|
| 11 |
#include <dune/geometry/type.hh> |
| 12 |
#include <dune/geometry/typeindex.hh> |
| 13 |
|
| 14 |
#include <dune/localfunctions/lagrange/lagrangecube.hh> |
| 15 |
#include <dune/localfunctions/lagrange/lagrangeprism.hh> |
| 16 |
#include <dune/localfunctions/lagrange/lagrangepyramid.hh> |
| 17 |
#include <dune/localfunctions/lagrange/lagrangesimplex.hh> |
| 18 |
#include <dune/localfunctions/lagrange/p0.hh> |
| 19 |
#include <dune/localfunctions/common/localfiniteelementvariantcache.hh> |
| 20 |
|
| 21 |
|
| 22 |
namespace Dune { |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
namespace Impl { |
| 27 |
|
| 28 |
// Provide implemented Lagrange local finite elements |
| 29 |
|
| 30 |
template<class D, class R, std::size_t dim, std::size_t order> |
| 31 |
struct ImplementedLagrangeFiniteElements : public FixedDimLocalGeometryTypeIndex<dim> |
| 32 |
{ |
| 33 |
using FixedDimLocalGeometryTypeIndex<dim>::index; |
| 34 |
static auto getImplementations() |
| 35 |
{ |
| 36 |
return std::make_tuple( |
| 37 |
std::make_pair(index(GeometryTypes::simplex(dim)), []() { return LagrangeSimplexLocalFiniteElement<D,R,dim,order>(); }), |
| 38 |
std::make_pair(index(GeometryTypes::cube(dim)), []() { return LagrangeCubeLocalFiniteElement<D,R,dim,order>(); }) |
| 39 |
); |
| 40 |
} |
| 41 |
}; |
| 42 |
|
| 43 |
template<class D, class R, std::size_t dim> |
| 44 |
struct ImplementedLagrangeFiniteElements<D,R,dim,0> : public FixedDimLocalGeometryTypeIndex<dim> |
| 45 |
{ |
| 46 |
using FixedDimLocalGeometryTypeIndex<dim>::index; |
| 47 |
static auto getImplementations() |
| 48 |
{ |
| 49 |
return std::make_tuple( |
| 50 |
std::make_pair(index(GeometryTypes::simplex(dim)), []() { return P0LocalFiniteElement<D,R,dim>(GeometryTypes::simplex(dim)); }), |
| 51 |
std::make_pair(index(GeometryTypes::cube(dim)), []() { return P0LocalFiniteElement<D,R,dim>(GeometryTypes::cube(dim)); }), |
| 52 |
std::make_pair(index(GeometryTypes::none(dim)), []() { return P0LocalFiniteElement<D,R,dim>(GeometryTypes::none(dim)); }) |
| 53 |
); |
| 54 |
} |
| 55 |
}; |
| 56 |
|
| 57 |
template<class D, class R> |
| 58 |
struct ImplementedLagrangeFiniteElements<D,R,3,0> : public FixedDimLocalGeometryTypeIndex<3> |
| 59 |
{ |
| 60 |
using FixedDimLocalGeometryTypeIndex<3>::index; |
| 61 |
static auto getImplementations() |
| 62 |
{ |
| 63 |
return std::make_tuple( |
| 64 |
std::make_pair(index(GeometryTypes::tetrahedron), []() { return P0LocalFiniteElement<D,R,3>(GeometryTypes::tetrahedron); }), |
| 65 |
std::make_pair(index(GeometryTypes::hexahedron), []() { return P0LocalFiniteElement<D,R,3>(GeometryTypes::hexahedron); }), |
| 66 |
std::make_pair(index(GeometryTypes::prism), []() { return P0LocalFiniteElement<D,R,3>(GeometryTypes::prism); }), |
| 67 |
std::make_pair(index(GeometryTypes::pyramid), []() { return P0LocalFiniteElement<D,R,3>(GeometryTypes::pyramid); }) |
| 68 |
); |
| 69 |
} |
| 70 |
}; |
| 71 |
|
| 72 |
template<class D, class R> |
| 73 |
struct ImplementedLagrangeFiniteElements<D,R,3,1> : public FixedDimLocalGeometryTypeIndex<3> |
| 74 |
{ |
| 75 |
using FixedDimLocalGeometryTypeIndex<3>::index; |
| 76 |
static auto getImplementations() |
| 77 |
{ |
| 78 |
return std::make_tuple( |
| 79 |
std::make_pair(index(GeometryTypes::tetrahedron), []() { return LagrangeSimplexLocalFiniteElement<D,R,3,1>(); }), |
| 80 |
std::make_pair(index(GeometryTypes::hexahedron), []() { return LagrangeCubeLocalFiniteElement<D,R,3,1>(); }), |
| 81 |
std::make_pair(index(GeometryTypes::prism), []() { return LagrangePrismLocalFiniteElement<D,R,1>(); }), |
| 82 |
std::make_pair(index(GeometryTypes::pyramid), []() { return LagrangePyramidLocalFiniteElement<D,R,1>(); }) |
| 83 |
); |
| 84 |
} |
| 85 |
}; |
| 86 |
|
| 87 |
template<class D, class R> |
| 88 |
struct ImplementedLagrangeFiniteElements<D,R,3,2> : public FixedDimLocalGeometryTypeIndex<3> |
| 89 |
{ |
| 90 |
using FixedDimLocalGeometryTypeIndex<3>::index; |
| 91 |
static auto getImplementations() |
| 92 |
{ |
| 93 |
return std::make_tuple( |
| 94 |
std::make_pair(index(GeometryTypes::tetrahedron), []() { return LagrangeSimplexLocalFiniteElement<D,R,3,2>(); }), |
| 95 |
std::make_pair(index(GeometryTypes::hexahedron), []() { return LagrangeCubeLocalFiniteElement<D,R,3,2>(); }), |
| 96 |
std::make_pair(index(GeometryTypes::prism), []() { return LagrangePrismLocalFiniteElement<D,R,2>(); }), |
| 97 |
std::make_pair(index(GeometryTypes::pyramid), []() { return LagrangePyramidLocalFiniteElement<D,R,2>(); }) |
| 98 |
); |
| 99 |
} |
| 100 |
}; |
| 101 |
|
| 102 |
} // namespace Impl |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
/** \brief A cache that stores all available Pk/Qk like local finite elements for the given dimension and order |
| 107 |
* |
| 108 |
* An interface for dealing with different vertex orders is currently missing. |
| 109 |
* |
| 110 |
* \tparam D Type used for domain coordinates |
| 111 |
* \tparam R Type used for shape function values |
| 112 |
* \tparam dim Element dimension |
| 113 |
* \tparam order Element order |
| 114 |
* |
| 115 |
* The cached finite element implementations can be obtained using get(GeometryType). |
| 116 |
*/ |
| 117 |
template<class D, class R, std::size_t dim, std::size_t order> |
| 118 |
using LagrangeLocalFiniteElementCache = LocalFiniteElementVariantCache<Impl::ImplementedLagrangeFiniteElements<D,R,dim,order>>; |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
} // namespace Dune |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
#endif // DUNE_LOCALFUNCTIONS_LAGRANGE_LAGRANGELFECACHE_HH |