Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer run before updater (example 5 broken) #75

Open
mxmlnkn opened this issue Aug 16, 2017 · 0 comments
Open

Analyzer run before updater (example 5 broken) #75

mxmlnkn opened this issue Aug 16, 2017 · 0 comments

Comments

@mxmlnkn
Copy link
Contributor

mxmlnkn commented Aug 16, 2017

Example 5, which demonstrates how it is possible to add particles using an updater called only once, fails to output meaningful results:

make && ./bin/Example5 && tail Rg2.dat
echo "===ex5output.dat==="; cat ex5output.dat

Output:

9.91e+06	0	0	0	0	
9.92e+06	0	0	0	0	
9.93e+06	0	0	0	0	
9.94e+06	0	0	0	0	
9.95e+06	0	0	0	0	
9.96e+06	0	0	0	0	
9.97e+06	0	0	0	0	
9.98e+06	0	0	0	0	
9.99e+06	0	0	0	0	
1e+07	0	0	0	0	

===ex5output.dat===
0	0	0

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant