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

app-bholger/gfem/upcastFormula.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <memory>
00004 #include "toolbox/sharedPointer.hh"
00005 #include "formula/elementFormulaRCP.hh"
00006 #include "formula/formula.hh"
00007 
00008 namespace concepts {
00009 namespace gfem {
00010 
00011 template<class ScalarT, class ScalarT2>
00012 class UpcastFormula : public concepts::ElementFormula<ScalarT> {
00013 public:
00014   //typedef typename Realtype<ScalarT>::type G;
00015   typedef Real G;
00016 
00017   UpcastFormula( const concepts::ElementFormula<ScalarT2>& other ) 
00018    : formula(other.clone()) 
00019   {
00020   }
00021 
00022   virtual ScalarT operator() (const ElementWithCell<G>& elm, const Real p,
00023       const Real t = 0.0) const
00024   {
00025     return formula->operator()(elm, p, t);
00026   }
00027   virtual ScalarT operator() (const ElementWithCell<G>& elm, const Real2d& p,
00028       const Real t = 0.0) const 
00029   {
00030     return formula->operator()(elm, p, t);
00031   }
00032 
00033   virtual ScalarT operator() (const ElementWithCell<G>& elm, const Real3d& p,
00034       const Real t = 0.0) const
00035   {
00036     return formula->operator()(elm, p, t);
00037   }
00038 
00040   virtual UpcastFormula<ScalarT, ScalarT2>* clone() const {
00041     return new UpcastFormula<ScalarT, ScalarT2>(*formula);
00042   }
00043 
00044 private:
00045   std::auto_ptr< concepts::ElementFormula<ScalarT2> > formula;
00046 };
00047 
00048 template<class ScalarT>
00049 class FormulaToElemFormula : public concepts::ElementFormula<ScalarT> {
00050 public:
00051   typedef Real G;
00052 
00053   FormulaToElemFormula(RCP< concepts::Formula<ScalarT> > form) 
00054   : form(form)
00055   {
00056 
00057   }
00058 
00059   ~FormulaToElemFormula() {
00060 
00061   }
00062 
00063   FormulaToElemFormula<ScalarT>* clone() const {
00064     return new FormulaToElemFormula<ScalarT>(*this);
00065   }
00066 
00067   ScalarT operator() (const ElementWithCell<G>& elm, const Real p,
00068       const Real t = 0.0) const 
00069   {
00070     return form->operator()(p, t);
00071   }
00072   ScalarT operator() (const ElementWithCell<G>& elm, const Real2d& p,
00073       const Real t = 0.0) const 
00074   {
00075     return form->operator()(p, t);  
00076   }
00077   ScalarT operator() (const ElementWithCell<G>& elm, const Real3d& p,
00078       const Real t = 0.0) const 
00079   {
00080     return form->operator()(p, t);
00081   }
00082 
00083 private:
00084   RCP<Formula<ScalarT> > form;
00085 };
00086 
00087 
00088 } //namespace
00089 } //namespace

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