compose(3rheolef)

πŸ“¦
version 7.2 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu questing

πŸ’– compose(3rheolef) πŸ’–

okay bestie, listen up β€” this is a page from the rheolef manual, version 7.2, and it's all about one little function that does a huge amount of work. sit down, grab a snack πŸ“, we're doing math.


✨ NAME ✨

compose β€” n-ary function application in expressions (rheolef-7.2)


✨ SYNOPSIS ✨

template <class Function, class... Expressions>
Expression compose (const Function& f, const Expressions&... exprs);

that's it. that's the whole signature. look at those variadic templates, they're literally iconic πŸ’…


✨ DESCRIPTION ✨

so what does it actually do, bestie? it composes an n-ary function f with n fields, and you use it inside nonlinear expressions for interpolate(3) and integrate(3).

like, n fields in, one composed expression out. it's giving ✨function composition✨ but make it fields. periodt.


✨ EXAMPLE ✨

the classic use case: you've got a user-provided function and you wanna slap it onto a field. here's how that looks when it's a unary function:

Float f (Float u) { return 1/u + sqrt(u); }
...
field vh = interpolate (Xh, compose(f, uh));

see how compose(f, uh) just... does the thing? no cap, that's the whole move.

and when two arguments are involved:

Float g (Float u, Float v) { return v/u + sqrt(u*v); }
...
field wh = interpolate (Xh, compose(g, uh, vh));

two functions in, two fields in, one expression out. obsessed 😭

and the important bit β€” the compose operator supports general n-ary functions and class-functions</>. so like, not just plain free functions. go wild.


✨ CHARACTERISTIC ✨

plot twist: compose also supports the method of characteristic(2), which you'd use for stuff like convection-diffusion problems 🌊

characteristic X (-delta_t*uh);
test v (Xh);
field lh = integrate (compose(uh,X)*v);

yeah. it's that versatile. main character energy fr fr πŸ‘‘


✨ IMPLEMENTATION ✨

lowkey a fun fact for the nerds (affectionate): this documentation has been generated from the file main/lib/compose.h. so if you wanna go read the source, you know exactly where to look 🫢


✨ AUTHOR ✨

Pierre Saramito <Pierre.Saramito@imag.fr> β€” thank you for your service king πŸ’œ


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.
bestie the "There is NO WARRANTY" part is real β€” it's free software, you can change it and redistribute it, but nobody's covering you if it goes sideways. read that bit twice. πŸ™ˆ

🌸 SEE ALSO 🌸


and that's the whole page, bestie πŸ’– rheolef, Version 7.2 β€” that's the version and the source this came from, cute sign-off, mwah πŸŽ€ go compose something beautiful. βœ¨πŸ¦‹

πŸ“¦ where this page comes from