Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

hp2D/formula.hh
Go to the documentation of this file.
00001 
00004 #ifndef formulahp2D_hh
00005 #define formulahp2D_hh
00006 
00007 #include "toolbox/sequence.hh"
00008 #include "toolbox/set.hh"
00009 #include "toolbox/hashMap.hh"
00010 #include "formula/elementFormula.hh"
00011 #include "space/element.hh"
00012 #include "space/function.hh"
00013 
00014 // debugging
00015 #include "basics/debug.hh"
00016 
00017 #define FormulaFromWeightConstr_D 0
00018 #define FormulaFromWeightAppl_D 0
00019 
00020 namespace concepts {
00021 
00022   template<typename F>
00023   class Array;
00024 
00025   template<typename F>
00026   class Vector;
00027 
00028   class Attribute;
00029   class Edge;
00030   class Edge2d;
00031 
00032 } // namespace concepts
00033 
00034 namespace hp2D {
00035 
00036   // forward declarations
00037   class TraceSpace;
00038 
00039   template<typename F>
00040   class BaseQuad;
00041 
00042   template<typename F>
00043   class Quad;
00044 
00045   template<typename F>
00046   class BaseEdge;
00047 
00048   using concepts::Real;
00049   using concepts::Real2d;
00050 
00051   // *********************************************************** H1Extension **
00052 
00063   template<class F>
00064   class H1Extension : public concepts::ElementFormula<F> {
00065   public:
00079     H1Extension(const concepts::ElementFormula<F>& frm);
00085     H1Extension(const concepts::ElementFormula<F>& frm,
00086                 const concepts::Set<concepts::Attribute> attributes);
00087 
00088     virtual ~H1Extension();
00089 
00090     virtual F operator() (const concepts::ElementWithCell<Real>& elm,
00091                           const Real p, const Real t = 0.0) const;
00092     virtual F operator() (const concepts::ElementWithCell<Real>& elm,
00093                           const Real2d& p, const Real t = 0.0) const;
00094     virtual F operator() (const concepts::ElementWithCell<Real>& elm,
00095                           const concepts::Real3d& p, const Real t = 0.0) const;
00096 
00098     virtual H1Extension<F>* clone() const {
00099       return new H1Extension<F>(*frm_);
00100     }
00101   protected:
00102     virtual std::ostream& info(std::ostream& os) const;
00103   private:
00105     std::auto_ptr<const concepts::ElementFormula<F> > frm_;
00109     const concepts::Set<concepts::Attribute> attributes_;
00111     mutable const concepts::ElementWithCell<Real>* elm_;
00113     mutable concepts::Array<concepts::ElementWithCell<Real>*> elmEdges_;
00115     mutable concepts::Sequence<concepts::Edge2d*> cellEdges_;
00117     mutable concepts::HashMap<const concepts::Edge*> edges_;
00119     mutable concepts::HashMap<F> vtxValues_;
00120 
00121     bool compute_(const hp2D::Quad<Real>* quad, const Real2d& p, const Real t,
00122                   F& val) const;
00123 
00125     void clear_() const;
00126   };
00127 
00128   // ********************************************** ElementFormulaInterpGrad **
00129 
00137   template<typename F, uint dim = 2>
00138   class ElementFormulaInterpGrad {};
00139 
00140   // ******************************************** ElementFormulaInterpGrad<2> **
00141 
00142   template<typename F>
00143   class ElementFormulaInterpGrad<F,2> : 
00144     public concepts::ElementFormula<concepts::Point<F,2> > {
00145   public:
00146     ElementFormulaInterpGrad(const concepts::ElementFormula<F>& f);
00147 
00148     virtual concepts::Point<F,2> operator() 
00149       (const concepts::ElementWithCell<Real>& elm,
00150        const Real p, const Real t = 0.0) const { return concepts::Point<F,2>(0.0); }
00151     virtual concepts::Point<F,2> operator()
00152       (const concepts::ElementWithCell<Real>& elm,
00153        const concepts::Real2d& p, const Real t = 0.0) const;
00154     virtual concepts::Point<F,2> operator()
00155       (const concepts::ElementWithCell<Real>& elm,
00156        const concepts::Real3d& p, const Real t = 0.0) const  { return concepts::Point<F,2>(0.0); }
00157 
00159     virtual ElementFormulaInterpGrad<F,2>* clone() const {
00160       return new ElementFormulaInterpGrad<F,2>(*f_);
00161     }
00162   protected:
00163     virtual std::ostream& info(std::ostream& os) const;
00164   private:
00166     std::auto_ptr<const concepts::ElementFormula<F> > f_;
00168     mutable const concepts::ElementWithCell<Real>* quad_;
00170     mutable concepts::Array<Real> x_[2];
00172     mutable bool samePoints_;
00174     mutable concepts::Array<F> values_;
00176     mutable bool zeroElement_;
00177   };
00178 
00179   // ********************************************* ElementFormulaInterpGradN **
00180 
00189   template<typename F, uint dim = 2>
00190   class ElementFormulaInterpGradN {};
00191 
00192   template<typename F>
00193   class ElementFormulaInterpGradN<F,2> : 
00194     public concepts::ElementFormula<concepts::Point<F,2> > {
00195   public:
00196     ElementFormulaInterpGradN(const concepts::ElementFormula<F>& f);
00197 
00198     virtual concepts::Point<F,2> operator() 
00199       (const concepts::ElementWithCell<Real>& elm,
00200        const Real p, const Real t = 0.0) const { return concepts::Point<F,2>(0.0); }
00201     virtual concepts::Point<F,2> operator()
00202       (const concepts::ElementWithCell<Real>& elm,
00203        const concepts::Real2d& p, const Real t = 0.0) const;
00204     virtual concepts::Point<F,2> operator()
00205       (const concepts::ElementWithCell<Real>& elm,
00206        const concepts::Real3d& p, const Real t = 0.0) const  { return concepts::Point<F,2>(0.0); }
00207 
00209     virtual ElementFormulaInterpGradN<F,2>* clone() const {
00210       return new ElementFormulaInterpGradN<F,2>(*f_);
00211     }
00212   protected:
00213     virtual std::ostream& info(std::ostream& os) const;
00214   private:
00216     std::auto_ptr<const concepts::ElementFormula<F> > f_;
00218     mutable const concepts::ElementWithCell<Real>* quad_;
00220     mutable concepts::Array<F> coeff_;
00222     mutable bool zeroElement_;
00223   };
00224 
00225   // ************************************************ ElementFormulaEdgeMean **
00226 
00232   template<typename F>
00233   class ElementFormulaEdgeMean : public concepts::ElementFormula<F> {
00234   public:
00235     ElementFormulaEdgeMean(const hp2D::TraceSpace& spc,
00236                            const concepts::Vector<F>& v,
00237                            const concepts::ElementFunction<F>& f);
00238 
00239     virtual F operator() (const concepts::ElementWithCell<Real>& elm,
00240                           const Real p, const Real t = 0.0) const;
00241     virtual F operator() (const concepts::ElementWithCell<Real>& elm,
00242                           const concepts::Real2d& p,
00243                           const Real t = 0.0) const { 
00244       return (*this)(elm, p[0], t);
00245     }
00246     virtual F operator() (const concepts::ElementWithCell<Real>& elm,
00247                           const concepts::Real3d& p,
00248                           const Real t = 0.0) const  { 
00249       return (*this)(elm, p[0], t);
00250     }
00251 
00253     virtual ElementFormulaEdgeMean<F>* clone() const {
00254       return new ElementFormulaEdgeMean<F>(spc_, v_, *f_);
00255     }
00256   protected:
00257     virtual std::ostream& info(std::ostream& os) const;
00258   private:
00260     const hp2D::TraceSpace& spc_;
00262     const concepts::Vector<F>& v_;
00264     std::auto_ptr<const concepts::ElementFunction<F> > f_;
00265   };
00266 
00267   // **************************************** ElementFormulaSignNormalVector **
00268 
00274   class ElementFormulaSignNormalVector : public concepts::ElementFormula<Real> {
00275   public:
00276     virtual Real operator() (const concepts::ElementWithCell<Real>& elm,
00277                           const Real p, const Real t = 0.0) const;
00278     virtual Real operator() (const concepts::ElementWithCell<Real>& elm,
00279                           const concepts::Real2d& p,
00280                           const Real t = 0.0) const { 
00281       return (*this)(elm, p[0], t);
00282     }
00283     virtual Real operator() (const concepts::ElementWithCell<Real>& elm,
00284                           const concepts::Real3d& p,
00285                           const Real t = 0.0) const  { 
00286       return (*this)(elm, p[0], t);
00287     }
00288 
00290     virtual ElementFormulaSignNormalVector* clone() const {
00291       return new ElementFormulaSignNormalVector();
00292     }
00293   protected:
00294     virtual std::ostream& info(std::ostream& os) const;
00295   };
00296 
00297 
00298 } // namespace hp2D
00299 
00300 #endif // formulahp2D_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)