Dune Core Modules (2.6.0)

qklocalinterpolation.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_LOCALFUNCTIONS_QKLOCALINTERPOLATION_HH
5#define DUNE_LOCALFUNCTIONS_QKLOCALINTERPOLATION_HH
6
9
10#include <dune/geometry/type.hh>
11
12#include <dune/localfunctions/common/localbasis.hh>
13#include <dune/localfunctions/common/localfiniteelementtraits.hh>
14
15
16namespace Dune
17{
19 template<int k, int d, class LB>
21 {
22
23 // Return i as a d-digit number in the (k+1)-nary system
24 static Dune::FieldVector<int,d> multiindex (int i)
25 {
27 for (int j=0; j<d; j++)
28 {
29 alpha[j] = i % (k+1);
30 i = i/(k+1);
31 }
32 return alpha;
33 }
34
35 public:
36
38 template<typename F, typename C>
39 void interpolate (const F& f, std::vector<C>& out) const
40 {
41 typename LB::Traits::DomainType x;
42 typename LB::Traits::RangeType y;
43
44 out.resize(StaticPower<k+1,d>::power);
45
46 for (int i=0; i<StaticPower<k+1,d>::power; i++)
47 {
48 // convert index i to multiindex
49 Dune::FieldVector<int,d> alpha(multiindex(i));
50
51 // Generate coordinate of the i-th Lagrange point
52 for (int j=0; j<d; j++)
53 x[j] = (1.0*alpha[j])/k;
54
55 f.evaluate(x,y); out[i] = y;
56 }
57 }
58 };
59
61 template<int d, class LB>
63 {
64 public:
66 template<typename F, typename C>
67 void interpolate (const F& f, std::vector<C>& out) const
68 {
69 typename LB::Traits::DomainType x(0);
70 typename LB::Traits::RangeType y;
71 f.evaluate(x,y);
72 out.resize(1);
73 out[0] = y;
74 }
75 };
76
77}
78
79
80#endif
vector space out of a tensor product of fields.
Definition: fvector.hh:93
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition: qklocalinterpolation.hh:67
Definition: qklocalinterpolation.hh:21
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition: qklocalinterpolation.hh:39
Various implementations of the power function for run-time and static arguments.
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:10
Calculates m^p at compile time.
Definition: power.hh:20
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)