mit-crpg/openmc — pull request #225 by nelsonag (2013-12-06 01:34:00+00:00)
Title: Resampling for starting source (to close issue #73)

Issue #73 states that it is desirable if external sources outside of the problem domain were re-sampled instead of throwing an error. This PR addresses that problem.

This was solved by checking the cell location as external box source sites are sampled. This wasn't done in a 100% ideal way, as using existing the existing geometry routine "find_cell" required a particle be initialized with the source site's info. This is a little wasteful, but probably cleaner than writing a version of find_cell which does not take a particle object as input. For eigenvalue problems (where the external source is only the initial guess), this should have no effect on performance after the first few inactive batches. Fixed source problems will have a bit of a slowdown, however. I measured this slowdown on a version of the examples/basic problem which was modified to be fixed source. This change actually ran faster; since thats impossible, we will say the slowdown is negligible :-).

I chose to not inact a similar test for the point source option since that will throw an error on particle 1 saying the particle could not be located. I think this message is probably instructive enough that we can safely avoid adding extra baggage incurred for every point source particle sampling.