Skip to content

Commit a326b65

Browse files
authored
Merge pull request #3066 from deslaughter/fastfarm_kdtree
Use k-d tree to speed up wake application to high-res grid in AWAE
2 parents 51c9b6c + 4910756 commit a326b65

File tree

12 files changed

+2826
-1618
lines changed

12 files changed

+2826
-1618
lines changed

glue-codes/fast-farm/src/FAST_Farm_IO_Params.f90

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9618,14 +9618,20 @@ MODULE FAST_Farm_IO_Params
96189618
contains
96199619

96209620
! --- Functions not automatically generated
9621-
logical function PointInAABB(x, y, z, x0, y0, z0, x1, y1, z1)
9622-
real(ReKi), intent(in) :: x,y,z,x0,y0,z0,x1,y1,z1
9621+
logical function PointInAABB(x, y, z, minXYZ, sizeXYZ)
9622+
real(ReKi), intent(in) :: x,y,z
9623+
real(ReKi), intent(in) :: minXYZ(3), sizeXYZ(3)
9624+
9625+
! Default to false
9626+
PointInAABB = .false.
96239627

9624-
! default to return false
9625-
PointInAABB = .false.;
9626-
!Check if the point is less than max and greater than min
9627-
if (x >= x0 .and. x <= x1 .and. y >= y0 .and. y <= y1 .and. z >= z0 .and. z <= z1) PointInAABB = .true.;
9628+
! If point is outside box, return false
9629+
if (x < minXYZ(1) .or. x > minXYZ(1) + sizeXYZ(1)) return
9630+
if (y < minXYZ(2) .or. y > minXYZ(2) + sizeXYZ(2)) return
9631+
if (z < minXYZ(3) .or. z > minXYZ(3) + sizeXYZ(3)) return
96289632

9633+
! If we reach here, the point is inside the AABB
9634+
PointInAABB = .true.
96299635

96309636
end function PointInAABB
96319637

@@ -15504,7 +15510,8 @@ SUBROUTINE Farm_SetOutParam(OutList, farm, ErrStat, ErrMsg )
1550415510

1550515511
! Add checks for the WindVel locations based on knowledge of the wind grids and NWindVel
1550615512
do i = 1, farm%p%NWindVel
15507-
if (.not. PointInAABB(farm%p%WindVelX(i), farm%p%WindVelY(i), farm%p%WindVelZ(i), farm%AWAE%p%X0_low, farm%AWAE%p%Y0_low,farm%AWAE%p%Z0_low, farm%AWAE%p%X0_low+(farm%AWAE%p%nX_low-1)*farm%AWAE%p%dX_low, farm%AWAE%p%Y0_low+(farm%AWAE%p%nY_low-1)*farm%AWAE%p%dY_low, farm%AWAE%p%Z0_low+(farm%AWAE%p%nZ_low-1)*farm%AWAE%p%dZ_low) ) then
15513+
if (.not. PointInAABB(farm%p%WindVelX(i), farm%p%WindVelY(i), farm%p%WindVelZ(i), &
15514+
farm%AWAE%p%LowRes%oXYZ, farm%AWAE%p%LowRes%Size)) then
1550815515
InvalidOutput( WVAmbX (i) ) = .true.
1550915516
InvalidOutput( WVAmbY (i) ) = .true.
1551015517
InvalidOutput( WVAmbZ (i) ) = .true.

glue-codes/fast-farm/src/FAST_Farm_Subs.f90

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,15 @@ SUBROUTINE Farm_Initialize( farm, InputFile, ErrStat, ErrMsg )
245245

246246
farm%AWAE%IsInitialized = .true.
247247

248-
farm%p%X0_Low = AWAE_InitOutput%X0_Low
249-
farm%p%Y0_low = AWAE_InitOutput%Y0_low
250-
farm%p%Z0_low = AWAE_InitOutput%Z0_low
251-
farm%p%nX_Low = AWAE_InitOutput%nX_Low
252-
farm%p%nY_low = AWAE_InitOutput%nY_low
253-
farm%p%nZ_low = AWAE_InitOutput%nZ_low
254-
farm%p%dX_low = AWAE_InitOutput%dX_low
255-
farm%p%dY_low = AWAE_InitOutput%dY_low
256-
farm%p%dZ_low = AWAE_InitOutput%dZ_low
248+
farm%p%X0_Low = AWAE_InitOutput%oXYZ_Low(1)
249+
farm%p%Y0_low = AWAE_InitOutput%oXYZ_Low(2)
250+
farm%p%Z0_low = AWAE_InitOutput%oXYZ_Low(3)
251+
farm%p%nX_Low = AWAE_InitOutput%nXYZ_Low(1)
252+
farm%p%nY_low = AWAE_InitOutput%nXYZ_Low(2)
253+
farm%p%nZ_low = AWAE_InitOutput%nXYZ_Low(3)
254+
farm%p%dX_low = AWAE_InitOutput%dXYZ_Low(1)
255+
farm%p%dY_low = AWAE_InitOutput%dXYZ_Low(2)
256+
farm%p%dZ_low = AWAE_InitOutput%dXYZ_Low(3)
257257
farm%p%Module_Ver( ModuleFF_AWAE ) = AWAE_InitOutput%Ver
258258

259259
!-------------------
@@ -653,10 +653,6 @@ SUBROUTINE Farm_InitFAST( farm, WD_InitInp, AWAE_InitOutput, ErrStat, ErrMsg )
653653
FWrap_InitInp%tmax = farm%p%TMax
654654
FWrap_InitInp%n_high_low = farm%p%n_high_low + 1 ! Add 1 because the FAST wrapper uses an index that starts at 1
655655
FWrap_InitInp%dt_high = farm%p%dt_high
656-
657-
FWrap_InitInp%nX_high = AWAE_InitOutput%nX_high
658-
FWrap_InitInp%nY_high = AWAE_InitOutput%nY_high
659-
FWrap_InitInp%nZ_high = AWAE_InitOutput%nZ_high
660656

661657
if (farm%p%MooringMod > 0) then
662658
FWrap_Interval = farm%p%dt_mooring ! when there is a farm-level mooring model, FASTWrapper will be called at the mooring coupling time step
@@ -676,14 +672,17 @@ SUBROUTINE Farm_InitFAST( farm, WD_InitInp, AWAE_InitOutput, ErrStat, ErrMsg )
676672
FWrap_InitInp%TurbNum = nt
677673
FWrap_InitInp%RootName = trim(farm%p%OutFileRoot)//'.T'//num2lstr(nt)
678674

679-
680-
FWrap_InitInp%p_ref_high(1) = AWAE_InitOutput%X0_high(nt)
681-
FWrap_InitInp%p_ref_high(2) = AWAE_InitOutput%Y0_high(nt)
682-
FWrap_InitInp%p_ref_high(3) = AWAE_InitOutput%Z0_high(nt)
675+
FWrap_InitInp%nX_high = AWAE_InitOutput%nXYZ_high(1,nt)
676+
FWrap_InitInp%nY_high = AWAE_InitOutput%nXYZ_high(2,nt)
677+
FWrap_InitInp%nZ_high = AWAE_InitOutput%nXYZ_high(3,nt)
678+
679+
FWrap_InitInp%p_ref_high(1) = AWAE_InitOutput%oXYZ_high(1,nt)
680+
FWrap_InitInp%p_ref_high(2) = AWAE_InitOutput%oXYZ_high(2,nt)
681+
FWrap_InitInp%p_ref_high(3) = AWAE_InitOutput%oXYZ_high(3,nt)
683682

684-
FWrap_InitInp%dX_high = AWAE_InitOutput%dX_high(nt)
685-
FWrap_InitInp%dY_high = AWAE_InitOutput%dY_high(nt)
686-
FWrap_InitInp%dZ_high = AWAE_InitOutput%dZ_high(nt)
683+
FWrap_InitInp%dX_high = AWAE_InitOutput%dXYZ_high(1,nt)
684+
FWrap_InitInp%dY_high = AWAE_InitOutput%dXYZ_high(2,nt)
685+
FWrap_InitInp%dZ_high = AWAE_InitOutput%dXYZ_high(3,nt)
687686

688687
FWrap_InitInp%Vdist_High => AWAE_InitOutput%Vdist_High(nt)%data
689688

0 commit comments

Comments
 (0)