diff --git a/src/hydro/Gadget2/hydro_iact.h b/src/hydro/Gadget2/hydro_iact.h index b9807b6332e08012d47ad63652377f4fe5337bf9..bec6b004a483e094e8ef299956a28ddfc7007a20 100644 --- a/src/hydro/Gadget2/hydro_iact.h +++ b/src/hydro/Gadget2/hydro_iact.h @@ -432,7 +432,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( const float balsara_j = pj->force.balsara; /* Are the particles moving towards each others ? */ - const float omega_ij = fminf(dvdr, 0.f); + const float omega_ij = (dvdr < 0.f) ? dvdr: 0.f; const float mu_ij = fac_mu * r_inv * omega_ij; /* This is 0 or negative */ /* Signal velocity */ @@ -465,8 +465,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force( pj->force.h_dt -= mi * dvdr * r_inv / rhoi * wj_dr; /* Update the signal velocity. */ - pi->force.v_sig = fmaxf(pi->force.v_sig, v_sig); - pj->force.v_sig = fmaxf(pj->force.v_sig, v_sig); + pi->force.v_sig = (pi->force.v_sig > v_sig) ? pi->force.v_sig : v_sig; + pj->force.v_sig = (pj->force.v_sig > v_sig) ? pj->force.v_sig : v_sig; /* Change in entropy */ pi->entropy_dt += mj * visc_term * dvdr; @@ -707,7 +707,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( const float balsara_j = pj->force.balsara; /* Are the particles moving towards each others ? */ - const float omega_ij = fminf(dvdr, 0.f); + const float omega_ij = (dvdr < 0.f) ? dvdr: 0.f; const float mu_ij = fac_mu * r_inv * omega_ij; /* This is 0 or negative */ /* Signal velocity */ @@ -735,7 +735,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force( pi->force.h_dt -= mj * dvdr * r_inv / rhoj * wi_dr; /* Update the signal velocity. */ - pi->force.v_sig = fmaxf(pi->force.v_sig, v_sig); + pi->force.v_sig = (pi->force.v_sig > v_sig) ? pi->force.v_sig : v_sig; /* Change in entropy */ pi->entropy_dt += mj * visc_term * dvdr; diff --git a/src/runner.c b/src/runner.c index eabc622e8c3aa41b5b06c604a4a540b8cf7c13b9..c9c2ef69f46dba5052a9aba917baef9ecaf519c3 100644 --- a/src/runner.c +++ b/src/runner.c @@ -487,8 +487,8 @@ void runner_do_ghost(struct runner *r, struct cell *c) { h_corr = (target_wcount - p->density.wcount) / p->density.wcount_dh; /* Truncate to the range [ -p->h/2 , p->h ]. */ - h_corr = fminf(h_corr, p->h); - h_corr = fmaxf(h_corr, -p->h * 0.5f); + h_corr = (h_corr < p->h) ? h_corr : p->h; + h_corr = (h_corr > -0.5f * p->h) ? h_corr : -0.5f * p->h; } /* Did we get the right number density? */ @@ -622,7 +622,7 @@ static void runner_do_drift(struct cell *c, struct engine *e) { const float dx2 = gp->x_diff[0] * gp->x_diff[0] + gp->x_diff[1] * gp->x_diff[1] + gp->x_diff[2] * gp->x_diff[2]; - dx2_max = fmaxf(dx2_max, dx2); + dx2_max = (dx2_max > dx2) ? dx2_max : dx2; } /* Loop over all the particles in the cell (more work for these !) */ @@ -640,10 +640,10 @@ static void runner_do_drift(struct cell *c, struct engine *e) { const float dx2 = xp->x_diff[0] * xp->x_diff[0] + xp->x_diff[1] * xp->x_diff[1] + xp->x_diff[2] * xp->x_diff[2]; - dx2_max = fmaxf(dx2_max, dx2); + dx2_max = (dx2_max > dx2) ? dx2_max : dx2; /* Maximal smoothing length */ - h_max = fmaxf(p->h, h_max); + h_max = (h_max > p->h) ? h_max : p->h; /* Now collect quantities for statistics */ diff --git a/src/timestep.h b/src/timestep.h index 569120cf9cf989b633da35529f7693c8f62a1910..582f10a658e0be595a22e1066341de3803afb7fc 100644 --- a/src/timestep.h +++ b/src/timestep.h @@ -70,14 +70,15 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep( const float new_dt_external = gravity_compute_timestep_external( e->external_potential, e->physical_constants, gp); - const float new_dt_self = - gravity_compute_timestep_self(e->physical_constants, gp); + /* const float new_dt_self = */ + /* gravity_compute_timestep_self(e->physical_constants, gp); */ + const float new_dt_self = FLT_MAX; // MATTHIEU - float new_dt = fminf(new_dt_external, new_dt_self); + float new_dt = (new_dt_external < new_dt_self) ? new_dt_external : new_dt_self; /* Limit timestep within the allowed range */ - new_dt = fminf(new_dt, e->dt_max); - new_dt = fmaxf(new_dt, e->dt_min); + new_dt = (new_dt < e->dt_max) ? new_dt : e->dt_max; + new_dt = (new_dt > e->dt_min) ? new_dt : e->dt_min; /* Convert to integer time */ const int new_dti = @@ -110,11 +111,11 @@ __attribute__((always_inline)) INLINE static int get_part_timestep( /* gravity_compute_timestep_self(e->physical_constants, p->gpart); */ const float new_dt_self = FLT_MAX; // MATTHIEU - new_dt_grav = fminf(new_dt_external, new_dt_self); + new_dt_grav = (new_dt_external < new_dt_self) ? new_dt_external : new_dt_self; } /* Final time-step is minimum of hydro and gravity */ - float new_dt = fminf(new_dt_hydro, new_dt_grav); + float new_dt = (new_dt_hydro < new_dt_grav) ? new_dt_hydro: new_dt_grav; /* Limit change in h */ const float dt_h_change = @@ -122,11 +123,11 @@ __attribute__((always_inline)) INLINE static int get_part_timestep( ? fabsf(e->hydro_properties->log_max_h_change * p->h / p->force.h_dt) : FLT_MAX; - new_dt = fminf(new_dt, dt_h_change); + new_dt = (new_dt < dt_h_change) ? new_dt : dt_h_change; /* Limit timestep within the allowed range */ - new_dt = fminf(new_dt, e->dt_max); - new_dt = fmaxf(new_dt, e->dt_min); + new_dt = (new_dt < e->dt_max) ? new_dt : e->dt_max; + new_dt = (new_dt > e->dt_min) ? new_dt : e->dt_min; /* Convert to integer time */ const int new_dti =