51 use mpi_f08,
only : mpi_wtime, mpi_barrier
53 use,
intrinsic :: iso_c_binding, only : c_ptr, c_int, c_null_ptr
62 type,
bind(c) :: kinematics_params_t
64 real(
c_rp) :: vtx, vty, vtz
65 real(
c_rp) :: vax, vay, vaz
67 real(
c_rp) :: r11, r12, r13
68 real(
c_rp) :: r21, r22, r23
69 real(
c_rp) :: r31, r32, r33
75 x_ref, y_ref, z_ref, phi, x, y, z, &
76 kin_params, n)
bind(c, name="add_kinematics_to_mesh_velocity_hip")
77 use,
intrinsic :: iso_c_binding
79 type(c_ptr),
value :: wx, wy, wz, x_ref, y_ref, z_ref, phi, x, y, z
81 integer(c_int),
value :: n
85 local_iters, nchange_d)
bind(c, name="compute_cheap_dist_hip")
86 use,
intrinsic :: iso_c_binding
87 type(c_ptr),
value :: d_d, x_d, y_d, z_d, nchange_d
88 integer(c_int),
value :: lx, ly, lz, nel, local_iters
94 x_ref, y_ref, z_ref, phi, x, y, z, &
95 kin_params, n)
bind(c, name="add_kinematics_to_mesh_velocity_cuda")
96 use,
intrinsic :: iso_c_binding
98 type(c_ptr),
value :: wx, wy, wz, x_ref, y_ref, z_ref, phi, x, y, z
100 integer(c_int),
value :: n
104 local_iters, nchange_d)
bind(c, name="compute_cheap_dist_cuda")
105 use,
intrinsic :: iso_c_binding
106 type(c_ptr),
value :: d_d, x_d, y_d, z_d, nchange_d
107 integer(c_int),
value :: lx, ly, lz, nel, local_iters
117 type(field_t),
intent(inout) :: dist_field
118 type(coef_t),
intent(in) :: coef
119 type(mesh_t),
intent(in) :: msh
120 type(zero_dirichlet_t) :: bc_wall
121 integer,
intent(in) :: zone_indices(:)
122 logical,
intent(in) :: copy_to_host
123 integer :: i, k, n, m, idx
124 integer :: ipass, max_pass, local_iters
125 integer :: lx, ly, lz, nel, z_idx
126 integer,
target :: change_vec(1)
128 character(len=LOG_SIZE) :: log_buf
129 type(c_ptr) :: nchange_d
131 nchange_d = c_null_ptr
141 local_iters = lx + ly + lz
143 call cfill(dist_field%x, huge(0.0_rp), n)
145 if (
size(zone_indices) .gt. 0)
then
146 call bc_wall%init_from_components(coef)
147 do k = 1,
size(zone_indices)
148 z_idx = zone_indices(k)
149 call bc_wall%mark_zone(msh%labeled_zones(z_idx))
151 call bc_wall%finalize()
155 dist_field%x(idx, 1, 1, 1) = 0.0_rp
160 call device_map(change_vec, nchange_d, 1)
161 call dist_field%copy_from(host_to_device, sync = .true.)
166 do while ((ipass .le. max_pass) .and. .not. done)
169 call device_memcpy(change_vec, nchange_d, 1, host_to_device, .true.)
173 coef%dof%x_d, coef%dof%y_d, coef%dof%z_d, &
174 lx, ly, lz, nel, local_iters, nchange_d)
177 coef%dof%x_d, coef%dof%y_d, coef%dof%z_d, &
178 lx, ly, lz, nel, local_iters, nchange_d)
181 call device_memcpy(change_vec, nchange_d, 1, device_to_host, .true.)
183 call coef%gs_h%gs_op_vector(dist_field%x, n, gs_op_min)
185 if (glimax(change_vec, 1) .eq. 0) done = .true.
189 call device_unmap(change_vec, nchange_d)
191 if (copy_to_host)
then
192 call dist_field%copy_from(device_to_host, sync = .true.)
196 write(log_buf,
'(A, I0, A)')
" converged in: ", ipass,
" passes"
197 call neko_log%message(log_buf)
199 write(log_buf,
'(A, I0, A)')
" reached max passes: ", ipass, &
200 " without convergence"
201 call neko_log%message(log_buf)
208 x_ref, y_ref, z_ref, phi, coef, kinematics, rot_mat, inital_pivot_loc)
209 type(field_t),
intent(inout) :: wx, wy, wz
210 type(field_t),
intent(in) :: x_ref, y_ref, z_ref
211 type(field_t),
intent(in) :: phi
212 type(coef_t),
intent(in) :: coef
213 type(body_kinematics_t),
intent(in) :: kinematics
214 real(kind=rp),
intent(in) :: inital_pivot_loc(3)
215 real(kind=rp),
intent(in) :: rot_mat(3,3)
216 integer(c_int),
target :: n
221 kin_params%cx = kinematics%center(1)
222 kin_params%cy = kinematics%center(2)
223 kin_params%cz = kinematics%center(3)
224 kin_params%vtx = kinematics%vel_trans(1)
225 kin_params%vty = kinematics%vel_trans(2)
226 kin_params%vtz = kinematics%vel_trans(3)
227 kin_params%vax = kinematics%vel_ang(1)
228 kin_params%vay = kinematics%vel_ang(2)
229 kin_params%vaz = kinematics%vel_ang(3)
230 kin_params%px = inital_pivot_loc(1)
231 kin_params%py = inital_pivot_loc(2)
232 kin_params%pz = inital_pivot_loc(3)
233 kin_params%r11 = rot_mat(1,1)
234 kin_params%r12 = rot_mat(1,2)
235 kin_params%r13 = rot_mat(1,3)
236 kin_params%r21 = rot_mat(2,1)
237 kin_params%r22 = rot_mat(2,2)
238 kin_params%r23 = rot_mat(2,3)
239 kin_params%r31 = rot_mat(3,1)
240 kin_params%r32 = rot_mat(3,2)
241 kin_params%r33 = rot_mat(3,3)
245 wx%x_d, wy%x_d, wz%x_d, &
246 x_ref%x_d, y_ref%x_d, z_ref%x_d, &
247 phi%x_d, coef%dof%x_d, coef%dof%y_d, coef%dof%z_d, &
251 wx%x_d, wy%x_d, wz%x_d, &
252 x_ref%x_d, y_ref%x_d, z_ref%x_d, &
253 phi%x_d, coef%dof%x_d, coef%dof%y_d, coef%dof%z_d, &
256 call neko_error(
"ALE: add_kinematics_to_mesh_velocity_device " // &
257 "supports only HIP or CUDA backends")
265 wm_y_lag, wm_z_lag, time, nadv, scheme_type)
267 type(coef_t),
intent(inout) :: c_xh
268 type(field_t),
intent(in) :: wm_x, wm_y, wm_z
269 type(field_series_t),
intent(in) :: wm_x_lag, wm_y_lag, wm_z_lag
270 type(time_state_t),
intent(in) :: time
271 type(ab_time_scheme_t) :: ab_scheme_obj
272 integer,
intent(in) :: nadv
274 character(len=*),
intent(in) :: scheme_type
275 real(kind=rp) :: ab_coeffs(4), dt_history(10), factor
277 call rzero(ab_coeffs, 4)
278 if (trim(scheme_type) .eq.
'ab')
then
279 dt_history(1) = time%dt
280 dt_history(2) = time%dtlag(1)
281 dt_history(3) = time%dtlag(2)
282 call ab_scheme_obj%compute_coeffs(ab_coeffs, dt_history, nadv)
284 call neko_error(
"ALE: Unknown mesh time-integration scheme")
290 factor = time%dt * ab_coeffs(1)
291 call device_add2s2(c_xh%dof%x_d, wm_x%x_d, factor, n)
292 call device_add2s2(c_xh%dof%y_d, wm_y%x_d, factor, n)
293 call device_add2s2(c_xh%dof%z_d, wm_z%x_d, factor, n)
297 factor = time%dt * ab_coeffs(j)
298 call device_add2s2(c_xh%dof%x_d, wm_x_lag%lf(j - 1)%x_d, factor, n)
299 call device_add2s2(c_xh%dof%y_d, wm_y_lag%lf(j - 1)%x_d, factor, n)
300 call device_add2s2(c_xh%dof%z_d, wm_z_lag%lf(j - 1)%x_d, factor, n)
void compute_cheap_dist_cuda(void *d_d, void *x_d, void *y_d, void *z_d, int lx, int ly, int lz, int nel, int local_iters, void *nchange_d)
void add_kinematics_to_mesh_velocity_cuda(void *wx, void *wy, void *wz, void *x_ref, void *y_ref, void *z_ref, void *phi, void *x, void *y, void *z, kinematics_params_t kin_params, int n)
Map a Fortran array to a device (allocate and associate)
Copy data between host and device (or device and device)
Unmap a Fortran array from a device (deassociate and free)
Adam-Bashforth scheme for time integration.
Defines data structures and algorithms for configuring, calculating, and time-integrating the rigid-b...
subroutine, public add_kinematics_to_mesh_velocity_device(wx, wy, wz, x_ref, y_ref, z_ref, phi, coef, kinematics, rot_mat, inital_pivot_loc)
Add Kinematics to Mesh Velocity.
subroutine, public compute_cheap_dist_device(dist_field, coef, msh, zone_indices, copy_to_host)
Cheap dist device implementation.
subroutine, public update_ale_mesh_device(c_xh, wm_x, wm_y, wm_z, wm_x_lag, wm_y_lag, wm_z_lag, time, nadv, scheme_type)
Update ALE Mesh.
type(mpi_comm), public neko_comm
MPI communicator.
subroutine, public device_add2s2(a_d, b_d, c1, n, strm)
Vector addition with scalar multiplication (multiplication on first argument)
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
integer, parameter, public device_to_host
Contains the field_serties_t type.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
subroutine, public rzero(a, n)
Zero a real vector.
integer function, public glimax(a, n)
Max of an integer vector of length n.
integer, parameter, public c_rp
integer, parameter, public rp
Global precision used in computations.
Module with things related to the simulation time.
Defines a zero-valued Dirichlet boundary condition.
Explicit Adam-Bashforth scheme for time integration.
Global ALE Configuration.
Calculated Kinematics for a body at current time.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...
A struct that contains all info about the time, expand as needed.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...