clawpack/amrclaw — pull request #118 by rjleveque (2014-12-26 17:07:49+00:00)
Title: [WIP] Refactored dumpgauge as print_gauges, moved into gauges_module

I plan to add gauges to 3d amrclaw but first suggest these changes:

I renamed `dumpgauge` to `print_gauges` and changed the algorithm.

Previously `setbestsrc` determined which patch to use for each gauge and then applied quicksort so that all the gauges for a particular patch were grouped together. Then in `dumpgauge`, a binary search was done to find the first gauge to handle and then the loop only went until the gauge number changed.

I changed it so that no sorting is done. Instead in `print_gauges`, when called for each patch it loops over all gauges and simply skips the ones for which this patch is not the best. If there were thousands of gauges this might be slightly slower than the sorting, but typically there are at most a handful and I think calling the binary search is probably much slower than simply looping over all gauges. Even with a huge number of gauges, I think the time sink in this routine would be the I/O, not the loop over all gauges. The new version is much simpler and easier to maintain.

@berger, do you agree?

I modified all the examples and tests and everything agrees. Note that `examples/compare_gauges.py` uses visclaw#137, a new utility that might be useful in general (I've written many versions of this in the past).

One possible change in the `fort.gauge` files produced: The gauges at a particular time might be printed in a different order than before since sorting is not done. The values printed should be identical, but the `fort.gauge` file may have permuted lines relative to old output.

I'm also adding Issue #117 regarding possible future improvements.