.\" .de Id .. .de Sp .if n .sp .if t .sp 0.4 .. .TH field_functor 2rheolef "rheolef-7.0" "rheolef-7.0" "rheolef-7.0" .\" label: /*Class:field_functor .SH NAME \fBfield_functor\fP - a functor wrapper suitable for field expressions (obsolete) .SH 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 \fBpoint\fP as parameter and returns a field value (scalar, vector, tensor). This mark was used to filter field expression arguments in \fBinterpolate\fP and \fBintegrate\fP. From version 6.7, this mark is no more required, and any function or functor that is callable with a \fBpoint\fP as argument is valid in a field expression. .PP A functor is a class-function, i.e. a class that defines the \fBoperator()\fP. A variable \fBf\fP of a class-function can be used as \fBf(arg)\fP and when its argument is of type \fBpoint\fP see point(2), the function \fBf\fP 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). .SH EXAMPLE .\" begin_example .Sp .nf struct f : field_functor { 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); .Sp .fi .\" end_example .SH IMPLEMENTATION NOTE The current implementation of a \fBfield_functor\fP class bases on the curiously recurring template pattern (CRTP) C++ idiom: the definition of the class \fBf\fP derives from \fBfield_functor\fP<\fBf\fP,Float> that depend itself upon \fBf\fP. So, be carrefull when using copy-paste, as there is no checks if you write e.g. \fBfield_functor\fP<\fBg\fP,Float> with another function \fBg\fP instead of \fBf\fP. .\" skip start:AUTHOR: .\" skip start:DATE: .\" END .SH IMPLEMENTATION .\" begin_example .Sp .nf template struct field_functor : std::unary_function >,Result> { const Function& get_ref() const { return static_cast(*this); } operator Function() const { return get_ref(); } Result operator() (const point& x) const { return get_ref().operator()(x); } }; .Sp .fi .\" end_example .\" LENGTH = 4 .SH SEE ALSO point(2), interpolate(4), field(2), integrate(4) .SH COPYRIGHT Copyright (C) 2000-2018 Pierre Saramito GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.