Dune Core Modules (2.8.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#include <dune/localfunctions/common/localinterpolation.hh>
8
9namespace Dune
10{
11 template<int dim, class LB>
12 class DualP1LocalInterpolation
13 {
14 public:
16 template<typename F, typename C>
17 void interpolate (const F& ff, std::vector<C>& out) const
18 {
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 auto&& f = Impl::makeFunctionWithCallOperator<decltype(x)>(ff);
25
26 // compute P1 interpolation coefficients
27 std::vector<C> p1Interpolation(dim+1);
28
29 // vertex 0
30 for (int i=0; i<dim; i++)
31 x[i] = 0;
32 p1Interpolation[0] = f(x);
33
34 // remaining vertices
35 for (int i=0; i<dim; i++) {
36 for (int j=0; j<dim; j++)
37 x[j] = (i==j);
38
39 p1Interpolation[i+1] = f(x);
40
41 }
42
43 // compute dual coefficients from the Lagrange ones
44 out.resize(dim+1);
45 for (int i=0; i<dim+1; i++) {
46 out[i] = 2*p1Interpolation[i]/(dim+2-faceDual);
47
48 for (int j=0; j<i; j++)
49 out[i] += p1Interpolation[j]/(dim+2-faceDual);
50
51 for (int j=i+1; j<=dim; j++)
52 out[i] += p1Interpolation[j]/(dim+2-faceDual);
53 }
54 }
55
56 };
57}
58
59#endif
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)