rannacherturek2dlocalbasis.hh

Go to the documentation of this file.
00001 // -*- tab-width: 4; indent-tabs-mode: nil -*-
00002 #ifndef DUNE_RANNACHER_TUREK2DLOCALBASIS_HH
00003 #define DUNE_RANNACHER_TUREK2DLOCALBASIS_HH
00004 
00005 #include <vector>
00006 
00007 #include <dune/common/fvector.hh>
00008 #include <dune/common/fmatrix.hh>
00009 
00010 #include <dune/localfunctions/common/localbasis.hh>
00011 
00012 namespace Dune {
00013 
00014   template<class D, class R>
00015   class RannacherTurek2DLocalBasis
00016   {
00017   public:
00018     typedef LocalBasisTraits<D,2,FieldVector<D,2>,
00019                                R,1,FieldVector<R,1>,
00020                                FieldMatrix<R,1,2> > Traits;
00021 
00022     unsigned int size () const {
00023       return 4;
00024     }
00025 
00027     inline void
00028     evaluateFunction (const typename Traits::DomainType& in,
00029                       std::vector<typename Traits::RangeType>& out) const
00030     { 
00031       out.resize(4);
00032       typename Traits::DomainFieldType qbase = in[0]*in[0]-in[1]*in[1];
00033       out[0] =  .75 - 2*in[0] +   in[1] + qbase;
00034       out[1] = -.25           +   in[1] + qbase;
00035       out[2] =  .75 +   in[0] - 2*in[1] - qbase;
00036       out[3] = -.25 +   in[0]           - qbase;
00037     }
00038   
00040     inline void 
00041     evaluateJacobian (const typename Traits::DomainType& in,
00042                       std::vector<typename Traits::JacobianType>& out) const
00043     {  
00044       out.resize(4);
00045 
00046       // see http://www.dune-project.org/doc/doxygen/html/classDune_1_1C1LocalBasisInterface.html#d6f8368f8aa43439cc7ef10419f6e2ea
00047       // out[i][j][k] = d_k \phi^i_j , where \phi^i_j is the j'th component of the i'th shape function.
00048 
00049       out[0][0][0] = -2 + 2*in[0]; out[0][0][1] =  1 - 2*in[1];
00050       out[1][0][0] =      2*in[0]; out[1][0][1] =  1 - 2*in[1];
00051       out[2][0][0] =  1 - 2*in[0]; out[2][0][1] = -2 + 2*in[1];
00052       out[3][0][0] =  1 - 2*in[0]; out[3][0][1] =      2*in[1];
00053     }
00054   
00056     unsigned int order () const  {
00057       // must be 2 here since it contains x^2 and x^2
00058       return 2;
00059     }
00060   };
00061 
00062 } //namespace Dune
00063 
00064 #endif // DUNE_RANNACHER_TUREK2DLOCALBASIS_HH

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].