Skip to content

Commit

Permalink
Merge pull request #241 from psnbaba/integrator_fix
Browse files Browse the repository at this point in the history
added check particle array size
  • Loading branch information
prabhuramachandran committed Sep 10, 2019
2 parents 9bfa8d6 + a5176f5 commit b7e4a61
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pysph/sph/integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,22 @@ def _get_explicit_dt_adapt(self):
'dt_adapt' in pa.properties for pa in a_eval.particle_arrays
)
if self._has_dt_adapt:
dt_min = 1e20
dt_min = np.inf
for pa in a_eval.particle_arrays:
if 'dt_adapt' in pa.properties:
if pa.gpu is not None:
from compyle.array import minimum
min_val = minimum(pa.gpu.dt_adapt)
if pa.gpu.get_number_of_particles() > 0:
from compyle.array import minimum
min_val = minimum(pa.gpu.dt_adapt)
else:
min_val = np.inf
else:
min_val = np.min(pa.dt_adapt)
if pa.get_number_of_particles() > 0:
min_val = np.min(pa.dt_adapt)
else:
min_val = np.inf
dt_min = min(dt_min, min_val)

if dt_min > 0.0:
return dt_min
else:
Expand Down Expand Up @@ -161,7 +168,7 @@ def compute_time_step(self, dt, cfl):
hmin = self.h_minimum

# default time steps set to some large value
dt_cfl = dt_force = dt_viscous = 1e10
dt_cfl = dt_force = dt_viscous = np.inf

# stable time step based on courant condition
if dt_cfl_fac > 0:
Expand All @@ -180,7 +187,7 @@ def compute_time_step(self, dt, cfl):

# return the computed time steps. If dt factors aren't
# defined, the default dt is returned
if dt_min <= 0.0 or abs(dt_min - 1e10) < 1:
if dt_min <= 0.0 or np.isinf(dt_min):
return None
else:
return cfl*dt_min
Expand Down

0 comments on commit b7e4a61

Please sign in to comment.