DUNE-FEM (unstable)

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// 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_DUAL_P1_LOCALINTERPOLATION_HH
6#define DUNE_DUAL_P1_LOCALINTERPOLATION_HH
7
8#include <vector>
9
10namespace Dune
11{
15 template<int dim, class LB>
16 class DualP1LocalInterpolation
17 {
18 public:
20 template<typename F, typename C>
21 void interpolate (const F& f, std::vector<C>& out) const
22 {
23 typename LB::Traits::DomainType x;
24 // If the dual functions are dual on the faces,
25 // then adjust the interpolation weights
26 const int faceDual(LB::faceDual);
27
28 // compute P1 interpolation coefficients
29 std::vector<C> p1Interpolation(dim+1);
30
31 // vertex 0
32 for (int i=0; i<dim; i++)
33 x[i] = 0;
34 p1Interpolation[0] = f(x);
35
36 // remaining vertices
37 for (int i=0; i<dim; i++) {
38 for (int j=0; j<dim; j++)
39 x[j] = (i==j);
40
41 p1Interpolation[i+1] = f(x);
42
43 }
44
45 // compute dual coefficients from the Lagrange ones
46 out.resize(dim+1);
47 for (int i=0; i<dim+1; i++) {
48 out[i] = 2*p1Interpolation[i]/(dim+2-faceDual);
49
50 for (int j=0; j<i; j++)
51 out[i] += p1Interpolation[j]/(dim+2-faceDual);
52
53 for (int j=i+1; j<=dim; j++)
54 out[i] += p1Interpolation[j]/(dim+2-faceDual);
55 }
56 }
57
58 };
59}
60
61#endif
static void interpolate(const GridFunction &u, DiscreteFunction &v)
perform native interpolation of a discrete function space
Definition: interpolate.hh:54
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)