Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sphere smoothing #798

Merged
merged 5 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pre_process/m_initial_condition.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
call s_sphere(i, ib_markers%sf, q_prim_vf, ib)
call s_sphere_levelset(levelset, levelset_norm, i)
! Cylindrical patch
elseif (patch_ib(i)%geometry == 9) then
call s_cuboid(i, ib_markers%sf, q_prim_vf, ib)

Check warning on line 212 in src/pre_process/m_initial_condition.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_initial_condition.fpp#L212

Added line #L212 was not covered by tests
call s_cuboid_levelset(levelset, levelset_norm, i)
elseif (patch_ib(i)%geometry == 10) then
call s_cylinder(i, ib_markers%sf, q_prim_vf, ib)
call s_cylinder_levelset(levelset, levelset_norm, i)
Expand Down
152 changes: 85 additions & 67 deletions src/pre_process/m_patches.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,34 +1605,34 @@
cart_z = z_cc(k)
end if

if ((x_cc(i) - x_centroid)**2 &
+ (cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2) &
then
if (.not. present(ib) .and. patch_icpp(patch_id)%smoothen) then
eta = tanh(smooth_coeff/min(dx, dy, dz)* &
(sqrt((x_cc(i) - x_centroid)**2 &

Check warning on line 1610 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1610

Added line #L1610 was not covered by tests
+ (cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp

Check warning on line 1613 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1613

Added line #L1613 was not covered by tests
end if

if (present(ib)) then
! Updating the patch identities bookkeeping variable
if (present(ib)) then
! Updating the patch identities bookkeeping variable
if (((x_cc(i) - x_centroid)**2 &
+ (cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2)) then
patch_id_fp(i, j, k) = patch_id
else
if (patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k)) .or. &
patch_id_fp(i, j, k) == smooth_patch_id) then

call s_assign_patch_primitive_variables(patch_id, i, j, k, &
eta, q_prim_vf, patch_id_fp)
end if
else
if ((((x_cc(i) - x_centroid)**2 &

Check warning on line 1624 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1624

Added line #L1624 was not covered by tests
+ (cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2) .and. &
patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k))) .or. &

Check warning on line 1627 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1626-L1627

Added lines #L1626 - L1627 were not covered by tests
patch_id_fp(i, j, k) == smooth_patch_id) then

@:analytical()
end if
call s_assign_patch_primitive_variables(patch_id, i, j, k, &
eta, q_prim_vf, patch_id_fp)

if (patch_icpp(patch_id)%smoothen) then
eta = tanh(smooth_coeff/min(dx, dy, dz)* &
(sqrt((x_cc(i) - x_centroid)**2 &
+ (cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp
end if
@:analytical()

Check warning on line 1633 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1633

Added line #L1633 was not covered by tests
end if
end if

end do
end do
end do
Expand Down Expand Up @@ -1810,58 +1810,76 @@
cart_z = z_cc(k)
end if

if ((.not. f_is_default(length_x) .and. &
(cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
x_boundary%beg <= x_cc(i) .and. &
x_boundary%end >= x_cc(i)) &
.or. &
(.not. f_is_default(length_y) .and. &
(x_cc(i) - x_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
y_boundary%beg <= cart_y .and. &
y_boundary%end >= cart_y) &
.or. &
(.not. f_is_default(length_z) .and. &
(x_cc(i) - x_centroid)**2 &
+ (cart_y - y_centroid)**2 <= radius**2 .and. &
z_boundary%beg <= cart_z .and. &
z_boundary%end >= cart_z)) then
if (.not. present(ib) .and. patch_icpp(patch_id)%smoothen) then
if (.not. f_is_default(length_x)) then
eta = tanh(smooth_coeff/min(dy, dz)* &
(sqrt((cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp
elseif (.not. f_is_default(length_y)) then

Check warning on line 1819 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1818-L1819

Added lines #L1818 - L1819 were not covered by tests
eta = tanh(smooth_coeff/min(dx, dz)* &
(sqrt((x_cc(i) - x_centroid)**2 &

Check warning on line 1821 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1821

Added line #L1821 was not covered by tests
+ (cart_z - z_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp

Check warning on line 1823 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1823

Added line #L1823 was not covered by tests
else
eta = tanh(smooth_coeff/min(dx, dy)* &
(sqrt((x_cc(i) - x_centroid)**2 &

Check warning on line 1826 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1826

Added line #L1826 was not covered by tests
+ (cart_y - y_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp

Check warning on line 1828 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1828

Added line #L1828 was not covered by tests
end if
end if

if (present(ib)) then
if (((.not. f_is_default(length_x) .and. &
(cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
x_boundary%beg <= x_cc(i) .and. &

Check warning on line 1836 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1836

Added line #L1836 was not covered by tests
x_boundary%end >= x_cc(i)) &
.or. &
(.not. f_is_default(length_y) .and. &
(x_cc(i) - x_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
y_boundary%beg <= cart_y .and. &
y_boundary%end >= cart_y) &
.or. &
(.not. f_is_default(length_z) .and. &
(x_cc(i) - x_centroid)**2 &
+ (cart_y - y_centroid)**2 <= radius**2 .and. &
z_boundary%beg <= cart_z .and. &
z_boundary%end >= cart_z))) then

if (present(ib)) then
! Updating the patch identities bookkeeping variable
patch_id_fp(i, j, k) = patch_id
else
if (patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k)) &
.or. patch_id_fp(i, j, k) == smooth_patch_id) then
end if

call s_assign_patch_primitive_variables(patch_id, i, j, k, &
eta, q_prim_vf, patch_id_fp)
else
if (((.not. f_is_default(length_x) .and. &
(cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
x_boundary%beg <= x_cc(i) .and. &

Check warning on line 1859 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1859

Added line #L1859 was not covered by tests
x_boundary%end >= x_cc(i)) &
.or. &
(.not. f_is_default(length_y) .and. &
(x_cc(i) - x_centroid)**2 &
+ (cart_z - z_centroid)**2 <= radius**2 .and. &
y_boundary%beg <= cart_y .and. &
y_boundary%end >= cart_y) &
.or. &
(.not. f_is_default(length_z) .and. &
(x_cc(i) - x_centroid)**2 &
+ (cart_y - y_centroid)**2 <= radius**2 .and. &
z_boundary%beg <= cart_z .and. &
z_boundary%end >= cart_z) .and. &
patch_icpp(patch_id)%alter_patch(patch_id_fp(i, j, k))) .or. &

Check warning on line 1873 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1872-L1873

Added lines #L1872 - L1873 were not covered by tests
patch_id_fp(i, j, k) == smooth_patch_id) then

@:analytical()
call s_assign_patch_primitive_variables(patch_id, i, j, k, &
eta, q_prim_vf, patch_id_fp)

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

Check warning on line 1879 in src/pre_process/m_patches.fpp

View check run for this annotation

Codecov / codecov/patch

src/pre_process/m_patches.fpp#L1879

Added line #L1879 was not covered by tests

if (patch_icpp(patch_id)%smoothen) then
if (.not. f_is_default(length_x)) then
eta = tanh(smooth_coeff/min(dy, dz)* &
(sqrt((cart_y - y_centroid)**2 &
+ (cart_z - z_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp
elseif (.not. f_is_default(length_y)) then
eta = tanh(smooth_coeff/min(dx, dz)* &
(sqrt((x_cc(i) - x_centroid)**2 &
+ (cart_z - z_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp
else
eta = tanh(smooth_coeff/min(dx, dy)* &
(sqrt((x_cc(i) - x_centroid)**2 &
+ (cart_y - y_centroid)**2) &
- radius))*(-0.5_wp) + 0.5_wp
end if
end if
! Updating the patch identities bookkeeping variable
if (1._wp - eta < 1e-16_wp) patch_id_fp(i, j, k) = patch_id
end if
end if
end do
Expand Down
58 changes: 29 additions & 29 deletions tests/07D9EBD1/golden-metadata.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions tests/07D9EBD1/golden.txt

Large diffs are not rendered by default.

Loading
Loading