269 zone_name, center, scale, coef, long_print, center_type)
271 character(len=*),
intent(in) :: name
272 real(kind=
rp),
intent(in) :: center(3)
273 real(kind=
rp),
intent(in) :: scale
274 character(len=*),
intent(in) :: fluid_name
275 character(len=*),
intent(in) :: zone_name
276 integer,
intent(in) :: zone_id
277 type(
coef_t),
target,
intent(in) :: coef
278 logical,
intent(in) :: long_print
279 character(len=*),
intent(in),
optional :: center_type
280 character(len=:),
allocatable :: ctype_str
281 integer :: n_pts, glb_n_pts, ierr
282 real(kind=
rp) :: avg_r(3)
283 character(len=1000) :: log_buf
286 this%zone_id = zone_id
288 this%zone_name = zone_name
290 if (
present(center_type))
then
291 ctype_str = center_type
296 call this%ale_link(zone_id, ctype_str, center)
298 if (ctype_str /=
'fixed' .and. .not. this%moving_center)
then
299 ctype_str =
'fixed (reverted from ' // ctype_str //
')'
303 if (.not. this%moving_center)
then
309 this%print_format =
'(I7,E20.10,E20.10,E20.10,E20.10,A)'
311 this%print_format =
'(I7,E13.5,E13.5,E13.5,E13.5,A)'
318 this%mu =>
neko_registry%get_field_by_name(fluid_name //
'_mu_tot')
321 call this%bc%init_base(this%coef)
322 call this%bc%mark_zone(this%case%msh%labeled_zones(this%zone_id))
323 call this%bc%finalize()
324 n_pts = this%bc%msk(0)
325 if (n_pts .gt. 0)
then
326 call this%n1%init(n_pts)
327 call this%n2%init(n_pts)
328 call this%n3%init(n_pts)
329 call this%r1%init(n_pts)
330 call this%r2%init(n_pts)
331 call this%r3%init(n_pts)
332 call this%force1%init(n_pts)
333 call this%force2%init(n_pts)
334 call this%force3%init(n_pts)
335 call this%force4%init(n_pts)
336 call this%force5%init(n_pts)
337 call this%force6%init(n_pts)
338 call this%s11msk%init(n_pts)
339 call this%s22msk%init(n_pts)
340 call this%s33msk%init(n_pts)
341 call this%s12msk%init(n_pts)
342 call this%s13msk%init(n_pts)
343 call this%s23msk%init(n_pts)
344 call this%pmsk%init(n_pts)
345 call this%mu_msk%init(n_pts)
349 this%n1%x, this%n2%x, this%n3%x, n_pts)
351 this%u%size(), n_pts)
353 this%u%size(), n_pts)
355 this%u%size(), n_pts)
357 call mpi_allreduce(n_pts, glb_n_pts, 1, &
360 avg_r(1) =
glsum(this%r1%x, n_pts)/glb_n_pts
361 avg_r(2) =
glsum(this%r2%x, n_pts)/glb_n_pts
362 avg_r(3) =
glsum(this%r3%x, n_pts)/glb_n_pts
364 call neko_log%section(
'Force/torque calculation')
365 write(log_buf,
'(A,I4,A,A)')
'Zone ', zone_id,
' ', trim(zone_name)
368 write(log_buf,
'(A,I6, I6)')
'Global number of GLL points in zone: ', &
372 write(log_buf,
'(A,A)')
'Center Type: ', trim(ctype_str)
375 if (trim(ctype_str) ==
'pivot' .or. &
376 trim(ctype_str) ==
'body_attached')
then
377 write(log_buf,
'(A,A)')
'Linked to ALE Body movement: ', &
378 trim(this%linked_body_name)
380 write(log_buf,
'(A,E15.7,E15.7,E15.7)') &
381 'Initial center for torque calculation: ', this%center
384 write(log_buf,
'(A,E15.7,E15.7,E15.7)') &
385 'Fixed center for torque calculation: ', this%center
389 write(log_buf,
'(A,E15.7,E15.7,E15.7)') &
390 'Average of zone''s coordinates: ', avg_r
393 write(log_buf,
'(A,E15.7)')
'Scale: ', scale
398 call cadd(this%r1%x, -this%center(1), n_pts)
399 call cadd(this%r2%x, -this%center(2), n_pts)
400 call cadd(this%r3%x, -this%center(3), n_pts)
463 real(kind=
rp) :: dgtq(12) = 0.0_rp
464 integer :: n_pts, temp_indices(6)
465 type(
field_t),
pointer :: s11, s22, s33, s12, s13, s23
466 character(len=1000) :: log_buf
467 real(kind=
rp) :: rot_offset(3)
468 n_pts = this%bc%msk(0)
472 if (this%moving_center .and.
associated(this%body_P))
then
473 if (
associated(this%body_R))
then
475 rot_offset(1) = this%body_R(1,1)*this%local_offset(1) + &
476 this%body_R(1,2)*this%local_offset(2) + &
477 this%body_R(1,3)*this%local_offset(3)
478 rot_offset(2) = this%body_R(2,1)*this%local_offset(1) + &
479 this%body_R(2,2)*this%local_offset(2) + &
480 this%body_R(2,3)*this%local_offset(3)
481 rot_offset(3) = this%body_R(3,1)*this%local_offset(1) + &
482 this%body_R(3,2)*this%local_offset(2) + &
483 this%body_R(3,3)*this%local_offset(3)
485 this%center = this%body_P + rot_offset
489 if (this%update_normals)
then
492 this%n1%x, this%n2%x, this%n3%x, n_pts)
495 this%u%size(), n_pts)
497 this%u%size(), n_pts)
499 this%u%size(), n_pts)
501 call cadd(this%r1%x, -this%center(1), n_pts)
502 call cadd(this%r2%x, -this%center(2), n_pts)
503 call cadd(this%r3%x, -this%center(3), n_pts)
529 s13%x, s23%x, this%u, this%v, this%w, this%coef)
534 this%u%size(), n_pts)
536 this%u%size(), n_pts)
538 this%u%size(), n_pts)
540 this%u%size(), n_pts)
542 this%u%size(), n_pts)
544 this%u%size(), n_pts)
546 this%u%size(), n_pts)
548 this%u%size(), n_pts)
550 this%force4%x, this%force5%x, this%force6%x, &
563 dgtq(1) =
glsum(this%force1%x, n_pts)
564 dgtq(2) =
glsum(this%force2%x, n_pts)
565 dgtq(3) =
glsum(this%force3%x, n_pts)
566 dgtq(4) =
glsum(this%force4%x, n_pts)
567 dgtq(5) =
glsum(this%force5%x, n_pts)
568 dgtq(6) =
glsum(this%force6%x, n_pts)
569 call vcross(this%s11msk%x, this%s22msk%x, this%s33msk%x, &
570 this%r1%x, this%r2%x, this%r3%x, &
571 this%force1%x, this%force2%x, this%force3%x, n_pts)
573 dgtq(7) =
glsum(this%s11msk%x, n_pts)
574 dgtq(8) =
glsum(this%s22msk%x, n_pts)
575 dgtq(9) =
glsum(this%s33msk%x, n_pts)
576 call vcross(this%s11msk%x, this%s22msk%x, this%s33msk%x, &
577 this%r1%x, this%r2%x, this%r3%x, &
578 this%force4%x, this%force5%x, this%force6%x, n_pts)
579 dgtq(10) =
glsum(this%s11msk%x, n_pts)
580 dgtq(11) =
glsum(this%s22msk%x, n_pts)
581 dgtq(12) =
glsum(this%s33msk%x, n_pts)
583 if (n_pts .gt. 0)
then
585 this%bc%msk_d, this%u%size(), n_pts)
587 this%bc%msk_d, this%u%size(), n_pts)
589 this%bc%msk_d, this%u%size(), n_pts)
591 this%bc%msk_d, this%u%size(), n_pts)
593 this%bc%msk_d, this%u%size(), n_pts)
595 this%bc%msk_d, this%u%size(), n_pts)
597 this%bc%msk_d, this%u%size(), n_pts)
599 this%bc%msk_d, this%u%size(), n_pts)
621 this%r1%x_d, this%r2%x_d, this%r3%x_d, &
622 this%force1%x_d, this%force2%x_d, &
623 this%force3%x_d, n_pts)
624 call device_vcross(this%s12msk%x_d, this%s13msk%x_d, this%s23msk%x_d,&
625 this%r1%x_d, this%r2%x_d, this%r3%x_d, &
626 this%force4%x_d, this%force5%x_d, this%force6%x_d, n_pts)
641 dgtq = this%scale*dgtq
642 write(log_buf,
'(A, I4, A, A)')
'Force and torque on zone ', &
643 this%zone_id,
' ', this%zone_name
645 write(log_buf,
'(A)') &
646 'Time step, time, total force/torque, pressure, viscous, direction'
648 write(log_buf, this%print_format) &
649 time%tstep, time%t, dgtq(1) + dgtq(4), dgtq(1), dgtq(4),
', forcex'
651 write(log_buf, this%print_format) &
652 time%tstep, time%t, dgtq(2) + dgtq(5), dgtq(2), dgtq(5),
', forcey'
654 write(log_buf, this%print_format) &
655 time%tstep, time%t, dgtq(3) + dgtq(6), dgtq(3), dgtq(6),
', forcez'
657 write(log_buf, this%print_format) &
658 time%tstep, time%t, dgtq(7) + dgtq(10), dgtq(7), dgtq(10),
', torquex'
660 write(log_buf, this%print_format) &
661 time%tstep, time%t, dgtq(8) + dgtq(11), dgtq(8), dgtq(11),
', torquey'
663 write(log_buf, this%print_format) &
664 time%tstep, time%t, dgtq(9) + dgtq(12), dgtq(9), dgtq(12),
', torquez'