dune-localfunctions 2.12-git
Loading...
Searching...
No Matches
enriched/simplexp1bubble/localinterpolation.hh
Go to the documentation of this file.
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_LOCALFUNCTIONS_ENRICHED_SIMPLEXP1BUBBLE_LOCALINTERPOLATION_HH
6#define DUNE_LOCALFUNCTIONS_ENRICHED_SIMPLEXP1BUBBLE_LOCALINTERPOLATION_HH
7
8#include <type_traits>
9#include <vector>
10
12
13namespace Dune
14{
34 template<class LB>
36 {
37 static const int dim = LB::dimension;
38 static const int numVertices = dim+1;
39
40 using DomainType = typename LB::Traits::DomainType;
41 using RangeType = typename LB::Traits::RangeType;
42
43 public:
51 template<class F, class C>
52 requires ( requires (const F& f, const DomainType& x, C& y){ y = Impl::rangeCast(f(x)); } )
53 static constexpr void interpolate (const F& f, std::vector<C>& out)
54 {
55 out.resize(numVertices+1);
56
57 // vertices
58 DomainType x(0);
59 out[0] = Impl::rangeCast(f(x));
60
61 for (int i = 0; i < dim; ++i) {
62 x = 0;
63 x[i] = 1;
64 out[i+1] = Impl::rangeCast(f(x));
65 }
66
67 // element bubble
68 x = 1.0/(dim+1);
69 auto y = Impl::rangeCast(f(x));
70
71 // evaluate the other shape functions in x and subtract this value
73 LB::evaluateFunction(x, sfValues);
74
75 out[numVertices] = y;
76 for (int i = 0; i < numVertices; ++i)
77 out[numVertices] -= out[i]*sfValues[i][0];
78 }
79 };
80
81} // end namespace Dune
82
83#endif // DUNE_LOCALFUNCTIONS_ENRICHED_SIMPLEXP1BUBBLE_LOCALINTERPOLATION_HH
size_type dim() const
Interpolation into the SimplexP1BubbleLocalBasis.
Definition enriched/simplexp1bubble/localinterpolation.hh:36
static constexpr void interpolate(const F &f, std::vector< C > &out)
Local interpolation of the function f.
Definition enriched/simplexp1bubble/localinterpolation.hh:53
T resize(T... args)