Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HD: Initialization of the low-pass-filtered displacements of potential-flow bodies when ExctnDisp = 2 #2341

Merged
merged 8 commits into from
Aug 8, 2024
38 changes: 30 additions & 8 deletions modules/hydrodyn/src/HydroDyn_DriverCode.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ PROGRAM HydroDynDriver
real(DbKi) :: TiLstPrn ! The simulation time of the last print
integer :: n_SttsTime ! Number of time steps between screen status messages (-)


integer :: i ! Loop counter

logical :: SeaState_Initialized, HydroDyn_Initialized
! For testing
Expand Down Expand Up @@ -230,10 +230,31 @@ PROGRAM HydroDynDriver
CALL CheckError()
end if
END IF


! Set any steady-state inputs, once before the time-stepping loop (these don't change, so we don't need to update them in the time-marching simulation)
CALL SetHDInputs_Constant(u(1), mappingData, drvrData, ErrStat, ErrMsg); CALL CheckError()

! Set initial inputs at t = 0
IF (( drvrData%PRPInputsMod /= 2 ) .AND. ( drvrData%PRPInputsMod >= 0 )) THEN
! Set any steady-state inputs, once before the time-stepping loop (these don't change, so we don't need to update them in the time-marching simulation)
CALL SetHDInputs_Constant(u(1), mappingData, drvrData, ErrStat, ErrMsg); CALL CheckError()
ELSE
CALL SetHDInputs(0.0_R8Ki, n, u(1), mappingData, drvrData, ErrStat, ErrMsg); CALL CheckError()
END IF

IF ( p%PotMod == 1_IntKi ) THEN
IF ( p%WAMIT(1)%ExctnDisp == 2_IntKi ) THEN
! Set the initial displacement of ED%PlatformPtMesh here to use MeshMapping
IF (p%NBodyMod .EQ. 1_IntKi) THEN ! One instance of WAMIT with NBody
DO i = 1,p%NBody
xd%WAMIT(1)%BdyPosFilt(1,i,:) = u(1)%WAMITMesh%TranslationDisp(1,i)
xd%WAMIT(1)%BdyPosFilt(2,i,:) = u(1)%WAMITMesh%TranslationDisp(2,i)
END DO
ELSE IF (p%NBodyMod > 1_IntKi) THEN ! NBody instance of WAMIT with one body each
DO i = 1,p%NBody
xd%WAMIT(i)%BdyPosFilt(1,1,:) = u(1)%WAMITMesh%TranslationDisp(1,i)
xd%WAMIT(i)%BdyPosFilt(2,1,:) = u(1)%WAMITMesh%TranslationDisp(2,i)
END DO
END IF
END IF
END IF

!...............................................................................................................................
! --- Linearization
Expand Down Expand Up @@ -270,10 +291,11 @@ PROGRAM HydroDynDriver
Time = (n-1) * drvrData%TimeInterval
InputTime(1) = Time

IF (( drvrData%PRPInputsMod == 2 ) .OR. ( drvrData%PRPInputsMod < 0 )) THEN
! Modify u (likely from the outputs of another module or a set of test conditions) here:
call SetHDInputs(Time, n, u(1), mappingData, drvrData, ErrStat, ErrMsg); CALL CheckError()
! SeaState has no inputs, so no need to set them.

call SetHDInputs(Time, n, u(1), mappingData, drvrData, ErrStat, ErrMsg); CALL CheckError()
! SeaState has no inputs, so no need to set them.
END IF

if (n==1 .and. drvrData%Linearize) then
! we set u(1)%PRPMesh motions, so we should assume that EDRP changed similarly:
Expand Down
36 changes: 36 additions & 0 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,42 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
ErrMsg = ""
END IF

! ----------------------------------------------------------------------------
! Initialize low-pass-filtered displacements of HydroDyn potential-flow bodies
! ----------------------------------------------------------------------------
IF ( (p_FAST%CompHydro == Module_HD) .AND. (HD%p%PotMod == 1_IntKi) ) THEN
IF ( HD%p%WAMIT(1)%ExctnDisp == 2_IntKi ) THEN
! Set the initial displacement of ED%PlatformPtMesh here to use MeshMapping
ED%y%PlatformPtMesh%TranslationDisp(:,1) = Init%OutData_ED%PlatformPos(1:3)
CALL SmllRotTrans( 'initial platform rotation ', &
REAL(Init%OutData_ED%PlatformPos(4),R8Ki), &
REAL(Init%OutData_ED%PlatformPos(5),R8Ki), &
REAL(Init%OutData_ED%PlatformPos(6),R8Ki), &
ED%y%PlatformPtMesh%Orientation(:,:,1), '', ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
ED%y%PlatformPtMesh%TranslationDisp(1,1) = ED%y%PlatformPtMesh%TranslationDisp(1,1) + ED%y%PlatformPtMesh%Orientation(3,1,1) * ED%p%PtfmRefzt
ED%y%PlatformPtMesh%TranslationDisp(2,1) = ED%y%PlatformPtMesh%TranslationDisp(2,1) + ED%y%PlatformPtMesh%Orientation(3,2,1) * ED%p%PtfmRefzt
ED%y%PlatformPtMesh%TranslationDisp(3,1) = ED%y%PlatformPtMesh%TranslationDisp(3,1) + ED%y%PlatformPtMesh%Orientation(3,3,1) * ED%p%PtfmRefzt - ED%p%PtfmRefzt
CALL Transfer_PlatformMotion_to_HD( ED%y%PlatformPtMesh, HD%Input(1), MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
IF (HD%p%NBodyMod .EQ. 1_IntKi) THEN ! One instance of WAMIT with NBody
DO i = 1,HD%p%NBody
HD%xd(STATE_CURR)%WAMIT(1)%BdyPosFilt(1,i,:) = HD%Input(1)%WAMITMesh%TranslationDisp(1,i)
HD%xd(STATE_CURR)%WAMIT(1)%BdyPosFilt(2,i,:) = HD%Input(1)%WAMITMesh%TranslationDisp(2,i)
END DO
ELSE IF (HD%p%NBodyMod > 1_IntKi) THEN ! NBody instance of WAMIT with one body each
DO i = 1,HD%p%NBody
HD%xd(STATE_CURR)%WAMIT(i)%BdyPosFilt(1,1,:) = HD%Input(1)%WAMITMesh%TranslationDisp(1,i)
HD%xd(STATE_CURR)%WAMIT(i)%BdyPosFilt(2,1,:) = HD%Input(1)%WAMITMesh%TranslationDisp(2,i)
END DO
END IF
END IF
END IF

! -------------------------------------------------------------------------
! Initialize for linearization or computing aero maps:
! -------------------------------------------------------------------------
Expand Down