diff --git a/goalie/go_mesh_seq.py b/goalie/go_mesh_seq.py index af5908d..6b32ed2 100644 --- a/goalie/go_mesh_seq.py +++ b/goalie/go_mesh_seq.py @@ -241,8 +241,7 @@ def indicate_errors( # delete current subinterval enriched mesh to reduce the memory footprint enriched_mesh_seq.meshes.pop(-1) - enriched_mesh_seq.time_partition.num_subintervals -= 1 - enriched_mesh_seq.time_partition.timesteps.pop(-1) + enriched_mesh_seq.time_partition.drop_last_subinterval() enriched_mesh_seq._update_function_spaces() return self.solutions, self.indicators diff --git a/goalie/time_partition.py b/goalie/time_partition.py index 0a080cb..604bf63 100644 --- a/goalie/time_partition.py +++ b/goalie/time_partition.py @@ -292,6 +292,19 @@ def __ne__(self, other): or not self.field_types == other.field_types ) + def drop_last_subinterval(self): + """ + Drop the last subinterval and reset lists and counters appropriately. + """ + self.end_time = self.subintervals[-1][0] + self.interval = (self.start_time, self.end_time) + self.num_subintervals -= 1 + self.timesteps.pop(-1) + self.subintervals.pop(-1) + self.num_timesteps_per_subinterval.pop(-1) + self.num_timesteps_per_export.pop(-1) + self.num_exports_per_subinterval.pop(-1) + class TimeInterval(TimePartition): """