Skip to content
Snippets Groups Projects
Commit 09ba6851 authored by Mladen Ivkovic's avatar Mladen Ivkovic
Browse files

use doubles to compute F^2, as on some occations it may exceed the single precision limits

parent b571bd55
No related branches found
No related tags found
6 merge requests!1891Merge master into Zoom merge,!1887Updating . . .,!1878updating working branch,!1873Merging master into zoom branch,!1861Fixes a missing member of zoom_props,!1854use doubles to compute F^2, as on some occations it may exceed the single precision limits
......@@ -72,11 +72,11 @@ __attribute__((always_inline)) INLINE static void rt_check_unphysical_state(
}
/* Check for too high fluxes */
const float flux2 = flux[0] * flux[0] + flux[1] * flux[1] + flux[2] * flux[2];
const float flux_norm = sqrtf(flux2);
const float flux_max = rt_params.reduced_speed_of_light * *energy_density;
const double flux2 = flux[0] * flux[0] + flux[1] * flux[1] + flux[2] * flux[2];
const double flux_norm = sqrt(flux2);
const double flux_max = rt_params.reduced_speed_of_light * *energy_density;
if (flux_norm > flux_max) {
const float correct = flux_max / flux_norm;
const double correct = flux_max / flux_norm;
flux[0] *= correct;
flux[1] *= correct;
flux[2] *= correct;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment