Provided by: librheolef-dev_6.7-6_amd64

**NAME**

functor- a function wrapper suitable for field expressions

**DESCRIPTION**

Afunctoris a class-function, i.e. a class that defines theoperator(): it can be used in place of an usual function. Moreover, functors can be used in Rheolef field expressions, mixed with fields (see field(2)). For instance, assuming thatuhis a field andu_exis a functor: Float err_l1 = integrate (omega, abs(uh - uh_ex), qopt); whereomegadenotes a mesh (see geo(2)) andqopta quadrature formula (see quadrature_option_type(2)). See also the integrate(4) function. An usual functionu_ex_fcannot always be mixed so nicely in expressions, due to c++ language rules. For instance, the following exprtession is valid: Float err_l1 = integrate (omega, abs(uh - u_ex_f), qopt); In some case, the compiler cannot build a field expression using usual functionsn e.g. Float I = integrate (omega, 0.5*u_ex_f), qopt); because0.5*u_ex_fis a direct algebraic operation between usual functions and flmoating points, that is not defined in the c++ language. A way to circumvent this difficulty is to convert the usual function into a functor, as in: Float I = integrate (omega, 0.5*functor(u_ex_f)), qopt);

**IMPLEMENTATION**

template<class R, class... Args> std::function<R(Args...)> functor (R(*f)(Args...)) { return std::function<R(Args...)>(f); }

**SEE** **ALSO**

field(2), geo(2), quadrature_option_type(2), integrate(4)