276 subroutine les_model_compute_delta(this)
277 class(les_model_t),
intent(inout) :: this
278 integer :: e, i, j, k
279 integer :: im, ip, jm, jp, km, kp
280 real(kind=rp) :: di, dj, dk, ndim_inv, volume_element
281 integer :: lx_half, ly_half, lz_half
282 character(len=:),
allocatable :: type_string
284 lx_half = this%coef%Xh%lx / 2
285 ly_half = this%coef%Xh%ly / 2
286 lz_half = this%coef%Xh%lz / 2
288 if (this%delta_type .eq.
"elementwise_max")
then
291 do e = 1, this%coef%msh%nelv
292 di = (this%coef%dof%x(lx_half, 1, 1, e) &
293 - this%coef%dof%x(lx_half + 1, 1, 1, e))**2 &
294 + (this%coef%dof%y(lx_half, 1, 1, e) &
295 - this%coef%dof%y(lx_half + 1, 1, 1, e))**2 &
296 + (this%coef%dof%z(lx_half, 1, 1, e) &
297 - this%coef%dof%z(lx_half + 1, 1, 1, e))**2
299 dj = (this%coef%dof%x(1, ly_half, 1, e) &
300 - this%coef%dof%x(1, ly_half + 1, 1, e))**2 &
301 + (this%coef%dof%y(1, ly_half, 1, e) &
302 - this%coef%dof%y(1, ly_half + 1, 1, e))**2 &
303 + (this%coef%dof%z(1, ly_half, 1, e) &
304 - this%coef%dof%z(1, ly_half + 1, 1, e))**2
306 dk = (this%coef%dof%x(1, 1, lz_half, e) &
307 - this%coef%dof%x(1, 1, lz_half + 1, e))**2 &
308 + (this%coef%dof%y(1, 1, lz_half, e) &
309 - this%coef%dof%y(1, 1, lz_half + 1, e))**2 &
310 + (this%coef%dof%z(1, 1, lz_half, e) &
311 - this%coef%dof%z(1, 1, lz_half + 1, e))**2
315 this%delta%x(:,:,:,e) = (di * dj * dk)**(1.0_rp / 3.0_rp)
317 else if (this%delta_type .eq.
"elementwise_average")
then
320 do e = 1, this%coef%msh%nelv
321 volume_element = 0.0_rp
322 do k = 1, this%coef%Xh%lx * this%coef%Xh%ly * this%coef%Xh%lz
323 volume_element = volume_element + this%coef%B(k, 1, 1, e)
325 this%delta%x(:,:,:,e) = (volume_element / &
326 (this%coef%Xh%lx - 1.0_rp) / &
327 (this%coef%Xh%ly - 1.0_rp) / &
328 (this%coef%Xh%lz - 1.0_rp) ) ** (1.0_rp / 3.0_rp)
330 else if (this%delta_type .eq.
"pointwise")
then
331 do e = 1, this%coef%msh%nelv
332 do k = 1, this%coef%Xh%lz
334 kp = min(this%coef%Xh%lz, k+1)
336 do j = 1, this%coef%Xh%ly
338 jp = min(this%coef%Xh%ly, j+1)
340 do i = 1, this%coef%Xh%lx
342 ip = min(this%coef%Xh%lx, i+1)
344 di = (this%coef%dof%x(ip, j, k, e) - &
345 this%coef%dof%x(im, j, k, e))**2 &
346 + (this%coef%dof%y(ip, j, k, e) - &
347 this%coef%dof%y(im, j, k, e))**2 &
348 + (this%coef%dof%z(ip, j, k, e) - &
349 this%coef%dof%z(im, j, k, e))**2
351 dj = (this%coef%dof%x(i, jp, k, e) - &
352 this%coef%dof%x(i, jm, k, e))**2 &
353 + (this%coef%dof%y(i, jp, k, e) - &
354 this%coef%dof%y(i, jm, k, e))**2 &
355 + (this%coef%dof%z(i, jp, k, e) - &
356 this%coef%dof%z(i, jm, k, e))**2
358 dk = (this%coef%dof%x(i, j, kp, e) - &
359 this%coef%dof%x(i, j, km, e))**2 &
360 + (this%coef%dof%y(i, j, kp, e) - &
361 this%coef%dof%y(i, j, km, e))**2 &
362 + (this%coef%dof%z(i, j, kp, e) - &
363 this%coef%dof%z(i, j, km, e))**2
365 di = sqrt(di) / (ip - im)
366 dj = sqrt(dj) / (jp - jm)
367 dk = sqrt(dk) / (kp - km)
368 this%delta%x(i,j,k,e) = (di * dj * dk)**(1.0_rp / 3.0_rp)
375 call neko_type_error(
"delta_type for LES model", &
376 this%delta_type, delta_known_types)
380 if (neko_bcknd_device .eq. 1)
then
381 call device_memcpy(this%delta%x, this%delta%x_d, this%delta%dof%size(),&
382 host_to_device, sync = .false.)
383 call this%coef%gs_h%op(this%delta%x, this%delta%dof%size(), gs_op_add)
384 call device_col2(this%delta%x_d, this%coef%mult_d, this%delta%dof%size())
386 call this%coef%gs_h%op(this%delta%x, this%delta%dof%size(), gs_op_add)
387 call col2(this%delta%x, this%coef%mult, this%delta%dof%size())