Skip to content

Commit 3e097d7

Browse files
Merge branch 'levelset-refactor' of github.com:danieljvickers/MFC into levelset-refactor
2 parents 128562b + b7b8d2d commit 3e097d7

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

src/simulation/m_compute_levelset.fpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ contains
7777
integer :: global_id
7878
real(wp), dimension(3) :: dist_vec
7979

80-
real(wp), dimension(1:3) :: xy_local !< x and y coordinates in local IB frame
80+
real(wp), dimension(1:3) :: xy_local, offset !< x and y coordinates in local IB frame
8181
real(wp), dimension(1:2) :: center
8282
real(wp), dimension(1:3, 1:3) :: rotation, inverse_rotation
8383

@@ -87,14 +87,15 @@ contains
8787
center(2) = patch_ib(ib_patch_id)%y_centroid
8888
inverse_rotation(:, :) = patch_ib(ib_patch_id)%rotation_matrix_inverse(:, :)
8989
rotation(:, :) = patch_ib(ib_patch_id)%rotation_matrix(:, :)
90+
offset(:) = patch_ib(ib_patch_id)%centroid_offset(:)
9091

9192
$:GPU_PARALLEL_LOOP(private='[i,j,xy_local,k,dist_vec,dist,global_dist,global_id]', &
92-
& copyin='[ib_patch_id,center,rotation,inverse_rotation,airfoil_grid_u,airfoil_grid_l]', collapse=2)
93+
& copyin='[ib_patch_id,center,rotation,inverse_rotation,offset,airfoil_grid_u,airfoil_grid_l]', collapse=2)
9394
do i = 0, m
9495
do j = 0, n
9596
xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] ! get coordinate frame centered on IB
9697
xy_local = matmul(inverse_rotation, xy_local) ! rotate the frame into the IB's coordinate
97-
xy_local = xy_local - patch_ib(ib_patch_id)%centroid_offset ! airfoils are a patch that require a centroid offset
98+
xy_local = xy_local - offset ! airfoils are a patch that require a centroid offset
9899
99100
if (xy_local(2) >= 0._wp) then
100101
! finds the location on the airfoil grid with the minimum distance (closest)
@@ -165,7 +166,7 @@ contains
165166
real(wp) :: lz, z_max, z_min
166167
real(wp), dimension(3) :: dist_vec
167168
168-
real(wp), dimension(1:3) :: xyz_local, center !< x, y, z coordinates in local IB frame
169+
real(wp), dimension(1:3) :: xyz_local, center, offset !< x, y, z coordinates in local IB frame
169170
real(wp), dimension(1:3, 1:3) :: rotation, inverse_rotation
170171
171172
real(wp) :: length_z
@@ -178,19 +179,20 @@ contains
178179
lz = patch_ib(ib_patch_id)%length_z
179180
inverse_rotation(:, :) = patch_ib(ib_patch_id)%rotation_matrix_inverse(:, :)
180181
rotation(:, :) = patch_ib(ib_patch_id)%rotation_matrix(:, :)
182+
offset(:) = patch_ib(ib_patch_id)%centroid_offset(:)
181183
182184
z_max = center(3) + lz/2
183185
z_min = center(3) - lz/2
184186
185187
$:GPU_PARALLEL_LOOP(private='[i,j,l,xyz_local,k,dist_vec,dist,global_dist,global_id,dist_side,dist_surf]', &
186-
& copyin='[ib_patch_id,center,rotation,inverse_rotation,airfoil_grid_u,airfoil_grid_l,z_min,z_max]', collapse=3)
188+
& copyin='[ib_patch_id,center,rotation,inverse_rotation,offset,airfoil_grid_u,airfoil_grid_l,z_min,z_max]', collapse=3)
187189
do l = 0, p
188190
do j = 0, n
189191
do i = 0, m
190192
191193
xyz_local = [x_cc(i) - center(1), y_cc(j) - center(2), z_cc(l) - center(3)] ! get coordinate frame centered on IB
192194
xyz_local = matmul(inverse_rotation, xyz_local) ! rotate the frame into the IB's coordinates
193-
xyz_local = xyz_local - patch_ib(ib_patch_id)%centroid_offset ! airfoils are a patch that require a centroid offset
195+
xyz_local = xyz_local - offset ! airfoils are a patch that require a centroid offset
194196

195197
if (xyz_local(2) >= center(2)) then
196198
do k = 1, Np
@@ -239,12 +241,12 @@ contains
239241
if (dist_side < dist_surf) then
240242
levelset%sf(i, j, l, ib_patch_id) = dist_side
241243
if (f_approx_equal(dist_side, abs(z_cc(l) - z_min))) then
242-
levelset_norm%sf(i, j, l, ib_patch_id, :) = (/0, 0, -1/)
244+
levelset_norm%sf(i, j, l, ib_patch_id, :) = (/0._wp, 0._wp, -1._wp/)
243245
else
244-
levelset_norm%sf(i, j, l, ib_patch_id, :) = (/0, 0, 1/)
246+
levelset_norm%sf(i, j, l, ib_patch_id, :) = (/0._wp, 0._wp, 1._wp/)
245247
end if
246248
levelset_norm%sf(i, j, l, ib_patch_id, :) = &
247-
matmul(rotation, levelset_norm%sf(i, j, l, ib_patch_id, :)/dist_surf)
249+
matmul(rotation, levelset_norm%sf(i, j, l, ib_patch_id, :))
248250
else
249251
levelset%sf(i, j, l, ib_patch_id) = dist_surf
250252
if (f_approx_equal(dist_surf, 0._wp)) then

src/simulation/m_ib_patches.fpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ contains
192192
integer :: i, j, k
193193
integer :: Np1, Np2
194194

195-
real(wp), dimension(1:3) :: xy_local !< x and y coordinates in local IB frame
195+
real(wp), dimension(1:3) :: xy_local, offset !< x and y coordinates in local IB frame
196196
real(wp), dimension(1:2) :: center !< x and y coordinates in local IB frame
197197
real(wp), dimension(1:3, 1:3) :: inverse_rotation
198198

@@ -203,6 +203,7 @@ contains
203203
ma = patch_ib(patch_id)%m
204204
ta = patch_ib(patch_id)%t
205205
inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :)
206+
offset(:) = patch_ib(patch_id)%centroid_offset(:)
206207

207208
! rank(dx) is not consistent between pre_process and simulation. This IFDEF prevents compilation errors
208209
#ifdef MFC_PRE_PROCESS
@@ -274,12 +275,12 @@ contains
274275
end if
275276

276277
$:GPU_PARALLEL_LOOP(private='[i,j,xy_local,k,f]', copy='[ib_markers_sf]',&
277-
& copyin='[patch_id,center,inverse_rotation,ma,ca_in,airfoil_grid_u,airfoil_grid_l]', collapse=2)
278+
& copyin='[patch_id,center,inverse_rotation,offset,ma,ca_in,airfoil_grid_u,airfoil_grid_l]', collapse=2)
278279
do j = 0, n
279280
do i = 0, m
280281
xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] ! get coordinate frame centered on IB
281282
xy_local = matmul(inverse_rotation, xy_local) ! rotate the frame into the IB's coordinates
282-
xy_local = xy_local - patch_ib(patch_id)%centroid_offset ! airfoils are a patch that require a centroid offset
283+
xy_local = xy_local - offset ! airfoils are a patch that require a centroid offset
283284
284285
if (xy_local(1) >= 0._wp .and. xy_local(1) <= ca_in) then
285286
xa = xy_local(1)/ca_in
@@ -345,7 +346,7 @@ contains
345346
integer :: i, j, k, l
346347
integer :: Np1, Np2
347348
348-
real(wp), dimension(1:3) :: xyz_local, center !< x, y, z coordinates in local IB frame
349+
real(wp), dimension(1:3) :: xyz_local, center, offset !< x, y, z coordinates in local IB frame
349350
real(wp), dimension(1:3, 1:3) :: inverse_rotation
350351
351352
center(1) = patch_ib(patch_id)%x_centroid
@@ -357,6 +358,7 @@ contains
357358
ma = patch_ib(patch_id)%m
358359
ta = patch_ib(patch_id)%t
359360
inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :)
361+
offset(:) = patch_ib(patch_id)%centroid_offset(:)
360362
361363
! rank(dx) is not consistent between pre_process and simulation. This IFDEF prevents compilation errors
362364
#ifdef MFC_PRE_PROCESS
@@ -428,13 +430,13 @@ contains
428430
end if
429431
430432
$:GPU_PARALLEL_LOOP(private='[i,j,l,xyz_local,k,f]', copy='[ib_markers_sf]',&
431-
& copyin='[patch_id,center,inverse_rotation,ma,ca_in,airfoil_grid_u,airfoil_grid_l]', collapse=3)
433+
& copyin='[patch_id,center,inverse_rotation,offset,ma,ca_in,airfoil_grid_u,airfoil_grid_l]', collapse=3)
432434
do l = 0, p
433435
do j = 0, n
434436
do i = 0, m
435437
xyz_local = [x_cc(i) - center(1), y_cc(j) - center(2), z_cc(l) - center(3)] ! get coordinate frame centered on IB
436438
xyz_local = matmul(inverse_rotation, xyz_local) ! rotate the frame into the IB's coordinates
437-
xyz_local = xyz_local - patch_ib(patch_id)%centroid_offset ! airfoils are a patch that require a centroid offset
439+
xyz_local = xyz_local - offset ! airfoils are a patch that require a centroid offset
438440

439441
if (xyz_local(3) >= z_min .and. xyz_local(3) <= z_max) then
440442

src/simulation/m_ibm.fpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,15 @@ contains
505505
.or. temp_loc > s_cc(index + 1)))
506506
index = index + dir
507507
if (index < -buff_size .or. index > bound) then
508-
print *, "temp_loc=", temp_loc, " s_cc(index)=", s_cc(index), " s_cc(index+1)=", s_cc(index + 1)
509-
print *, "Increase buff_size further in m_helper_basic (currently set to a minimum of 10)"
510-
error stop "Increase buff_size"
508+
print *, "A required image point is not located in this computational domain."
509+
print *, "Ghost Point is located at ", [x_cc(i), y_cc(j), z_cc(k)], " while moving in dimension ", dim
510+
print *, "We are searching for image point at ", ghost_points_in(q)%ip_loc(:)
511+
print *, "We can only support points located inside the box from ", [x_cc(-buff_size), y_cc(-buff_size), z_cc(-buff_size)]
512+
print *, "To ", [x_cc( m + buff_size - 1), y_cc(n + buff_size - 1), z_cc(p + buff_size - 1)]
513+
print *, "Image point is located approximately ", (ghost_points_in(q)%loc(dim) - ghost_points_in(q)%ip_loc(dim)) / (s_cc(1) - s_cc(0)), " grid cells away"
514+
print *, "Levelset ", dist, " and Norm: ", norm(:)
515+
print *, "A short term fix may include increasing buff_size further in m_helper_basic (currently set to a minimum of 10)"
516+
error stop "Ghost Point and Image Point on Different Processors"
511517
end if
512518
end do
513519
ghost_points_in(q)%ip_grid(dim) = index

0 commit comments

Comments
 (0)