field_functor(2rheolef) | rheolef-7.0 | field_functor(2rheolef) |
field_functor - a functor wrapper suitable for field expressions (obsolete)
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).
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);
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.
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); } };
Copyright (C) 2000-2018 Pierre Saramito <Pierre.Saramito@imag.fr> GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
rheolef-7.0 | rheolef-7.0 |