Commit 2a3f908b authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Do not call fmin or fmax in the gizmo functions. Use our macro instead.

parent 08cca88d
...@@ -322,7 +322,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_fluxes_common( ...@@ -322,7 +322,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_fluxes_common(
float Xi = Vi; float Xi = Vi;
float Xj = Vj; float Xj = Vj;
#ifdef GIZMO_VOLUME_CORRECTION #ifdef GIZMO_VOLUME_CORRECTION
if (fabsf(Vi - Vj) / fminf(Vi, Vj) > 1.5 * hydro_dimension) { if (fabsf(Vi - Vj) / min(Vi, Vj) > 1.5 * hydro_dimension) {
Xi = (Vi * hj + Vj * hi) / (hi + hj); Xi = (Vi * hj + Vj * hi) / (hi + hj);
Xj = Xi; Xj = Xi;
} }
......
...@@ -57,29 +57,29 @@ hydro_slope_limit_cell_collect(struct part* pi, struct part* pj, float r) { ...@@ -57,29 +57,29 @@ hydro_slope_limit_cell_collect(struct part* pi, struct part* pj, float r) {
/* basic slope limiter: collect the maximal and the minimal value for the /* basic slope limiter: collect the maximal and the minimal value for the
* primitive variables among the ngbs */ * primitive variables among the ngbs */
pi->primitives.limiter.rho[0] = pi->primitives.limiter.rho[0] =
fmin(pj->primitives.rho, pi->primitives.limiter.rho[0]); min(pj->primitives.rho, pi->primitives.limiter.rho[0]);
pi->primitives.limiter.rho[1] = pi->primitives.limiter.rho[1] =
fmax(pj->primitives.rho, pi->primitives.limiter.rho[1]); max(pj->primitives.rho, pi->primitives.limiter.rho[1]);
pi->primitives.limiter.v[0][0] = pi->primitives.limiter.v[0][0] =
fmin(pj->primitives.v[0], pi->primitives.limiter.v[0][0]); min(pj->primitives.v[0], pi->primitives.limiter.v[0][0]);
pi->primitives.limiter.v[0][1] = pi->primitives.limiter.v[0][1] =
fmax(pj->primitives.v[0], pi->primitives.limiter.v[0][1]); max(pj->primitives.v[0], pi->primitives.limiter.v[0][1]);
pi->primitives.limiter.v[1][0] = pi->primitives.limiter.v[1][0] =
fmin(pj->primitives.v[1], pi->primitives.limiter.v[1][0]); min(pj->primitives.v[1], pi->primitives.limiter.v[1][0]);
pi->primitives.limiter.v[1][1] = pi->primitives.limiter.v[1][1] =
fmax(pj->primitives.v[1], pi->primitives.limiter.v[1][1]); max(pj->primitives.v[1], pi->primitives.limiter.v[1][1]);
pi->primitives.limiter.v[2][0] = pi->primitives.limiter.v[2][0] =
fmin(pj->primitives.v[2], pi->primitives.limiter.v[2][0]); min(pj->primitives.v[2], pi->primitives.limiter.v[2][0]);
pi->primitives.limiter.v[2][1] = pi->primitives.limiter.v[2][1] =
fmax(pj->primitives.v[2], pi->primitives.limiter.v[2][1]); max(pj->primitives.v[2], pi->primitives.limiter.v[2][1]);
pi->primitives.limiter.P[0] = pi->primitives.limiter.P[0] =
fmin(pj->primitives.P, pi->primitives.limiter.P[0]); min(pj->primitives.P, pi->primitives.limiter.P[0]);
pi->primitives.limiter.P[1] = pi->primitives.limiter.P[1] =
fmax(pj->primitives.P, pi->primitives.limiter.P[1]); max(pj->primitives.P, pi->primitives.limiter.P[1]);
pi->primitives.limiter.maxr = fmax(r, pi->primitives.limiter.maxr); pi->primitives.limiter.maxr = max(r, pi->primitives.limiter.maxr);
} }
/** /**
...@@ -119,7 +119,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell( ...@@ -119,7 +119,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell(
gradtrue *= p->primitives.limiter.maxr; gradtrue *= p->primitives.limiter.maxr;
gradmax = p->primitives.limiter.rho[1] - p->primitives.rho; gradmax = p->primitives.limiter.rho[1] - p->primitives.rho;
gradmin = p->primitives.rho - p->primitives.limiter.rho[0]; gradmin = p->primitives.rho - p->primitives.limiter.rho[0];
alpha = fmin(1.0f, fmin(gradmax / gradtrue, gradmin / gradtrue)); alpha = min3(1.0f, gradmax / gradtrue, gradmin / gradtrue);
p->primitives.gradients.rho[0] *= alpha; p->primitives.gradients.rho[0] *= alpha;
p->primitives.gradients.rho[1] *= alpha; p->primitives.gradients.rho[1] *= alpha;
p->primitives.gradients.rho[2] *= alpha; p->primitives.gradients.rho[2] *= alpha;
...@@ -131,7 +131,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell( ...@@ -131,7 +131,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell(
gradtrue *= p->primitives.limiter.maxr; gradtrue *= p->primitives.limiter.maxr;
gradmax = p->primitives.limiter.v[0][1] - p->primitives.v[0]; gradmax = p->primitives.limiter.v[0][1] - p->primitives.v[0];
gradmin = p->primitives.v[0] - p->primitives.limiter.v[0][0]; gradmin = p->primitives.v[0] - p->primitives.limiter.v[0][0];
alpha = fmin(1.0f, fmin(gradmax / gradtrue, gradmin / gradtrue)); alpha = min3(1.0f, gradmax / gradtrue, gradmin / gradtrue);
p->primitives.gradients.v[0][0] *= alpha; p->primitives.gradients.v[0][0] *= alpha;
p->primitives.gradients.v[0][1] *= alpha; p->primitives.gradients.v[0][1] *= alpha;
p->primitives.gradients.v[0][2] *= alpha; p->primitives.gradients.v[0][2] *= alpha;
...@@ -143,7 +143,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell( ...@@ -143,7 +143,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell(
gradtrue *= p->primitives.limiter.maxr; gradtrue *= p->primitives.limiter.maxr;
gradmax = p->primitives.limiter.v[1][1] - p->primitives.v[1]; gradmax = p->primitives.limiter.v[1][1] - p->primitives.v[1];
gradmin = p->primitives.v[1] - p->primitives.limiter.v[1][0]; gradmin = p->primitives.v[1] - p->primitives.limiter.v[1][0];
alpha = fmin(1.0f, fmin(gradmax / gradtrue, gradmin / gradtrue)); alpha = min3(1.0f, gradmax / gradtrue, gradmin / gradtrue);
p->primitives.gradients.v[1][0] *= alpha; p->primitives.gradients.v[1][0] *= alpha;
p->primitives.gradients.v[1][1] *= alpha; p->primitives.gradients.v[1][1] *= alpha;
p->primitives.gradients.v[1][2] *= alpha; p->primitives.gradients.v[1][2] *= alpha;
...@@ -155,7 +155,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell( ...@@ -155,7 +155,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell(
gradtrue *= p->primitives.limiter.maxr; gradtrue *= p->primitives.limiter.maxr;
gradmax = p->primitives.limiter.v[2][1] - p->primitives.v[2]; gradmax = p->primitives.limiter.v[2][1] - p->primitives.v[2];
gradmin = p->primitives.v[2] - p->primitives.limiter.v[2][0]; gradmin = p->primitives.v[2] - p->primitives.limiter.v[2][0];
alpha = fmin(1.0f, fmin(gradmax / gradtrue, gradmin / gradtrue)); alpha = min3(1.0f, gradmax / gradtrue, gradmin / gradtrue);
p->primitives.gradients.v[2][0] *= alpha; p->primitives.gradients.v[2][0] *= alpha;
p->primitives.gradients.v[2][1] *= alpha; p->primitives.gradients.v[2][1] *= alpha;
p->primitives.gradients.v[2][2] *= alpha; p->primitives.gradients.v[2][2] *= alpha;
...@@ -167,7 +167,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell( ...@@ -167,7 +167,7 @@ __attribute__((always_inline)) INLINE static void hydro_slope_limit_cell(
gradtrue *= p->primitives.limiter.maxr; gradtrue *= p->primitives.limiter.maxr;
gradmax = p->primitives.limiter.P[1] - p->primitives.P; gradmax = p->primitives.limiter.P[1] - p->primitives.P;
gradmin = p->primitives.P - p->primitives.limiter.P[0]; gradmin = p->primitives.P - p->primitives.limiter.P[0];
alpha = fmin(1.0f, fmin(gradmax / gradtrue, gradmin / gradtrue)); alpha = min3(1.0f, gradmax / gradtrue, gradmin / gradtrue);
p->primitives.gradients.P[0] *= alpha; p->primitives.gradients.P[0] *= alpha;
p->primitives.gradients.P[1] *= alpha; p->primitives.gradients.P[1] *= alpha;
p->primitives.gradients.P[2] *= alpha; p->primitives.gradients.P[2] *= alpha;
......
...@@ -47,8 +47,8 @@ hydro_slope_limit_face_quantity(float phi_i, float phi_j, float phi_mid0, ...@@ -47,8 +47,8 @@ hydro_slope_limit_face_quantity(float phi_i, float phi_j, float phi_mid0,
delta1 = psi1 * fabs(phi_i - phi_j); delta1 = psi1 * fabs(phi_i - phi_j);
delta2 = psi2 * fabs(phi_i - phi_j); delta2 = psi2 * fabs(phi_i - phi_j);
phimin = fmin(phi_i, phi_j); phimin = min(phi_i, phi_j);
phimax = fmax(phi_i, phi_j); phimax = max(phi_i, phi_j);
phibar = phi_i + xij_norm / r * (phi_j - phi_i); phibar = phi_i + xij_norm / r * (phi_j - phi_i);
...@@ -75,9 +75,11 @@ hydro_slope_limit_face_quantity(float phi_i, float phi_j, float phi_mid0, ...@@ -75,9 +75,11 @@ hydro_slope_limit_face_quantity(float phi_i, float phi_j, float phi_mid0,
} }
if (phi_i < phi_j) { if (phi_i < phi_j) {
phi_mid = fmax(phiminus, fmin(phibar + delta2, phi_mid0)); const float temp = min(phibar + delta2, phi_mid0);
phi_mid = max(phiminus, temp);
} else { } else {
phi_mid = fmin(phiplus, fmax(phibar - delta2, phi_mid0)); const float temp = max(phibar - delta2, phi_mid0);
phi_mid = min(phiplus, temp);
} }
return phi_mid - phi_i; return phi_mid - phi_i;
......
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