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

formula/frmE_sum.hh
Go to the documentation of this file.
00001 
00004 #ifndef sumelementformula_hh
00005 #define sumelementformula_hh
00006 
00007 #include "basics/typedefs.hh"
00008 #include "basics/vectorsMatricesForward.hh"
00009 #include "elementFormulaContainer.hh"
00010 #include "exceptions.hh"
00011 
00012 #define SumElemFormConstr_D 0
00013 #define SumElemFormDestr_D  0
00014 #define SumElemFormClone_D  0
00015 
00016 namespace concepts {
00017    
00018  
00019  // **************************************************************** FrmE_Sum **
00020 
00029   template<class F, class H = F, class J = F,
00030            class G  = typename Realtype<F>::type>
00031   class FrmE_Sum : public ElementFormula<F,G> {
00032   public:
00033     FrmE_Sum(const ElementFormulaContainer<H> frm1,
00034              const ElementFormulaContainer<J> frm2) 
00035       : frm1_(frm1), frm2_(frm2), a_(0.0)
00036     {
00037       if (frm1.empty()) throw(PointerToEmptyElementFormula());
00038       if (frm2.empty()) throw(PointerToEmptyElementFormula());
00039     }
00040     FrmE_Sum(const ElementFormulaContainer<H> frm1,
00041              const F a) 
00042       : frm1_(frm1), frm2_(), a_(a)
00043     {
00044       DEBUGL(SumElemFormConstr_D, "frm1 = " << frm1);
00045       if (frm1.empty()) throw(PointerToEmptyElementFormula());
00046     }
00047     virtual ~FrmE_Sum() {
00048       DEBUGL(SumElemFormDestr_D, "Delete " << *this)
00049     }
00050 
00051 
00052     virtual F operator() (const ElementWithCell<G>& elm, const Real p,
00053                           const Real t = 0.0) const
00054     {
00055       F v = frm1_(elm, p,t);
00056       if (!frm2_.empty())
00057         v += frm2_(elm, p,t);
00058       
00059       return v + a_;
00060     }
00061     virtual F operator() (const ElementWithCell<G>& elm, const Real2d& p,
00062                           const Real t = 0.0) const 
00063     {
00064       F v = frm1_(elm, p,t);
00065       if (!frm2_.empty())
00066         v += frm2_(elm, p,t);
00067       
00068       return v + a_;
00069     }
00070     virtual F operator() (const ElementWithCell<G>& elm, const Real3d& p,
00071                           const Real t = 0.0) const 
00072     {
00073       F v = frm1_(elm, p,t);
00074       if (!frm2_.empty())
00075         v += frm2_(elm, p,t);
00076 
00077       return v + a_;
00078     }
00079 
00080     virtual FrmE_Sum<F,H,J,G>* clone() const {
00081       DEBUGL(SumElemFormClone_D, *this << " = *" << this);
00082       return new FrmE_Sum<F,H,J,G>(frm1_, frm2_, a_);
00083     }
00084   protected:
00085     virtual std::ostream& info(std::ostream& os) const {
00086       os << "FrmE_Sum(" << frm1_;
00087       if (!frm2_.empty())
00088         os << " + " << frm2_;
00089       if (!(a_ == F(0.0)))
00090         os << " + " << a_;
00091       return os << ")";
00092     }
00093   private:
00095     ElementFormulaContainer<H> frm1_;
00097     ElementFormulaContainer<J> frm2_;
00099     F a_;
00100 
00102     FrmE_Sum(const ElementFormulaContainer<H> frm1,
00103              const ElementFormulaContainer<J> frm2,
00104              const F a) 
00105       : frm1_(frm1), frm2_(frm2), a_(a) 
00106     {
00107       DEBUGL(SumElemFormConstr_D, 
00108              "frm1 = " << frm1 << ", frm2 = " << frm2 << ", a = " << a);
00109       if (frm1.empty()) throw(PointerToEmptyElementFormula());
00110     }
00111   };
00112 
00113 
00114   // ************************************************************ operator+ **
00115 
00117 
00118   ElementFormulaContainer<Real> 
00119   operator+(const ElementFormulaContainer<Real> frm, const Real  a);
00120   
00121   ElementFormulaContainer<Cmplx> 
00122   operator+(const ElementFormulaContainer<Cmplx> frm, const Real  a);
00123   
00124   ElementFormulaContainer<Cmplx> 
00125   operator+(const ElementFormulaContainer<Cmplx> frm, const Cmplx a);
00126   
00127   ElementFormulaContainer<Cmplx> 
00128   operator+(const ElementFormulaContainer<Real> frm, const Cmplx a);
00129 
00130   //                             ************     
00131 
00132   ElementFormulaContainer<Real2d> 
00133   operator+(const ElementFormulaContainer<Real2d> frm, const Real2d  a);
00134   
00135   ElementFormulaContainer<Cmplx2d> 
00136   operator+(const ElementFormulaContainer<Cmplx2d> frm, const Real2d  a);
00137   
00138   ElementFormulaContainer<Cmplx2d> 
00139   operator+(const ElementFormulaContainer<Cmplx2d> frm, const Cmplx2d a);
00140   
00141   ElementFormulaContainer<Cmplx2d> 
00142   operator+(const ElementFormulaContainer<Real2d> frm, const Cmplx2d a);
00143 
00144 
00147   ElementFormulaContainer<Real> 
00148   operator+(const ElementFormulaContainer<Real> frm1,
00149             const ElementFormulaContainer<Real> frm2);
00150 
00151   ElementFormulaContainer<Cmplx> 
00152   operator+(const ElementFormulaContainer<Cmplx> frm1,
00153             const ElementFormulaContainer<Real> frm2);
00154 
00155   ElementFormulaContainer<Cmplx> 
00156   operator+(const ElementFormulaContainer<Real> frm1,
00157             const ElementFormulaContainer<Cmplx> frm2);
00158 
00159   ElementFormulaContainer<Cmplx> 
00160   operator+(const ElementFormulaContainer<Cmplx> frm1,
00161             const ElementFormulaContainer<Cmplx> frm2);
00162 
00163   //                             ************     
00164 
00165   ElementFormulaContainer<Real2d> 
00166   operator+(const ElementFormulaContainer<Real2d> frm1,
00167             const ElementFormulaContainer<Real2d> frm2);
00168 
00169   ElementFormulaContainer<Cmplx2d> 
00170   operator+(const ElementFormulaContainer<Cmplx2d> frm1,
00171             const ElementFormulaContainer<Real2d> frm2);
00172 
00173   ElementFormulaContainer<Cmplx2d> 
00174   operator+(const ElementFormulaContainer<Real2d> frm1,
00175             const ElementFormulaContainer<Cmplx2d> frm2);
00176 
00177   ElementFormulaContainer<Cmplx2d> 
00178   operator+(const ElementFormulaContainer<Cmplx2d> frm1,
00179             const ElementFormulaContainer<Cmplx2d> frm2);
00180 
00182 
00183   ElementFormulaContainer<Real> 
00184   operator-(const ElementFormulaContainer<Real> frm, const Real  a);
00185   
00186   ElementFormulaContainer<Cmplx> 
00187   operator-(const ElementFormulaContainer<Cmplx> frm, const Real  a);
00188   
00189   ElementFormulaContainer<Cmplx> 
00190   operator-(const ElementFormulaContainer<Cmplx> frm, const Cmplx a);
00191   
00192   ElementFormulaContainer<Cmplx> 
00193   operator-(const ElementFormulaContainer<Real> frm, const Cmplx a);
00194 
00195   //                             ************     
00196 
00197   ElementFormulaContainer<Real2d> 
00198   operator-(const ElementFormulaContainer<Real2d> frm, const Real2d  a);
00199   
00200   ElementFormulaContainer<Cmplx2d> 
00201   operator-(const ElementFormulaContainer<Cmplx2d> frm, const Real2d  a);
00202   
00203   ElementFormulaContainer<Cmplx2d> 
00204   operator-(const ElementFormulaContainer<Cmplx2d> frm, const Cmplx2d a);
00205   
00206   ElementFormulaContainer<Cmplx2d> 
00207   operator-(const ElementFormulaContainer<Real2d> frm, const Cmplx2d a);
00208 
00211   ElementFormulaContainer<Real> 
00212   operator-(const ElementFormulaContainer<Real> frm1,
00213             const ElementFormulaContainer<Real> frm2);
00214 
00215   ElementFormulaContainer<Cmplx> 
00216   operator-(const ElementFormulaContainer<Cmplx> frm1,
00217             const ElementFormulaContainer<Real> frm2);
00218 
00219   ElementFormulaContainer<Cmplx> 
00220   operator-(const ElementFormulaContainer<Real> frm1,
00221             const ElementFormulaContainer<Cmplx> frm2);
00222 
00223   ElementFormulaContainer<Cmplx> 
00224   operator-(const ElementFormulaContainer<Cmplx> frm1,
00225             const ElementFormulaContainer<Cmplx> frm2);
00226 
00227   //                             ************     
00228 
00229   ElementFormulaContainer<Real2d> 
00230   operator-(const ElementFormulaContainer<Real2d> frm1,
00231             const ElementFormulaContainer<Real2d> frm2);
00232 
00233   ElementFormulaContainer<Cmplx2d> 
00234   operator-(const ElementFormulaContainer<Cmplx2d> frm1,
00235             const ElementFormulaContainer<Real2d> frm2);
00236 
00237   ElementFormulaContainer<Cmplx2d> 
00238   operator-(const ElementFormulaContainer<Real2d> frm1,
00239             const ElementFormulaContainer<Cmplx2d> frm2);
00240 
00241   ElementFormulaContainer<Cmplx2d> 
00242   operator-(const ElementFormulaContainer<Cmplx2d> frm1,
00243             const ElementFormulaContainer<Cmplx2d> frm2);
00244 
00245 } // namespace concepts
00246 
00247 
00248 #endif // sumelementformula_hh

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