| 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 |
|
| 6 |
#ifndef DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_HH |
| 7 |
#define DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_HH |
| 8 |
|
| 9 |
#include <dune/geometry/type.hh> |
| 10 |
|
| 11 |
#include <dune/localfunctions/whitney/edges0.5/basis.hh> |
| 12 |
#include <dune/localfunctions/whitney/edges0.5/coefficients.hh> |
| 13 |
#include <dune/localfunctions/whitney/edges0.5/interpolation.hh> |
| 14 |
|
| 15 |
namespace Dune { |
| 16 |
|
| 17 |
////////////////////////////////////////////////////////////////////// |
| 18 |
// |
| 19 |
// FiniteElement |
| 20 |
// |
| 21 |
|
| 22 |
//! FiniteElement for lowest order edge elements on simplices |
| 23 |
/** |
| 24 |
* Uses the representation |
| 25 |
* \f[ |
| 26 |
* \mathbf N^i=(L^{i_0}\nabla L^{i_1}- |
| 27 |
* L^{i_1}\nabla L^{i_0})\ell^i |
| 28 |
* \f] |
| 29 |
* where \f$L^k\f$ is the P1 shape function for vertex \f$k\f$, \f$i_0\f$ |
| 30 |
* and \f$i_1\f$ are the indices of the vertices of edge \f$i\f$ and |
| 31 |
* \f$\ell^i\f$ is the length of edge \f$i\f$. |
| 32 |
* |
| 33 |
* \ingroup Whitney |
| 34 |
* |
| 35 |
* \tparam D Type to represent the field in the domain. |
| 36 |
* \tparam R Type to represent the field in the range. |
| 37 |
* \tparam dim Dimension of both domain and range. |
| 38 |
* |
| 39 |
* \nosubgrouping |
| 40 |
*/ |
| 41 |
template<class Geometry, class RF> |
| 42 |
class EdgeS0_5FiniteElement { |
| 43 |
public: |
| 44 |
/** |
| 45 |
* \implements FiniteElementInterface::Traits |
| 46 |
*/ |
| 47 |
struct Traits { |
| 48 |
typedef EdgeS0_5Basis<Geometry, RF> Basis; |
| 49 |
typedef EdgeS0_5Interpolation<Geometry, |
| 50 |
typename Basis::Traits> Interpolation; |
| 51 |
typedef EdgeS0_5Coefficients<Geometry::mydimension> Coefficients; |
| 52 |
}; |
| 53 |
|
| 54 |
private: |
| 55 |
typename Traits::Basis basis_; |
| 56 |
typename Traits::Interpolation interpolation_; |
| 57 |
static const typename Traits::Coefficients& coefficients_; |
| 58 |
|
| 59 |
public: |
| 60 |
//! Constructor |
| 61 |
/** |
| 62 |
* \copydetails EdgeS0_5Basis::EdgeS0_5Basis(const Geometry& geo, const VertexOrder& vertexOrder) |
| 63 |
*/ |
| 64 |
template<class VertexOrder> |
| 65 |
EdgeS0_5FiniteElement(const Geometry& geo, |
| 66 |
const VertexOrder& vertexOrder) : |
| 67 |
basis_(geo, vertexOrder), interpolation_(geo, vertexOrder) |
| 68 |
{ } |
| 69 |
|
| 70 |
//! return reference to the basis object |
| 71 |
const typename Traits::Basis& basis() const { return basis_; } |
| 72 |
//! return reference to the interpolation object |
| 73 |
const typename Traits::Interpolation& interpolation() const |
| 74 |
{ return interpolation_; } |
| 75 |
//! return reference to the coefficients object |
| 76 |
const typename Traits::Coefficients& coefficients() const |
| 77 |
{ return coefficients_; } |
| 78 |
//! return geometry type of this element |
| 79 |
static constexpr GeometryType type() { return GeometryTypes::simplex(Geometry::mydimension); } |
| 80 |
}; |
| 81 |
|
| 82 |
template<class Geometry, class RF> |
| 83 |
const typename EdgeS0_5FiniteElement<Geometry, RF>::Traits::Coefficients& |
| 84 |
EdgeS0_5FiniteElement<Geometry, RF>::coefficients_ = |
| 85 |
typename Traits::Coefficients(); |
| 86 |
|
| 87 |
//////////////////////////////////////////////////////////////////////// |
| 88 |
// |
| 89 |
// Factory |
| 90 |
// |
| 91 |
|
| 92 |
//! Factory for EdgeS0_5FiniteElement objects |
| 93 |
/** |
| 94 |
* Constructs EdgeS0_5FiniteElement objects given a geometry and a vertex |
| 95 |
* ordering. |
| 96 |
* |
| 97 |
* \tparam Geometry Geometry for the local to global transformation. |
| 98 |
* \tparam RF Field type of the range. |
| 99 |
* |
| 100 |
* \implements FiniteElementFactoryInterface |
| 101 |
*/ |
| 102 |
template<class Geometry, class RF> |
| 103 |
struct EdgeS0_5FiniteElementFactory { |
| 104 |
typedef EdgeS0_5FiniteElement<Geometry, RF> FiniteElement; |
| 105 |
|
| 106 |
//! construct the factory |
| 107 |
/** |
| 108 |
* \param geometry The geometry object to use for adaption. |
| 109 |
* \param vertexOrder The global ordering of the vertices within the grid, |
| 110 |
* used to determine orientation of the edges. This |
| 111 |
* vertexOrder object must support codim=0. |
| 112 |
* |
| 113 |
* \note The returned object stores the reference to the geometry passed |
| 114 |
* here. Any use of the returned value after this references has |
| 115 |
* become invalid results in undefined behaviour. The exception is |
| 116 |
* that the destructor of this class may still be called. The |
| 117 |
* information contained in the vertexOrder object is extracted and |
| 118 |
* the object is no longer needed after the constructor returns. No |
| 119 |
* reference to internal data of the factory is stored. |
| 120 |
*/ |
| 121 |
template<class VertexOrder> |
| 122 |
const FiniteElement make(const Geometry& geometry, |
| 123 |
const VertexOrder& vertexOrder) |
| 124 |
{ return FiniteElement(geometry, vertexOrder); } |
| 125 |
}; |
| 126 |
|
| 127 |
} // namespace Dune |
| 128 |
|
| 129 |
#endif // DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_HH |