dune-localfunctions  2.4.1
brezzidouglasmarini1cube2dlocalbasis.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 #ifndef DUNE_LOCALFUNCTIONS_BREZZIDOUGLASMARINI1_CUBE2D_LOCALBASIS_HH
4 #define DUNE_LOCALFUNCTIONS_BREZZIDOUGLASMARINI1_CUBE2D_LOCALBASIS_HH
5 
6 #include <array>
7 #include <vector>
8 #include <bitset>
9 
10 #include <dune/common/fmatrix.hh>
11 
12 #include "../../common/localbasis.hh"
13 
14 namespace Dune
15 {
25  template<class D, class R>
27  {
28 
29  public:
30  typedef LocalBasisTraits<D,2,Dune::FieldVector<D,2>,R,2,Dune::FieldVector<R,2>,
31  Dune::FieldMatrix<R,2,2> > Traits;
32 
35  {
36  for (size_t i=0; i<4; i++)
37  sign_[i] = 1.0;
38  }
39 
45  BDM1Cube2DLocalBasis (std::bitset<4> s)
46  {
47  for (size_t i=0; i<4; i++)
48  sign_[i] = s[i] ? -1.0 : 1.0;
49  }
50 
52  unsigned int size () const
53  {
54  return 8;
55  }
56 
63  inline void evaluateFunction (const typename Traits::DomainType& in,
64  std::vector<typename Traits::RangeType>& out) const
65  {
66  out.resize(8);
67 
68  out[0][0] = sign_[0]*(in[0] - 1.0);
69  out[0][1] = 0.0;
70  out[1][0] = 6.0*in[0]*in[1] - 3.0*in[0]-6*in[1] + 3.0;
71  out[1][1] = -3.0*in[1]*in[1] + 3.0*in[1];
72  out[2][0] = sign_[1]*(in[0]);
73  out[2][1] = 0.0;
74  out[3][0] = -6.0*in[0]*in[1] + 3.0*in[0];
75  out[3][1] = 3.0*in[1]*in[1] - 3.0*in[1];
76  out[4][0] = 0.0;
77  out[4][1] = sign_[2]*(in[1] - 1.0);
78  out[5][0] = 3.0*in[0]*in[0] - 3.0*in[0];
79  out[5][1] = -6.0*in[0]*in[1] + 6.0*in[0] + 3.0*in[1] - 3.0;
80  out[6][0] = 0.0;
81  out[6][1] = sign_[3]*(in[1]);
82  out[7][0] = -3.0*in[0]*in[0] + 3.0*in[0];
83  out[7][1] = 6.0*in[0]*in[1] - 3.0*in[1];
84  }
85 
92  inline void evaluateJacobian (const typename Traits::DomainType& in,
93  std::vector<typename Traits::JacobianType>& out) const
94  {
95  out.resize(8);
96 
97  out[0][0][0] = sign_[0];
98  out[0][0][1] = 0.0;
99  out[0][1][0] = 0.0;
100  out[0][1][1] = 0.0;
101 
102  out[1][0][0] = 6.0*in[1] - 3.0;
103  out[1][0][1] = 6.0*in[0] - 6.0;
104  out[1][1][0] = 0.0;
105  out[1][1][1] = -6.0*in[1] + 3.0;
106 
107  out[2][0][0] = sign_[1];
108  out[2][0][1] = 0.0;
109  out[2][1][0] = 0.0;
110  out[2][1][1] = 0.0;
111 
112  out[3][0][0] = -6.0*in[1] + 3.0;
113  out[3][0][1] = -6.0*in[0];
114  out[3][1][0] = 0.0;
115  out[3][1][1] = 6.0*in[1] - 3.0;
116 
117  out[4][0][0] = 0.0;
118  out[4][0][1] = 0.0;
119  out[4][1][0] = 0.0;
120  out[4][1][1] = sign_[2];
121 
122  out[5][0][0] = 6.0*in[0] - 3.0;
123  out[5][0][1] = 0.0;
124  out[5][1][0] = -6.0*in[1] + 6.0;
125  out[5][1][1] = -6.0*in[0] + 3.0;
126 
127  out[6][0][0] = 0.0;
128  out[6][0][1] = 0.0;
129  out[6][1][0] = 0.0;
130  out[6][1][1] = sign_[3];
131 
132  out[7][0][0] = -6.0*in[0] + 3.0;
133  out[7][0][1] = 0.0;
134  out[7][1][0] = 6.0*in[1];
135  out[7][1][1] = 6.0*in[0] - 3.0;
136  }
137 
139  unsigned int order () const
140  {
141  return 2;
142  }
143 
144  private:
145  std::array<R,4> sign_;
146  };
147 }
148 #endif // DUNE_LOCALFUNCTIONS_BREZZIDOUGLASMARINI1_CUBE2D_LOCALBASIS_HH
unsigned int size() const
number of shape functions
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:52
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:37
BDM1Cube2DLocalBasis(std::bitset< 4 > s)
Make set number s, where 0 <= s < 16.
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:45
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:92
First order Brezzi-Douglas-Marini shape functions on the reference quadrilateral. ...
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:26
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:14
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:63
unsigned int order() const
Polynomial order of the shape functions.
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:139
BDM1Cube2DLocalBasis()
Standard constructor.
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:34
D DomainType
domain type
Definition: localbasis.hh:49
LocalBasisTraits< D, 2, Dune::FieldVector< D, 2 >, R, 2, Dune::FieldVector< R, 2 >, Dune::FieldMatrix< R, 2, 2 > > Traits
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:31