| 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_P0LOCALINTERPOLATION_HH |
| 6 |
#define DUNE_P0LOCALINTERPOLATION_HH |
| 7 |
|
| 8 |
#include <vector> |
| 9 |
#include <dune/geometry/referenceelements.hh> |
| 10 |
|
| 11 |
|
| 12 |
namespace Dune |
| 13 |
{ |
| 14 |
|
| 15 |
/** |
| 16 |
* \ingroup LagrangeImpl |
| 17 |
*/ |
| 18 |
template<class LB> |
| 19 |
class P0LocalInterpolation |
| 20 |
{ |
| 21 |
public: |
| 22 |
P0LocalInterpolation (const GeometryType& gt) : gt_(gt) |
| 23 |
{} |
| 24 |
|
| 25 |
//! determine coefficients interpolating a given function |
| 26 |
template<typename F, typename C> |
| 27 |
void interpolate (const F& f, std::vector<C>& out) const |
| 28 |
{ |
| 29 |
typedef typename LB::Traits::DomainType DomainType; |
| 30 |
typedef typename LB::Traits::DomainFieldType DF; |
| 31 |
const int dim=LB::Traits::dimDomain; |
| 32 |
|
| 33 |
DomainType x = Dune::ReferenceElements<DF,dim>::general(gt_).position(0,0); |
| 34 |
|
| 35 |
out.resize(1); |
| 36 |
out[0] = f(x); |
| 37 |
} |
| 38 |
|
| 39 |
private: |
| 40 |
GeometryType gt_; |
| 41 |
}; |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
#endif |