dune-localfunctions  2.2.0
pk1dlocalcoefficients.hh
Go to the documentation of this file.
00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002 // vi: set et ts=4 sw=2 sts=2:
00003 
00004 #ifndef DUNE_PK1DLOCALCOEFFICIENTS_HH
00005 #define DUNE_PK1DLOCALCOEFFICIENTS_HH
00006 
00007 #include <cstddef>
00008 #include <vector>
00009 
00010 #include <dune/localfunctions/common/localkey.hh>
00011 
00012 namespace Dune 
00013 {
00014 
00021   template<unsigned int k>
00022   class Pk1DLocalCoefficients 
00023   {
00024         enum {N = k+1};
00025 
00026   public:
00028         Pk1DLocalCoefficients () : li(N)
00029         {
00030           fill_default();
00031         }
00032 
00034         Pk1DLocalCoefficients (int variant) : li(N)
00035         {
00036           fill_default();
00037         }
00038 
00048     template<class VertexMap>
00049     explicit Pk1DLocalCoefficients(const VertexMap &vertexmap) : li(N)
00050         {
00051           fill_default();
00052         }
00053 
00055         std::size_t size () const
00056         {
00057           return N;
00058         }
00059 
00061         const LocalKey& localKey (std::size_t i) const
00062         {
00063           return li[i];
00064         } 
00065 
00066   private:
00067         std::vector<LocalKey> li;
00068 
00069         void fill_default()
00070         {
00071             li.resize(N);
00072             
00073             if (N==1) {
00074                 li[0] = LocalKey(0,0,0);
00075             } else {
00076                 li[0] = LocalKey(0,1,0);
00077                 for (int i=1; i<N-1; i++)
00078                     li[i] = LocalKey(0,0,i-1);  // element dofs
00079                 li.back() = LocalKey(1,1,0);
00080             }
00081         }
00082   };
00083 
00084 }
00085 
00086 #endif