Contrib equationReader/Efficiency

From OpenFOAMWiki

1 How fast is equationReader?

The most recent version of equationReader (Version 0.5.0, released September 25th, 2011) handles fields roughly 10x faster than the previous version. Overall, equationReader now takes approximately 5.87 times longer than a hard-coded solution when handling GeometricFields. That's for a simple equation. For more complex equations, equationReader's performance improves.

Straight up scalars are still much slower. I haven't benchmarked the latest version, but previous versions were coming in at around 300 x slower.

2 Will it get faster?

Yes! The next plan is to have equationReader compile your equations at runtime. In theory, they will execute as fast as a hard-coded solution, less a small amount of overhead with the function call.

3 Parsing and evaluating

There is a difference between parsing and evaluating. When the equation is first read, it is a human-readable string expression. equationReader translates the human-readable form into an operation list. This is parsing. To calculate the result, equationReader does a forAll(operations, i). This is evaluating.

Parsing happens only once, and is slow. Evaluating happens at every cell index, at every timestep (or however you've used it), and it is fast.