Add option to not save previous q for Strang splitting
Suggested by Grady:
With Strang splitting, all variants of Clawpack currently save the previous time step's q array before advancing by the first half time step of the source term, in case the hyperbolic step has to be rejected. For some problems (I'm thinking of my poroelasticity code here, but the situation is the same for any linear problem and maybe well-behaved nonlinear ones) time steps will never rejected, so I was thinking that it might be worthwhile to add a run time option to not save the previous time step.
I actually tried doing this yesterday, and it didn't seem to have an effect on memory usage as reported by top. It seems like it should be possible to save memory this way, but I currently don't know how to reason about memory usage in PyClaw.
@gradylemoine,
If you're measuring with top, you need to manually fire the garbage collector to make sure you're not looking at uncollected memory:
import gc
gc.collect()
The bigger issue of PetClaw inefficiently maintaining extra copies in memory needs to be addressed, as far I understand PyClaw and PetClaw memory consumption should be the same. This issue was looked at by @amal-ghamdi, but your (preliminary) tests indicate that we either had a regression or it was never correctly implemented. How critical is this for your work with the package?
When I tried doing this, I did it by actually removing the statements where the array is copied, so that the copy was never created. I'd have thought that would prevent the memory from being allocated i the first place? I'll keep that in mind about top; I'm not used to trying to reason about memory usage in a dynamic language. As for the PetClaw memory consumption, I'll put my comments over with that issue.