whitney/edges0.5/interpolation.hh

Go to the documentation of this file.
00001 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002 // vi: set ts=8 sw=2 et sts=2:
00003 
00004 #ifndef DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH
00005 #define DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH
00006 
00007 #include <cstddef>
00008 #include <vector>
00009 
00010 #include <dune/localfunctions/whitney/edges0.5/common.hh>
00011 
00012 namespace Dune {
00013 
00015   //
00016   // Interpolation
00017   //
00018 
00020 
00026   template<class Geometry, class Traits_>
00027   class EdgeS0_5Interpolation :
00028     private EdgeS0_5Common<Traits_::dimDomainLocal,
00029                            typename Traits_::DomainField>
00030   {
00031   public:
00032     typedef Traits_ Traits;
00033 
00034   private:
00035     static const std::size_t dim = Traits::dimDomainLocal;
00036     typedef EdgeS0_5Common<dim, typename Traits::DomainField> Base;
00037     using Base::refelem;
00038     using Base::s;
00039 
00040     std::vector<typename Traits::DomainGlobal> edgev;
00041 
00042   public:
00044 
00050     template<typename VertexOrder>
00051     EdgeS0_5Interpolation(const Geometry& geo,
00052                           const VertexOrder& vertexOrder) :
00053       edgev(s)
00054     {
00055       for(std::size_t i = 0; i < s; ++i) {
00056         const std::size_t i0 = refelem.subEntity(i,dim-1,0,dim);
00057         const std::size_t i1 = refelem.subEntity(i,dim-1,1,dim);
00058 
00059         edgev[i] = geo.corner(i1);
00060         edgev[i] -= geo.corner(i0);
00061         edgev[i] /= edgev[i].two_norm();
00062 
00063         const typename VertexOrder::iterator& edgeVertexOrder =
00064           vertexOrder.begin(dim-1, i);
00065         if(edgeVertexOrder[0] > edgeVertexOrder[1])
00066           edgev[i] *= -1;
00067       }
00068     }
00069 
00071     template<typename F, typename C>
00072     void interpolate(const F& f, std::vector<C>& out) const {
00073       typename Traits::Range y;
00074 
00075       out.resize(s);
00076 
00077       for(std::size_t i = 0; i < s; ++i) {
00078         f.evaluate(refelem.position(i,dim-1), y);
00079 
00080         out[i] = y * edgev[i];
00081       }
00082     }
00083   };
00084 
00085 } // namespace Dune
00086 
00087 #endif // DUNE_LOCALFUNCTIONS_WHITNEY_EDGES0_5_INTERPOLATION_HH

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