// -*- 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_WHITNEY_EDGES0_5_INTERPOLATION_HH #define DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH #include #include #include namespace Dune { ////////////////////////////////////////////////////////////////////// // // Interpolation // //! Interpolation for lowest order edge elements on simplices /** * \tparam Geometry Type of the local-to-global map. * \tparam RF Type to represent the field in the range. * * \nosubgrouping * \ingroup WhitneyImpl */ template class EdgeS0_5Interpolation : private EdgeS0_5Common { public: typedef Traits_ Traits; private: static const std::size_t dim = Traits::dimDomainLocal; typedef EdgeS0_5Common Base; using Base::refelem; using Base::s; std::vector edgev; public: //! constructor /** * \param geo Geometry of the element to construct a local basis * for. * \param vertexOrder Vertex ordering information. Only the vertex order * on the dim=1 sub-entities (edges) is required. */ template EdgeS0_5Interpolation(const Geometry& geo, const VertexOrder& vertexOrder) : edgev(s) { for(std::size_t i = 0; i < s; ++i) { const std::size_t i0 = refelem.subEntity(i,dim-1,0,dim); const std::size_t i1 = refelem.subEntity(i,dim-1,1,dim); edgev[i] = geo.corner(i1); edgev[i] -= geo.corner(i0); edgev[i] /= edgev[i].two_norm(); const typename VertexOrder::iterator& edgeVertexOrder = vertexOrder.begin(dim-1, i); if(edgeVertexOrder[0] > edgeVertexOrder[1]) edgev[i] *= -1; } } //! Interpolation of a function template void interpolate(const F& f, std::vector& out) const { typename Traits::Range y; out.resize(s); for(std::size_t i = 0; i < s; ++i) { y = f(refelem.position(i,dim-1)); out[i] = y * edgev[i]; } } }; } // namespace Dune #endif // DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH