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

space/function.hh
Go to the documentation of this file.
00001 /* Functions
00002  * Functions of a in the FE space approximated function
00003  */
00004 
00005 #ifndef spcFunction_hh
00006 #define spcFunction_hh
00007 
00008 #include <cstring>
00009 #include "basics/outputOperator.hh"
00010 #include "basics/vectorsMatrices.hh"
00011 #include "toolbox/array.hh"
00012 #include "element.hh"
00013 
00014 namespace concepts {
00015 
00016   // ****************************************************** ElementFunction **
00017 
00022   template<class F, class G = typename Realtype<F>::type>
00023   class ElementFunction : public OutputOperator {
00024   public:
00026     virtual uint n() const = 0;
00033     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00034                              Array<F>& val, const uint *i) const = 0;
00042     virtual void operator() (const Element<G>& elm, const uint* j,
00043                              Array<F>& val, const uint* i) const = 0;
00045 
00053     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00054                              Array<F>& val, const Real p, 
00055                              const Real t = 0.0) const = 0;
00056     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00057                              Array<F>& val, const Real2d& p,
00058                              const Real t = 0.0) const = 0;
00059     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00060                              Array<F>& val, const Real3d& p,
00061                              const Real t = 0.0) const = 0;
00063 
00064     virtual ElementFunction<F,G>* clone() const = 0;
00065   protected:
00066     virtual std::ostream& info(std::ostream& os) const {
00067       return os << "ElementFunction()";
00068     }
00069   };
00070 
00071   // *************************************************************** Squared **
00072 
00076   template<class F, class G = typename Realtype<F>::type>
00077   class Squared : public ElementFunction<F, G> {
00078   public:
00080     Squared(ElementFunction<F,G>& fun) : fun_(fun) {}
00081     virtual ~Squared() {}
00082     virtual uint n() const { return fun_.n(); }
00083 
00084     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00085                              Array<F>& val, const uint *i) const;
00086     virtual void operator() (const Element<G>& elm, const uint* j,
00087                              Array<F>& val, const uint* i) const;
00088     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00089                              Array<F>& val, const Real p,
00090                              const Real t = 0.0) const;
00091     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00092                              Array<F>& val, const Real2d& p,
00093                              const Real t = 0.0) const;
00094     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00095                              Array<F>& val, const Real3d& p,
00096                              const Real t = 0.0) const;
00097 
00098     virtual Squared<F,G>* clone() const { return new Squared(fun_); }
00099   protected:
00100     virtual std::ostream& info(std::ostream& os) const;
00101   private:
00103     ElementFunction<F,G>& fun_;
00105     template<class H>
00106     void square_(Array<H>& val) const {
00107       conceptsAssert(val.size() <= n(), Assertion());
00108       for(uint j=0; j < n(); ++j)
00109         val[j] = val[j]*val[j];
00110     }
00111   };
00112 
00113   // ********************************************************** AbsoluteComp **
00114 
00123   template<class F, class G = typename Realtype<F>::type>
00124   class AbsoluteComp : public ElementFunction<F, G> {
00125   public:
00127     AbsoluteComp(ElementFunction<F,G>& fun) : fun_(fun) {}
00128     virtual ~AbsoluteComp() {}
00129     virtual uint n() const { return fun_.n(); }
00130 
00131     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00132                              Array<F>& val, const uint *i) const;
00133     virtual void operator() (const Element<G>& elm, const uint* j,
00134                              Array<F>& val, const uint* i) const;
00135     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00136                              Array<F>& val, const Real p,
00137                              const Real t = 0.0) const;
00138     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00139                              Array<F>& val, const Real2d& p,
00140                              const Real t = 0.0) const;
00141     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00142                              Array<F>& val, const Real3d& p,
00143                              const Real t = 0.0) const;
00144     virtual AbsoluteComp<F,G>* clone() const { return new AbsoluteComp(fun_); }
00145   protected:
00146     virtual std::ostream& info(std::ostream& os) const;
00147   private:
00149     ElementFunction<F,G>& fun_;
00151     void absolute_(Array<F>& val) const;
00152   };
00153 
00154   // ************************************************************** Absolute **
00155 
00164   template<class F, class G = typename Realtype<F>::type>
00165   class Absolute : public ElementFunction<F, G> {
00166   public:
00168     Absolute(ElementFunction<F,G>& fun) : fun_(fun) {}
00169     virtual ~Absolute() {}
00170     virtual uint n() const { return 1; }
00171 
00172     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00173                              Array<F>& val, const uint *i) const;
00174     virtual void operator() (const Element<G>& elm, const uint* j,
00175                              Array<F>& val, const uint* i) const;
00176     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00177                              Array<F>& val, const Real p,
00178                              const Real t = 0.0) const;
00179     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00180                              Array<F>& val, const Real2d& p,
00181                              const Real t = 0.0) const;
00182     virtual void operator() (const Element<G>& elm, const Array<F>& coeff,
00183                              Array<F>& val, const Real3d& p,
00184                              const Real t = 0.0) const;
00185     virtual Absolute<F,G>* clone() const { return new Absolute(fun_); }
00186   protected:
00187     virtual std::ostream& info(std::ostream& os) const;
00188   private:
00190     ElementFunction<F,G>& fun_;
00192     F absolute_(const Array<F>& val) const;
00193   };
00194 
00195 } // namespace concepts
00196 
00197 #endif // spcFunction_hh

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