dune-localfunctions
2.1.1
|
00001 #ifndef DUNE_Q22DLOCALBASIS_HH 00002 #define DUNE_Q22DLOCALBASIS_HH 00003 00004 #include <dune/common/fmatrix.hh> 00005 00006 #include <dune/localfunctions/common/localbasis.hh> 00007 00008 namespace Dune 00009 { 00020 template<class D, class R> 00021 class Q22DLocalBasis 00022 { 00023 public: 00024 typedef LocalBasisTraits<D,2,Dune::FieldVector<D,2>,R,1,Dune::FieldVector<R,1>, 00025 Dune::FieldMatrix<R,1,2> > Traits; 00026 00028 unsigned int size () const 00029 { 00030 return 9; 00031 } 00032 00034 inline void evaluateFunction (const typename Traits::DomainType& in, 00035 std::vector<typename Traits::RangeType>& out) const 00036 { 00037 out.resize(9); 00038 00039 R x=in[0], y=in[1]; 00040 R X0=2*x*x-3*x+1, X1=-4*x*x+4*x, X2=2*x*x-x; 00041 R Y0=2*y*y-3*y+1, Y1=-4*y*y+4*y, Y2=2*y*y-y; 00042 00043 out[2] = X0*Y2; 00044 out[7] = X1*Y2; 00045 out[3] = X2*Y2; 00046 00047 out[4] = X0*Y1; 00048 out[8] = X1*Y1; 00049 out[5] = X2*Y1; 00050 00051 out[0] = X0*Y0; 00052 out[6] = X1*Y0; 00053 out[1] = X2*Y0; 00054 } 00055 00057 inline void 00058 evaluateJacobian (const typename Traits::DomainType& in, // position 00059 std::vector<typename Traits::JacobianType>& out) const // return value 00060 { 00061 out.resize(9); 00062 00063 R x=in[0], y=in[1]; 00064 R X0=2*x*x-3*x+1, X1=-4*x*x+4*x, X2=2*x*x-x; 00065 R Y0=2*y*y-3*y+1, Y1=-4*y*y+4*y, Y2=2*y*y-y; 00066 R DX0=4*x-3, DX1=-8*x+4, DX2=4*x-1; 00067 R DY0=4*y-3, DY1=-8*y+4, DY2=4*y-1; 00068 00069 out[2][0][0] = DX0*Y2; out[7][0][0] = DX1*Y2; out[3][0][0] = DX2*Y2; 00070 out[2][0][1] = X0*DY2; out[7][0][1] = X1*DY2; out[3][0][1] = X2*DY2; 00071 00072 out[4][0][0] = DX0*Y1; out[8][0][0] = DX1*Y1; out[5][0][0] = DX2*Y1; 00073 out[4][0][1] = X0*DY1; out[8][0][1] = X1*DY1; out[5][0][1] = X2*DY1; 00074 00075 out[0][0][0] = DX0*Y0; out[6][0][0] = DX1*Y0; out[1][0][0] = DX2*Y0; 00076 out[0][0][1] = X0*DY0; out[6][0][1] = X1*DY0; out[1][0][1] = X2*DY0; 00077 } 00078 00080 unsigned int order () const 00081 { 00082 return 2; 00083 } 00084 }; 00085 } 00086 #endif