dune-localfunctions  2.2.1
brezzidouglasmarini12dlocalbasis.hh
Go to the documentation of this file.
1 #ifndef DUNE_LOCALFUNCTIONS_BREZZIDOUGLASMARINI1TRIANGLELOCALBASIS_HH
2 #define DUNE_LOCALFUNCTIONS_BREZZIDOUGLASMARINI1TRIANGLELOCALBASIS_HH
3 
4 #include <vector>
5 
6 #include <dune/common/fmatrix.hh>
7 
8 #include "../../common/localbasis.hh"
9 
10 namespace Dune
11 {
21  template<class D, class R>
23  {
24 
25 public:
26  typedef LocalBasisTraits<D,2,Dune::FieldVector<D,2>,R,2,Dune::FieldVector<R,2>,
27  Dune::FieldMatrix<R,2,2> > Traits;
28 
31  {
32  sign0 = sign1 = sign2 = 1.0;
33  }
34 
40  BDM12DLocalBasis (unsigned int s)
41  {
42  sign0 = sign1 = sign2 = 1.0;
43  if (s & 1)
44  {
45  sign0 = -1.0;
46  }
47  if (s & 2)
48  {
49  sign1 = -1.0;
50  }
51  if (s & 4)
52  {
53  sign2 = -1.0;
54  }
55  }
56 
58  unsigned int size () const
59  {
60  return 6;
61  }
62 
69  inline void evaluateFunction (const typename Traits::DomainType& in,
70  std::vector<typename Traits::RangeType>& out) const
71  {
72  out.resize(6);
73 
74  out[0][0] = sign0*in[0];
75  out[0][1] = sign0*(in[1] - 1.0);
76  out[1][0] = sign1*(in[0] - 1.0);
77  out[1][1] = sign1*in[1];
78  out[2][0] = sign2*in[0];
79  out[2][1] = sign2*in[1];
80  out[3][0] = 3.0*in[0];
81  out[3][1] = 3.0 - 6.0*in[0] - 3.0*in[1];
82  out[4][0] = -3.0 + 3.0*in[0] + 6.0*in[1];
83  out[4][1] = -3.0*in[1];
84  out[5][0] = -3.0*in[0];
85  out[5][1] = 3.0*in[1];
86  }
87 
94  inline void evaluateJacobian (const typename Traits::DomainType& in,
95  std::vector<typename Traits::JacobianType>& out) const
96  {
97  out.resize(6);
98 
99  out[0][0][0] = sign0;
100  out[0][0][1] = 0.0;
101  out[0][1][0] = 0.0;
102  out[0][1][1] = sign0;
103 
104  out[1][0][0] = sign1;
105  out[1][0][1] = 0.0;
106  out[1][1][0] = 0.0;
107  out[1][1][1] = sign1;
108 
109  out[2][0][0] = sign2;
110  out[2][0][1] = 0.0;
111  out[2][1][0] = 0.0;
112  out[2][1][1] = sign2;
113 
114  out[3][0][0] = 3.0;
115  out[3][0][1] = 0.0;
116  out[3][1][0] = -6.0;
117  out[3][1][1] = -3.0;
118 
119  out[4][0][0] = 3.0;
120  out[4][0][1] = 6.0;
121  out[4][1][0] = 0.0;
122  out[4][1][1] = -3.0;
123 
124  out[5][0][0] = -3.0;
125  out[5][0][1] = 0.0;
126  out[5][1][0] = 0.0;
127  out[5][1][1] = 3.0;
128  }
129 
131  unsigned int order () const
132  {
133  return 1;
134  }
135 
136  private:
137  R sign0, sign1, sign2;
138  };
139 }
140 #endif // DUNE_LOCALFUNCTIONS_BREZZIDOUGLASMARINI1TRIANGLELOCALBASIS_HH