Custom Source definition - multi thread problem

(not sure if this is really a user support question or a development question)

For simulations using cosmic ray neutrons, I have created a custom source definition that calculates source neutron energies and directions using the CRY library by LLNL (GitHub - ohnemax/cry-with-openmc: Make CRY available as OpenMC external source).

Unfortunately, I’m not able to get my custom source to run on multiple cores simultaneously. It crashes with segmentation fault. I suspect this is due to the fact that I pass a pointer to both RNG and the current seed on to the CRY library (it needs a random number generator internally). However, my C/C++ skills are insufficient to find out whether this is true, or how to fix it.

No code example here, but the github repository linked above contains a simple example.py.

Thanks for any suggestions!

@ohnemax welcome to the community. Your custom source looks really cool! I took a look at your code and saw that the way you were modifying the vector of particles returned by CRY was being done in a manner that was not threadsafe. I’ve submitted a pull request to your repo with some changes that should allow it to work with multiple threads. Let me know if you have any questions about it.