Skip to content

Commit a8e1ea8

Browse files
committed
fix: replace fragile floating-point equality comparisons
- m_ibm.fpp: Re(1) /= 0._wp -> Re(1) > 0._wp (matches convention in m_global_parameters.fpp where Re is checked with > 0) - m_ibm.fpp: sqrt(sum(axis**2)) == 0 -> < sgm_eps (floating-point magnitude should not be compared with exact equality) - ExtrusionHardcodedIC.fpp: dummy_x == x0 -> f_approx_equal (coordinates read from files should not be compared with exact equality)
1 parent 42ac3ce commit a8e1ea8

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/common/include/ExtrusionHardcodedIC.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
do
110110
read (unit2, *, iostat=ios2) dummy_x, dummy_y, dummy_z
111111
if (ios2 /= 0) exit
112-
if (dummy_x == x0 .and. dummy_y /= y0) then
112+
if (f_approx_equal(dummy_x, x0) .and. (.not. f_approx_equal(dummy_y, y0))) then
113113
yRows = yRows + 1
114114
else
115115
exit

src/simulation/m_ibm.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ contains
904904

905905
if (viscous) then
906906
do fluid_idx = 1, num_fluids
907-
if (fluid_pp(fluid_idx)%Re(1) /= 0._wp) then
907+
if (fluid_pp(fluid_idx)%Re(1) > 0._wp) then
908908
dynamic_viscosities(fluid_idx) = 1._wp/fluid_pp(fluid_idx)%Re(1)
909909
else
910910
dynamic_viscosities(fluid_idx) = 0._wp
@@ -1110,7 +1110,7 @@ contains
11101110

11111111
if (p == 0) then
11121112
normal_axis = [0, 0, 1]
1113-
else if (sqrt(sum(axis**2)) == 0) then
1113+
else if (sqrt(sum(axis**2)) < sgm_eps) then
11141114
! if the object is not actually rotating at this time, return a dummy value and exit
11151115
patch_ib(ib_marker)%moment = 1._wp
11161116
return

0 commit comments

Comments
 (0)