MHDCT fix for temporary pointers, fixes memory leaks when using MHDCT and sinks (which also uses ZeroUnderSubgrid)

#257 Merged at 0891342
  1. dcollins4096

This PR fixes a memory leak when using sink particles and MHDCT. The source is the collision of using BaryonField[NumberOfBaryohnFields] as a temporary array in both ComputePressure and ZeroSolutionUnderSubgridFields-- In ComputePressure, it's used to temporarily point CenteredB at BaryonField[BxNum]; in ZeroSolution it's used as the flagging field. This collision is rectified by having the ComputePressure first look for a non-Null BaryonField. It passes the quick suite, as far as I can tell it should only affect MHDCT runs.

Comments (4)

  1. dcollins4096 author

    I see two possible long term solutions. Basically the treatment of fields should be regularized. One replaces CenteredB with BaryonField. This is reasonably straight forward, but a significant amount of work that I won't be able to do until probably summer time. It would also be a large change, so it might take a while to pass PRs.
    Two punts on One, and waits for FieldObjects in enzo3.0, which would replace all of the MHDCT objects. Work is currently underway with field objects, so this will happen before too long. But, it will only happen in enzo3.0.

  2. Brian OShea

    @haoxu , @gbryan , could you both take a quick look at this (short, simple) fix and make sure it looks sensible to you?