Dune Core Modules (2.8.0)

interpolation.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH
5#define DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH
6
7#include <cstddef>
8#include <vector>
9
10#include <dune/localfunctions/whitney/edges0.5/common.hh>
11#include <dune/localfunctions/common/localinterpolation.hh>
12
13namespace Dune {
14
16 //
17 // Interpolation
18 //
19
21
27 template<class Geometry, class Traits_>
29 private EdgeS0_5Common<Traits_::dimDomainLocal,
30 typename Traits_::DomainField>
31 {
32 public:
33 typedef Traits_ Traits;
34
35 private:
36 static const std::size_t dim = Traits::dimDomainLocal;
38 using Base::refelem;
39 using Base::s;
40
41 std::vector<typename Traits::DomainGlobal> edgev;
42
43 public:
45
51 template<typename VertexOrder>
53 const VertexOrder& vertexOrder) :
54 edgev(s)
55 {
56 for(std::size_t i = 0; i < s; ++i) {
57 const std::size_t i0 = refelem.subEntity(i,dim-1,0,dim);
58 const std::size_t i1 = refelem.subEntity(i,dim-1,1,dim);
59
60 edgev[i] = geo.corner(i1);
61 edgev[i] -= geo.corner(i0);
62 edgev[i] /= edgev[i].two_norm();
63
64 const typename VertexOrder::iterator& edgeVertexOrder =
65 vertexOrder.begin(dim-1, i);
66 if(edgeVertexOrder[0] > edgeVertexOrder[1])
67 edgev[i] *= -1;
68 }
69 }
70
72 template<typename F, typename C>
73 void interpolate(const F& ff, std::vector<C>& out) const {
74 typename Traits::Range y;
75
76 auto&& f = Impl::makeFunctionWithCallOperator<std::decay_t<decltype(refelem.position(0,dim-1))>>(ff);
77
78 out.resize(s);
79
80 for(std::size_t i = 0; i < s; ++i) {
81 y = f(refelem.position(i,dim-1));
82
83 out[i] = y * edgev[i];
84 }
85 }
86 };
87
88} // namespace Dune
89
90#endif // DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH
FieldTraits< value_type >::real_type two_norm() const
two norm sqrt(sum over squared values of entries)
Definition: densevector.hh:642
Interpolation for lowest order edge elements on simplices.
Definition: interpolation.hh:31
void interpolate(const F &ff, std::vector< C > &out) const
Interpolation of a function.
Definition: interpolation.hh:73
EdgeS0_5Interpolation(const Geometry &geo, const VertexOrder &vertexOrder)
constructor
Definition: interpolation.hh:52
Wrapper class for geometries.
Definition: geometry.hh:67
GlobalCoordinate corner(int i) const
Obtain a corner of the geometry.
Definition: geometry.hh:156
Dune namespace.
Definition: alignedallocator.hh:11
Common base class for edge elements.
Definition: common.hh:17
RefElem refelem
The reference element for this edge element.
Definition: common.hh:24
std::size_t s
The number of base functions.
Definition: common.hh:32
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)