def read(self, function, name, index): if index <= self._last_index: restart_file = XMLFile(self._full_filename + "_" + str(index) + ".xml") restart_file >> function else: raise OSError
def write(self, function, name, index): assert index in (self._last_index, self._last_index + 1) if index == self._last_index + 1: # writing out solutions after time stepping self._update_function_container(function) self._visualization_file << self._function_container restart_file = XMLFile(self._full_filename + "_" + str(index) + ".xml") restart_file << self._function_container # Once solutions have been written to file, update last written index self._write_last_index(index) elif index == self._last_index: # corner case for problems with two (or more) unknowns which are written separately to file; # one unknown was written to file, while the other was not: since the problem might be coupled, # a recomputation of both is required, but there is no need to update storage pass else: raise ValueError("Invalid index")