Skip to content

Commit

Permalink
Merge pull request OpenFAST#2445 from andrew-platt/b/ExtInfw_Init
Browse files Browse the repository at this point in the history
ExtInfw: relocate initialization to after AD_Init
  • Loading branch information
deslaughter authored Oct 1, 2024
2 parents 56c645d + 3361339 commit 4da8b4e
Showing 1 changed file with 52 additions and 45 deletions.
97 changes: 52 additions & 45 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -548,51 +548,7 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, SED, BD, S
END IF

ELSEIF ( p_FAST%CompInflow == Module_ExtInfw ) THEN

IF ( PRESENT(ExternInitData) ) THEN
Init%InData_ExtInfw%NumActForcePtsBlade = ExternInitData%NumActForcePtsBlade
Init%InData_ExtInfw%NumActForcePtsTower = ExternInitData%NumActForcePtsTower
ELSE
CALL SetErrStat( ErrID_Fatal, 'ExternalInflow integration can be used only with external input data (not the stand-alone executable).', ErrStat, ErrMsg, RoutineName )
CALL Cleanup()
RETURN
END IF
! get blade and tower info from AD. Assumption made that all blades have same spanwise characteristics
Init%InData_ExtInfw%BladeLength = Init%OutData_AD%rotors(1)%BladeProps(1)%BlSpn(Init%OutData_AD%rotors(1)%BladeProps(1)%NumBlNds)
if (allocated(Init%OutData_AD%rotors(1)%TwrElev)) then
Init%InData_ExtInfw%TowerHeight = Init%OutData_AD%rotors(1)%TwrElev(SIZE(Init%OutData_AD%rotors(1)%TwrElev)) - Init%OutData_AD%rotors(1)%TwrElev(1) ! TwrElev is based on ground or MSL. Need flexible tower length and first node
Init%InData_ExtInfw%TowerBaseHeight = Init%OutData_AD%rotors(1)%TwrElev(1)
ALLOCATE(Init%InData_ExtInfw%StructTwrHNodes( SIZE(Init%OutData_AD%rotors(1)%TwrElev)), STAT=ErrStat2)
Init%InData_ExtInfw%StructTwrHNodes(:) = Init%OutData_AD%rotors(1)%TwrElev(:)
else
Init%InData_ExtInfw%TowerHeight = 0.0_ReKi
Init%InData_ExtInfw%TowerBaseHeight = 0.0_ReKi
endif
ALLOCATE(Init%InData_ExtInfw%StructBldRNodes(Init%OutData_AD%rotors(1)%BladeProps(1)%NumBlNds), STAT=ErrStat2)
Init%InData_ExtInfw%StructBldRNodes(:) = Init%OutData_AD%rotors(1)%BladeProps(1)%BlSpn(:)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating ExtInfw%InitInput.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF

!Set node clustering type
Init%InData_ExtInfw%NodeClusterType = ExternInitData%NodeClusterType
! set up the data structures for integration with ExternalInflow
CALL Init_ExtInfw( Init%InData_ExtInfw, p_FAST, AirDens, AD%Input(1), Init%OutData_AD, AD%y, ExtInfw, Init%OutData_ExtInfw, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)

IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF

!bjj: fix me!!! to do
Init%OutData_IfW%WindFileInfo%MWS = 0.0_ReKi

! Set pointer to flowfield
IF (p_FAST%CompAero == Module_AD) AD%p%FlowField => Init%OutData_ExtInfw%FlowField

! ExtInfw requires initialization of AD first, so nothing executed here
ELSE
Init%OutData_IfW%WindFileInfo%MWS = 0.0_ReKi
END IF ! CompInflow
Expand Down Expand Up @@ -874,6 +830,57 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, SED, BD, S
ENDIF


! ........................
! initialize ExtInfw
! Ideally this would be initialized in the same logic as InflowWind above. However AD outputs are required
! ........................
IF ( p_FAST%CompInflow == Module_ExtInfw ) THEN

IF ( PRESENT(ExternInitData) ) THEN
Init%InData_ExtInfw%NumActForcePtsBlade = ExternInitData%NumActForcePtsBlade
Init%InData_ExtInfw%NumActForcePtsTower = ExternInitData%NumActForcePtsTower
ELSE
CALL SetErrStat( ErrID_Fatal, 'ExternalInflow integration can be used only with external input data (not the stand-alone executable).', ErrStat, ErrMsg, RoutineName )
CALL Cleanup()
RETURN
END IF
! get blade and tower info from AD. Assumption made that all blades have same spanwise characteristics
Init%InData_ExtInfw%BladeLength = Init%OutData_AD%rotors(1)%BladeProps(1)%BlSpn(Init%OutData_AD%rotors(1)%BladeProps(1)%NumBlNds)
if (allocated(Init%OutData_AD%rotors(1)%TwrElev)) then
Init%InData_ExtInfw%TowerHeight = Init%OutData_AD%rotors(1)%TwrElev(SIZE(Init%OutData_AD%rotors(1)%TwrElev)) - Init%OutData_AD%rotors(1)%TwrElev(1) ! TwrElev is based on ground or MSL. Need flexible tower length and first node
Init%InData_ExtInfw%TowerBaseHeight = Init%OutData_AD%rotors(1)%TwrElev(1)
ALLOCATE(Init%InData_ExtInfw%StructTwrHNodes( SIZE(Init%OutData_AD%rotors(1)%TwrElev)), STAT=ErrStat2)
Init%InData_ExtInfw%StructTwrHNodes(:) = Init%OutData_AD%rotors(1)%TwrElev(:)
else
Init%InData_ExtInfw%TowerHeight = 0.0_ReKi
Init%InData_ExtInfw%TowerBaseHeight = 0.0_ReKi
endif
ALLOCATE(Init%InData_ExtInfw%StructBldRNodes(Init%OutData_AD%rotors(1)%BladeProps(1)%NumBlNds), STAT=ErrStat2)
Init%InData_ExtInfw%StructBldRNodes(:) = Init%OutData_AD%rotors(1)%BladeProps(1)%BlSpn(:)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating ExtInfw%InitInput.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF

!Set node clustering type
Init%InData_ExtInfw%NodeClusterType = ExternInitData%NodeClusterType
! set up the data structures for integration with ExternalInflow
CALL Init_ExtInfw( Init%InData_ExtInfw, p_FAST, AirDens, AD%Input(1), Init%OutData_AD, AD%y, ExtInfw, Init%OutData_ExtInfw, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)

IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF

!bjj: fix me!!! to do
Init%OutData_IfW%WindFileInfo%MWS = 0.0_ReKi

! Set pointer to flowfield -- I would prefer that we did this through the AD_Init, but AD_InitOut results are required for ExtInfw_Init
IF (p_FAST%CompAero == Module_AD) AD%p%FlowField => Init%OutData_ExtInfw%FlowField
endif


! ........................
! initialize SuperController
Expand Down

0 comments on commit 4da8b4e

Please sign in to comment.