| 1 | // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 2 | // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 3 | #ifndef DUNE_LOCALFUNCTIONS_BREZZIDOUGLASFORTINMARINI_CUBE_LOCALCOEFFICIENTS_HH |
| 4 | #define DUNE_LOCALFUNCTIONS_BREZZIDOUGLASFORTINMARINI_CUBE_LOCALCOEFFICIENTS_HH |
| 5 | |
| 6 | #include <cstddef> |
| 7 | #include <vector> |
| 8 | |
| 9 | #include <dune/common/math.hh> |
| 10 | #include <dune/common/rangeutilities.hh> |
| 11 | #include <dune/common/typetraits.hh> |
| 12 | |
| 13 | #include <dune/localfunctions/common/localkey.hh> |
| 14 | |
| 15 | namespace Dune |
| 16 | { |
| 17 | |
| 18 | /** |
| 19 | * \ingroup BrezziDouglasFortinMariniImpl |
| 20 | * |
| 21 | * \brief Layout map for Brezzi-Douglas-Fortin-Marini elements on cubes. |
| 22 | * |
| 23 | * \tparam D Type of represent the field in the domain. |
| 24 | * \tparam R Type of represent the field in the domain. |
| 25 | * \tparam dim dimension of the reference element, must be >= 2. |
| 26 | * \tparam order order of the element, must be >= 1. |
| 27 | * |
| 28 | * \nosubgrouping |
| 29 | * \implements Dune::LocalCoefficientsVirtualImp |
| 30 | */ |
| 31 | template<class D, class R, unsigned int dim, unsigned int order> |
| 32 | class BDFMCubeLocalCoefficients |
| 33 | { |
| 34 | static constexpr unsigned int interiorDofs = dim*binomial(dim+order-2, order-2); |
| 35 | static constexpr unsigned int faceDofs = binomial(dim+order-2, order-1); |
| 36 | |
| 37 | static constexpr std::size_t numFaces = 2*dim; |
| 38 | static constexpr std::size_t numDofs = numFaces*faceDofs + interiorDofs; |
| 39 | |
| 40 | public: |
| 41 | //! \brief Standard constructor |
| 42 | BDFMCubeLocalCoefficients () : li(numDofs) |
| 43 | { |
| 44 | for (auto j : range(numFaces)) |
| 45 | for (auto i : range(faceDofs)) |
| 46 | li[j*faceDofs + i] = LocalKey(j, 1, i); |
| 47 | |
| 48 | for (auto i : range(interiorDofs)) |
| 49 | li[numFaces*faceDofs + i] = LocalKey(0, 0, i); |
| 50 | } |
| 51 | |
| 52 | //! \brief number of coefficients |
| 53 | std::size_t size () const { return numDofs; } |
| 54 | |
| 55 | //! \brief geth i'th index |
| 56 | auto localKey (std::size_t i) const -> const LocalKey& { return li[i]; } |
| 57 | |
| 58 | private: |
| 59 | std::vector<LocalKey> li; |
| 60 | }; |
| 61 | |
| 62 | template<class D, class R, unsigned int dim, unsigned int order> |
| 63 | constexpr unsigned int BDFMCubeLocalCoefficients<D, R, dim, order>::interiorDofs; |
| 64 | |
| 65 | template<class D, class R, unsigned int dim, unsigned int order> |
| 66 | constexpr unsigned int BDFMCubeLocalCoefficients<D, R, dim, order>::faceDofs; |
| 67 | |
| 68 | template<class D, class R, unsigned int dim, unsigned int order> |
| 69 | constexpr std::size_t BDFMCubeLocalCoefficients<D, R, dim, order>::numFaces; |
| 70 | |
| 71 | // template<class D, class R, unsigned int dim, unsigned int order> |
| 72 | // constexpr std::size_t BDFMCubeLocalCoefficients<D, R, dim, order>::numDofs; |
| 73 | |
| 74 | |
| 75 | #ifndef DOXYGEN |
| 76 | template<class D, class R, unsigned int dim> |
| 77 | class BDFMCubeLocalCoefficients<D, R, dim, 0> |
| 78 | { |
| 79 | static_assert( AlwaysFalse<D>::value, |
| 80 | "`BDFMCubeLocalCoefficients` not defined for order 0." ); |
| 81 | }; |
| 82 | #endif // #ifndef DOXYGEN |
| 83 | |
| 84 | } // namespace Dune |
| 85 | |
| 86 | #endif // #ifndef DUNE_LOCALFUNCTIONS_BREZZIDOUGLASFORTINMARINI_CUBE_LOCALCOEFFICIENTS_HH |