diff --git a/program2D/source/extemp/co_fu2D.h b/program2D/source/extemp/co_fu2D.h index 95efcea65bcae9c530a633181d5e617ce59f31ae..991e2b7fafff356f4d8f781e6cfe8bbe1c3e49fb 100644 --- a/program2D/source/extemp/co_fu2D.h +++ b/program2D/source/extemp/co_fu2D.h @@ -517,6 +517,93 @@ class Function2d3 { }; /* @} */ + +////////////////////////////////////////////////////////////////////////// +// 4 arguments +////////////////////////////////////////////////////////////////////////// +template <class A, class B, class C, class D, class DTyp> +class Exp2D_Function4 : public Expr2D<Exp2D_Function4<A, B, C, D, DTyp> > { + const A& a_; + const B& b_; + const C& c_; + const D& d_; + + DTyp ( *Formula_ ) ( DTyp x1, DTyp x2, DTyp x3, DTyp x4); + + public: + inline Exp2D_Function4(const A& a, + const B& b, + const C& c, + const D& d, + DTyp ( *Formula ) ( DTyp x1, DTyp x2, DTyp x3, DTyp x4 )) : + a_(a), b_(b), c_(c), d_(d), Formula_ ( Formula ) {} + + stencil_typ Give_stencil_typ() const { return no_stencil; } + + typedef DTyp Result; + + template <elementTyp TYP_EL> + inline DTyp Give_data ( params2D_in ) const; + + inline DTyp Give_cell_rectangle ( params2D_in_cell ) const; + + + template <elementTyp TYP_EL> + void Update ( int id ) const { + a_.template Update<TYP_EL> ( id ); + b_.template Update<TYP_EL> ( id ); + c_.template Update<TYP_EL> ( id ); + d_.template Update<TYP_EL> ( id ); + } + + inline Unstructured2DGrid * Give_Ug() const { + return a_.Give_Ug(); + } +}; + +template <class A, class B, class C, class D, class DTyp> +template <elementTyp TYP_EL> +inline DTyp Exp2D_Function4<A, B, C, D, DTyp>::Give_data ( params2D_in ) const { + return Formula_ ( a_.template Give_data<TYP_EL> ( params2D_out ), + b_.template Give_data<TYP_EL> ( params2D_out ), + c_.template Give_data<TYP_EL> ( params2D_out ), + d_.template Give_data<TYP_EL> ( params2D_out ) + ); +} + +template <class A, class B, class C, class D, class DTyp> +inline DTyp Exp2D_Function4<A, B, C, D, DTyp>::Give_cell_rectangle ( params2D_in_cell ) const { + return Formula_ ( a_.Give_cell_rectangle ( params2D_out_cell ), + b_.Give_cell_rectangle ( params2D_out_cell ), + c_.Give_cell_rectangle ( params2D_out_cell ), + d_.Give_cell_rectangle ( params2D_out_cell ) + ); +} + +/** \addtogroup ExpressionTemplates2D **/ +/* @{ */ +template <class DTyp> +class Function2d4 { + public: + typedef DTyp Result; + + Function2d4( DTyp ( *formula ) (DTyp x1, DTyp x2, DTyp x3, DTyp x4)) : Formula ( formula ) {}; + + template <class A, class B, class C, class D> + inline Exp2D_Function4<A, B, C, D, DTyp> operator() ( const Expr2D<A>& a, + const Expr2D<B>& b, + const Expr2D<C>& c, + const Expr2D<D>& d) const + { return Exp2D_Function4<A, B, C, D, DTyp> ( a, b, c, d, Formula); } + + + + private: + DTyp ( *Formula ) ( DTyp x1, DTyp x2, DTyp x3, DTyp x4); +}; +/* @} */ + + ////////////////////////////////////////////////////////////////////////// // 5 arguments //////////////////////////////////////////////////////////////////////////