Skip to content
Merged
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
17 changes: 14 additions & 3 deletions parcels/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,12 @@ def execute(
time = starttime

while (time < endtime and dt > 0) or (time > endtime and dt < 0):
# Check if we can fast-forward to the next time needed for the particles
if dt > 0:
skip_kernel = True if min(self.time) > (time + dt) else False
else:
skip_kernel = True if max(self.time) < (time + dt) else False

time_at_startofloop = time

next_input = self.fieldset.computeTimeChunk(time, dt)
Expand All @@ -1170,9 +1176,10 @@ def execute(

# If we don't perform interaction, only execute the normal kernel efficiently.
if self._interaction_kernel is None:
res = self._kernel.execute(self, endtime=next_time, dt=dt)
if res == StatusCode.StopAllExecution:
return StatusCode.StopAllExecution
if not skip_kernel:
res = self._kernel.execute(self, endtime=next_time, dt=dt)
if res == StatusCode.StopAllExecution:
return StatusCode.StopAllExecution
# Interaction: interleave the interaction and non-interaction kernel for each time step.
# E.g. Normal -> Inter -> Normal -> Inter if endtime-time == 2*dt
else:
Expand All @@ -1188,6 +1195,10 @@ def execute(
# End of interaction specific code
time = next_time

# Check for empty ParticleSet
if np.isinf(next_prelease) and len(self) == 0:
return StatusCode.StopAllExecution

if abs(time - next_output) < tol:
for fld in self.fieldset.get_fields():
if hasattr(fld, "to_write") and fld.to_write:
Expand Down
Loading