Replace hypot with cheaper impl

This commit is contained in:
Magnus Ulimoen 2021-03-26 15:52:55 +01:00
parent 52c21dbbe9
commit 7ab6f311c1
1 changed files with 6 additions and 2 deletions

View File

@ -644,8 +644,12 @@ fn upwind_dissipation(
assert!(p > 0.0); assert!(p > 0.0);
let c = (GAMMA * p / rho).sqrt(); let c = (GAMMA * p / rho).sqrt();
let alpha_u = uhat.abs() + c * Float::hypot(*detj_dxi_dx, *detj_dxi_dy); // The accurate hypot is very slow, and the accuracy is
let alpha_v = vhat.abs() + c * Float::hypot(*detj_deta_dx, *detj_deta_dy); // not that important in this case
let hypot = |x: Float, y: Float| Float::sqrt(x * x + y * y);
let alpha_u = uhat.abs() + c * hypot(*detj_dxi_dx, *detj_dxi_dy);
let alpha_v = vhat.abs() + c * hypot(*detj_deta_dx, *detj_deta_dy);
tmp0[0] = alpha_u * rho; tmp0[0] = alpha_u * rho;
tmp1[0] = alpha_v * rho; tmp1[0] = alpha_v * rho;