Skip to content

Use k-d tree to speed up wake application to high-res grid in AWAE#3066

Merged
deslaughter merged 19 commits intoOpenFAST:dev-tcfrom
deslaughter:fastfarm_kdtree
Nov 19, 2025
Merged

Use k-d tree to speed up wake application to high-res grid in AWAE#3066
deslaughter merged 19 commits intoOpenFAST:dev-tcfrom
deslaughter:fastfarm_kdtree

Conversation

@deslaughter
Copy link
Copy Markdown
Collaborator

@deslaughter deslaughter commented Nov 11, 2025

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HighResGridCalcOutput to use spatial search instead of brute-force iteration
  • Updated AWAE_UpdateStates to 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

@andrew-platt andrew-platt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@deslaughter deslaughter merged commit a326b65 into OpenFAST:dev-tc Nov 19, 2025
13 checks passed
@deslaughter deslaughter deleted the fastfarm_kdtree branch January 28, 2026 14:13
This was referenced Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants