Dune Core Modules (2.6.0)

dualp1localinterpolation.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_DUAL_P1_LOCALINTERPOLATION_HH
4#define DUNE_DUAL_P1_LOCALINTERPOLATION_HH
5
6#include <vector>
7
8namespace Dune
9{
10 template<int dim, class LB>
11 class DualP1LocalInterpolation
12 {
13 public:
15 template<typename F, typename C>
16 void interpolate (const F& f, std::vector<C>& out) const
17 {
18 typename LB::Traits::RangeType y;
19 typename LB::Traits::DomainType x;
20 // If the dual functions are dual on the faces,
21 // then adjust the interpolation weights
22 const int faceDual(LB::faceDual);
23
24 // compute P1 interpolation coefficients
25 std::vector<C> p1Interpolation(dim+1);
26
27 // vertex 0
28 for (int i=0; i<dim; i++)
29 x[i] = 0;
30 f.evaluate(x,y); p1Interpolation[0] = y;
31
32 // remaining vertices
33 for (int i=0; i<dim; i++) {
34 for (int j=0; j<dim; j++)
35 x[j] = (i==j);
36
37 f.evaluate(x,y); p1Interpolation[i+1] = y;
38
39 }
40
41 // compute dual coefficients from the Lagrange ones
42 out.resize(dim+1);
43 for (int i=0; i<dim+1; i++) {
44 out[i] = 2*p1Interpolation[i]/(dim+2-faceDual);
45
46 for (int j=0; j<i; j++)
47 out[i] += p1Interpolation[j]/(dim+2-faceDual);
48
49 for (int j=i+1; j<=dim; j++)
50 out[i] += p1Interpolation[j]/(dim+2-faceDual);
51 }
52 }
53
54 };
55}
56
57#endif
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)