monomlocalinterpolation.hh

Go to the documentation of this file.
00001 // -*- tab-width: 4; indent-tabs-mode: nil -*-
00002 #ifndef DUNE_MONOMLOCALINTERPOLATION_HH
00003 #define DUNE_MONOMLOCALINTERPOLATION_HH
00004 
00005 #include <vector>
00006 
00007 #include <dune/common/deprecated.hh>
00008 #include <dune/common/geometrytype.hh>
00009 #include <dune/common/fvector.hh>
00010 #include <dune/common/fmatrix.hh>
00011 #include <dune/grid/common/quadraturerules.hh>
00012 
00013 namespace Dune 
00014 {
00015 
00016   template<class LB, unsigned int size>
00017   class MonomLocalInterpolation 
00018   {
00019     typedef typename LB::Traits::DomainType D;
00020     typedef typename LB::Traits::DomainFieldType DF;
00021     static const int dimD=LB::Traits::dimDomain;
00022     typedef typename LB::Traits::RangeType R;
00023     typedef typename LB::Traits::RangeFieldType RF;
00024 
00025     typedef QuadratureRule<DF,dimD> QR;
00026     typedef typename QR::iterator QRiterator;
00027 
00028     void init() {
00029       if(size != lb.size())
00030         DUNE_THROW(Exception, "size template parameter does not match size of "
00031                    "local basis");
00032 
00033       const QRiterator qrend = qr.end();
00034       for(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
00035         std::vector<R> base;
00036         lb.evaluateFunction(qrit->position(),base);
00037 
00038         for(unsigned int i = 0; i < size; ++i)
00039           for(unsigned int j = 0; j < size; ++j)
00040             Minv[i][j] += qrit->weight() * base[i] * base[j];
00041       }
00042       Minv.invert();
00043     }
00044 
00045   public:
00046         MonomLocalInterpolation (const GeometryType::BasicType &bt_,
00047                              const LB &lb_) DUNE_DEPRECATED
00048       : gt(bt_, dimD), lb(lb_), Minv(0)
00049       , qr(QuadratureRules<DF,dimD>::rule(gt, 2*lb.order()))
00050     { init(); }
00051 
00052     MonomLocalInterpolation (const GeometryType &gt_,
00053                              const LB &lb_)
00054       : gt(gt_), lb(lb_), Minv(0)
00055       , qr(QuadratureRules<DF,dimD>::rule(gt, 2*lb.order()))
00056     { init(); }
00057 
00059         template<typename F, typename C>
00060         void interpolate (const F& f, std::vector<C>& out) const
00061         {
00062           out.clear();
00063       out.resize(size, 0);
00064       
00065       const QRiterator qrend = qr.end();
00066       for(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
00067         //TODO: mass matrix
00068         R y;
00069         f.evaluate(qrit->position(),y);
00070 
00071         std::vector<R> base;
00072         lb.evaluateFunction(qrit->position(),base);
00073 
00074         for(unsigned int i = 0; i < size; ++i)
00075           for(unsigned int j = 0; j < size; ++j)
00076             out[i] += Minv[i][j] * qrit->weight() * y * base[j];
00077       }
00078         }
00079 
00080   private:
00081     GeometryType gt;
00082     const LB &lb;
00083     FieldMatrix<RF, size, size> Minv;
00084     const QR &qr;
00085   };
00086 
00087 }
00088 
00089 #endif //DUNE_MONOMLOCALINTERPOLATION_HH

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