Skip to content

Conversation

@andrew-platt
Copy link
Collaborator

@andrew-platt andrew-platt commented Dec 18, 2025

Ready to merge

Feature or improvement description

Several improvements to the c-bindings interfaces were developed jointly with an external partner. This PR brings in updates for the following:

AeroDyn_Inflow_C_Binding

  • Support usage of instance of InflowWind outside of the library
    • New routines ADI_C_GetFlowFieldPointer and ADI_C_GetFlowFieldPointer for directly manipulating FlowField pointer
    • New flag for external FlowField data (i.e. from an instance of InflowWind outside the c-bind library)
      • propogate flag down to ADI library
  • updated handling of VTK step
  • Improved clearing of memory
  • moved VTK settings from ADI_C_Init to ADI_C_PreInit

HydroDyn_C_Binding

  • correction to logic checks on number of nodes passed in for flexible models

InflowWind_C_Binding

  • general code cleanup
  • use NWTC_C_Binding error handling and params
  • add DebugLevel outputs for troubleshooting interface issues
  • Improved memory handling (new MemClear routine)
  • new routines:
    • IfW_C_GetWindVel
    • IfW_C_GetFlowFieldPointer
    • IfW_C_SetFlowFieldPointer

SeaState

  • SeaSt_WaveField.f90 and c-bindings
    • added WaveField_GetMinMaxWaveElevEstimate routine (simple sum of max/min values of 1st and second )
  • SeaState_C_Binding.f90
    • add DebugLevel outputs for troubleshooting interface issues
    • new environment variable routines:
      • SeaSt_C_GetDens
      • SeaSt_C_GetDpth
      • SeaSt_C_GetMSL2SWL

pyOpenFAST

  • updated python libraries to match above changes.
  • Moved some common code pieces into base OpenFASTInterfaceType class in interface_abc.py
    • NOTE: there are inconsistencies in usage of the interface_abc.py base class between module interfaces, but that is not addressed here

WaveTank.f90

  • updates to match revised API of c-bind libraries

Related issue, if one exists

Depends on #3065

Impacted areas of the software

C-binding library interfaces, pyOpenFAST, and regression testing interfaces

Test results, if applicable

No results change, but interface in py_seastate_1 is updated to match changes in seastate.py

- cleanup moordyn.py to use common stuff in interface_abc
- cleanup seastate.py to use common stuff in interface_abc
- cleanup aerodyn_inflow.py to use common stuff in interface_abc
- use interface_abc with inflowwind.py
- use interface_abc with hydrodyn.py
- New external routines:
  - IfW_C_GetFlowFieldPointer
  - IfW_C_SetFlowFieldPointer
  - IfW_C_GetWindVel
- Updated to use NWTC_C_BINDING
- minor linting
- add routine to clear library memory
- ADI_C_GetFlowFieldPointer
- ADI_C_SetFlowFieldPointer
to set the pointer, IfW will need to be initialized with a null data set.  Init doesn't allow this at the moment
This is accurate for 1st order waves, but will exagerate a bit for 2nd order
- SeaSt_C_GetDens
- SeaSt_C_GetDpth
- SeaSt_C_GetMSL2SWL
Also improved check on valid pointer
Interfaces are not up to date for all the changes here
@andrew-platt andrew-platt self-assigned this Dec 18, 2025
@andrew-platt andrew-platt added this to the v4.2.0 milestone Dec 18, 2025
@andrew-platt andrew-platt marked this pull request as draft December 18, 2025 21:12
@andrew-platt andrew-platt marked this pull request as ready for review January 6, 2026 22:33
Copy link
Collaborator

@deslaughter deslaughter left a comment

Choose a reason for hiding this comment

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

I'm a little worried about the use of .encode('utf-8') in a lot of the Python code as I'm not sure how Fortran will handle it. I researched it a bit and it seemed to be compiler and OS dependent. UTF-8 is essentially ASCII if there aren't any non-ASCII characters, so that should be fine. I think we should leave it for now, but if we get bugs in the future, the solution is to change it to .encode('ascii', 'strict') which will force the user to use ASCII file paths.

Co-authored-by: Derek Slaughter <[email protected]>
@andrew-platt
Copy link
Collaborator Author

I agree on the utf-8 encoding. I suspect I borrowed it from someone else without really understanding the implications.

@andrew-platt andrew-platt merged commit 883c72e into OpenFAST:dev Jan 7, 2026
12 checks passed
@andrew-platt andrew-platt deleted the f/c-bind_updates_ADI branch January 7, 2026 20:25
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.

2 participants