From 671c86c079faa37386f59eb3c814dc837c4df4c5 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 2 Apr 2013 18:29:33 -0400 Subject: Replace abs() by fabs() Replace calls to abs() with floating arguments by calls to fabs(), to ensure the results are not accidentally truncated to integer. --- Carpet/Carpet/src/Evolve.cc | 6 +++--- Carpet/Carpet/src/Recompose.cc | 2 +- Carpet/Carpet/src/SetupGH.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'Carpet/Carpet') diff --git a/Carpet/Carpet/src/Evolve.cc b/Carpet/Carpet/src/Evolve.cc index 8864ee9ee..4c97d13a9 100644 --- a/Carpet/Carpet/src/Evolve.cc +++ b/Carpet/Carpet/src/Evolve.cc @@ -110,15 +110,15 @@ namespace Carpet { timer.start(); CCTK_REAL const eps = pow(numeric_limits::epsilon(), CCTK_REAL(0.75)); - assert (abs (cctkGH->cctk_time - global_time) <= eps * global_time); + assert (fabs (cctkGH->cctk_time - global_time) <= eps * global_time); for (int ml=0; mlcctk_iteration % do_every == 0) { - // assert (abs (leveltimes.AT(ml).AT(rl) - global_time) <= + // assert (fabs (leveltimes.AT(ml).AT(rl) - global_time) <= // eps * global_time); - assert (abs (tt->get_time(ml,rl,0) - global_time) <= + assert (fabs (tt->get_time(ml,rl,0) - global_time) <= eps * global_time); } } diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc index bedfb0364..703963f97 100644 --- a/Carpet/Carpet/src/Recompose.cc +++ b/Carpet/Carpet/src/Recompose.cc @@ -1441,7 +1441,7 @@ namespace Carpet { rvect rcost = cost (superreg); CCTK_REAL const rfact = pow (nprocs / prod(rcost), CCTK_REAL(1)/dim); rcost *= rfact; - assert (abs (prod (rcost) - nprocs) <= 1.0e-6); + assert (fabs (prod (rcost) - nprocs) <= 1.0e-6); if (recompose_verbose) cout << "SRMA shapes " << rcost << endl; // Choose a direction diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc index 47f9dcad1..4db6b8106 100644 --- a/Carpet/Carpet/src/SetupGH.cc +++ b/Carpet/Carpet/src/SetupGH.cc @@ -1837,7 +1837,7 @@ namespace Carpet { npoints = floor (real_npoints + static_cast (0.5)); // Check domain size - if (any (abs (rvect (npoints) - real_npoints) > + if (any (fabs (rvect (npoints) - real_npoints) > static_cast (0.001))) { CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -2100,7 +2100,7 @@ namespace Carpet { free (groupname); } - if (any(abs(rvect(sizes) - real_sizes) > static_cast (1.0e-8))) { + if (any(fabs(rvect(sizes) - real_sizes) > static_cast (1.0e-8))) { char * const groupname = CCTK_GroupName(group); CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, "The shape of group \"%s\" scaled for convergence level %d with convergence factor %d is not integer", -- cgit v1.2.3