dune-localfunctions 3.0-git
whitney/edges0.5/interpolation.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
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
11
12namespace Dune {
13
15 //
16 // Interpolation
17 //
18
20
26 template<class Geometry, class Traits_>
28 private EdgeS0_5Common<Traits_::dimDomainLocal,
29 typename Traits_::DomainField>
30 {
31 public:
32 typedef Traits_ Traits;
33
34 private:
35 static const std::size_t dim = Traits::dimDomainLocal;
37 using Base::refelem;
38 using Base::s;
39
40 std::vector<typename Traits::DomainGlobal> edgev;
41
42 public:
44
50 template<typename VertexOrder>
51 EdgeS0_5Interpolation(const Geometry& geo,
52 const VertexOrder& vertexOrder) :
53 edgev(s)
54 {
55 for(std::size_t i = 0; i < s; ++i) {
56 const std::size_t i0 = refelem.subEntity(i,dim-1,0,dim);
57 const std::size_t i1 = refelem.subEntity(i,dim-1,1,dim);
58
59 edgev[i] = geo.corner(i1);
60 edgev[i] -= geo.corner(i0);
61 edgev[i] /= edgev[i].two_norm();
62
63 const typename VertexOrder::iterator& edgeVertexOrder =
64 vertexOrder.begin(dim-1, i);
65 if(edgeVertexOrder[0] > edgeVertexOrder[1])
66 edgev[i] *= -1;
67 }
68 }
69
71 template<typename F, typename C>
72 void interpolate(const F& f, std::vector<C>& out) const {
73 typename Traits::Range y;
74
75 out.resize(s);
76
77 for(std::size_t i = 0; i < s; ++i) {
78 f.evaluate(refelem.position(i,dim-1), y);
79
80 out[i] = y * edgev[i];
81 }
82 }
83 };
84
85} // namespace Dune
86
87#endif // DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH
Definition brezzidouglasmarini1cube2d.hh:14
Common base class for edge elements.
Definition common.hh:15
static const ReferenceElement< DF, dim > & refelem
The reference element for this edge element.
Definition common.hh:17
static const std::size_t s
The number of base functions.
Definition common.hh:23
Interpolation for lowest order edge elements on simplices.
Definition whitney/edges0.5/interpolation.hh:30
void interpolate(const F &f, std::vector< C > &out) const
Interpolation of a function.
Definition whitney/edges0.5/interpolation.hh:72
Traits_ Traits
Definition whitney/edges0.5/interpolation.hh:32
EdgeS0_5Interpolation(const Geometry &geo, const VertexOrder &vertexOrder)
constructor
Definition whitney/edges0.5/interpolation.hh:51