Go to the documentation of this file.00001
00002
00003
00004 #ifndef formulaFromWeight2D_hh
00005 #define formulaFromWeight2D_hh
00006
00007 #include <typeinfo>
00008 #include "formula/elementFormula.hh"
00009 #include "space/element.hh"
00010 #include "shortestDist.hh"
00011 #include "quad.hh"
00012 #include "basics/exceptions.hh"
00013
00014
00015 #include "basics/debug.hh"
00016
00017 #define FormulaFromWeightConstr_D 0
00018 #define FormulaFromWeightAppl_D 0
00019
00020
00021 namespace hp2D {
00022
00023
00024
00029 template<typename Weight = TrivialWeight>
00030 class FormulaFromWeight : public concepts::ElementFormula<Real> {
00031 public:
00035 FormulaFromWeight(const SingularSet& singularities);
00036
00037 virtual Real operator()(const concepts::Element<Real>& elm, const Real p,
00038 const Real t = 0.0) const;
00039 virtual Real operator()(const concepts::Element<Real>& elm,
00040 const concepts::Real2d& p,
00041 const Real t = 0.0) const;
00042 virtual Real operator()(const concepts::Element<Real>& elm,
00043 const concepts::Real3d& p,
00044 const Real t = 0.0) const;
00045 virtual FormulaFromWeight<Weight>* clone() const {
00046 return new FormulaFromWeight(singularities_); }
00047 private:
00048 Weight weight_;
00049 const SingularSet& singularities_;
00050 };
00051
00052 template<typename Weight>
00053 FormulaFromWeight<Weight>::FormulaFromWeight
00054 (const SingularSet& singularities) :
00055 weight_(), singularities_(singularities) {
00056 DEBUGL(FormulaFromWeightConstr_D, "weight is " << typeid(weight_).name());
00057 DEBUGL(FormulaFromWeightConstr_D, "singularities: " << singularities_);
00058 }
00059
00060 template<typename Weight>
00061 Real FormulaFromWeight<Weight>::operator()
00062 (const concepts::Element<Real>& elm, const Real p, const Real t) const {
00063 const Quad<Real>* quad = dynamic_cast<const Quad<Real>*>(&elm);
00064 conceptsAssert(quad, concepts::Assertion());
00065 return weight_(singularities_, concepts::Real2d(p, 0), quad);
00066 }
00067
00068 template<typename Weight>
00069 Real FormulaFromWeight<Weight>::operator()
00070 (const concepts::Element<Real>& elm, const concepts::Real2d& p,
00071 const Real t) const {
00072 const Quad<Real>* quad = dynamic_cast<const Quad<Real>*>(&elm);
00073 conceptsAssert(quad, concepts::Assertion());
00074 DEBUGL(FormulaFromWeightAppl_D, "p = " << p << ", singularities = "
00075 << singularities_);
00076 return weight_(singularities_, p, quad);
00077 }
00078
00079 template<typename Weight>
00080 Real FormulaFromWeight<Weight>::operator()
00081 (const concepts::Element<Real>& elm, const concepts::Real3d& p,
00082 const Real t) const {
00083 const Quad<Real>* quad = dynamic_cast<const Quad<Real>*>(&elm);
00084 conceptsAssert(quad, concepts::Assertion());
00085 return weight_(singularities_, concepts::Real2d(p[0], p[1]), quad);
00086 }
00087
00088 }
00089
00090 #endif // formulaFromWeight2D_hh