| 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_PK1DLOCALFINITEELEMENT_HH |
| 6 |
#define DUNE_PK1DLOCALFINITEELEMENT_HH |
| 7 |
|
| 8 |
#include <cstddef> |
| 9 |
|
| 10 |
#include <dune/geometry/type.hh> |
| 11 |
|
| 12 |
#include <dune/localfunctions/common/localfiniteelementtraits.hh> |
| 13 |
#include <dune/localfunctions/common/localtoglobaladaptors.hh> |
| 14 |
#include <dune/localfunctions/lagrange/lagrangesimplex.hh> |
| 15 |
|
| 16 |
namespace Dune |
| 17 |
{ |
| 18 |
|
| 19 |
|
| 20 |
//! Langrange finite element of arbitrary order on triangles |
| 21 |
/** |
| 22 |
* \tparam Geometry Geometry for the local to global transformation. |
| 23 |
* \tparam RF Field type of the range. |
| 24 |
* \tparam k Maximum polynomial order of the base functions. |
| 25 |
* |
| 26 |
* \implements FiniteElementInterface |
| 27 |
*/ |
| 28 |
template<class Geometry, class RF, std::size_t k> |
| 29 |
class Pk1DFiniteElement { |
| 30 |
typedef typename Geometry::ctype DF; |
| 31 |
typedef Impl::LagrangeSimplexLocalBasis<DF,RF,1,k> LocalBasis; |
| 32 |
typedef Impl::LagrangeSimplexLocalInterpolation<LocalBasis> LocalInterpolation; |
| 33 |
|
| 34 |
public: |
| 35 |
/** |
| 36 |
* \implements FiniteElementInterface::Traits |
| 37 |
*/ |
| 38 |
struct Traits { |
| 39 |
typedef ScalarLocalToGlobalBasisAdaptor<LocalBasis, Geometry> Basis; |
| 40 |
typedef LocalToGlobalInterpolationAdaptor< |
| 41 |
LocalInterpolation, |
| 42 |
typename Basis::Traits |
| 43 |
> Interpolation; |
| 44 |
typedef Impl::LagrangeSimplexLocalCoefficients<1,k> Coefficients; |
| 45 |
}; |
| 46 |
|
| 47 |
private: |
| 48 |
static const GeometryType gt; |
| 49 |
static const LocalBasis localBasis; |
| 50 |
static const LocalInterpolation localInterpolation; |
| 51 |
|
| 52 |
typename Traits::Basis basis_; |
| 53 |
typename Traits::Interpolation interpolation_; |
| 54 |
typename Traits::Coefficients coefficients_; |
| 55 |
|
| 56 |
public: |
| 57 |
//! construct a Pk1DFiniteElement |
| 58 |
/** |
| 59 |
* \param geometry The geometry object to use for adaption. |
| 60 |
* \param vertexOrder The global ordering of the vertices within the grid, |
| 61 |
* used to determine orientation of the edges. This |
| 62 |
* vertexOrder object must support codim=0. |
| 63 |
* |
| 64 |
* \note This class stores the reference to the geometry passed here. Any |
| 65 |
* use of this class after this references has become invalid |
| 66 |
* results in undefined behaviour. The exception is that the |
| 67 |
* destructor of this class may still be called. The information |
| 68 |
* contained in the vertexOrder object is extracted and the object |
| 69 |
* is no longer needed after the constructor returns. |
| 70 |
*/ |
| 71 |
template<class VertexOrder> |
| 72 |
Pk1DFiniteElement(const Geometry &geometry, |
| 73 |
const VertexOrder& vertexOrder) : |
| 74 |
basis_(localBasis, geometry), interpolation_(localInterpolation), |
| 75 |
coefficients_(vertexOrder.begin(0, 0)) |
| 76 |
{ } |
| 77 |
|
| 78 |
const typename Traits::Basis& basis() const { return basis_; } |
| 79 |
const typename Traits::Interpolation& interpolation() const |
| 80 |
{ return interpolation_; } |
| 81 |
const typename Traits::Coefficients& coefficients() const |
| 82 |
{ return coefficients_; } |
| 83 |
const GeometryType &type() const { return gt; } |
| 84 |
}; |
| 85 |
|
| 86 |
template<class Geometry, class RF, std::size_t k> |
| 87 |
const GeometryType |
| 88 |
Pk1DFiniteElement<Geometry, RF, k>::gt(GeometryTypes::simplex(2)); |
| 89 |
|
| 90 |
template<class Geometry, class RF, std::size_t k> |
| 91 |
const typename Pk1DFiniteElement<Geometry, RF, k>::LocalBasis |
| 92 |
Pk1DFiniteElement<Geometry, RF, k>::localBasis = LocalBasis(); |
| 93 |
|
| 94 |
template<class Geometry, class RF, std::size_t k> |
| 95 |
const typename Pk1DFiniteElement<Geometry, RF, k>::LocalInterpolation |
| 96 |
Pk1DFiniteElement<Geometry, RF, k>::localInterpolation = |
| 97 |
LocalInterpolation(); |
| 98 |
|
| 99 |
//! Factory for Pk1DFiniteElement objects |
| 100 |
/** |
| 101 |
* Constructs Pk1DFiniteElement objects given a geometry and a vertex |
| 102 |
* ordering. |
| 103 |
* |
| 104 |
* \tparam Geometry Geometry for the local to global transformation. |
| 105 |
* \tparam RF Field type of the range. |
| 106 |
* \tparam k Maximum polynomial order of the base functions. |
| 107 |
* |
| 108 |
* \implements FiniteElementFactoryInterface |
| 109 |
*/ |
| 110 |
template<class Geometry, class RF, std::size_t k> |
| 111 |
struct Pk1DFiniteElementFactory { |
| 112 |
typedef Pk1DFiniteElement<Geometry, RF, k> FiniteElement; |
| 113 |
|
| 114 |
//! construct Pk1DFiniteElementFactory |
| 115 |
/** |
| 116 |
* \param geometry The geometry object to use for adaption. |
| 117 |
* \param vertexOrder The global ordering of the vertices within the grid, |
| 118 |
* used to determine orientation of the edges. This |
| 119 |
* vertexOrder object must support codim=0. |
| 120 |
* |
| 121 |
* \note The returned object stores the reference to the geometry passed |
| 122 |
* here. Any use of the returned value after this references has |
| 123 |
* become invalid results in undefined behaviour. The exception is |
| 124 |
* that the destructor of this class may still be called. The |
| 125 |
* information contained in the vertexOrder object is extracted and |
| 126 |
* the object is no longer needed after the constructor returns. No |
| 127 |
* reference to internal data of the factory is stored. |
| 128 |
*/ |
| 129 |
template<class VertexOrder> |
| 130 |
const FiniteElement make(const Geometry& geometry, |
| 131 |
const VertexOrder& vertexOrder) |
| 132 |
{ return FiniteElement(geometry, vertexOrder); } |
| 133 |
}; |
| 134 |
} |
| 135 |
|
| 136 |
#endif |