00001
00008 #ifndef productelementformula_hh
00009 #define productelementformula_hh
00010
00011 #include "basics/debug.hh"
00012 #include "elementFormulaContainer.hh"
00013 #include "exceptions.hh"
00014
00015 #define ProdElemFormConstr_D 0
00016 #define ProdElemFormDestr_D 0
00017 #define ProdElemFormClone_D 0
00018
00019 namespace concepts {
00020
00021
00022
00023
00033 template<typename F,
00034 typename H = F,
00035 typename J = typename Datatype<F>::type,
00036 typename G = typename Realtype<F>::type>
00037 class FrmE_Product : public ElementFormula<F,G> {
00038 public:
00039 FrmE_Product(const ElementFormulaContainer<H> frm1,
00040 const ElementFormulaContainer<J> frm2)
00041 : frm1_(frm1), frm2_(frm2)
00042 {
00043 if (frm1.empty()) throw(PointerToEmptyElementFormula());
00044 if (frm2.empty()) throw(PointerToEmptyElementFormula());
00045 }
00046 FrmE_Product(const ElementFormulaContainer<H> frm1,
00047 const J a)
00048 : frm1_(frm1), frm2_(), a_(new J(a))
00049 {
00050 DEBUGL(ProdElemFormConstr_D, "frm1 = " << frm1);
00051 if (frm1.empty()) throw(PointerToEmptyElementFormula());
00052 }
00054 FrmE_Product(const FrmE_Product<F,H,J,G>& frm)
00055 : frm1_(frm.frm1_), frm2_(frm.frm2_), a_(frm.a_) {}
00056
00057 virtual ~FrmE_Product() {
00058 DEBUGL(ProdElemFormDestr_D, "Delete " << *this)
00059 }
00060
00061 virtual F operator() (const ElementWithCell<G>& elm,
00062 const Real p, const Real t = 0.0) const {
00063 H v = frm1_(elm, p,t);
00064
00065 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
00066
00067 if (frm2_.empty())
00068 return v * *a_;
00069
00070 return v * frm2_(elm, p,t);
00071 }
00072 virtual F operator() (const ElementWithCell<G>& elm,
00073 const Real2d& p, const Real t = 0.0) const {
00074 H v = frm1_(elm, p,t);
00075
00076 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
00077
00078 if (frm2_.empty())
00079 return v * *a_;
00080
00081 return v * frm2_(elm, p,t);
00082 }
00083 virtual F operator() (const ElementWithCell<G>& elm,
00084 const Real3d& p, const Real t = 0.0) const {
00085 H v = frm1_(elm, p,t);
00086
00087 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
00088
00089 if (frm2_.empty())
00090 return v * *a_;
00091
00092 return v * frm2_(elm, p,t);
00093 }
00094 virtual FrmE_Product<F,H,J,G>* clone() const {
00095 DEBUGL(ProdElemFormClone_D, *this << " = *" << this);
00096 return new FrmE_Product<F,H,J,G>(frm1_, frm2_, a_);
00097 }
00098 protected:
00099 virtual std::ostream& info(std::ostream& os) const {
00100 os << "FrmE_Product(" << frm1_;
00101 conceptsAssert(!frm2_.empty() xor (a_.get() != 0), Assertion());
00102 if (!frm2_.empty())
00103 os << " * " << frm2_;
00104 if (a_.get())
00105 os << " * " << *a_;
00106 return os << ")";
00107 }
00108 private:
00110 ElementFormulaContainer<H> frm1_;
00112 ElementFormulaContainer<J> frm2_;
00114 RCP<J> a_;
00115
00117 FrmE_Product(const ElementFormulaContainer<H> frm1,
00118 const ElementFormulaContainer<J> frm2,
00119 const RCP<J> a)
00120 : frm1_(frm1), frm2_(frm2), a_(a)
00121 {
00122 DEBUGL(ProdElemFormConstr_D,
00123 "frm1 = " << frm1 << ", frm2 = " << frm2 << ", a = " << a);
00124 if (frm1.empty()) throw(PointerToEmptyElementFormula());
00125 }
00126 };
00127
00128
00129
00131
00132 ElementFormulaContainer<Real>
00133 operator*(const ElementFormulaContainer<Real> frm, const Real a);
00134
00135 ElementFormulaContainer<Cmplx>
00136 operator*(const ElementFormulaContainer<Cmplx> frm, const Real a);
00137
00138 ElementFormulaContainer<Cmplx>
00139 operator*(const ElementFormulaContainer<Cmplx> frm, const Cmplx a);
00140
00141 ElementFormulaContainer<Cmplx>
00142 operator*(const ElementFormulaContainer<Real> frm, const Cmplx a);
00143
00144
00145
00146 ElementFormulaContainer<Real2d>
00147 operator*(const ElementFormulaContainer<Real2d> frm, const Real a);
00148
00149 ElementFormulaContainer<Cmplx2d>
00150 operator*(const ElementFormulaContainer<Cmplx2d> frm, const Real a);
00151
00152 ElementFormulaContainer<Cmplx2d>
00153 operator*(const ElementFormulaContainer<Cmplx2d> frm, const Cmplx a);
00154
00155 ElementFormulaContainer<Cmplx2d>
00156 operator*(const ElementFormulaContainer<Real2d> frm, const Cmplx a);
00157
00158
00159
00160 ElementFormulaContainer<Real2d>
00161 operator*(const ElementFormulaContainer<Real> frm, const Real2d a);
00162
00163 ElementFormulaContainer<Cmplx2d>
00164 operator*(const ElementFormulaContainer<Cmplx> frm, const Real2d a);
00165
00166 ElementFormulaContainer<Cmplx2d>
00167 operator*(const ElementFormulaContainer<Cmplx> frm, const Cmplx2d a);
00168
00169 ElementFormulaContainer<Cmplx2d>
00170 operator*(const ElementFormulaContainer<Real> frm, const Cmplx2d a);
00171
00172
00173
00174 ElementFormulaContainer<MapReal2d>
00175 operator*(const ElementFormulaContainer<MapReal2d> frm, const Real a);
00176
00177 ElementFormulaContainer<MapCmplx2d>
00178 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Real a);
00179
00180 ElementFormulaContainer<MapCmplx2d>
00181 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Cmplx a);
00182
00183 ElementFormulaContainer<MapCmplx2d>
00184 operator*(const ElementFormulaContainer<MapReal2d> frm, const Cmplx a);
00185
00186
00187
00188 ElementFormulaContainer<MapReal2d>
00189 operator*(const Real a, const ElementFormulaContainer<MapReal2d> frm);
00190
00191 ElementFormulaContainer<MapCmplx2d>
00192 operator*(const Real a, const ElementFormulaContainer<MapCmplx2d> frm);
00193
00194 ElementFormulaContainer<MapCmplx2d>
00195 operator*(const Cmplx a, const ElementFormulaContainer<MapCmplx2d> frm);
00196
00197 ElementFormulaContainer<MapCmplx2d>
00198 operator*(const Cmplx a, const ElementFormulaContainer<MapReal2d> frm);
00199
00200
00201
00202
00203
00204
00205 ElementFormulaContainer<Real2d>
00206 operator*(const ElementFormulaContainer<MapReal2d> frm, const Real2d a);
00207
00208 ElementFormulaContainer<Cmplx2d>
00209 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Real2d a);
00210
00211 ElementFormulaContainer<Cmplx2d>
00212 operator*(const ElementFormulaContainer<MapCmplx2d> frm, const Cmplx2d a);
00213
00214 ElementFormulaContainer<Cmplx2d>
00215 operator*(const ElementFormulaContainer<MapReal2d> frm, const Cmplx2d a);
00216
00218
00219 ElementFormulaContainer<Real>
00220 operator*(const ElementFormulaContainer<Real> frm1,
00221 const ElementFormulaContainer<Real> frm2);
00222
00223 ElementFormulaContainer<Cmplx>
00224 operator*(const ElementFormulaContainer<Cmplx> frm1,
00225 const ElementFormulaContainer<Real> frm2);
00226
00227 ElementFormulaContainer<Cmplx>
00228 operator*(const ElementFormulaContainer<Real> frm1,
00229 const ElementFormulaContainer<Cmplx> frm2);
00230
00231 ElementFormulaContainer<Cmplx>
00232 operator*(const ElementFormulaContainer<Cmplx> frm1,
00233 const ElementFormulaContainer<Cmplx> frm2);
00234
00235
00236
00237 ElementFormulaContainer<Real2d>
00238 operator*(const ElementFormulaContainer<Real2d> frm1,
00239 const ElementFormulaContainer<Real> frm2);
00240
00241 ElementFormulaContainer<Cmplx2d>
00242 operator*(const ElementFormulaContainer<Cmplx2d> frm1,
00243 const ElementFormulaContainer<Real> frm2);
00244
00245 ElementFormulaContainer<Cmplx2d>
00246 operator*(const ElementFormulaContainer<Real2d> frm1,
00247 const ElementFormulaContainer<Cmplx> frm2);
00248
00249 ElementFormulaContainer<Cmplx2d>
00250 operator*(const ElementFormulaContainer<Cmplx2d> frm1,
00251 const ElementFormulaContainer<Cmplx> frm2);
00252
00253
00254
00255 ElementFormulaContainer<Real2d>
00256 operator*(const ElementFormulaContainer<Real> frm1,
00257 const ElementFormulaContainer<Real2d> frm2);
00258
00259 ElementFormulaContainer<Cmplx2d>
00260 operator*(const ElementFormulaContainer<Cmplx> frm1,
00261 const ElementFormulaContainer<Real2d> frm2);
00262
00263 ElementFormulaContainer<Cmplx2d>
00264 operator*(const ElementFormulaContainer<Real> frm1,
00265 const ElementFormulaContainer<Cmplx2d> frm2);
00266
00267 ElementFormulaContainer<Cmplx2d>
00268 operator*(const ElementFormulaContainer<Cmplx> frm1,
00269 const ElementFormulaContainer<Cmplx2d> frm2);
00270
00271
00272
00273 ElementFormulaContainer<Real>
00274 operator*(const ElementFormulaContainer<Real2d> frm1,
00275 const ElementFormulaContainer<Real2d> frm2);
00276
00277 ElementFormulaContainer<Cmplx>
00278 operator*(const ElementFormulaContainer<Cmplx2d> frm1,
00279 const ElementFormulaContainer<Real2d> frm2);
00280
00281 ElementFormulaContainer<Cmplx>
00282 operator*(const ElementFormulaContainer<Real2d> frm1,
00283 const ElementFormulaContainer<Cmplx2d> frm2);
00284
00285 ElementFormulaContainer<Cmplx>
00286 operator*(const ElementFormulaContainer<Cmplx2d> frm1,
00287 const ElementFormulaContainer<Cmplx2d> frm2);
00288
00289
00290
00291 ElementFormulaContainer<MapReal2d>
00292 operator*(const ElementFormulaContainer<MapReal2d> frm1,
00293 const ElementFormulaContainer<Real> frm2);
00294
00295 ElementFormulaContainer<MapCmplx2d>
00296 operator*(const ElementFormulaContainer<MapCmplx2d> frm1,
00297 const ElementFormulaContainer<Real> frm2);
00298
00299 ElementFormulaContainer<MapCmplx2d>
00300 operator*(const ElementFormulaContainer<MapCmplx2d> frm1,
00301 const ElementFormulaContainer<Cmplx> frm2);
00302
00303 ElementFormulaContainer<MapCmplx2d>
00304 operator*(const ElementFormulaContainer<MapReal2d> frm1,
00305 const ElementFormulaContainer<Cmplx> frm2);
00306
00307
00308
00309 ElementFormulaContainer<MapReal2d>
00310 operator*(const ElementFormulaContainer<Real> frm1,
00311 const ElementFormulaContainer<MapReal2d> frm2);
00312
00313 ElementFormulaContainer<MapCmplx2d>
00314 operator*(const ElementFormulaContainer<Real> frm1,
00315 const ElementFormulaContainer<MapCmplx2d> frm2);
00316
00317 ElementFormulaContainer<MapCmplx2d>
00318 operator*(const ElementFormulaContainer<Cmplx> frm1,
00319 const ElementFormulaContainer<MapCmplx2d> frm2);
00320
00321 ElementFormulaContainer<MapCmplx2d>
00322 operator*(const ElementFormulaContainer<Cmplx> frm1,
00323 const ElementFormulaContainer<MapReal2d> frm2);
00324
00325
00326
00327
00328
00329
00330 ElementFormulaContainer<Real2d>
00331 operator*(const ElementFormulaContainer<MapReal2d> frm1,
00332 const ElementFormulaContainer<Real2d> frm2);
00333
00334 ElementFormulaContainer<Cmplx2d>
00335 operator*(const ElementFormulaContainer<MapCmplx2d> frm1,
00336 const ElementFormulaContainer<Real2d> frm2);
00337
00338 ElementFormulaContainer<Cmplx2d>
00339 operator*(const ElementFormulaContainer<MapCmplx2d> frm1,
00340 const ElementFormulaContainer<Cmplx2d> frm2);
00341
00342 ElementFormulaContainer<Cmplx2d>
00343 operator*(const ElementFormulaContainer<MapReal2d> frm1,
00344 const ElementFormulaContainer<Cmplx2d> frm2);
00345
00346
00347
00349
00350 ElementFormulaContainer<Real>
00351 operator/(const ElementFormulaContainer<Real> frm1,
00352 const ElementFormulaContainer<Real> frm2);
00353
00354 ElementFormulaContainer<Cmplx>
00355 operator/(const ElementFormulaContainer<Cmplx> frm1,
00356 const ElementFormulaContainer<Real> frm2);
00357
00358 ElementFormulaContainer<Cmplx>
00359 operator/(const ElementFormulaContainer<Real> frm1,
00360 const ElementFormulaContainer<Cmplx> frm2);
00361
00362 ElementFormulaContainer<Cmplx>
00363 operator/(const ElementFormulaContainer<Cmplx> frm1,
00364 const ElementFormulaContainer<Cmplx> frm2);
00365
00366
00367 }
00368
00369
00370 #endif // productelementformula_hh