Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/festim/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ def is_it_time_to_export(
) -> bool:
"""
Checks if the exported field should be written to a file or not based on the
current time and the times in `export.times`
current time and the times in `export.times'

After a successful match, the corresponding time is removed from the list to
prevent multiple exports for the same target time.


Args:
current_time: the current simulation time
Expand All @@ -337,14 +341,16 @@ def is_it_time_to_export(
"""
if times is None:
return True

for time in times:
for i, time in enumerate(times):
if np.isclose(time, current_time, atol=atol, rtol=rtol):
times.pop(i) # consume the time so it is not exported again
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be safer to make a copy of times elsewhere in order to avoid destroying user inputs?

return True

return False



_residual0 = 0
_prev_xnorm = 0

Expand Down
Loading