Commit eff8cca6 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Replaced all calls to fminf and fmaxf by the macros that was added for the...

Replaced all calls to fminf and fmaxf by the macros that was added for the integer min/max functions.
parent d0033162
......@@ -1959,7 +1959,7 @@ void engine_marktasks_fixdt_mapper(void *map_data, int num_elements,
/* Too much particle movement? */
if (t->tight &&
(fmaxf(ci->h_max, cj->h_max) + ci->dx_max + cj->dx_max > cj->dmin ||
(max(ci->h_max, cj->h_max) + ci->dx_max + cj->dx_max > cj->dmin ||
ci->dx_max > space_maxreldx * ci->h_max ||
cj->dx_max > space_maxreldx * cj->h_max))
*rebuild_space = 1;
......@@ -2031,7 +2031,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements,
/* Too much particle movement? */
if (t->tight &&
(fmaxf(ci->h_max, cj->h_max) + ci->dx_max + cj->dx_max > cj->dmin ||
(max(ci->h_max, cj->h_max) + ci->dx_max + cj->dx_max > cj->dmin ||
ci->dx_max > space_maxreldx * ci->h_max ||
cj->dx_max > space_maxreldx * cj->h_max))
*rebuild_space = 1;
......
......@@ -21,6 +21,7 @@
#define SWIFT_DEFAULT_GRAVITY_H
#include <float.h>
#include "minmax.h"
#include "potentials.h"
/**
......@@ -41,16 +42,14 @@ gravity_compute_timestep_external(const struct external_potential* potential,
float dt = FLT_MAX;
#ifdef EXTERNAL_POTENTIAL_POINTMASS
dt =
fminf(dt, external_gravity_pointmass_timestep(potential, phys_const, gp));
dt = min(dt, external_gravity_pointmass_timestep(potential, phys_const, gp));
#endif
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
dt = fminf(dt, external_gravity_isothermalpotential_timestep(potential,
phys_const, gp));
dt = min(dt, external_gravity_isothermalpotential_timestep(potential,
phys_const, gp));
#endif
#ifdef EXTERNAL_POTENTIAL_DISK_PATCH
dt = fminf(dt,
external_gravity_disk_patch_timestep(potential, phys_const, gp));
dt = min(dt, external_gravity_disk_patch_timestep(potential, phys_const, gp));
#endif
return dt;
}
......
......@@ -22,6 +22,7 @@
#include "adiabatic_index.h"
#include "approx_math.h"
#include "equation_of_state.h"
#include "minmax.h"
#include <float.h>
......@@ -148,7 +149,7 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep(
(p->force.u_dt != 0.0f) ? fabsf(const_max_u_change * p->u / p->force.u_dt)
: FLT_MAX;
return fminf(dt_cfl, dt_u_change);
return min(dt_cfl, dt_u_change);
}
/**
......@@ -273,7 +274,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
const float tau = h / (2.f * const_viscosity_length * p->force.soundspeed);
/* Viscosity source term */
const float S = fmaxf(-normDiv_v, 0.f);
const float S = max(-normDiv_v, 0.f);
/* Compute the particle's viscosity parameter time derivative */
const float alpha_dot = (const_viscosity_alpha_min - p->alpha) / tau +
......
......@@ -395,7 +395,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
/* Compute the relative velocity. (This is 0 if the particles move away from
* each other and negative otherwise) */
omega_ij = fminf(dvdr, 0.f);
omega_ij = min(dvdr, 0.f);
/* Compute signal velocity */
v_sig = pi->force.soundspeed + pj->force.soundspeed - 2.0f * omega_ij;
......@@ -441,8 +441,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
pj->force.h_dt -= mi * dvdr / 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 = max(pi->force.v_sig, v_sig);
pj->force.v_sig = max(pj->force.v_sig, v_sig);
}
/**
......@@ -635,8 +635,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
pj[k]->force.u_dt += pju_dt.f[k];
pi[k]->force.h_dt -= pih_dt.f[k];
pj[k]->force.h_dt -= pjh_dt.f[k];
pi[k]->force.v_sig = fmaxf(pi[k]->force.v_sig, v_sig.f[k]);
pj[k]->force.v_sig = fmaxf(pj[k]->force.v_sig, v_sig.f[k]);
pi[k]->force.v_sig = max(pi[k]->force.v_sig, v_sig.f[k]);
pj[k]->force.v_sig = max(pj[k]->force.v_sig, v_sig.f[k]);
for (j = 0; j < 3; j++) {
pi[k]->a_hydro[j] -= pia[j].f[k];
pj[k]->a_hydro[j] += pja[j].f[k];
......@@ -696,7 +696,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
/* Compute the relative velocity. (This is 0 if the particles move away from
* each other and negative otherwise) */
omega_ij = fminf(dvdr, 0.f);
omega_ij = min(dvdr, 0.f);
/* Compute signal velocity */
v_sig = pi->force.soundspeed + pj->force.soundspeed - 2.0f * omega_ij;
......@@ -737,7 +737,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
pi->force.h_dt -= mj * dvdr / rhoj * wi_dr;
/* Update the signal velocity. */
pi->force.v_sig = fmaxf(pi->force.v_sig, v_sig);
pi->force.v_sig = max(pi->force.v_sig, v_sig);
}
/**
......@@ -920,7 +920,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
for (k = 0; k < VEC_SIZE; k++) {
pi[k]->force.u_dt += piu_dt.f[k];
pi[k]->force.h_dt -= pih_dt.f[k];
pi[k]->force.v_sig = fmaxf(pi[k]->force.v_sig, v_sig.f[k]);
pi[k]->force.v_sig = max(pi[k]->force.v_sig, v_sig.f[k]);
for (j = 0; j < 3; j++) pi[k]->a_hydro[j] -= pia[j].f[k];
}
......
......@@ -641,8 +641,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
}
pi[k]->force.h_dt -= pih_dt.f[k];
pj[k]->force.h_dt -= pjh_dt.f[k];
pi[k]->force.v_sig = fmaxf(pi[k]->force.v_sig, v_sig.f[k]);
pj[k]->force.v_sig = fmaxf(pj[k]->force.v_sig, v_sig.f[k]);
pi[k]->force.v_sig = max(pi[k]->force.v_sig, v_sig.f[k]);
pj[k]->force.v_sig = max(pj[k]->force.v_sig, v_sig.f[k]);
pi[k]->entropy_dt += entropy_dt.f[k] * mj.f[k];
pj[k]->entropy_dt += entropy_dt.f[k] * mi.f[k];
}
......@@ -900,7 +900,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
for (k = 0; k < VEC_SIZE; k++) {
for (j = 0; j < 3; j++) pi[k]->a_hydro[j] -= pia[j].f[k];
pi[k]->force.h_dt -= pih_dt.f[k];
pi[k]->force.v_sig = fmaxf(pi[k]->force.v_sig, v_sig.f[k]);
pi[k]->force.v_sig = max(pi[k]->force.v_sig, v_sig.f[k]);
pi[k]->entropy_dt += entropy_dt.f[k];
}
......
......@@ -21,6 +21,7 @@
#include "adiabatic_index.h"
#include "approx_math.h"
#include "hydro_gradients.h"
#include "minmax.h"
/**
* @brief Computes the hydro time-step of a given particle
......
......@@ -242,14 +242,14 @@ __attribute__((always_inline)) INLINE static void runner_iact_fluxes_common(
if (dvdotdx > 0.) {
vmax -= dvdotdx / r;
}
pi->timestepvars.vmax = fmaxf(pi->timestepvars.vmax, vmax);
pi->timestepvars.vmax = max(pi->timestepvars.vmax, vmax);
if (mode == 1) {
pj->timestepvars.vmax = fmaxf(pj->timestepvars.vmax, vmax);
pj->timestepvars.vmax = max(pj->timestepvars.vmax, vmax);
}
/* The flux will be exchanged using the smallest time step of the two
* particles */
mindt = fminf(dti, dtj);
mindt = min(dti, dtj);
dti = mindt;
dtj = mindt;
......
......@@ -34,6 +34,7 @@
*/
#include "adiabatic_index.h"
#include "minmax.h"
/**
* @brief Density loop
......@@ -161,7 +162,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
(pi->v[2] - pj->v[2]) * dx[2];
/* Are the particles moving towards each others ? */
const float omega_ij = fminf(dvdr, 0.f);
const float omega_ij = min(dvdr, 0.f);
const float mu_ij = fac_mu * r_inv * omega_ij; /* This is 0 or negative */
/* Compute sound speeds and signal velocity */
......@@ -212,8 +213,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 = max(pi->force.v_sig, v_sig);
pj->force.v_sig = max(pj->force.v_sig, v_sig);
}
/**
......@@ -272,7 +273,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
(pi->v[2] - pj->v[2]) * dx[2];
/* Are the particles moving towards each others ? */
const float omega_ij = fminf(dvdr, 0.f);
const float omega_ij = min(dvdr, 0.f);
const float mu_ij = fac_mu * r_inv * omega_ij; /* This is 0 or negative */
/* Compute sound speeds and signal velocity */
......@@ -315,7 +316,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 = max(pi->force.v_sig, v_sig);
}
/**
......
......@@ -31,6 +31,7 @@
#include <float.h>
#include "adiabatic_index.h"
#include "minmax.h"
#include "riemann_vacuum.h"
/**
......@@ -145,12 +146,12 @@ __attribute__((always_inline)) INLINE static float riemann_guess_p(
float pguess, pmin, pmax, qmax;
float ppv;
pmin = fminf(WL[4], WR[4]);
pmax = fmaxf(WL[4], WR[4]);
pmin = min(WL[4], WR[4]);
pmax = max(WL[4], WR[4]);
qmax = pmax / pmin;
ppv =
0.5f * (WL[4] + WR[4]) - 0.125f * (vR - vL) * (WL[0] + WR[0]) * (aL + aR);
ppv = fmaxf(1.e-8f, ppv);
ppv = max(1.e-8f, ppv);
if (qmax <= 2.0f && pmin <= ppv && ppv <= pmax) {
pguess = ppv;
} else {
......@@ -171,7 +172,7 @@ __attribute__((always_inline)) INLINE static float riemann_guess_p(
value for pressure (...).
Thus in order to avoid negative guess values we introduce the small
positive constant _tolerance" */
pguess = fmaxf(1.e-8f, pguess);
pguess = max(1.e-8f, pguess);
return pguess;
}
......
......@@ -21,6 +21,7 @@
#define SWIFT_RIEMANN_HLLC_H
#include "adiabatic_index.h"
#include "minmax.h"
#include "riemann_vacuum.h"
__attribute__((always_inline)) INLINE static void riemann_solve_for_flux(
......@@ -57,7 +58,7 @@ __attribute__((always_inline)) INLINE static void riemann_solve_for_flux(
rhobar = 0.5 * (WL[0] + WR[0]);
abar = 0.5 * (aL + aR);
pPVRS = 0.5 * (WL[4] + WR[4]) - 0.5 * (uR - uL) * rhobar * abar;
pstar = fmaxf(0., pPVRS);
pstar = max(0., pPVRS);
/* STEP 2: wave speed estimates
all these speeds are along the interface normal, since uL and uR are */
......
......@@ -762,8 +762,8 @@ static void runner_do_drift(struct cell *c, struct engine *e) {
/* Recurse. */
runner_do_drift(cp, e);
dx_max = fmaxf(dx_max, cp->dx_max);
h_max = fmaxf(h_max, cp->h_max);
dx_max = max(dx_max, cp->dx_max);
h_max = max(h_max, cp->h_max);
mass += cp->mass;
e_kin += cp->e_kin;
e_int += cp->e_int;
......@@ -1091,7 +1091,7 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) {
// if(ti_end < ti_current) error("Received invalid particle !");
ti_end_min = min(ti_end_min, ti_end);
ti_end_max = max(ti_end_max, ti_end);
h_max = fmaxf(h_max, parts[k].h);
h_max = max(h_max, parts[k].h);
}
for (size_t k = 0; k < nr_gparts; k++) {
const int ti_end = gparts[k].ti_end;
......@@ -1109,7 +1109,7 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) {
runner_do_recv_cell(r, c->progeny[k], 0);
ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min);
ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max);
h_max = fmaxf(h_max, c->progeny[k]->h_max);
h_max = max(h_max, c->progeny[k]->h_max);
}
}
}
......
......@@ -1739,7 +1739,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
if (ci->ti_end_min > ti_current && cj->ti_end_min > ti_current) return;
/* Get the cell dimensions. */
const float h = fminf(ci->width[0], fminf(ci->width[1], ci->width[2]));
const float h = min(ci->width[0], min(ci->width[1], ci->width[2]));
/* Get the type of pair if not specified explicitly. */
// if ( sid < 0 )
......@@ -1748,7 +1748,7 @@ void DOSUB_PAIR1(struct runner *r, struct cell *ci, struct cell *cj, int sid,
/* Recurse? */
if (ci->split && cj->split &&
fmaxf(ci->h_max, cj->h_max) * kernel_gamma + ci->dx_max + cj->dx_max <
max(ci->h_max, cj->h_max) * kernel_gamma + ci->dx_max + cj->dx_max <
h / 2) {
/* Different types of flags. */
......@@ -2023,7 +2023,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
if (ci->ti_end_min > ti_current && cj->ti_end_min > ti_current) return;
/* Get the cell dimensions. */
const float h = fminf(ci->width[0], fminf(ci->width[1], ci->width[2]));
const float h = min(ci->width[0], min(ci->width[1], ci->width[2]));
/* Get the type of pair if not specified explicitly. */
// if ( sid < 0 )
......@@ -2032,7 +2032,7 @@ void DOSUB_PAIR2(struct runner *r, struct cell *ci, struct cell *cj, int sid,
/* Recurse? */
if (ci->split && cj->split &&
fmaxf(ci->h_max, cj->h_max) * kernel_gamma + ci->dx_max + cj->dx_max <
max(ci->h_max, cj->h_max) * kernel_gamma + ci->dx_max + cj->dx_max <
h / 2) {
/* Different types of flags. */
......@@ -2336,11 +2336,11 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
else {
/* Get the cell dimensions. */
const float h = fminf(ci->width[0], fminf(ci->width[1], ci->width[2]));
const float h = min(ci->width[0], min(ci->width[1], ci->width[2]));
/* Recurse? */
if (ci->split && cj->split &&
fmaxf(ci->h_max, cj->h_max) * kernel_gamma + ci->dx_max + cj->dx_max <
max(ci->h_max, cj->h_max) * kernel_gamma + ci->dx_max + cj->dx_max <
h / 2) {
/* Get the type of pair if not specified explicitly. */
......
......@@ -268,7 +268,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
s->width[k] = s->dim[k] / cdim[k];
s->iwidth[k] = 1.0 / s->width[k];
}
const float dmin = fminf(s->width[0], fminf(s->width[1], s->width[2]));
const float dmin = min(s->width[0], min(s->width[1], s->width[2]));
/* Allocate the highest level of cells. */
s->tot_cells = s->nr_cells = cdim[0] * cdim[1] * cdim[2];
......@@ -1307,7 +1307,7 @@ void space_split_mapper(void *map_data, int num_elements, void *extra_data) {
c->progeny[k] = NULL;
} else {
space_split_mapper(c->progeny[k], 1, s);
h_max = fmaxf(h_max, c->progeny[k]->h_max);
h_max = max(h_max, c->progeny[k]->h_max);
ti_end_min = min(ti_end_min, c->progeny[k]->ti_end_min);
ti_end_max = max(ti_end_max, c->progeny[k]->ti_end_max);
if (c->progeny[k]->maxdepth > maxdepth)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment