Man pages sections > man2 > field_functor

field_functor - a functor wrapper suitable for field expressions

field_functor(2rheolef) rheolef-6.7 field_functor(2rheolef)

NAME

field_functor - a functor wrapper suitable for field expressions (obsolete)

DESCRIPTION

This class is now obsolete, from Rheolef version 6.7 and is maintained for backward compatibility purpose only. Until Rheolef version 6.6, this class was used to mark functors with profil compatible with fields, i.e. that accepts point as parameter and returns a field value (scalar, vector, tensor). This mark was used to filter field expression arguments in interpolate and integrate. From version 6.7, this mark is no more required, and any function or functor that is callable with a point as argument is valid in a field expression.
A functor is a class-function, i.e. a class that defines the operator(). A variable f of a class-function can be used as f(arg) and when its argument is of type point see point(2), the function f interprets as a continuous field field. Thus, it can be interpolated see interpolate(4) and it can be combined within field expressions see field(2) that appears in arguments of see integrate(4).

EXAMPLE

    struct f : field_functor<f,Float> {
      Float operator() (const point& x) const { return 1-norm(x); }
    };
    // ...
    geo omega ("square");
    space Xh (omega, "P1");
    field fh = interpolate (Xh, f);
    test  (Xh);
    field lh = integrate (f*v);
 

IMPLEMENTATION NOTE

The current implementation of a field_functor class bases on the curiously recurring template pattern (CRTP) C++ idiom: the definition of the class f derives from field_functor<f,Float> that depend itself upon f. So, be carrefull when using copy-paste, as there is no checks if you write e.g. field_functor<g,Float> with another function g instead of f.

IMPLEMENTATION

template <class Function, class Result>
struct field_functor
  : std::unary_function<point_basic<float_traits<Result> >,Result> {
 const Function& get_ref() const { return static_cast<const Function&>(*this); }
 operator Function() const { return get_ref(); }
 Result operator() (const point& x) const { return get_ref().operator()(x); }
};
 
 

SEE ALSO

point(2), interpolate(4), field(2), integrate(4)
rheolef-6.7 rheolef-6.7