Use k-d tree to speed up wake application to high-res grid in AWAE#3066
Use k-d tree to speed up wake application to high-res grid in AWAE#3066deslaughter merged 19 commits intoOpenFAST:dev-tcfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces k-d tree spatial indexing to optimize wake application calculations in the AWAE module for FAST.Farm simulations. The previous algorithm checked every combination of wake regions and grid points, which was computationally expensive for large farms. The new implementation uses a k-d tree to efficiently find nearby wake points for each turbine's high-resolution grid, significantly reducing computation time.
Key changes:
- Added k-d tree module and data structures to NWTC Library
- Refactored
HighResGridCalcOutputto use spatial search instead of brute-force iteration - Updated
AWAE_UpdateStatesto use modern InflowWind API (IfW_FlowField_GetVelAcc) and cleaner pointer-based velocity transfer
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| modules/elastodyn/src/ElastoDyn.f90 | Simplified SmllRotTrans calls by removing time string parameter |
| modules/awae/src/AWAE_Types.f90 | Added k-d tree fields and supporting arrays with proper copy/destroy/pack/unpack implementations |
| modules/awae/src/AWAE_Registry.txt | Registered new k-d tree type and metadata arrays |
| modules/awae/src/AWAE.f90 | Implemented k-d tree-based wake search, refactored grid calculations, and modernized InflowWind integration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR is ready to be merged.
Feature or improvement description
This PR adds a k-d tree implementation (https://en.wikipedia.org/wiki/K-d_tree) to NWTC Library and uses it in the AWAE module to more efficiently apply the wake effects to each turbine's high-resolution inflow grid and to the overall low-resolution grid. The previous algorithm in AWAE checked every combination of every wake region of every turbine for each point in each turbine's high-res grid and for every point in the low-res grid. This was a slow process due to the large number of wind grid points, wake points, and turbines, especially for large farms.
The new algorithm loads the wake points from all turbines into a k-d tree, finds the center of each turbine's high-res grid, calculates a search radius from that center point to 1) cover the destination turbine's high-res grid, 2) include the largest wake diameter, 3) be large enough to capture a wake which may span an entire grid. Then, the wake points that are near the high-res grid are processed and added to the grid. This significantly reduces the amount of time spent searching for which wake points are applicable to a given high-res grid point.
A similar is approach is applied to the low-res grid which is now divided into roughly equal sized chunks along the horizontal dimensions. Each chunk has a center, search radius, and grid indices which are used for separate k-d tree searches and allow for selectively updating parts of the low-res grid.
Impacted areas of the software
NWTC Library and AWAE module (used by FAST.Farm)
Test results, if applicable
Existing FAST.Farm tests are unchanged.