61 type(
coef_t),
intent(inout) :: coef
63 integer :: i, n, b, ierr
64 integer,
allocatable :: cheap_map(:)
65 integer :: n_cheap, map_idx
66 real(kind=
rp) :: x, y, z
67 real(kind=
rp) :: raw_dist, body_stiff_val, max_added_stiff
68 real(kind=
rp) :: cx, cy, cz
69 real(kind=
rp) :: arg, decay, gain, norm_dist
70 real(kind=
rp) :: sample_start_time, sample_end_time, sample_time
71 real(kind=
rp),
allocatable :: dist_fields(:,:)
72 character(len=128) :: log_buf
77 allocate(cheap_map(params%nbodies))
81 do b = 1, params%nbodies
82 if (trim(params%bodies(b)%stiff_geom%type) ==
'cheap_dist')
then
84 cheap_map(b) = n_cheap
90 allocate(dist_fields(n, n_cheap))
91 dist_fields = huge(0.0_rp)
93 do b = 1, params%nbodies
94 map_idx = cheap_map(b)
97 call neko_log%message(
" Start: cheap dist calculation " // &
98 "for body '" // trim(params%bodies(b)%name) //
"'")
100 sample_start_time = mpi_wtime()
109 coef%msh, params%bodies(b)%zone_indices)
112 sample_end_time = mpi_wtime()
113 sample_time = sample_end_time - sample_start_time
115 write(log_buf,
'(A, A, A, ES11.4, A)')
" cheap dist for '", &
116 trim(params%bodies(b)%name),
"' took ", sample_time,
" (s)"
124 select case (trim(params%stiffness_type))
127 do concurrent(i = 1:n)
128 x = coef%dof%x(i, 1, 1, 1)
129 y = coef%dof%y(i, 1, 1, 1)
130 z = coef%dof%z(i, 1, 1, 1)
132 max_added_stiff = 0.0_rp
135 do b = 1, params%nbodies
136 gain = params%bodies(b)%stiff_geom%gain
137 if (trim(params%bodies(b)%stiff_geom%type) ==
'cheap_dist')
then
138 decay = params%bodies(b)%stiff_geom%stiff_dist
140 decay = params%bodies(b)%stiff_geom%radius
144 cx = params%bodies(b)%stiff_geom%center(1)
145 cy = params%bodies(b)%stiff_geom%center(2)
146 cz = params%bodies(b)%stiff_geom%center(3)
148 raw_dist = huge(0.0_rp)
151 select case (trim(params%bodies(b)%stiff_geom%type))
154 raw_dist = sqrt((x - cx)**2 + (y - cy)**2 + (z - cz)**2)
159 raw_dist = sqrt((x - cx)**2 + (y - cy)**2)
167 map_idx = cheap_map(b)
168 if (map_idx > 0)
then
169 raw_dist = dist_fields(i, map_idx)
175 body_stiff_val = 0.0_rp
176 select case (trim(params%bodies(b)%stiff_geom%decay_profile))
180 arg = -(raw_dist**2) / (decay**2)
181 arg = arg * params%bodies(b)%stiff_geom%cutoff_coef
182 body_stiff_val = gain * exp(arg)
187 norm_dist = (raw_dist / decay)
188 norm_dist = norm_dist * &
189 params%bodies(b)%stiff_geom%cutoff_coef
190 body_stiff_val = gain * (1.0_rp - tanh(norm_dist))
194 if (body_stiff_val > max_added_stiff)
then
195 max_added_stiff = body_stiff_val
200 coef%h1(i, 1, 1, 1) = 1.0_rp + max_added_stiff
201 coef%h2(i, 1, 1, 1) = 0.0_rp
205 call neko_error(
"ALE Manager: Unknown stiffness type")
209 if (
allocated(dist_fields))
deallocate(dist_fields)
210 if (
allocated(cheap_map))
deallocate(cheap_map)
215 real(kind=
rp),
intent(inout),
target :: d(:)
216 type(
coef_t),
intent(in) :: coef
217 type(
mesh_t),
intent(in) :: msh
219 integer,
intent(in) :: zone_indices(:)
220 real(kind=
rp),
pointer :: d4(:, :, :, :)
221 integer :: i, j, k, e, n
222 integer :: ipass, nchange, max_pass
223 integer :: ii, jj, kk, i0, i1, j0, j1, k0, k1
224 integer :: lx, ly, lz, nel, z_idx
226 real(kind=
rp) :: dtmp, x1, y1, z1, x2, y2, z2
227 integer :: change_vec(1)
235 d4(1:lx, 1:ly, 1:lz, 1:nel) => d
239 call cfill(d, huge(0.0_rp), n)
241 if (
size(zone_indices) > 0)
then
242 call bc_wall%init_from_components(coef)
243 do k = 1,
size(zone_indices)
244 z_idx = zone_indices(k)
245 call bc_wall%mark_zone(msh%labeled_zones(z_idx))
247 call bc_wall%finalize()
258 do while (ipass <= max_pass .and. .not. done)
264 x1 = coef%dof%x(i, j, k, e)
265 y1 = coef%dof%y(i, j, k, e)
266 z1 = coef%dof%z(i, j, k, e)
276 if (ii == i .and. jj == j .and. kk == k) cycle
277 x2 = coef%dof%x(ii, jj, kk, e)
278 y2 = coef%dof%y(ii, jj, kk, e)
279 z2 = coef%dof%z(ii, jj, kk, e)
280 dtmp = d4(ii, jj, kk, e) + &
281 sqrt((x1 - x2)**2 + &
282 (y1 - y2)**2 + (z1 - z2)**2)
283 if (dtmp < d4(i, j, k, e))
then
284 d4(i, j, k, e) = dtmp
285 nchange = nchange + 1
294 call coef%gs_h%gs_op_vector(d, n, gs_op_min)
295 change_vec(1) = nchange
296 if (
glimax(change_vec, 1) == 0) done = .true.
305 real(kind=
rp),
intent(inout),
target :: d(:)
306 type(
coef_t),
intent(in) :: coef
307 type(
mesh_t),
intent(in) :: msh
309 integer,
intent(in) :: zone_indices(:)
310 real(kind=
rp),
pointer :: d4(:, :, :, :)
311 integer :: i, j, k, e, n
312 integer :: ipass, nchange, max_pass
313 integer :: ii, jj, kk, i0, i1, j0, j1, k0, k1
314 integer :: lx, ly, lz, nel, z_idx
315 integer :: m, idx, iter, local_iters
316 real(kind=
rp) :: dtmp, x1, y1, z1, x2, y2, z2
317 integer :: change_vec(1)
318 logical :: done, changed_local, element_changed_ever
319 character(len=128) :: log_buf
326 d4(1:lx, 1:ly, 1:lz, 1:nel) => d
331 local_iters = lx + ly + lz
333 call cfill(d, huge(0.0_rp), n)
335 if (
size(zone_indices) > 0)
then
336 call bc_wall%init_from_components(coef)
337 do k = 1,
size(zone_indices)
338 z_idx = zone_indices(k)
339 call bc_wall%mark_zone(msh%labeled_zones(z_idx))
341 call bc_wall%finalize()
352 do while (ipass <= max_pass .and. .not. done)
357 element_changed_ever = .false.
358 changed_local = .true.
359 do while (changed_local .and. iter <= local_iters)
361 changed_local = .false.
365 x1 = coef%dof%x(i, j, k, e)
366 y1 = coef%dof%y(i, j, k, e)
367 z1 = coef%dof%z(i, j, k, e)
377 if (ii == i .and. jj == j .and. kk == k) cycle
379 x2 = coef%dof%x(ii, jj, kk, e)
380 y2 = coef%dof%y(ii, jj, kk, e)
381 z2 = coef%dof%z(ii, jj, kk, e)
383 dtmp = d4(ii, jj, kk, e) + &
384 sqrt((x1 - x2)**2 + &
385 (y1 - y2)**2 + (z1 - z2)**2)
387 if (dtmp < d4(i, j, k, e))
then
388 d4(i, j, k, e) = dtmp
389 changed_local = .true.
398 if (changed_local) element_changed_ever = .true.
402 if (element_changed_ever) nchange = nchange + 1
405 call coef%gs_h%gs_op_vector(d, n, gs_op_min)
406 change_vec(1) = nchange
408 if (
glimax(change_vec, 1) == 0) done = .true.
412 write(log_buf,
'(A, I0, A)')
" converged in: ", ipass,
" passes"
419 x_ref, y_ref, z_ref, phi, coef, kinematics, rot_mat, inital_pivot_loc)
420 type(
field_t),
intent(inout) :: wx, wy, wz
421 type(
field_t),
intent(in) :: x_ref, y_ref, z_ref
422 type(
field_t),
intent(in) :: phi
423 type(
coef_t),
intent(in) :: coef
425 real(kind=
rp),
intent(in) :: inital_pivot_loc(3)
426 real(kind=
rp),
intent(in) :: rot_mat(3,3)
428 real(kind=
rp) :: rx, ry, rz
429 real(kind=
rp) :: v_tan_x, v_tan_y, v_tan_z
430 real(kind=
rp) :: dx_ref, dy_ref, dz_ref
431 real(kind=
rp) :: rx_target, ry_target, rz_target
432 real(kind=
rp) :: p_val
434 associate(x => coef%dof%x, y => coef%dof%y, z => coef%dof%z)
435 do concurrent(i = 1:n)
439 if ( abs(phi%x(i, 1, 1, 1) - 1.0_rp) < 1e-6_rp )
then
441 rx = x(i, 1, 1, 1) - kinematics%center(1)
442 ry = y(i, 1, 1, 1) - kinematics%center(2)
443 rz = z(i, 1, 1, 1) - kinematics%center(3)
444 v_tan_x = kinematics%vel_ang(2) * rz - kinematics%vel_ang(3) * ry
445 v_tan_y = kinematics%vel_ang(3) * rx - kinematics%vel_ang(1) * rz
446 v_tan_z = kinematics%vel_ang(1) * ry - kinematics%vel_ang(2) * rx
447 wx%x(i, 1, 1, 1) = wx%x(i, 1, 1, 1) + &
448 (kinematics%vel_trans(1) + v_tan_x) * phi%x(i, 1, 1, 1)
449 wy%x(i, 1, 1, 1) = wy%x(i, 1, 1, 1) + &
450 (kinematics%vel_trans(2) + v_tan_y) * phi%x(i, 1, 1, 1)
451 wz%x(i, 1, 1, 1) = wz%x(i, 1, 1, 1) + &
452 (kinematics%vel_trans(3) + v_tan_z) * phi%x(i, 1, 1, 1)
457 dx_ref = x_ref%x(i, 1, 1, 1) - inital_pivot_loc(1)
458 dy_ref = y_ref%x(i, 1, 1, 1) - inital_pivot_loc(2)
459 dz_ref = z_ref%x(i, 1, 1, 1) - inital_pivot_loc(3)
463 rx_target = rot_mat(1,1)*dx_ref + rot_mat(1,2)*dy_ref + &
465 ry_target = rot_mat(2,1)*dx_ref + rot_mat(2,2)*dy_ref + &
467 rz_target = rot_mat(3,1)*dx_ref + rot_mat(3,2)*dy_ref + &
472 v_tan_x = kinematics%vel_ang(2) * rz_target - &
473 kinematics%vel_ang(3) * ry_target
474 v_tan_y = kinematics%vel_ang(3) * rx_target - &
475 kinematics%vel_ang(1) * rz_target
476 v_tan_z = kinematics%vel_ang(1) * ry_target - &
477 kinematics%vel_ang(2) * rx_target
479 p_val = phi%x(i, 1, 1, 1)
482 wx%x(i, 1, 1, 1) = wx%x(i, 1, 1, 1) + &
483 (kinematics%vel_trans(1) + v_tan_x) * p_val
484 wy%x(i, 1, 1, 1) = wy%x(i, 1, 1, 1) + &
485 (kinematics%vel_trans(2) + v_tan_y) * p_val
486 wz%x(i, 1, 1, 1) = wz%x(i, 1, 1, 1) + &
487 (kinematics%vel_trans(3) + v_tan_z) * p_val
496 wm_z_lag, time, nadv, scheme_type)
497 type(coef_t),
intent(inout) :: c_xh
498 type(field_t),
intent(in) :: wm_x, wm_y, wm_z
499 type(field_series_t),
intent(in) :: wm_x_lag, wm_y_lag, wm_z_lag
500 type(time_state_t),
intent(in) :: time
501 type(ab_time_scheme_t) :: ab_scheme_obj
502 integer,
intent(in) :: nadv
504 character(len=*),
intent(in) :: scheme_type
505 real(kind=rp) :: ab_coeffs(4), dt_history(10)
507 call rzero(ab_coeffs, 4)
508 if (trim(scheme_type) .eq.
'ab')
then
509 dt_history(1) = time%dt
510 dt_history(2) = time%dtlag(1)
511 dt_history(3) = time%dtlag(2)
512 call ab_scheme_obj%compute_coeffs(ab_coeffs, dt_history, nadv)
514 call neko_error(
"ALE: Unknown mesh time-integration scheme")
519 do concurrent(i = 1:n)
520 c_xh%dof%x(i, 1, 1, 1) = c_xh%dof%x(i, 1, 1, 1) + &
521 time%dt * ab_coeffs(1) * wm_x%x(i, 1, 1, 1)
522 c_xh%dof%y(i, 1, 1, 1) = c_xh%dof%y(i, 1, 1, 1) + &
523 time%dt * ab_coeffs(1) * wm_y%x(i, 1, 1, 1)
524 c_xh%dof%z(i, 1, 1, 1) = c_xh%dof%z(i, 1, 1, 1) + &
525 time%dt * ab_coeffs(1) * wm_z%x(i, 1, 1, 1)
528 c_xh%dof%x(i, 1, 1, 1) = c_xh%dof%x(i, 1, 1, 1) + &
529 time%dt * ab_coeffs(j) * wm_x_lag%lf(j - 1)%x(i, 1, 1, 1)
530 c_xh%dof%y(i, 1, 1, 1) = c_xh%dof%y(i, 1, 1, 1) + &
531 time%dt * ab_coeffs(j) * wm_y_lag%lf(j - 1)%x(i, 1, 1, 1)
532 c_xh%dof%z(i, 1, 1, 1) = c_xh%dof%z(i, 1, 1, 1) + &
533 time%dt * ab_coeffs(j) * wm_z_lag%lf(j - 1)%x(i, 1, 1, 1)