/usr/include/dune/localfunctions/meta/power/interpolation.hh is in libdune-localfunctions-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=8 sw=2 sts=2:
#ifndef DUNE_LOCALFUNCTIONS_META_POWER_INTERPOLATION_HH
#define DUNE_LOCALFUNCTIONS_META_POWER_INTERPOLATION_HH
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <vector>
#include <dune/common/static_assert.hh>
namespace Dune {
//! \brief Meta-interpolation turning a scalar interpolation into
//! vector-valued interpolation
/**
* \tparam Backend Type of the scalar interpolation.
* \tparam BasisTraits Traits type of the corresponding PowerBasis.
*
* \nosubgrouping
*/
template<class Backend, class BasisTraits>
class PowerInterpolation {
dune_static_assert(Backend::Traits::dimRange == 1, "PowerInterpolation "
"works only with scalar backends");
const Backend *backend;
public:
//! Export basis traits
typedef BasisTraits Traits;
//! Construct a PowerInterpolation
/**
* \param backend_ Backend interpolation object to construct this object
* from. This object holds a reference to the backend
* object. This reference is also copied when this object
* is copied.
*/
PowerInterpolation(const Backend &backend_) : backend(&backend_) { }
private:
template<class F>
class ComponentEvaluator {
const F &f;
std::size_t comp;
public:
ComponentEvaluator(const F &f_, std::size_t comp_) :
f(f_), comp(comp_)
{ }
void evaluate(const typename Backend::Traits::DomainLocal &x,
typename Backend::Traits::Range &y) const
{
typename Traits::Range fy;
f.evaluate(x, fy);
y[0] = fy[comp];
}
};
public:
//! Determine coefficients interpolating a given function
/**
* \param f An object supporting the expression \c f.evaluate(x,y),
* where \c x is of type \c Traits::DomainLocal and \c y of the
* type \c Traits::Range. When \c f.evaluate(x,y) is
* evaluated, \c x will be a local coordinate, and the
* expression should set \c y to the function value at that
* position. The initial value of \c y should not be used.
* \param out Vector where to store the interpolated coefficients.
*/
template<typename F, typename C>
void interpolate(const F& f, std::vector<C>& out) const {
out.clear();
std::vector<C> cout;
for(std::size_t d = 0; d < Traits::dimRange; ++d) {
backend->interpolate(ComponentEvaluator<F>(f, d), cout);
if(d == 0)
out.resize(cout.size()*Traits::dimRange);
// make sure the size of cout does not change surprisingly
assert(out.size() == cout.size()*Traits::dimRange);
std::copy(cout.begin(), cout.end(), out.begin() + d*cout.size());
}
}
};
} // namespace Dune
#endif // DUNE_LOCALFUNCTIONS_META_POWER_INTERPOLATION_HH
|