// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception #ifndef DUNE_LOCALFUNCTIONS_ENRICHED_CUBEQ1BUBBLE_LOCALBASIS_HH #define DUNE_LOCALFUNCTIONS_ENRICHED_CUBEQ1BUBBLE_LOCALBASIS_HH #include #include #include #include #include #include #include namespace Dune { /** * \ingroup LocalFunctionsImpl * \brief Q1 basis in dim-d enriched by an (order 2) element bubble function. * * The shape functions are associated to the vertices and to the barycenter. The * bubble function is the product of the edge bubble basis functions scaled by * the factor 2^(2^dim). The edge bubble functions are the product of the * corresponding vertex basis functions. * * \tparam D Type to represent the field in the domain. * \tparam R Type to represent the field in the range. * * \nosubgrouping **/ template class CubeQ1BubbleLocalBasis { template friend class CubeQ1BubbleLocalInterpolation; //! Type of the local coordinates in the domain using DomainType = FieldVector; //! Range type of the basis functions using RangeType = FieldVector; //! Type of the jacobians of the basis functions using JacobianType = FieldMatrix; static constexpr int dimension = dim; static constexpr int numVertices = power(2, dim); // scaling factor of bubble basis function for normalization static constexpr int scaling = power(2, 2*dim); public: //! Type traits for function signature using Traits = LocalBasisTraits; //! Returns number of shape functions static constexpr std::size_t size () noexcept { return numVertices+1; } /// Evaluate all shape functions static constexpr void evaluateFunction (const DomainType& x, std::vector& out) { out.resize(size()); for (int i = 0; i < numVertices; ++i) { out[i] = 1; for (int j = 0; j < dimension; ++j) { // if j-th bit of i is set multiply with x[j], else with 1-x[j] out[i] *= (i & (1<& out) { out.resize(size()); // Loop over all linear shape functions for (int i = 0; i < numVertices; ++i) { // Loop over all coordinate directions for (int j = 0; j < dimension; ++j) { // Initialize: the overall expression as a product // if j-th bit of i is set to 1, else -11 out[i][0][j] = (i & (1<& order, const DomainType& x, std::vector& out) { unsigned int totalOrder = 0; for (int i = 0; i < dimension; ++i) totalOrder += order[i]; switch (totalOrder) { case 0: evaluateFunction(x,out); break; case 1: { out.resize(size()); int d = 0; // the direction of differentiation for (int i = 0; i < dimension; ++i) d += i * order[i]; if (d >= dimension) throw std::invalid_argument("Direction of partial derivative not found!"); // Loop over all shape functions for (int i = 0; i < numVertices; ++i) { // Initialize: the overall expression is a product // if j-th bit of i is set to 1, otherwise to -1 out[i] = (i & (1<