dune-localfunctions  2.2.0
p0localinterpolation.hh
Go to the documentation of this file.
00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002 // vi: set ts=4 sw=2 et sts=2:
00003 #ifndef DUNE_P0LOCALINTERPOLATION_HH
00004 #define DUNE_P0LOCALINTERPOLATION_HH
00005 
00006 #include <vector>
00007 #include <dune/geometry/referenceelements.hh>
00008 
00009 
00010 namespace Dune 
00011 {
00012 
00013   template<class LB>
00014   class P0LocalInterpolation 
00015   {
00016   public:
00017         P0LocalInterpolation (const GeometryType& gt) : gt_(gt)
00018         {}
00019 
00021         template<typename F, typename C>
00022         void interpolate (const F& f, std::vector<C>& out) const
00023         {
00024           typedef typename LB::Traits::DomainType DomainType;
00025           typedef typename LB::Traits::RangeType RangeType;
00026           typedef typename LB::Traits::DomainFieldType DF;
00027           const int dim=LB::Traits::dimDomain;
00028           
00029           DomainType x = Dune::GenericReferenceElements<DF,dim>::general(gt_).position(0,0);
00030           RangeType y;
00031           
00032           out.resize(1);
00033           f.evaluate(x,y); out[0] = y;
00034         }
00035 
00036   private:
00037         GeometryType gt_;
00038   };
00039 
00040 }
00041 
00042 #endif