Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,522 changes: 4,761 additions & 4,761 deletions modules/aerodyn/src/AeroDyn_Driver_Types.f90

Large diffs are not rendered by default.

45 changes: 19 additions & 26 deletions modules/openfast-library/src/FAST_Solver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,16 @@ SUBROUTINE AD_InputSolve_IfW( p_FAST, u_AD, y_IfW, y_OpFM, ErrStat, ErrMsg )

NumBl = size(u_AD%rotors(1)%InflowOnBlade,3)
Nnodes = size(u_AD%rotors(1)%InflowOnBlade,2)


! Hub -- first point
if (u_AD%rotors(1)%HubMotion%NNodes > 0) then
u_AD%rotors(1)%InflowOnHub(1) = y_OpFM%u(1)
u_AD%rotors(1)%InflowOnHub(2) = y_OpFM%v(1)
u_AD%rotors(1)%InflowOnHub(3) = y_OpFM%w(1)
else
u_AD%rotors(1)%InflowOnHub = 0.0_ReKi
end if

do k=1,NumBl
do j=1,Nnodes
u_AD%rotors(1)%InflowOnBlade(1,j,k) = y_OpFM%u(node)
Expand All @@ -562,25 +571,14 @@ SUBROUTINE AD_InputSolve_IfW( p_FAST, u_AD, y_IfW, y_OpFM, ErrStat, ErrMsg )

! Nacelle
if (u_AD%rotors(1)%NacelleMotion%NNodes > 0) then
! for cfd we will lump the hub and nacelle together
u_AD%rotors(1)%InflowOnNacelle(1) = y_OpFM%u(1)
u_AD%rotors(1)%InflowOnNacelle(2) = y_OpFM%v(1)
u_AD%rotors(1)%InflowOnNacelle(3) = y_OpFM%w(1)
u_AD%rotors(1)%InflowOnNacelle(1) = y_OpFM%u(node)
u_AD%rotors(1)%InflowOnNacelle(2) = y_OpFM%v(node)
u_AD%rotors(1)%InflowOnNacelle(3) = y_OpFM%w(node)
node = node + 1
else
u_AD%rotors(1)%InflowOnNacelle = 0.0_ReKi
end if

! Hub
if (u_AD%rotors(1)%HubMotion%NNodes > 0) then
u_AD%rotors(1)%InflowOnHub(1) = y_OpFM%u(node)
u_AD%rotors(1)%InflowOnHub(2) = y_OpFM%v(node)
u_AD%rotors(1)%InflowOnHub(3) = y_OpFM%w(node)
node = node + 1
else
u_AD%rotors(1)%InflowOnHub = 0.0_ReKi
end if

! TailFin
if (u_AD%rotors(1)%TFinMotion%NNodes > 0) then
u_AD%rotors(1)%InflowOnTailFin(1) = y_OpFM%u(node)
Expand Down Expand Up @@ -706,14 +704,13 @@ SUBROUTINE AD_InputSolve_NoIfW( p_FAST, u_AD, y_SrvD, y_ED, BD, MeshMapData, Err
END SUBROUTINE AD_InputSolve_NoIfW
!----------------------------------------------------------------------------------------------------------------------------------
!> This routine sets the AeroDyn14 wind inflow inputs.
SUBROUTINE AD14_InputSolve_IfW( p_FAST, u_AD14, y_IfW, y_OpFM, ErrStat, ErrMsg )
SUBROUTINE AD14_InputSolve_IfW( p_FAST, u_AD14, y_IfW, ErrStat, ErrMsg )
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

! Passed variables
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST !< parameter FAST data
TYPE(AD14_InputType), INTENT(INOUT) :: u_AD14 !< The inputs to AeroDyn14
TYPE(InflowWind_OutputType), INTENT(IN) :: y_IfW !< The outputs from InflowWind
TYPE(OpFM_OutputType), INTENT(IN) :: y_OpFM !< outputs from the OpenFOAM integration module

INTEGER(IntKi) :: ErrStat !< Error status of the operation
CHARACTER(*) :: ErrMsg !< Error message if ErrStat /= ErrID_None
Expand All @@ -739,10 +736,6 @@ SUBROUTINE AD14_InputSolve_IfW( p_FAST, u_AD14, y_IfW, y_OpFM, ErrStat, ErrMsg )
ELSE
u_AD14%InflowVelocity = y_IfW%VelocityUVW(:,:)
END IF
ELSEIF ( p_FAST%CompInflow == MODULE_OpFM ) THEN
u_AD14%InflowVelocity(1,:) = y_OpFM%u(2:)
u_AD14%InflowVelocity(2,:) = y_OpFM%v(2:)
u_AD14%InflowVelocity(3,:) = y_OpFM%w(2:)
ELSE
u_AD14%InflowVelocity = 0.0_ReKi ! whole array
END IF
Expand Down Expand Up @@ -5157,7 +5150,7 @@ SUBROUTINE CalcOutputs_And_SolveForInputs( n_t_global, this_time, this_state, ca

! because we're not calling InflowWind_CalcOutput or getting new values from OpenFOAM,
! this probably can be skipped
CALL AD14_InputSolve_IfW( p_FAST, AD14%Input(1), IfW%y, OpFM%y, ErrStat2, ErrMsg2 )
CALL AD14_InputSolve_IfW( p_FAST, AD14%Input(1), IfW%y, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )

ELSEIF ( p_FAST%CompAero == Module_AD ) THEN
Expand All @@ -5180,7 +5173,7 @@ SUBROUTINE CalcOutputs_And_SolveForInputs( n_t_global, this_time, this_state, ca
! OpenFOAM is the driver and it sets these inputs outside of this solve; the OpenFOAM inputs and outputs thus don't change
! in this scenario until OpenFOAM takes another step **this is a source of error, but it is the way the OpenFOAM-FAST7 coupling
! works, so I'm not going to spend time that I don't have now to fix it**
CALL OpFM_SetInputs( p_FAST, AD14%p, AD14%Input(1), AD14%y, AD%Input(1), AD%y, ED%y, SrvD%y, OpFM, ErrStat2, ErrMsg2 )
CALL OpFM_SetInputs( p_FAST, AD%Input(1), AD%y, SrvD%y, OpFM, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
END IF

Expand Down Expand Up @@ -5592,15 +5585,15 @@ SUBROUTINE SolveOption2c_Inp2AD_SrvD(this_time, this_state, p_FAST, m_FAST, ED,
! ! OpenFOAM is the driver and it computes outputs outside of this solve; the OpenFOAM inputs and outputs thus don't change
! ! in this scenario until OpenFOAM takes another step **this is a source of error, but it is the way the OpenFOAM-FAST7 coupling
! ! works, so I'm not going to spend time that I don't have now to fix it**
! CALL OpFM_SetInputs( p_FAST, AD14%p, AD14%Input(1), AD14%y, AD%Input(1), AD%y, ED%y, SrvD%y, OpFM, ErrStat2, ErrMsg2 )
! CALL OpFM_SetInputs( p_FAST, AD%Input(1), AD%y, ED%y, SrvD%y, OpFM, ErrStat2, ErrMsg2 )
! CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! CALL OpFM_SetWriteOutput(OpFM)

END IF

IF ( p_FAST%CompAero == Module_AD14 ) THEN

CALL AD14_InputSolve_IfW( p_FAST, AD14%Input(1), IfW%y, OpFM%y, ErrStat2, ErrMsg2 )
CALL AD14_InputSolve_IfW( p_FAST, AD14%Input(1), IfW%y, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )

ELSE IF ( p_FAST%CompAero == Module_AD ) THEN
Expand Down Expand Up @@ -5703,7 +5696,7 @@ SUBROUTINE SolveOption2(this_time, this_state, p_FAST, m_FAST, ED, BD, AD14, AD,
! in this scenario until OpenFOAM takes another step **this is a source of error, but it is the way the OpenFOAM-FAST7 coupling
! works, so I'm not going to spend time that I don't have now to fix it**
! note that I'm setting these inputs AFTER the call to ServoDyn so OpenFOAM gets all the inputs updated at the same step
CALL OpFM_SetInputs( p_FAST, AD14%p, AD14%Input(1), AD14%y, AD%Input(1), AD%y, ED%y, SrvD%y, OpFM, ErrStat2, ErrMsg2 )
CALL OpFM_SetInputs( p_FAST, AD%Input(1), AD%y, SrvD%y, OpFM, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
CALL OpFM_SetWriteOutput(OpFM)

Expand Down
24 changes: 16 additions & 8 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
INTEGER(IntKi) :: IceDim ! dimension we're pre-allocating for number of IceDyn legs/instances
INTEGER(IntKi) :: I ! generic loop counter
INTEGER(IntKi) :: k ! blade loop counter
INTEGER(IntKi) :: nNodes ! temp var for OpFM coupling
logical :: CallStart


Expand Down Expand Up @@ -636,20 +637,26 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
CALL Cleanup()
RETURN
END IF
Init%InData_OpFM%BladeLength = Init%OutData_ED%BladeLength
Init%InData_OpFM%TowerHeight = Init%OutData_ED%TowerHeight
Init%InData_OpFM%TowerBaseHeight = Init%OutData_ED%TowerBaseHeight
ALLOCATE(Init%InData_OpFM%StructBldRNodes( SIZE(Init%OutData_ED%BldRNodes)), STAT=ErrStat2)
Init%InData_OpFM%StructBldRNodes(:) = Init%OutData_ED%BldRNodes(:)
ALLOCATE(Init%InData_OpFM%StructTwrHNodes( SIZE(Init%OutData_ED%TwrHNodes)), STAT=ErrStat2)
Init%InData_OpFM%StructTwrHNodes(:) = Init%OutData_ED%TwrHNodes(:)
! get blade and tower info from AD. Assumption made that all blades have same spanwise characteristics
Init%InData_OpFM%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_OpFM%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_OpFM%TowerBaseHeight = Init%OutData_AD%rotors(1)%TwrElev(1)
ALLOCATE(Init%InData_OpFM%StructTwrHNodes( SIZE(Init%OutData_AD%rotors(1)%TwrElev)), STAT=ErrStat2)
Init%InData_OpFM%StructTwrHNodes(:) = Init%OutData_AD%rotors(1)%TwrElev(:)
else
Init%InData_OpFM%TowerHeight = 0.0_ReKi
Init%InData_OpFM%TowerBaseHeight = 0.0_ReKi
endif
ALLOCATE(Init%InData_OpFM%StructBldRNodes(Init%OutData_AD%rotors(1)%BladeProps(1)%NumBlNds), STAT=ErrStat2)
Init%InData_OpFM%StructBldRNodes(:) = Init%OutData_AD%rotors(1)%BladeProps(1)%BlSpn(:)
IF (ErrStat2 /= 0) THEN
CALL SetErrStat(ErrID_Fatal,"Error allocating OpFM%InitInput.",ErrStat,ErrMsg,RoutineName)
CALL Cleanup()
RETURN
END IF
! set up the data structures for integration with OpenFOAM
CALL Init_OpFM( Init%InData_OpFM, p_FAST, AirDens, AD14%Input(1), AD%Input(1), Init%OutData_AD, AD%y, ED%y, OpFM, Init%OutData_OpFM, ErrStat2, ErrMsg2 )
CALL Init_OpFM( Init%InData_OpFM, p_FAST, AirDens, AD%Input(1), Init%OutData_AD, AD%y, OpFM, Init%OutData_OpFM, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)

IF (ErrStat >= AbortErrLev) THEN
Expand Down Expand Up @@ -1863,6 +1870,7 @@ SUBROUTINE ValidateInputData(p, m_FAST, ErrStat, ErrMsg)
END IF

IF (p%CompElast == Module_BD .and. p%CompAero == Module_AD14 ) CALL SetErrStat( ErrID_Fatal, 'AeroDyn14 cannot be used when BeamDyn is used. Change CompAero or CompElast in the FAST input file.', ErrStat, ErrMsg, RoutineName )
if (p%CompInflow == MODULE_OpFM .and. p%CompAero == Module_AD14 ) CALL SetErrStat( ErrID_Fatal, 'AeroDyn14 cannot be used when OpenFOAM is used. Change CompAero or CompInflow in the FAST input file.', ErrStat, ErrMsg, RoutineName )

IF (p%MHK /= 0 .and. p%MHK /= 1 .and. p%MHK /= 2) CALL SetErrStat( ErrID_Fatal, 'MHK switch is invalid. Set MHK to 0, 1, or 2 in the FAST input file.', ErrStat, ErrMsg, RoutineName )

Expand Down
Loading