Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/festim/exports/profile_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
self.t = []
self.x = None
self.subdomain = subdomain
self.times = times
self.times = times.copy() if times is not None else None

self._dofs = None
self._sort_coords = None
9 changes: 7 additions & 2 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 @@ -338,8 +342,9 @@ 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
return True

return False
Expand Down
Loading