Skip to content

Commit

Permalink
Merge pull request #2097 from andrew-platt/b/FASTlib_TurbineIndex_1
Browse files Browse the repository at this point in the history
Consistent use of turbine indexing when coupled to c/c++
  • Loading branch information
andrew-platt authored Mar 20, 2024
2 parents e0cb005 + 4c001eb commit 3e029ef
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 62 deletions.
2 changes: 1 addition & 1 deletion glue-codes/fast-farm/src/FASTWrapper.f90
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ SUBROUTINE FWrap_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Init

end if
!.... multi-turbine options ....
ExternInitData%TurbineID = InitInp%TurbNum
ExternInitData%TurbIDforName = InitInp%TurbNum
ExternInitData%TurbinePos = InitInp%p_ref_Turbine
ExternInitData%WaveFieldMod = InitInp%WaveFieldMod

Expand Down
139 changes: 90 additions & 49 deletions modules/openfast-library/src/FAST_Library.f90

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/openfast-library/src/FAST_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ EXTERNAL_ROUTINE void FAST_DeallocateTurbines(int *ErrStat, char *ErrMsg);

EXTERNAL_ROUTINE void FAST_OpFM_Restart(int * iTurb, const char *CheckpointRootName, int *AbortErrLev, double * dt, int * NumBl, int * NumBlElem, int * n_t_global,
OpFM_InputType_t* OpFM_Input, OpFM_OutputType_t* OpFM_Output, SC_DX_InputType_t* SC_DX_Input, SC_DX_OutputType_t* SC_DX_Output, int *ErrStat, char *ErrMsg);
EXTERNAL_ROUTINE void FAST_OpFM_Init(int * iTurb, double *TMax, const char *InputFileName, int * TurbineID, int * NumSC2CtrlGlob, int * NumSC2Ctrl, int * NumCtrl2SC, float * initSCInputsGlob, float * initSCInputsTurbine, int * NumActForcePtsBlade, int * NumActForcePtsTower, float * TurbinePosition,
EXTERNAL_ROUTINE void FAST_OpFM_Init(int * iTurb, double *TMax, const char *InputFileName, int * TurbIDforName, int * NumSC2CtrlGlob, int * NumSC2Ctrl, int * NumCtrl2SC, float * initSCInputsGlob, float * initSCInputsTurbine, int * NumActForcePtsBlade, int * NumActForcePtsTower, float * TurbinePosition,
int *AbortErrLev, double * dt, int * NumBl, int * NumBlElem, int * NodeClusterType, OpFM_InputType_t* OpFM_Input, OpFM_OutputType_t* OpFM_Output, SC_DX_InputType_t* SC_DX_Input, SC_DX_OutputType_t* SC_DX_Output,
int *ErrStat, char *ErrMsg);
EXTERNAL_ROUTINE void FAST_OpFM_Solution0(int * iTurb, int *ErrStat, char *ErrMsg);
Expand Down
2 changes: 1 addition & 1 deletion modules/openfast-library/src/FAST_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ typedef ^ FAST_InitData IceD_InitOutputType OutData_IceD - -
typedef ^ FAST_ExternInitType DbKi Tmax - -1 - "External code specified Tmax" s
typedef ^ FAST_ExternInitType IntKi SensorType - SensorType_None - "lidar sensor type, which should not be pulsed at the moment; this input should be replaced with a section in the InflowWind input file" -
typedef ^ FAST_ExternInitType LOGICAL LidRadialVel - - - "TRUE => return radial component, FALSE => return 'x' direction estimate" -
typedef ^ FAST_ExternInitType IntKi TurbineID - 0 - "ID number for turbine (used to create output file naming convention)" -
typedef ^ FAST_ExternInitType IntKi TurbIDforName - -1 - "ID number for turbine (used to create output file naming convention)" -
typedef ^ FAST_ExternInitType ReKi TurbinePos {3} - - "Initial position of turbine base (origin used for graphics or in FAST.Farm)" m
typedef ^ FAST_ExternInitType IntKi WaveFieldMod - - - "Wave field handling (-) (switch) 0: use individual HydroDyn inputs without adjustment, 1: adjust wave phases based on turbine offsets from farm origin" -
typedef ^ FAST_ExternInitType IntKi NumSC2CtrlGlob - - - "number of global controller inputs [from supercontroller]" -
Expand Down
6 changes: 3 additions & 3 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
y_FAST%Lin%WindSpeed = 0.0_ReKi

if (present(ExternInitData)) then
CallStart = .not. ExternInitData%FarmIntegration ! .and. ExternInitData%TurbineID == 1
if (ExternInitData%TurbineID > 0) p_FAST%TDesc = 'T'//trim(num2lstr(ExternInitData%TurbineID))
CallStart = .not. ExternInitData%FarmIntegration
if (ExternInitData%TurbIDforName >= 0) p_FAST%TDesc = 'T'//trim(num2lstr(ExternInitData%TurbIDforName))
else
CallStart = .true.
end if
Expand Down Expand Up @@ -205,7 +205,7 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
if (ExternInitData%FarmIntegration) then ! we're integrating with FAST.Farm
CALL FAST_Init( p_FAST, m_FAST, y_FAST, t_initial, InputFile, ErrStat2, ErrMsg2, ExternInitData%TMax, OverrideAbortLev=.false., RootName=ExternInitData%RootName )
else
CALL FAST_Init( p_FAST, m_FAST, y_FAST, t_initial, InputFile, ErrStat2, ErrMsg2, ExternInitData%TMax, ExternInitData%TurbineID ) ! We have the name of the input file and the simulation length from somewhere else (e.g. Simulink)
CALL FAST_Init( p_FAST, m_FAST, y_FAST, t_initial, InputFile, ErrStat2, ErrMsg2, ExternInitData%TMax, ExternInitData%TurbIDforName ) ! We have the name of the input file and the simulation length from somewhere else (e.g. Simulink)
end if

else
Expand Down
10 changes: 5 additions & 5 deletions modules/openfast-library/src/FAST_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ MODULE FAST_Types
REAL(DbKi) :: Tmax = -1 !< External code specified Tmax [s]
INTEGER(IntKi) :: SensorType = SensorType_None !< lidar sensor type, which should not be pulsed at the moment; this input should be replaced with a section in the InflowWind input file [-]
LOGICAL :: LidRadialVel !< TRUE => return radial component, FALSE => return 'x' direction estimate [-]
INTEGER(IntKi) :: TurbineID = 0 !< ID number for turbine (used to create output file naming convention) [-]
INTEGER(IntKi) :: TurbIDforName = -1 !< ID number for turbine (used to create output file naming convention) [-]
REAL(ReKi) , DIMENSION(1:3) :: TurbinePos !< Initial position of turbine base (origin used for graphics or in FAST.Farm) [m]
INTEGER(IntKi) :: WaveFieldMod !< Wave field handling (-) (switch) 0: use individual HydroDyn inputs without adjustment, 1: adjust wave phases based on turbine offsets from farm origin [-]
INTEGER(IntKi) :: NumSC2CtrlGlob !< number of global controller inputs [from supercontroller] [-]
Expand Down Expand Up @@ -48020,7 +48020,7 @@ SUBROUTINE FAST_CopyExternInitType( SrcExternInitTypeData, DstExternInitTypeData
DstExternInitTypeData%Tmax = SrcExternInitTypeData%Tmax
DstExternInitTypeData%SensorType = SrcExternInitTypeData%SensorType
DstExternInitTypeData%LidRadialVel = SrcExternInitTypeData%LidRadialVel
DstExternInitTypeData%TurbineID = SrcExternInitTypeData%TurbineID
DstExternInitTypeData%TurbIDforName = SrcExternInitTypeData%TurbIDforName
DstExternInitTypeData%TurbinePos = SrcExternInitTypeData%TurbinePos
DstExternInitTypeData%WaveFieldMod = SrcExternInitTypeData%WaveFieldMod
DstExternInitTypeData%NumSC2CtrlGlob = SrcExternInitTypeData%NumSC2CtrlGlob
Expand Down Expand Up @@ -48127,7 +48127,7 @@ SUBROUTINE FAST_PackExternInitType( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat,
Db_BufSz = Db_BufSz + 1 ! Tmax
Int_BufSz = Int_BufSz + 1 ! SensorType
Int_BufSz = Int_BufSz + 1 ! LidRadialVel
Int_BufSz = Int_BufSz + 1 ! TurbineID
Int_BufSz = Int_BufSz + 1 ! TurbIDforName
Re_BufSz = Re_BufSz + SIZE(InData%TurbinePos) ! TurbinePos
Int_BufSz = Int_BufSz + 1 ! WaveFieldMod
Int_BufSz = Int_BufSz + 1 ! NumSC2CtrlGlob
Expand Down Expand Up @@ -48184,7 +48184,7 @@ SUBROUTINE FAST_PackExternInitType( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat,
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%LidRadialVel, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%TurbineID
IntKiBuf(Int_Xferred) = InData%TurbIDforName
Int_Xferred = Int_Xferred + 1
DO i1 = LBOUND(InData%TurbinePos,1), UBOUND(InData%TurbinePos,1)
ReKiBuf(Re_Xferred) = InData%TurbinePos(i1)
Expand Down Expand Up @@ -48287,7 +48287,7 @@ SUBROUTINE FAST_UnPackExternInitType( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrSt
Int_Xferred = Int_Xferred + 1
OutData%LidRadialVel = TRANSFER(IntKiBuf(Int_Xferred), OutData%LidRadialVel)
Int_Xferred = Int_Xferred + 1
OutData%TurbineID = IntKiBuf(Int_Xferred)
OutData%TurbIDforName = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
i1_l = LBOUND(OutData%TurbinePos,1)
i1_u = UBOUND(OutData%TurbinePos,1)
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ option(CTEST_NO_RUN_FLAG "Complete the regression test comparison but do not ex
# Set the OpenFAST executable configuration option and default
set(CTEST_OPENFAST_EXECUTABLE "${CMAKE_BINARY_DIR}/glue-codes/openfast/openfast${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "Specify the OpenFAST executable to use in testing.")

if(BUILD_OPENFAST_CPP_DRIVER)
if(BUILD_OPENFAST_CPP_API)
# Set the OpenFAST executable configuration option and default
set(CTEST_OPENFASTCPP_EXECUTABLE "${CMAKE_BINARY_DIR}/glue-codes/openfast-cpp/openfastcpp${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "Specify the OpenFAST C++ executable to use in testing.")
endif()
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/CTestList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ of_regression("MHK_RM1_Floating" "openfast;elastodyn;aerod
of_regression("Tailfin_FreeYaw1DOF_PolarBased" "openfast;elastodyn;aerodyn15")

# OpenFAST C++ API test
if(BUILD_OPENFAST_CPP_DRIVER)
if(BUILD_OPENFAST_CPP_API)
of_cpp_interface_regression("5MW_Land_DLL_WTurb_cpp" "openfast;fastlib;cpp")
endif()

Expand Down

0 comments on commit 3e029ef

Please sign in to comment.