Skip to content

Commit d02076c

Browse files
committed
Fix non-Newtonian viscosity bugs: mu_max sentinel, shear-rate clamp, D_xz/D_yz boundary fallback, weno_Re_flux validation
1 parent 231ae8d commit d02076c

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/simulation/m_checker.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ contains
113113
@:PROHIBIT(fluid_pp(i)%nn <= 0._wp, "Non-Newtonian fluid flow behavior index nn must be > 0")
114114
@:PROHIBIT(fluid_pp(i)%tau0 < 0._wp, "Non-Newtonian fluid yield stress tau0 must be >= 0")
115115
@:PROHIBIT(fluid_pp(i)%mu_min < 0._wp, "Non-Newtonian fluid mu_min must be >= 0")
116-
@:PROHIBIT(fluid_pp(i)%mu_max < dflt_real .and. fluid_pp(i)%mu_max <= fluid_pp(i)%mu_min, &
116+
@:PROHIBIT(.not. f_is_default(fluid_pp(i)%mu_max) .and. fluid_pp(i)%mu_max <= fluid_pp(i)%mu_min, &
117117
& "Non-Newtonian fluid mu_max must be > mu_min when set")
118118
@:PROHIBIT(fluid_pp(i)%hb_m <= 0._wp, "Non-Newtonian Papanastasiou parameter hb_m must be > 0")
119119
end if

src/simulation/m_hb_function.fpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ contains
4242

4343
mu = yield_term + power_law_term
4444
mu = max(mu, mu_min_val)
45-
if (mu_max_val > 0._wp) mu = min(mu, mu_max_val)
45+
if (mu_max_val > dflt_real) mu = min(mu, mu_max_val)
4646

4747
end function f_compute_hb_viscosity
4848

@@ -65,9 +65,6 @@ contains
6565
! 2*D_ij*D_ij = 2*(D_xx^2+D_yy^2+D_zz^2+2*(D_xy^2+D_xz^2+D_yz^2))
6666
shear_rate = sqrt(2._wp*(D_xx*D_xx + D_yy*D_yy + D_zz*D_zz + 2._wp*(D_xy*D_xy + D_xz*D_xz + D_yz*D_yz)))
6767

68-
! Clamp for numerical safety
69-
shear_rate = min(max(shear_rate, 1.0e-2_wp), 1.0e5_wp)
70-
7168
end function f_compute_shear_rate_from_components
7269

7370
end module m_hb_function

src/simulation/m_re_visc.fpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ contains
130130
& l) - q_prim_vf(eqn_idx%mom%beg + 2)%sf(j - 1, k, l))/(x_cc(j + 1) - x_cc(j - 1)))
131131
else
132132
D_xz = 0._wp
133+
if (l - 1 >= l_lo .and. l + 1 <= l_hi) then
134+
D_xz = 0.5_wp*(q_prim_vf(eqn_idx%mom%beg)%sf(j, k, l + 1) - q_prim_vf(eqn_idx%mom%beg)%sf(j, k, &
135+
& l - 1))/(z_cc(l + 1) - z_cc(l - 1))
136+
end if
137+
if (j - 1 >= j_lo .and. j + 1 <= j_hi) then
138+
D_xz = D_xz + 0.5_wp*(q_prim_vf(eqn_idx%mom%beg + 2)%sf(j + 1, k, &
139+
& l) - q_prim_vf(eqn_idx%mom%beg + 2)%sf(j - 1, k, l))/(x_cc(j + 1) - x_cc(j - 1))
140+
end if
133141
end if
134142
else
135143
D_xz = 0._wp
@@ -143,6 +151,14 @@ contains
143151
& l) - q_prim_vf(eqn_idx%mom%beg + 2)%sf(j, k - 1, l))/(y_cc(k + 1) - y_cc(k - 1)))
144152
else
145153
D_yz = 0._wp
154+
if (l - 1 >= l_lo .and. l + 1 <= l_hi) then
155+
D_yz = 0.5_wp*(q_prim_vf(eqn_idx%mom%beg + 1)%sf(j, k, l + 1) - q_prim_vf(eqn_idx%mom%beg + 1)%sf(j, k, &
156+
& l - 1))/(z_cc(l + 1) - z_cc(l - 1))
157+
end if
158+
if (k - 1 >= k_lo .and. k + 1 <= k_hi) then
159+
D_yz = D_yz + 0.5_wp*(q_prim_vf(eqn_idx%mom%beg + 2)%sf(j, k + 1, l) - q_prim_vf(eqn_idx%mom%beg + 2)%sf(j, &
160+
& k - 1, l))/(y_cc(k + 1) - y_cc(k - 1))
161+
end if
146162
end if
147163
else
148164
D_yz = 0._wp

toolchain/mfc/case_validator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,9 @@ def check_viscosity(self):
877877
# Check Re(1) requirement
878878
self.prohibit(Re1 is None and viscous, f"viscous is set to true, but fluid_pp({i})%Re(1) is not specified")
879879

880+
weno_Re_flux = self.get("weno_Re_flux", "F") == "T"
881+
self.prohibit(weno_Re_flux and not viscous, "weno_Re_flux requires viscous to be enabled")
882+
880883
def check_non_newtonian(self):
881884
"""Checks constraints on non-Newtonian fluid parameters"""
882885
viscous = self.get("viscous", "F") == "T"

0 commit comments

Comments
 (0)