That output looked wrong, so I looked in the code and found that the custom analyzer in ex5analyzer.h saves the number of particles in its initialize-method. But that method is called before ex5updater.h's execute method which spawns the particles. That's why the analyzer sees zero particles. One workaround might be to not save the number of particles in the initialize method. That shouldn't result in a measurable performance hit. Getting the number of elements in an std::vector should be O(1). I did this tentatively here. After that change the custom analyzer worked.
But as the default radius of gyration analyzer has the same problem it might be better to put the particle creation code into the initialize method of ex5updater.h instead of putting it in execute. But then again src/utility/TaskManager.cpp:TaskManager::initialize contains the comment @todo initialize updaters necessary?, so I guess the initialize method wasn't intended to be used like this. Therefore this might be a bigger design problem needing discussion.
Example 5, which demonstrates how it is possible to add particles using an updater called only once, fails to output meaningful results:
Output:
That output looked wrong, so I looked in the code and found that the custom analyzer in
ex5analyzer.h
saves the number of particles in itsinitialize
-method. But that method is called beforeex5updater.h
'sexecute
method which spawns the particles. That's why the analyzer sees zero particles. One workaround might be to not save the number of particles in the initialize method. That shouldn't result in a measurable performance hit. Getting the number of elements in anstd::vector
should be O(1). I did this tentatively here. After that change the custom analyzer worked.But as the default radius of gyration analyzer has the same problem it might be better to put the particle creation code into the
initialize
method ofex5updater.h
instead of putting it inexecute
. But then againsrc/utility/TaskManager.cpp:TaskManager::initialize
contains the comment@todo initialize updaters necessary?
, so I guess the initialize method wasn't intended to be used like this. Therefore this might be a bigger design problem needing discussion.