diff --git a/src/festim/exports/profile_1d.py b/src/festim/exports/profile_1d.py index 670e9a527..ccc2feefb 100644 --- a/src/festim/exports/profile_1d.py +++ b/src/festim/exports/profile_1d.py @@ -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 diff --git a/src/festim/helpers.py b/src/festim/helpers.py index 53e2cf700..47025048b 100644 --- a/src/festim/helpers.py +++ b/src/festim/helpers.py @@ -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 @@ -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