clawpack / pyclaw

PyClaw is a Python-based interface to the algorithms of Clawpack and SharpClaw. It also contains the PetClaw package, which adds parallelism through PETSc.
http://www.clawpack.com/pyclaw
BSD 3-Clause "New" or "Revised" License
164 stars 99 forks source link

Repeated calls to solution.read() do not modify the solution #519

Open ketch opened 9 years ago

ketch commented 9 years ago

The solution.read method loads a solution from file into an existing (empty) solution object. However, if a solution has already been loaded into a given object, attempting to load a different solution into it has no effect. This is easily reproduced by doing the following in a directory that has output in ./_output/:

s = pyclaw.Solution()
s.read(0)
print s.t
s.read(1)
print s.t

The printed time will be the same for both frames.

ketch commented 9 years ago

I haven't yet investigated what causes this, but it strikes me that a better interface would look like:

solution = pyclaw.io.read(frame=0,path='./_output',file_format='hdf5')

That is, the read functions would not be methods belonging to Solution, but just stand-alone functions that return a Solution object.

mandli commented 9 years ago

+1 on removing the read functionality from solution. I would say that we should keep the ability to initialize a solution object by providing a path and frame, in effect calling the appropriate read functionality. The read function in solution does not do a whole lot anyway. Also, as an added benefit this jives with @ketch's proposal for griddle.