Skip to content
Snippets Groups Projects
Commit 4c462f17 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Get rid of unnecessary divisions

parent 892b5334
Branches
Tags
2 merge requests!136Master,!90Improved multi-timestep SPH
...@@ -87,19 +87,21 @@ __attribute__((always_inline)) ...@@ -87,19 +87,21 @@ __attribute__((always_inline))
/* Finish the calculation by inserting the missing h-factors */ /* Finish the calculation by inserting the missing h-factors */
p->rho *= ih * ih2; p->rho *= ih * ih2;
p->rho_dh *= ih4; p->rho_dh *= ih4;
p->density.wcount *= (4.0f / 3.0 * M_PI * kernel_gamma3); p->density.wcount *= (4.0f / 3.0f * M_PI * kernel_gamma3);
p->density.wcount_dh *= ih * (4.0f / 3.0 * M_PI * kernel_gamma3); p->density.wcount_dh *= ih * (4.0f / 3.0f * M_PI * kernel_gamma3);
const float irho = 1.f / p->rho;
/* Compute the derivative term */ /* Compute the derivative term */
p->rho_dh = 1.f / (1.f + 0.33333333f * p->h * p->rho_dh / p->rho); p->rho_dh = 1.f / (1.f + 0.33333333f * p->h * p->rho_dh * irho);
/* Finish calculation of the velocity curl components */ /* Finish calculation of the velocity curl components */
p->density.rot_v[0] *= ih4 / p->rho; p->density.rot_v[0] *= ih4 * irho;
p->density.rot_v[1] *= ih4 / p->rho; p->density.rot_v[1] *= ih4 * irho;
p->density.rot_v[2] *= ih4 / p->rho; p->density.rot_v[2] *= ih4 * irho;
/* Finish calculation of the velocity divergence */ /* Finish calculation of the velocity divergence */
p->div_v *= ih4 / p->rho; p->div_v *= ih4 * irho;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment