pyclaw icon indicating copy to clipboard operation
pyclaw copied to clipboard

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

Open ketch opened this issue 10 years ago • 2 comments

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 avatar May 30 '15 12:05 ketch

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.

ketch avatar May 30 '15 12:05 ketch

+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.

mandli avatar Jun 02 '15 00:06 mandli