Dune Core Modules (2.9.1)

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 (C) 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#include <dune/localfunctions/common/localinterpolation.hh>
10
11namespace Dune
12{
13 template<int dim, class LB>
14 class DualP1LocalInterpolation
15 {
16 public:
18 template<typename F, typename C>
19 void interpolate (const F& ff, std::vector<C>& out) const
20 {
21 typename LB::Traits::DomainType x;
22 // If the dual functions are dual on the faces,
23 // then adjust the interpolation weights
24 const int faceDual(LB::faceDual);
25
26 auto&& f = Impl::makeFunctionWithCallOperator<decltype(x)>(ff);
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
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)