Commit c9b8f182 authored by James Willis's avatar James Willis
Browse files

Changed 'c' and 'POrho2' to 'soundspeed' and 'P_over_rho2'. Fixed signal...

Changed 'c' and 'POrho2' to 'soundspeed' and 'P_over_rho2'. Fixed signal velocity assigment bug in vectorised versions of the force interactions.
parent 45adeccf
......@@ -145,17 +145,17 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
/* Compute this particle's sound speed. */
const float u = p->u;
const float fc = p->force.c = sqrtf(hydro_gamma * hydro_gamma_minus_one * u);
const float fc = p->force.soundspeed = sqrtf(hydro_gamma * hydro_gamma_minus_one * u);
/* Compute the P/Omega/rho2. */
xp->omega = 1.0f + 0.3333333333f * h * p->rho_dh / p->rho;
p->force.POrho2 = u * hydro_gamma_minus_one / (p->rho * xp->omega);
p->force.P_over_rho2 = u * hydro_gamma_minus_one / (p->rho * xp->omega);
/* Balsara switch */
p->force.balsara = normDiv_v / (normDiv_v + normRot_v + 0.0001f * fc * ih);
/* Viscosity parameter decay time */
const float tau = h / (2.f * const_viscosity_length * p->force.c);
const float tau = h / (2.f * const_viscosity_length * p->force.soundspeed);
/* Viscosity source term */
const float S = fmaxf(-normDiv_v, 0.f);
......@@ -214,7 +214,7 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
u = p->u *= expf(w);
/* Predict gradient term */
p->force.POrho2 = u * hydro_gamma_minus_one / (p->rho * xp->omega);
p->force.P_over_rho2 = u * hydro_gamma_minus_one / (p->rho * xp->omega);
}
/**
......
......@@ -371,8 +371,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
mj = pj->mass;
rhoi = pi->rho;
rhoj = pj->rho;
POrho2i = pi->force.POrho2;
POrho2j = pj->force.POrho2;
POrho2i = pi->force.P_over_rho2;
POrho2j = pj->force.P_over_rho2;
/* Get the kernel for hi. */
hi_inv = 1.0f / hi;
......@@ -398,7 +398,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_force(
omega_ij = fminf(dvdr, 0.f);
/* Compute signal velocity */
v_sig = pi->force.c + pj->force.c - 2.0f * omega_ij;
v_sig = pi->force.soundspeed + pj->force.soundspeed - 2.0f * omega_ij;
/* Compute viscosity parameter */
alpha_ij = -0.5f * (pi->alpha + pj->alpha);
......@@ -480,13 +480,13 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
mj.v = vec_set(pj[0]->mass, pj[1]->mass, pj[2]->mass, pj[3]->mass,
pj[4]->mass, pj[5]->mass, pj[6]->mass, pj[7]->mass);
piPOrho2.v =
vec_set(pi[0]->force.POrho2, pi[1]->force.POrho2, pi[2]->force.POrho2,
pi[3]->force.POrho2, pi[4]->force.POrho2, pi[5]->force.POrho2,
pi[6]->force.POrho2, pi[7]->force.POrho2);
vec_set(pi[0]->force.P_over_rho2, pi[1]->force.P_over_rho2, pi[2]->force.P_over_rho2,
pi[3]->force.P_over_rho2, pi[4]->force.P_over_rho2, pi[5]->force.P_over_rho2,
pi[6]->force.P_over_rho2, pi[7]->force.P_over_rho2);
pjPOrho2.v =
vec_set(pj[0]->force.POrho2, pj[1]->force.POrho2, pj[2]->force.POrho2,
pj[3]->force.POrho2, pj[4]->force.POrho2, pj[5]->force.POrho2,
pj[6]->force.POrho2, pj[7]->force.POrho2);
vec_set(pj[0]->force.P_over_rho2, pj[1]->force.P_over_rho2, pj[2]->force.P_over_rho2,
pj[3]->force.P_over_rho2, pj[4]->force.P_over_rho2, pj[5]->force.P_over_rho2,
pj[6]->force.P_over_rho2, pj[7]->force.P_over_rho2);
pirho.v = vec_set(pi[0]->rho, pi[1]->rho, pi[2]->rho, pi[3]->rho, pi[4]->rho,
pi[5]->rho, pi[6]->rho, pi[7]->rho);
pjrho.v = vec_set(pj[0]->rho, pj[1]->rho, pj[2]->rho, pj[3]->rho, pj[4]->rho,
......@@ -496,11 +496,11 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
pju.v = vec_set(pj[0]->u, pj[1]->u, pj[2]->u, pj[3]->u, pj[4]->u, pj[5]->u,
pj[6]->u, pj[7]->u);
ci.v =
vec_set(pi[0]->force.c, pi[1]->force.c, pi[2]->force.c, pi[3]->force.c,
pi[4]->force.c, pi[5]->force.c, pi[6]->force.c, pi[7]->force.c);
vec_set(pi[0]->force.soundspeed, pi[1]->force.soundspeed, pi[2]->force.soundspeed, pi[3]->force.soundspeed,
pi[4]->force.soundspeed, pi[5]->force.soundspeed, pi[6]->force.soundspeed, pi[7]->force.soundspeed);
cj.v =
vec_set(pj[0]->force.c, pj[1]->force.c, pj[2]->force.c, pj[3]->force.c,
pj[4]->force.c, pj[5]->force.c, pj[6]->force.c, pj[7]->force.c);
vec_set(pj[0]->force.soundspeed, pj[1]->force.soundspeed, pj[2]->force.soundspeed, pj[3]->force.soundspeed,
pj[4]->force.soundspeed, pj[5]->force.soundspeed, pj[6]->force.soundspeed, pj[7]->force.soundspeed);
vi_sig.v = vec_set(pi[0]->force.v_sig, pi[1]->force.v_sig, pi[2]->force.v_sig,
pi[3]->force.v_sig, pi[4]->force.v_sig, pi[5]->force.v_sig,
pi[6]->force.v_sig, pi[7]->force.v_sig);
......@@ -530,18 +530,18 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
#elif VEC_SIZE == 4
mi.v = vec_set(pi[0]->mass, pi[1]->mass, pi[2]->mass, pi[3]->mass);
mj.v = vec_set(pj[0]->mass, pj[1]->mass, pj[2]->mass, pj[3]->mass);
piPOrho2.v = vec_set(pi[0]->force.POrho2, pi[1]->force.POrho2,
pi[2]->force.POrho2, pi[3]->force.POrho2);
pjPOrho2.v = vec_set(pj[0]->force.POrho2, pj[1]->force.POrho2,
pj[2]->force.POrho2, pj[3]->force.POrho2);
piPOrho2.v = vec_set(pi[0]->force.P_over_rho2, pi[1]->force.P_over_rho2,
pi[2]->force.P_over_rho2, pi[3]->force.P_over_rho2);
pjPOrho2.v = vec_set(pj[0]->force.P_over_rho2, pj[1]->force.P_over_rho2,
pj[2]->force.P_over_rho2, pj[3]->force.P_over_rho2);
pirho.v = vec_set(pi[0]->rho, pi[1]->rho, pi[2]->rho, pi[3]->rho);
pjrho.v = vec_set(pj[0]->rho, pj[1]->rho, pj[2]->rho, pj[3]->rho);
piu.v = vec_set(pi[0]->u, pi[1]->u, pi[2]->u, pi[3]->u);
pju.v = vec_set(pj[0]->u, pj[1]->u, pj[2]->u, pj[3]->u);
ci.v =
vec_set(pi[0]->force.c, pi[1]->force.c, pi[2]->force.c, pi[3]->force.c);
vec_set(pi[0]->force.soundspeed, pi[1]->force.soundspeed, pi[2]->force.soundspeed, pi[3]->force.soundspeed);
cj.v =
vec_set(pj[0]->force.c, pj[1]->force.c, pj[2]->force.c, pj[3]->force.c);
vec_set(pj[0]->force.soundspeed, pj[1]->force.soundspeed, pj[2]->force.soundspeed, pj[3]->force.soundspeed);
vi_sig.v = vec_set(pi[0]->force.v_sig, pi[1]->force.v_sig, pi[2]->force.v_sig,
pi[3]->force.v_sig);
vj_sig.v = vec_set(pj[0]->force.v_sig, pj[1]->force.v_sig, pj[2]->force.v_sig,
......@@ -637,18 +637,14 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force(
piu_dt.v += mj.v * tc.v * (piu.v - pju.v);
pju_dt.v += mi.v * tc.v * (pju.v - piu.v);
/* compute the signal velocity (this is always symmetrical). */
vi_sig.v = vec_fmax(vi_sig.v, v_sig.v);
vj_sig.v = vec_fmax(vj_sig.v, v_sig.v);
/* Store the forces back on the particles. */
for (k = 0; k < VEC_SIZE; k++) {
pi[k]->force.u_dt += piu_dt.f[k];
pj[k]->force.u_dt += pju_dt.f[k];
pi[k]->h_dt -= pih_dt.f[k];
pj[k]->h_dt -= pjh_dt.f[k];
pi[k]->force.v_sig = vi_sig.f[k];
pj[k]->force.v_sig = vj_sig.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]);
for (j = 0; j < 3; j++) {
pi[k]->a_hydro[j] -= pia[j].f[k];
pj[k]->a_hydro[j] += pja[j].f[k];
......@@ -684,8 +680,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
mj = pj->mass;
rhoi = pi->rho;
rhoj = pj->rho;
POrho2i = pi->force.POrho2;
POrho2j = pj->force.POrho2;
POrho2i = pi->force.P_over_rho2;
POrho2j = pj->force.P_over_rho2;
/* Get the kernel for hi. */
hi_inv = 1.0f / hi;
......@@ -711,7 +707,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
omega_ij = fminf(dvdr, 0.f);
/* Compute signal velocity */
v_sig = pi->force.c + pj->force.c - 2.0f * omega_ij;
v_sig = pi->force.soundspeed + pj->force.soundspeed - 2.0f * omega_ij;
/* Compute viscosity parameter */
alpha_ij = -0.5f * (pi->alpha + pj->alpha);
......@@ -750,7 +746,6 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
/* 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);
}
/**
......@@ -786,13 +781,13 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
mj.v = vec_set(pj[0]->mass, pj[1]->mass, pj[2]->mass, pj[3]->mass,
pj[4]->mass, pj[5]->mass, pj[6]->mass, pj[7]->mass);
piPOrho2.v =
vec_set(pi[0]->force.POrho2, pi[1]->force.POrho2, pi[2]->force.POrho2,
pi[3]->force.POrho2, pi[4]->force.POrho2, pi[5]->force.POrho2,
pi[6]->force.POrho2, pi[7]->force.POrho2);
vec_set(pi[0]->force.P_over_rho2, pi[1]->force.P_over_rho2, pi[2]->force.P_over_rho2,
pi[3]->force.P_over_rho2, pi[4]->force.P_over_rho2, pi[5]->force.P_over_rho2,
pi[6]->force.P_over_rho2, pi[7]->force.P_over_rho2);
pjPOrho2.v =
vec_set(pj[0]->force.POrho2, pj[1]->force.POrho2, pj[2]->force.POrho2,
pj[3]->force.POrho2, pj[4]->force.POrho2, pj[5]->force.POrho2,
pj[6]->force.POrho2, pj[7]->force.POrho2);
vec_set(pj[0]->force.P_over_rho2, pj[1]->force.P_over_rho2, pj[2]->force.P_over_rho2,
pj[3]->force.P_over_rho2, pj[4]->force.P_over_rho2, pj[5]->force.P_over_rho2,
pj[6]->force.P_over_rho2, pj[7]->force.P_over_rho2);
pirho.v = vec_set(pi[0]->rho, pi[1]->rho, pi[2]->rho, pi[3]->rho, pi[4]->rho,
pi[5]->rho, pi[6]->rho, pi[7]->rho);
pjrho.v = vec_set(pj[0]->rho, pj[1]->rho, pj[2]->rho, pj[3]->rho, pj[4]->rho,
......@@ -802,11 +797,11 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
pju.v = vec_set(pj[0]->u, pj[1]->u, pj[2]->u, pj[3]->u, pj[4]->u, pj[5]->u,
pj[6]->u, pj[7]->u);
ci.v =
vec_set(pi[0]->force.c, pi[1]->force.c, pi[2]->force.c, pi[3]->force.c,
pi[4]->force.c, pi[5]->force.c, pi[6]->force.c, pi[7]->force.c);
vec_set(pi[0]->force.soundspeed, pi[1]->force.soundspeed, pi[2]->force.soundspeed, pi[3]->force.soundspeed,
pi[4]->force.soundspeed, pi[5]->force.soundspeed, pi[6]->force.soundspeed, pi[7]->force.soundspeed);
cj.v =
vec_set(pj[0]->force.c, pj[1]->force.c, pj[2]->force.c, pj[3]->force.c,
pj[4]->force.c, pj[5]->force.c, pj[6]->force.c, pj[7]->force.c);
vec_set(pj[0]->force.soundspeed, pj[1]->force.soundspeed, pj[2]->force.soundspeed, pj[3]->force.soundspeed,
pj[4]->force.soundspeed, pj[5]->force.soundspeed, pj[6]->force.soundspeed, pj[7]->force.soundspeed);
vi_sig.v = vec_set(pi[0]->force.v_sig, pi[1]->force.v_sig, pi[2]->force.v_sig,
pi[3]->force.v_sig, pi[4]->force.v_sig, pi[5]->force.v_sig,
pi[6]->force.v_sig, pi[7]->force.v_sig);
......@@ -835,18 +830,18 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
pj[4]->alpha, pj[5]->alpha, pj[6]->alpha, pj[7]->alpha);
#elif VEC_SIZE == 4
mj.v = vec_set(pj[0]->mass, pj[1]->mass, pj[2]->mass, pj[3]->mass);
piPOrho2.v = vec_set(pi[0]->force.POrho2, pi[1]->force.POrho2,
pi[2]->force.POrho2, pi[3]->force.POrho2);
pjPOrho2.v = vec_set(pj[0]->force.POrho2, pj[1]->force.POrho2,
pj[2]->force.POrho2, pj[3]->force.POrho2);
piPOrho2.v = vec_set(pi[0]->force.P_over_rho2, pi[1]->force.P_over_rho2,
pi[2]->force.P_over_rho2, pi[3]->force.P_over_rho2);
pjPOrho2.v = vec_set(pj[0]->force.P_over_rho2, pj[1]->force.P_over_rho2,
pj[2]->force.P_over_rho2, pj[3]->force.P_over_rho2);
pirho.v = vec_set(pi[0]->rho, pi[1]->rho, pi[2]->rho, pi[3]->rho);
pjrho.v = vec_set(pj[0]->rho, pj[1]->rho, pj[2]->rho, pj[3]->rho);
piu.v = vec_set(pi[0]->u, pi[1]->u, pi[2]->u, pi[3]->u);
pju.v = vec_set(pj[0]->u, pj[1]->u, pj[2]->u, pj[3]->u);
ci.v =
vec_set(pi[0]->force.c, pi[1]->force.c, pi[2]->force.c, pi[3]->force.c);
vec_set(pi[0]->force.soundspeed, pi[1]->force.soundspeed, pi[2]->force.soundspeed, pi[3]->force.soundspeed);
cj.v =
vec_set(pj[0]->force.c, pj[1]->force.c, pj[2]->force.c, pj[3]->force.c);
vec_set(pj[0]->force.soundspeed, pj[1]->force.soundspeed, pj[2]->force.soundspeed, pj[3]->force.soundspeed);
vi_sig.v = vec_set(pi[0]->force.v_sig, pi[1]->force.v_sig, pi[2]->force.v_sig,
pi[3]->force.v_sig);
vj_sig.v = vec_set(pj[0]->force.v_sig, pj[1]->force.v_sig, pj[2]->force.v_sig,
......@@ -937,16 +932,11 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force(
/* Add the thermal conductivity */
piu_dt.v += mj.v * tc.v * (piu.v - pju.v);
/* compute the signal velocity (this is always symmetrical). */
vi_sig.v = vec_fmax(vi_sig.v, v_sig.v);
vj_sig.v = vec_fmax(vj_sig.v, v_sig.v);
/* Store the forces back on the particles. */
for (k = 0; k < VEC_SIZE; k++) {
pi[k]->force.u_dt += piu_dt.f[k];
pi[k]->h_dt -= pih_dt.f[k];
pi[k]->force.v_sig = vi_sig.f[k];
pj[k]->force.v_sig = vj_sig.f[k];
pi[k]->force.v_sig = fmaxf(pi[k]->force.v_sig,v_sig.f[k]);
for (j = 0; j < 3; j++) pi[k]->a_hydro[j] -= pia[j].f[k];
}
......
......@@ -93,7 +93,7 @@ struct part {
float balsara;
/* Aggregate quantities. */
float POrho2;
float P_over_rho2;
/* Change in particle energy over time. */
float u_dt;
......@@ -102,7 +102,7 @@ struct part {
float v_sig;
/* Sound speed */
float c;
float soundspeed;
} force;
};
......
Supports Markdown
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