| 1 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 | // vi: set et ts=4 sw=2 sts=2: |
| 3 | // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 4 | // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 5 | #ifndef DUNE_RANNACHER_TUREK_LOCALINTERPOLATION_HH |
| 6 | #define DUNE_RANNACHER_TUREK_LOCALINTERPOLATION_HH |
| 7 | |
| 8 | #include <cassert> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <dune/common/fvector.hh> |
| 12 | |
| 13 | #include <dune/geometry/referenceelements.hh> |
| 14 | |
| 15 | #include <dune/localfunctions/common/localbasis.hh> |
| 16 | |
| 17 | namespace Dune |
| 18 | { |
| 19 | |
| 20 | /** |
| 21 | \brief please doc me |
| 22 | |
| 23 | \tparam D type to represent the field in the domain. |
| 24 | \tparam R type to represent the field in the range. |
| 25 | \tparam d domain dimension |
| 26 | * |
| 27 | * \ingroup RannacherTurekImpl |
| 28 | */ |
| 29 | template< class D, class R, unsigned int d > |
| 30 | class RannacherTurekLocalInterpolation |
| 31 | { |
| 32 | typedef LocalBasisTraits< D, d, FieldVector< D, d >, |
| 33 | R, 1, FieldVector< R, 1 >, |
| 34 | FieldMatrix< R, 1, d > > Traits; |
| 35 | |
| 36 | public: |
| 37 | template< class F, class C > |
| 38 | void interpolate ( const F &f, std::vector< C > &out ) const |
| 39 | { |
| 40 | typedef typename Traits::DomainType DomainType; |
| 41 | |
| 42 | // get cubic reference element |
| 43 | auto referenceElement = ReferenceElements< D, d >::cube(); |
| 44 | |
| 45 | const int size = 2*d; |
| 46 | assert( size == referenceElement.size( 1 ) ); |
| 47 | |
| 48 | // resize vector |
| 49 | out.resize( size ); |
| 50 | |
| 51 | // evaluate local function in barycenter of codim 1 subentities |
| 52 | for( int i = 0; i < size; ++i ) |
| 53 | { |
| 54 | const DomainType &x = referenceElement.position( i, 1 ); |
| 55 | out[ i ] = f(x); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | }; |
| 60 | |
| 61 | } // namespace Dune |
| 62 | |
| 63 | #endif // #ifndef DUNE_RANNACHER_TUREK_LOCALINTERPOLATION_HH |