dune-localfunctions  2.7.1
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 
12 
13 namespace 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>
52  EdgeS0_5Interpolation(const Geometry& geo,
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
Definition: bdfmcube.hh:16
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
Interpolation for lowest order edge elements on simplices.
Definition: whitney/edges0.5/interpolation.hh:31
void interpolate(const F &ff, std::vector< C > &out) const
Interpolation of a function.
Definition: whitney/edges0.5/interpolation.hh:73
Traits_ Traits
Definition: whitney/edges0.5/interpolation.hh:33
EdgeS0_5Interpolation(const Geometry &geo, const VertexOrder &vertexOrder)
constructor
Definition: whitney/edges0.5/interpolation.hh:52