dune-localfunctions  2.2.1
rannacherturek2dlocalbasis.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil -*-
2 #ifndef DUNE_RANNACHER_TUREK2DLOCALBASIS_HH
3 #define DUNE_RANNACHER_TUREK2DLOCALBASIS_HH
4 
5 #include <vector>
6 
7 #include <dune/common/fvector.hh>
8 #include <dune/common/fmatrix.hh>
9 
11 
12 namespace Dune {
13 
14  template<class D, class R>
16  {
17  public:
19  R,1,FieldVector<R,1>,
20  FieldMatrix<R,1,2> > Traits;
21 
22  unsigned int size () const {
23  return 4;
24  }
25 
27  inline void
28  evaluateFunction (const typename Traits::DomainType& in,
29  std::vector<typename Traits::RangeType>& out) const
30  {
31  out.resize(4);
32  typename Traits::DomainFieldType qbase = in[0]*in[0]-in[1]*in[1];
33  out[0] = .75 - 2*in[0] + in[1] + qbase;
34  out[1] = -.25 + in[1] + qbase;
35  out[2] = .75 + in[0] - 2*in[1] - qbase;
36  out[3] = -.25 + in[0] - qbase;
37  }
38 
40  inline void
41  evaluateJacobian (const typename Traits::DomainType& in,
42  std::vector<typename Traits::JacobianType>& out) const
43  {
44  out.resize(4);
45 
46  // see http://www.dune-project.org/doc/doxygen/html/classDune_1_1C1LocalBasisInterface.html#d6f8368f8aa43439cc7ef10419f6e2ea
47  // out[i][j][k] = d_k \phi^i_j , where \phi^i_j is the j'th component of the i'th shape function.
48 
49  out[0][0][0] = -2 + 2*in[0]; out[0][0][1] = 1 - 2*in[1];
50  out[1][0][0] = 2*in[0]; out[1][0][1] = 1 - 2*in[1];
51  out[2][0][0] = 1 - 2*in[0]; out[2][0][1] = -2 + 2*in[1];
52  out[3][0][0] = 1 - 2*in[0]; out[3][0][1] = 2*in[1];
53  }
54 
56  unsigned int order () const {
57  // must be 2 here since it contains x^2 and x^2
58  return 2;
59  }
60  };
61 
62 } //namespace Dune
63 
64 #endif // DUNE_RANNACHER_TUREK2DLOCALBASIS_HH