Skip to content

Commit

Permalink
#220 add time_partition method to drop
Browse files Browse the repository at this point in the history
 last interval
  • Loading branch information
acse-ej321 committed Oct 24, 2024
1 parent 714f9ef commit 8e78325
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions goalie/go_mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions goalie/time_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 8e78325

Please sign in to comment.