dune-localfunctions 2.12-git
Loading...
Searching...
No Matches
enriched/cubeq1bubble/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_CUBEQ1BUBBLE_LOCALINTERPOLATION_HH
6#define DUNE_LOCALFUNCTIONS_ENRICHED_CUBEQ1BUBBLE_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 = power(2, dim);
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 for (int i = 0; i < numVertices; ++i)
60 {
61 // Generate coordinate of the i-th corner of the reference cube
62 for (int j = 0; j < dim; ++j)
63 x[j] = (i & (1<<j)) ? 1 : 0;
64
65 out[i] = Impl::rangeCast(f(x));
66 }
67
68 // element bubble
69 x = 0.5;
70 auto y = Impl::rangeCast(f(x));
71
72 // evaluate the other shape functions in x and subtract this value
74 LB::evaluateFunction(x, sfValues);
75
76 out[numVertices] = y;
77 for (int i = 0; i < numVertices; ++i)
78 out[numVertices] -= out[i]*sfValues[i][0];
79 }
80 };
81
82} // end namespace Dune
83
84#endif // DUNE_LOCALFUNCTIONS_ENRICHED_CUBEQ1BUBBLE_LOCALINTERPOLATION_HH
size_type dim() const
constexpr Base power(Base m, Exponent p)
Interpolation into the CubeQ1BubbleLocalBasis.
Definition enriched/cubeq1bubble/localinterpolation.hh:36
static constexpr void interpolate(const F &f, std::vector< C > &out)
Local interpolation of the function f.
Definition enriched/cubeq1bubble/localinterpolation.hh:53
T resize(T... args)