Commit 142ba14f authored by Nestler, Michael's avatar Nestler, Michael
Browse files

added expressions with 4 and 5 Terms

parent 7135961b
......@@ -159,6 +159,99 @@ namespace AMDiS
inline double operator()(const int& iq) const;
};
/* 150203 added by Michael */
template<typename Term1, typename Term2, typename Term3, typename Term4>
struct LazyOperatorTerm4 : public LazyOperatorTermBase
{
Term1 term1;
Term2 term2;
Term3 term3;
Term4 term4;
LazyOperatorTerm4(const Term1& term1_, const Term2& term2_, const Term3& term3_, const Term4& term4_)
: term1(term1_), term2(term2_), term3(term3_), term4(term4_) {}
template<typename List>
inline void insertFeSpaces(List& feSpaces)
{
term1.insertFeSpaces(feSpaces);
term2.insertFeSpaces(feSpaces);
term3.insertFeSpaces(feSpaces);
term4.insertFeSpaces(feSpaces);
}
template<typename OT>
inline void initElement(OT* ot, const ElInfo* elInfo,
SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL)
{
term1.initElement(ot, elInfo, subAssembler, quad, basisFct);
term2.initElement(ot, elInfo, subAssembler, quad, basisFct);
term3.initElement(ot, elInfo, subAssembler, quad, basisFct);
term4.initElement(ot, elInfo, subAssembler, quad, basisFct);
}
template<typename OT>
inline void initElement(OT* ot, const ElInfo* smallElInfo, const ElInfo* largeElInfo,
SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL)
{
term1.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
term2.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
term3.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
term4.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
}
inline double operator()(const int& iq) const;
};
/* 150203 added by Michael */
template<typename Term1, typename Term2, typename Term3, typename Term4, typename Term5>
struct LazyOperatorTerm5 : public LazyOperatorTermBase
{
Term1 term1;
Term2 term2;
Term3 term3;
Term4 term4;
Term5 term5;
LazyOperatorTerm5(const Term1& term1_, const Term2& term2_, const Term3& term3_, const Term4& term4_, const Term5& term5_)
: term1(term1_), term2(term2_), term3(term3_), term4(term4_), term5(term5_) {}
template<typename List>
inline void insertFeSpaces(List& feSpaces)
{
term1.insertFeSpaces(feSpaces);
term2.insertFeSpaces(feSpaces);
term3.insertFeSpaces(feSpaces);
term4.insertFeSpaces(feSpaces);
term5.insertFeSpaces(feSpaces);
}
template<typename OT>
inline void initElement(OT* ot, const ElInfo* elInfo,
SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL)
{
term1.initElement(ot, elInfo, subAssembler, quad, basisFct);
term2.initElement(ot, elInfo, subAssembler, quad, basisFct);
term3.initElement(ot, elInfo, subAssembler, quad, basisFct);
term4.initElement(ot, elInfo, subAssembler, quad, basisFct);
term5.initElement(ot, elInfo, subAssembler, quad, basisFct);
}
template<typename OT>
inline void initElement(OT* ot, const ElInfo* smallElInfo, const ElInfo* largeElInfo,
SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL)
{
term1.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
term2.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
term3.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
term4.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
term5.initElement(ot, smallElInfo, largeElInfo, subAssembler, quad, basisFct);
}
inline double operator()(const int& iq) const;
};
} // end namespace AMDiS
......
......@@ -123,6 +123,52 @@ namespace AMDiS
inline value_type operator()(const int& iq) const { return f(super::term1(iq), super::term2(iq), super::term3(iq)); }
};
/* 150203 added by Michael */
/// Expressions for a functor with 4 arguments
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4>
struct Function4 : public LazyOperatorTerm4<Term1, Term2, Term3, Term4>
{
typedef LazyOperatorTerm4<Term1, Term2, Term3, Term4> super;
BOOST_STATIC_ASSERT_MSG( (boost::is_base_of<FunctorBase, F>::value), "********** ERROR: Only functors with base FunctorBase allowed **********" );
typedef typename traits::functor_result_type<F>::type value_type;
BOOST_STATIC_ASSERT_MSG( (!boost::is_same<value_type, traits::no_valid_type>::value), "********** ERROR: You have to define a result_type for your Functor **********" );
F f;
Function4(const F& f_, const Term1& term1_, const Term2& term2_, const Term3& term3_, const Term4& term4_)
: super(term1_, term2_, term3_, term4_), f(f_) {}
int getDegree() const
{
return f.getDegree(super::term1.getDegree(), super::term2.getDegree(), super::term3.getDegree(), super::term2.getDegree());
}
inline value_type operator()(const int& iq) const { return f(super::term1(iq), super::term2(iq), super::term3(iq), super::term4(iq)); }
};
/* 150203 added by Michael */
/// Expressions for a functor with 5 arguments
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4, typename Term5>
struct Function5 : public LazyOperatorTerm5<Term1, Term2, Term3, Term4, Term5>
{
typedef LazyOperatorTerm5<Term1, Term2, Term3, Term4, Term5> super;
BOOST_STATIC_ASSERT_MSG( (boost::is_base_of<FunctorBase, F>::value), "********** ERROR: Only functors with base FunctorBase allowed **********" );
typedef typename traits::functor_result_type<F>::type value_type;
BOOST_STATIC_ASSERT_MSG( (!boost::is_same<value_type, traits::no_valid_type>::value), "********** ERROR: You have to define a result_type for your Functor **********" );
F f;
Function5(const F& f_, const Term1& term1_, const Term2& term2_, const Term3& term3_, const Term4& term4_, const Term5& term5_)
: super(term1_, term2_, term3_, term4_, term5_), f(f_) {}
int getDegree() const
{
return f.getDegree(super::term1.getDegree(), super::term2.getDegree(), super::term3.getDegree(), super::term2.getDegree(), super::term5.getDegree());
}
inline value_type operator()(const int& iq) const { return f(super::term1(iq), super::term2(iq), super::term3(iq), super::term4(iq), super::term5(iq)); }
};
/// A wrapper functor for AMDiS::AbstractFunctions
......@@ -194,6 +240,52 @@ namespace AMDiS
typename traits::to_expr<Term3>::type
>
> {};
/* 150203 added by Michael */
// function with four arguments
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4>
struct Function4 : boost::enable_if
<
typename boost::mpl::and_
<
typename traits::is_valid_arg<Term1>::type,
typename traits::is_valid_arg<Term2>::type,
typename traits::is_valid_arg<Term3>::type,
typename traits::is_valid_arg<Term4>::type
>::type,
expressions::Function4
<
F,
typename traits::to_expr<Term1>::type,
typename traits::to_expr<Term2>::type,
typename traits::to_expr<Term3>::type,
typename traits::to_expr<Term4>::type
>
> {};
/* 150203 added by Michael */
// function with five arguments
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4, typename Term5>
struct Function5 : boost::enable_if
<
typename boost::mpl::and_
<
typename traits::is_valid_arg<Term1>::type,
typename traits::is_valid_arg<Term2>::type,
typename traits::is_valid_arg<Term3>::type,
typename traits::is_valid_arg<Term4>::type,
typename traits::is_valid_arg<Term5>::type
>::type,
expressions::Function5
<
F,
typename traits::to_expr<Term1>::type,
typename traits::to_expr<Term2>::type,
typename traits::to_expr<Term3>::type,
typename traits::to_expr<Term4>::type,
typename traits::to_expr<Term5>::type
>
> {};
} // end namespace result_of
......@@ -267,6 +359,64 @@ namespace AMDiS
(F(), Expr1::get(t1), Expr2::get(t2), Expr3::get(t3));
}
/* 150203 added by Michael */
// call a function with 4 arguments
// _____________________________________________________________________________
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4>
inline typename result_of::Function4<F, Term1, Term2, Term3, Term4>::type
function_(const F& f, const Term1& t1, const Term2& t2, const Term3& t3, const Term4& t4)
{
typedef typename traits::to_expr<Term1>::to Expr1;
typedef typename traits::to_expr<Term2>::to Expr2;
typedef typename traits::to_expr<Term3>::to Expr3;
typedef typename traits::to_expr<Term4>::to Expr4;
return expressions::Function4<F, typename Expr1::type, typename Expr2::type, typename Expr3::type, typename Expr4::type>
(f, Expr1::get(t1), Expr2::get(t2), Expr3::get(t3), Expr4::get(t4));
}
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4>
inline typename result_of::Function4<F, Term1, Term2, Term3, Term4>::type
function_(const Term1& t1, const Term2& t2, const Term3& t3, const Term4& t4)
{
typedef typename traits::to_expr<Term1>::to Expr1;
typedef typename traits::to_expr<Term2>::to Expr2;
typedef typename traits::to_expr<Term3>::to Expr3;
typedef typename traits::to_expr<Term4>::to Expr4;
return expressions::Function4<F, typename Expr1::type, typename Expr2::type, typename Expr3::type, typename Expr4::type>
(F(), Expr1::get(t1), Expr2::get(t2), Expr3::get(t3), Expr4::get(t4));
}
/* 150203 added by Michael */
// call a function with 5 arguments
// _____________________________________________________________________________
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4, typename Term5>
inline typename result_of::Function5<F, Term1, Term2, Term3, Term4, Term5>::type
function_(const F& f, const Term1& t1, const Term2& t2, const Term3& t3, const Term4& t4, const Term5& t5)
{
typedef typename traits::to_expr<Term1>::to Expr1;
typedef typename traits::to_expr<Term2>::to Expr2;
typedef typename traits::to_expr<Term3>::to Expr3;
typedef typename traits::to_expr<Term4>::to Expr4;
typedef typename traits::to_expr<Term5>::to Expr5;
return expressions::Function5<F, typename Expr1::type, typename Expr2::type, typename Expr3::type, typename Expr4::type, typename Expr5::type>
(f, Expr1::get(t1), Expr2::get(t2), Expr3::get(t3), Expr4::get(t4), Expr5::get(t5));
}
template<typename F, typename Term1, typename Term2, typename Term3, typename Term4, typename Term5>
inline typename result_of::Function5<F, Term1, Term2, Term3, Term4, Term5>::type
function_(const Term1& t1, const Term2& t2, const Term3& t3, const Term4& t4, const Term5& t5)
{
typedef typename traits::to_expr<Term1>::to Expr1;
typedef typename traits::to_expr<Term2>::to Expr2;
typedef typename traits::to_expr<Term3>::to Expr3;
typedef typename traits::to_expr<Term4>::to Expr4;
typedef typename traits::to_expr<Term5>::to Expr5;
return expressions::Function5<F, typename Expr1::type, typename Expr2::type, typename Expr3::type, typename Expr4::type, typename Expr5::type>
(F(), Expr1::get(t1), Expr2::get(t2), Expr3::get(t3), Expr4::get(t4), Expr5::get(t5));
}
// function wrapper for abstract functions
// _____________________________________________________________________________
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment