Skip to content

Commit f785c7b

Browse files
wilfonbahaochey
andauthored
Fix sphere smoothing (#798)
* Fix sphere smoothing * format * Fix Cylinder and Sphere * Fix Smooth Function in Cylinder and Sphere * Fix Cylinder and Sphere Smooth function --------- Co-authored-by: haochey <[email protected]>
1 parent 08f02bd commit f785c7b

File tree

18 files changed

+357
-336
lines changed

18 files changed

+357
-336
lines changed

src/pre_process/m_initial_condition.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ contains
208208
call s_sphere(i, ib_markers%sf, q_prim_vf, ib)
209209
call s_sphere_levelset(levelset, levelset_norm, i)
210210
! Cylindrical patch
211+
elseif (patch_ib(i)%geometry == 9) then
212+
call s_cuboid(i, ib_markers%sf, q_prim_vf, ib)
213+
call s_cuboid_levelset(levelset, levelset_norm, i)
211214
elseif (patch_ib(i)%geometry == 10) then
212215
call s_cylinder(i, ib_markers%sf, q_prim_vf, ib)
213216
call s_cylinder_levelset(levelset, levelset_norm, i)

src/pre_process/m_patches.fpp

Lines changed: 85 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,34 +1605,34 @@ contains
16051605
cart_z = z_cc(k)
16061606
end if
16071607

1608-
if ((x_cc(i) - x_centroid)**2 &
1609-
+ (cart_y - y_centroid)**2 &
1610-
+ (cart_z - z_centroid)**2 <= radius**2) &
1611-
then
1608+
if (.not. present(ib) .and. patch_icpp(patch_id)%smoothen) then
1609+
eta = tanh(smooth_coeff/min(dx, dy, dz)* &
1610+
(sqrt((x_cc(i) - x_centroid)**2 &
1611+
+ (cart_y - y_centroid)**2 &
1612+
+ (cart_z - z_centroid)**2) &
1613+
- radius))*(-0.5_wp) + 0.5_wp
1614+
end if
16121615

1613-
if (present(ib)) then
1614-
! Updating the patch identities bookkeeping variable
1616+
if (present(ib)) then
1617+
! Updating the patch identities bookkeeping variable
1618+
if (((x_cc(i) - x_centroid)**2 &
1619+
+ (cart_y - y_centroid)**2 &
1620+
+ (cart_z - z_centroid)**2 <= radius**2)) then
16151621
patch_id_fp(i, j, k) = patch_id
1616-
else
1617-
if (patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k)) .or. &
1618-
patch_id_fp(i, j, k) == smooth_patch_id) then
1619-
1620-
call s_assign_patch_primitive_variables(patch_id, i, j, k, &
1621-
eta, q_prim_vf, patch_id_fp)
1622+
end if
1623+
else
1624+
if ((((x_cc(i) - x_centroid)**2 &
1625+
+ (cart_y - y_centroid)**2 &
1626+
+ (cart_z - z_centroid)**2 <= radius**2) .and. &
1627+
patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k))) .or. &
1628+
patch_id_fp(i, j, k) == smooth_patch_id) then
16221629

1623-
@:analytical()
1624-
end if
1630+
call s_assign_patch_primitive_variables(patch_id, i, j, k, &
1631+
eta, q_prim_vf, patch_id_fp)
16251632

1626-
if (patch_icpp(patch_id)%smoothen) then
1627-
eta = tanh(smooth_coeff/min(dx, dy, dz)* &
1628-
(sqrt((x_cc(i) - x_centroid)**2 &
1629-
+ (cart_y - y_centroid)**2 &
1630-
+ (cart_z - z_centroid)**2) &
1631-
- radius))*(-0.5_wp) + 0.5_wp
1632-
end if
1633+
@:analytical()
16331634
end if
16341635
end if
1635-
16361636
end do
16371637
end do
16381638
end do
@@ -1810,58 +1810,76 @@ contains
18101810
cart_z = z_cc(k)
18111811
end if
18121812

1813-
if ((.not. f_is_default(length_x) .and. &
1814-
(cart_y - y_centroid)**2 &
1815-
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
1816-
x_boundary%beg <= x_cc(i) .and. &
1817-
x_boundary%end >= x_cc(i)) &
1818-
.or. &
1819-
(.not. f_is_default(length_y) .and. &
1820-
(x_cc(i) - x_centroid)**2 &
1821-
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
1822-
y_boundary%beg <= cart_y .and. &
1823-
y_boundary%end >= cart_y) &
1824-
.or. &
1825-
(.not. f_is_default(length_z) .and. &
1826-
(x_cc(i) - x_centroid)**2 &
1827-
+ (cart_y - y_centroid)**2 <= radius**2 .and. &
1828-
z_boundary%beg <= cart_z .and. &
1829-
z_boundary%end >= cart_z)) then
1813+
if (.not. present(ib) .and. patch_icpp(patch_id)%smoothen) then
1814+
if (.not. f_is_default(length_x)) then
1815+
eta = tanh(smooth_coeff/min(dy, dz)* &
1816+
(sqrt((cart_y - y_centroid)**2 &
1817+
+ (cart_z - z_centroid)**2) &
1818+
- radius))*(-0.5_wp) + 0.5_wp
1819+
elseif (.not. f_is_default(length_y)) then
1820+
eta = tanh(smooth_coeff/min(dx, dz)* &
1821+
(sqrt((x_cc(i) - x_centroid)**2 &
1822+
+ (cart_z - z_centroid)**2) &
1823+
- radius))*(-0.5_wp) + 0.5_wp
1824+
else
1825+
eta = tanh(smooth_coeff/min(dx, dy)* &
1826+
(sqrt((x_cc(i) - x_centroid)**2 &
1827+
+ (cart_y - y_centroid)**2) &
1828+
- radius))*(-0.5_wp) + 0.5_wp
1829+
end if
1830+
end if
1831+
1832+
if (present(ib)) then
1833+
if (((.not. f_is_default(length_x) .and. &
1834+
(cart_y - y_centroid)**2 &
1835+
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
1836+
x_boundary%beg <= x_cc(i) .and. &
1837+
x_boundary%end >= x_cc(i)) &
1838+
.or. &
1839+
(.not. f_is_default(length_y) .and. &
1840+
(x_cc(i) - x_centroid)**2 &
1841+
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
1842+
y_boundary%beg <= cart_y .and. &
1843+
y_boundary%end >= cart_y) &
1844+
.or. &
1845+
(.not. f_is_default(length_z) .and. &
1846+
(x_cc(i) - x_centroid)**2 &
1847+
+ (cart_y - y_centroid)**2 <= radius**2 .and. &
1848+
z_boundary%beg <= cart_z .and. &
1849+
z_boundary%end >= cart_z))) then
18301850

1831-
if (present(ib)) then
18321851
! Updating the patch identities bookkeeping variable
18331852
patch_id_fp(i, j, k) = patch_id
1834-
else
1835-
if (patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k)) &
1836-
.or. patch_id_fp(i, j, k) == smooth_patch_id) then
1853+
end if
18371854

1838-
call s_assign_patch_primitive_variables(patch_id, i, j, k, &
1839-
eta, q_prim_vf, patch_id_fp)
1855+
else
1856+
if (((.not. f_is_default(length_x) .and. &
1857+
(cart_y - y_centroid)**2 &
1858+
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
1859+
x_boundary%beg <= x_cc(i) .and. &
1860+
x_boundary%end >= x_cc(i)) &
1861+
.or. &
1862+
(.not. f_is_default(length_y) .and. &
1863+
(x_cc(i) - x_centroid)**2 &
1864+
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
1865+
y_boundary%beg <= cart_y .and. &
1866+
y_boundary%end >= cart_y) &
1867+
.or. &
1868+
(.not. f_is_default(length_z) .and. &
1869+
(x_cc(i) - x_centroid)**2 &
1870+
+ (cart_y - y_centroid)**2 <= radius**2 .and. &
1871+
z_boundary%beg <= cart_z .and. &
1872+
z_boundary%end >= cart_z) .and. &
1873+
patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k))) .or. &
1874+
patch_id_fp(i, j, k) == smooth_patch_id) then
18401875

1841-
@:analytical()
1876+
call s_assign_patch_primitive_variables(patch_id, i, j, k, &
1877+
eta, q_prim_vf, patch_id_fp)
18421878

1843-
! Updating the patch identities bookkeeping variable
1844-
if (1._wp - eta < 1e-16_wp) patch_id_fp(i, j, k) = patch_id
1845-
end if
1879+
@:analytical()
18461880

1847-
if (patch_icpp(patch_id)%smoothen) then
1848-
if (.not. f_is_default(length_x)) then
1849-
eta = tanh(smooth_coeff/min(dy, dz)* &
1850-
(sqrt((cart_y - y_centroid)**2 &
1851-
+ (cart_z - z_centroid)**2) &
1852-
- radius))*(-0.5_wp) + 0.5_wp
1853-
elseif (.not. f_is_default(length_y)) then
1854-
eta = tanh(smooth_coeff/min(dx, dz)* &
1855-
(sqrt((x_cc(i) - x_centroid)**2 &
1856-
+ (cart_z - z_centroid)**2) &
1857-
- radius))*(-0.5_wp) + 0.5_wp
1858-
else
1859-
eta = tanh(smooth_coeff/min(dx, dy)* &
1860-
(sqrt((x_cc(i) - x_centroid)**2 &
1861-
+ (cart_y - y_centroid)**2) &
1862-
- radius))*(-0.5_wp) + 0.5_wp
1863-
end if
1864-
end if
1881+
! Updating the patch identities bookkeeping variable
1882+
if (1._wp - eta < 1e-16_wp) patch_id_fp(i, j, k) = patch_id
18651883
end if
18661884
end if
18671885
end do

tests/07D9EBD1/golden-metadata.txt

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/07D9EBD1/golden.txt

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)