Hi,
here comes a question which in any other language would be wishful, yet in Julia, I dare wish.
So I program a function
R = f(X)
think finite elements 101, given nodal displacements, the function returns nodal forces.
Of course, there are many intermediate results, say strain, and stress, not needed outside of my function f, in the logic of the FEA solver, but valuable for debugging and not least, for reporting.
My strategy is to not store intermediate results systematically during the analysis. This gobbles memory and CPU, and fills the code with boilerplate. What I want to do is store all the X (for all elements and steps…), and if I want, call f after the analysis is complete. And now the crux: while adding as little boilerplate as possible, I want to be able to “call f(X)” and add “give me the stresses”.
How would I do that?
- store intermediate results in a struct, return the struct, and the solver just throws it away
- metaprogramming? Transform readable code for function f into code with boilerplate for the reporting of intermediate results?
- …???
With what strategy would you attack the problem? I am not asking for code, but pointers to the relevant language features that could be exploited here.
: )
Philippe