// -*- 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_DUAL_Q1_LOCALFINITEELEMENT_HH #define DUNE_DUAL_Q1_LOCALFINITEELEMENT_HH #include #include #include #include #include #include #include #include #include "dualq1/dualq1localbasis.hh" #include "dualq1/dualq1localcoefficients.hh" #include "dualq1/dualq1localinterpolation.hh" namespace Dune { /** * \brief The local dual Q1 finite element on cubes * * Note that if the dual functions are chosen to be dual on the faces, * the integrated product of a Lagrange \f$\lambda_p\f$ and dual * function \f$\theta_q\f$ over faces not containing \f$q\f$ does in * general not vanish. * * \ingroup DualMortar * * \tparam D Domain data type * \tparam R Range data type * \tparam dim Dimension of the hypercube * \tparam faceDual If set, the basis functions are bi-orthogonal only on faces containing the corresponding vertex. */ template class DualQ1LocalFiniteElement { public: /** \todo Please doc me ! */ typedef LocalFiniteElementTraits,DualQ1LocalCoefficients, DualQ1LocalInterpolation > > Traits; /** \todo Please doc me ! */ DualQ1LocalFiniteElement () { if (faceDual) setupFaceDualCoefficients(); else setupDualCoefficients(); } /** \todo Please doc me ! */ const typename Traits::LocalBasisType& localBasis () const { return basis; } /** \todo Please doc me ! */ const typename Traits::LocalCoefficientsType& localCoefficients () const { return coefficients; } /** \todo Please doc me ! */ const typename Traits::LocalInterpolationType& localInterpolation () const { return interpolation; } /** \brief Number of shape functions in this finite element */ unsigned int size () const { return basis.size(); } /** \todo Please doc me ! */ static constexpr GeometryType type () { return GeometryTypes::cube(dim); } private: /** \brief Setup the coefficients for the face dual basis functions. */ void setupFaceDualCoefficients(); /** \brief Setup the coefficients for the dual basis functions. */ void setupDualCoefficients(); DualQ1LocalBasis basis; DualQ1LocalCoefficients coefficients; DualQ1LocalInterpolation > interpolation; }; template void DualQ1LocalFiniteElement::setupDualCoefficients() { const int size = 1 <, size> coeffs; // dual basis functions are linear combinations of Lagrange elements // compute these coefficients here because the basis and the local interpolation needs them const auto& quad = Dune::QuadratureRules::rule(type(), 2*dim); // assemble mass matrix on the reference element Dune::FieldMatrix massMat; massMat = 0; // and the integrals of the lagrange shape functions std::vector > integral(size); for (int i=0; i q1Basis; for(size_t pt=0; pt& pos = quad[pt].position(); std::vector > q1Values(size); q1Basis.evaluateFunction(pos,q1Values); D weight = quad[pt].weight(); for (int k=0; k rhs(0); rhs[i] = integral[i]; coeffs[i] = 0; massMat.solve(coeffs[i] ,rhs); } basis.setCoefficients(coeffs); interpolation.setCoefficients(coeffs); } template void DualQ1LocalFiniteElement::setupFaceDualCoefficients() { const int size = 1 <, size> coeffs; // dual basis functions are linear combinations of Lagrange elements Dune::Impl::LagrangeCubeLocalBasis q1Basis; const auto& refElement = Dune::ReferenceElements::general(type()); // loop over faces for (int i=0; i::rule(refElement.type(i,1),2*dim); // for each face assemble the mass matrix over the face of all // non-vanishing basis functions, // for cubes refElement.size(i,1,dim)=size/2 Dune::FieldMatrix massMat; massMat = 0; // get geometry const auto& geometry = refElement.template geometry<1>(i); // and the integrals of the lagrange shape functions std::vector > integral(size/2); for (int k=0; k > q1Values(size); q1Basis.evaluateFunction(elementPos,q1Values); D weight = quad[pt].weight(); for (int k=0; k rhs(0); rhs[l] = integral[l]; Dune::FieldVector x(0); massMat.solve(x ,rhs); for (int k=0; k