// -*- 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_NEDELEC_NEDELECSIMPLEX_NEDELECSIMPLEXPREBASIS_HH #define DUNE_LOCALFUNCTIONS_NEDELEC_NEDELECSIMPLEX_NEDELECSIMPLEXPREBASIS_HH #include #include #include #include namespace Dune { template < GeometryType::Id geometryId, class Field > struct NedelecVecMatrix; /** * \ingroup NedelecImpl */ template struct NedelecPreBasisFactory { typedef MonomialBasisProvider MBasisFactory; typedef typename MBasisFactory::Object MBasis; typedef StandardEvaluator EvalMBasis; typedef PolynomialBasisWithMatrix > Basis; typedef const Basis Object; typedef std::size_t Key; template struct EvaluationBasisFactory { typedef MonomialBasisProvider Type; }; template< GeometryType::Id geometryId > static Object *create ( Key order ) { /* * The nedelec parameter begins at 1. * This is the numbering used by J.C. Nedelec himself. * See "Mixed Finite Elements in \R^3" published in 1980. * * This construction is based on the construction of Raviart-Thomas elements. * There the numbering starts at 0. * Because of this we reduce the order internally by 1. */ order--; NedelecVecMatrix vecMatrix(order); MBasis *mbasis = MBasisFactory::template create(order+1); std::remove_const_t* tmBasis = new std::remove_const_t(*mbasis); tmBasis->fill(vecMatrix); return tmBasis; } static void release( Object *object ) { delete object; } }; template struct NedelecVecMatrix { static constexpr GeometryType geometry = geometryId; static const unsigned int dim = geometry.dim(); typedef MultiIndex MI; typedef MonomialBasis MIBasis; NedelecVecMatrix(std::size_t order) { /* * Construction of Nedelec elements see "Mixed Finite Elements in \R^3" by Nedelec, 1980. * * Let $\P_{n,k}$ be the space of polynomials in $n$ variables with degree $\leq k$. * The space of Nedelec functions in $n$ dimensions with index $k$ is defined as * * \begin{equation*} * Ned_k := (\P_{n,k-1})^n \oplus \{p \in (\P_{n,k})^n: =0 \} * \end{equation*} * with $x=(x,y)$ in two dimensions and $x=(x,y,z)$ in three dimensions. * * For $Ned_k$ holds * \begin{equation*} * (\P_{n,k-1})^n \subset Ned_k \subset (\P_{n,k})^n. * \end{equation*} * * We construct $(\P_{n,k})^n$ and and only use the monomials contained in $Ned$. * */ if( (dim!=2 && dim!=3) || !geometry.isSimplex()) DUNE_THROW(Dune::NotImplemented,"High order nedelec elements are only supported by simplices in 2d and 3d"); MIBasis basis(order+1); FieldVector< MI, dim > x; /* * Init MultiIndices * x[0]=(1,0,0) x * x[1]=(0,1,0) y * x[2]=(0,0,1) z */ for( unsigned int i = 0; i < dim; ++i ) x[i].set(i,1); std::vector< MI > val( basis.size() ); // val now contains all monomials in $n$ dimensions with degree $\leq order+1$ basis.evaluate( x, val ); col_ = basis.size(); // get $\dim (\P_{n,order-1})$ unsigned int notHomogen = 0; if (order>0) notHomogen = basis.sizes()[order-1]; // the number of basis functions for the set of homogeneous polynomials with degree $order$ unsigned int homogen = basis.sizes()[order]-notHomogen; /* * 2D: * \begin{equation*} * Ned_{order} = (\P_{order-1})^2 \oplus (-y,x)^T \widetilde \P_{order-1} * \end{equation*} * * It gets more complicated in higher dimensions. * * 3D: * \begin{equation*} * Ned_{order} = (\P_{n,order-1})^3 \oplus (z,0,-x)^T \widetilde \P_{n,order-1} \oplus (-y,x,0)^T \widetilde \P_{n,order-1} \oplus (0,-z,y)^T \widetilde \P_{n-1,order-1} * \end{equation*} * * Note the last term. The index $n-1$ is on purpose. * Else i.e. k=2 * * (0,z,-y)^T x = (z,0,-x)^T y - (y,-x,0)^T z. * */ /* * compute the number of rows for the coefficient matrix * * row_ = dim* \dim Ned_{order} */ if (dim == 2) row_ = (notHomogen*dim+homogen*(dim+1))*dim; else if (dim==3) { // get dim \P_{n-1,order-1} int homogenTwoVariables = 0; for (unsigned int w = notHomogen; w0; /* * Init 9 rows to zero. * If the homogeneous monomial has a positive x-exponent (0,-z,y) gets skipped ( see example for the Nedelec space in 3D ) * In this case only 6 rows get initialised. */ for (unsigned int r=0; r void row( const unsigned int row, Vector &vec ) const { const unsigned int N = cols(); assert( vec.size() == N ); for (unsigned int i=0; i