simplebasis.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 #ifndef DUNE_SIMPLEBASIS_HH
00004 #define DUNE_SIMPLEBASIS_HH
00005 
00006 #include <vector>
00007 
00008 #include <dune/common/fmatrix.hh>
00009 #include <dune/common/static_assert.hh>
00010 #include<dune/common/typetraits.hh>
00011 
00012 #include "basis.hh"
00013 
00014 namespace Dune 
00015 {
00016 
00017   template<typename LB>
00018   class C0SimpleBasis;
00028   template<typename LB>
00029   struct BasisTraits<C0SimpleBasis<LB> >
00030     : public LB::Traits
00031   {
00033     static const unsigned diffOrder = 0;
00034   };
00047   template<typename LB>
00048   class C0SimpleBasis
00049     : public C0BasisInterface<C0SimpleBasis<LB> >
00050   {
00051     const LB& lb;
00052 
00053   public:
00055     typedef BasisTraits<C0SimpleBasis<LB> > Traits;
00056 
00057     // construct a C0SimpleBasis from a localbasis
00063     C0SimpleBasis(const LB& lb_)
00064       : lb(lb_)
00065     {}
00066 
00068         unsigned int size () const
00069         {
00070       return lb.size();
00071         }
00072 
00074     inline void
00075     evaluateFunction(const typename Traits::DomainType& in,
00076                      std::vector<typename Traits::RangeType>& out) const
00077         {  
00078       lb.evaluateFunction(in,out);
00079         }
00080 
00082         unsigned int order () const
00083         {
00084       return lb.order();
00085         }
00086   };
00087 
00088   template<typename LB, typename Geo>
00089   class C1SimpleBasis;
00098   template<typename LB, typename Geo>
00099   struct BasisTraits<C1SimpleBasis<LB, Geo> >
00100     : public LB::Traits
00101   {
00102     dune_static_assert(Geo::mydimension == LB::Traits::dimDomain,
00103                        "Local dimension of the geometry and "
00104                        "domain dimension of the local basis must match");
00105     dune_static_assert(LB::Traits::diffOrder >= 1,
00106                        "diffOrder of local basis must be at least 1 "
00107                        "for C1SimpleBasis");
00108 
00110     static const unsigned diffOrder = 1;
00112     typedef FieldMatrix<
00113       typename LB::Traits::JacobianType::field_type::field_type,
00114       LB::Traits::dimRange, Geo::coorddimension> JacobianType;
00115   };
00130   template<typename LB, typename Geo>
00131   class C1SimpleBasis
00132     : public C1BasisInterface<C1SimpleBasis<LB, Geo> >
00133   {
00134     const LB& lb;
00135     const Geo& geo;
00136 
00137   public:
00139     typedef BasisTraits<C1SimpleBasis<LB, Geo> > Traits;
00140 
00142 
00147     C1SimpleBasis(const LB& lb_, const Geo& geo_)
00148       : lb(lb_), geo(geo_)
00149     {}
00150 
00152     unsigned int size () const
00153     {
00154       return lb.size();
00155     }
00156 
00158     inline void
00159     evaluateFunction(const typename Traits::DomainType& in,
00160                      std::vector<typename Traits::RangeType>& out) const
00161     {
00162       lb.evaluateFunction(in,out);
00163     }
00164 
00166     unsigned int order () const
00167     {
00168       return lb.order();
00169     }
00170 
00172 
00197         inline void 
00198         evaluateJacobian(const typename Traits::DomainType& in,         // position
00199                                          std::vector<typename Traits::JacobianType>& out) const      // return value
00200         {  
00201       out.resize(lb.size());
00202       std::vector<typename LB::Traits::JacobianType> localJ(lb.size());
00203       lb.evaluateJacobian(in, localJ);
00204       typename Geo::Jacobian geoJinvT = geo.jacobianInverseTransposed(in);
00205       for(unsigned baseno = 0; baseno < lb.size(); ++baseno)
00206         for(unsigned compno = 0; compno < Traits::dimRange; ++compno)
00207           geoJinvT.mv(localJ[baseno][compno], out[baseno][compno]);
00208         }
00209 
00210   };
00211 }
00212 #endif // DUNE_SIMPLEBASIS_HH
Generated on Sat Apr 24 11:15:35 2010 for dune-localfunctions by  doxygen 1.6.3