Skip to content

Commit

Permalink
Merge remote-tracking branch 'OpenFAST/dev-unstable-pointers' into b/…
Browse files Browse the repository at this point in the history
…ExtLoads_pointers
  • Loading branch information
andrew-platt committed Mar 7, 2024
2 parents 9d46ce0 + c3d4887 commit 434a759
Show file tree
Hide file tree
Showing 37 changed files with 1,877 additions and 2,533 deletions.
135 changes: 71 additions & 64 deletions .github/workflows/automated-dev-tests.yml

Large diffs are not rendered by default.

42 changes: 19 additions & 23 deletions modules/hydrodyn/src/HydroDyn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2619,39 +2619,35 @@ SUBROUTINE HD_Perturb_x( p, n, perturb_sign, x, dx )


! local variables
integer(intKi) :: i, offset1, offset2, n2
integer(intKi) :: i, j, k

if ( p%totalStates == 0 ) return

!Note: All excitation states for all bodies are stored 1st, then all radiation states
dx = p%dx(n)
offset1 = 1
if ( n <= p%totalExctnStates ) then

! Find body index for exctn states
do i=1,p%nWAMITObj
offset2 = offset1 + p%WAMIT(i)%SS_Exctn%numStates
if ( n >= offset1 .and. n < offset2) then
n2 = n - offset1 + 1
x%WAMIT(i)%SS_Exctn%x( n2 ) = x%WAMIT(i)%SS_Exctn%x( n2 ) + dx * perturb_sign
exit
k = 1

! Find body index for exctn states
do i = 1, p%nWAMITObj
do j = 1, p%WAMIT(i)%SS_Exctn%numStates
if (n == k) then
x%WAMIT(i)%SS_Exctn%x(j) = x%WAMIT(i)%SS_Exctn%x(j) + dx * perturb_sign
return
end if
offset1 = offset2
k = k + 1
end do
end do

else
offset1 = p%totalExctnStates + 1
! Find body index for rdtn states
do i=1,p%nWAMITObj
offset2 = offset1 + p%WAMIT(i)%SS_Exctn%numStates
if ( n >= offset1 .and. n < offset2) then
n2 = n - offset1 + 1
x%WAMIT(i)%SS_Rdtn%x( n2 ) = x%WAMIT(i)%SS_Rdtn%x( n2 ) + dx * perturb_sign
exit
! Find body index for rdtn states
do i = 1, p%nWAMITObj
do j = 1, p%WAMIT(i)%SS_Rdtn%numStates
if (n == k) then
x%WAMIT(i)%SS_Rdtn%x(j) = x%WAMIT(i)%SS_Rdtn%x(j) + dx * perturb_sign
return
end if
offset1 = offset2
k = k + 1
end do
end if
end do

END SUBROUTINE HD_Perturb_x

Expand Down
14 changes: 12 additions & 2 deletions modules/hydrodyn/src/HydroDyn_Input.f90
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,19 @@ SUBROUTINE HydroDyn_ParseInput( InputFileName, OutRootName, FileInfo_In, InputFi
END IF

DO I = 1,InputFileData%Morison%NAxCoefs
! read the table entries AxCoefID CdAx CaAx in the HydroDyn input file
! read the table entries AxCoefID, AxCd, AxCa, AxCp, AxFdMod, AxVnCOff, AxFDLoFSc in the HydroDyn input file
! Try reading in 7 entries first
call ParseAry( FileInfo_In, CurLine, ' axial coefficients line '//trim( Int2LStr(I)), tmpReArray, size(tmpReArray), ErrStat2, ErrMsg2, UnEc )
if (Failed()) return;
if ( ErrStat2 /= 0 ) then ! Try reading in 5 entries
tmpReArray(6) = -1.0 ! AxVnCoff
tmpReArray(7) = 1.0 ! AxFDLoFSc
call ParseAry( FileInfo_In, CurLine, ' axial coefficients line '//trim( Int2LStr(I)), tmpReArray(1:5), 5, ErrStat2, ErrMsg2, UnEc )
if ( ErrStat2 /= 0 ) then ! Try reading in 4 entries
tmpReArray(5) = 0.0 ! AxFdMod
call ParseAry( FileInfo_In, CurLine, ' axial coefficients line '//trim( Int2LStr(I)), tmpReArray(1:4), 4, ErrStat2, ErrMsg2, UnEc )
if (Failed()) return;
end if
end if
InputFileData%Morison%AxialCoefs(I)%AxCoefID = NINT(tmpReArray(1))
InputFileData%Morison%AxialCoefs(I)%AxCd = tmpReArray(2)
InputFileData%Morison%AxialCoefs(I)%AxCa = tmpReArray(3)
Expand Down
25 changes: 15 additions & 10 deletions modules/hydrodyn/src/Morison.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ MODULE Morison
USE Waves
USE Morison_Types
USE Morison_Output
USE SeaState_Interp
USE SeaSt_WaveField
! USE HydroDyn_Output_Types
USE NWTC_Library
Expand Down Expand Up @@ -2603,7 +2602,7 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,

!===============================================================================================
! Calculate the fluid kinematics at all mesh nodes and store for use in the equations below
CALL WaveField_GetWaveKin( p%WaveField, m%SeaSt_Interp_m, Time, m%DispNodePosHdn, .FALSE., m%nodeInWater, m%WaveElev1, m%WaveElev2, m%WaveElev, m%FDynP, m%FV, m%FA, m%FAMCF, ErrStat2, ErrMsg2 )
CALL WaveField_GetWaveKin( p%WaveField, m%WaveField_m, Time, m%DispNodePosHdn, .FALSE., m%nodeInWater, m%WaveElev1, m%WaveElev2, m%WaveElev, m%FDynP, m%FV, m%FA, m%FAMCF, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Compute fluid velocity relative to the structure
DO j = 1, p%NNodes
Expand Down Expand Up @@ -2716,9 +2715,10 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,

! lower node
Ioffset = mem%h_cmg_l(i)*mem%h_cmg_l(i)*mem%m_mg_l(i)
Imat = 0.0_ReKi
Imat(1,1) = mem%I_rmg_l(i) - Ioffset
Imat(2,2) = mem%I_rmg_l(i) - Ioffset
Imat(3,3) = mem%I_lmg_l(i) - Ioffset
Imat(3,3) = mem%I_lmg_l(i)
Imat = matmul(matmul(CMatrix, Imat), CTrans)
iArm = mem%h_cmg_l(i) * k_hat
iTerm = ( -a_s1 - cross_product(omega_s1, cross_product(omega_s1,iArm )) - cross_product(alpha_s1,iArm) ) * mem%m_mg_l(i)
Expand All @@ -2731,9 +2731,10 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,

! upper node
Ioffset = mem%h_cmg_u(i)*mem%h_cmg_u(i)*mem%m_mg_u(i)
Imat = 0.0_ReKi
Imat(1,1) = mem%I_rmg_u(i) - Ioffset
Imat(2,2) = mem%I_rmg_u(i) - Ioffset
Imat(3,3) = mem%I_lmg_u(i) - Ioffset
Imat(3,3) = mem%I_lmg_u(i)
Imat = matmul(matmul(CMatrix, Imat), CTrans)
iArm = mem%h_cmg_u(i) * k_hat
iTerm = ( -a_s2 - cross_product(omega_s2, cross_product(omega_s2,iArm )) - cross_product(alpha_s2,iArm) ) * mem%m_mg_u(i)
Expand Down Expand Up @@ -2829,9 +2830,11 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,
! ------------------ flooded ballast inertia: sides: Section 6.1.1 : Always compute regardless of PropPot setting ---------------------
! lower node
Ioffset = mem%h_cfb_l(i)*mem%h_cfb_l(i)*mem%m_fb_l(i)
Imat = 0.0_ReKi
Imat(1,1) = mem%I_rfb_l(i) - Ioffset
Imat(2,2) = mem%I_rfb_l(i) - Ioffset
Imat(3,3) = mem%I_lfb_l(i) - Ioffset
Imat(3,3) = mem%I_lfb_l(i)
Imat = matmul(matmul(CMatrix, Imat), CTrans)
iArm = mem%h_cfb_l(i) * k_hat
iTerm = ( -a_s1 - cross_product(omega_s1, cross_product(omega_s1,iArm )) - cross_product(alpha_s1,iArm) ) * mem%m_fb_l(i)
F_If(1:3) = iTerm
Expand All @@ -2843,9 +2846,11 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,

! upper node
Ioffset = mem%h_cfb_u(i)*mem%h_cfb_u(i)*mem%m_fb_u(i)
Imat = 0.0_ReKi
Imat(1,1) = mem%I_rfb_u(i) - Ioffset
Imat(2,2) = mem%I_rfb_u(i) - Ioffset
Imat(3,3) = mem%I_lfb_u(i) - Ioffset
Imat(3,3) = mem%I_lfb_u(i)
Imat = matmul(matmul(CMatrix, Imat), CTrans)
iArm = mem%h_cfb_u(i) * k_hat
iTerm = ( -a_s2 - cross_product(omega_s2, cross_product(omega_s2,iArm )) - cross_product(alpha_s2,iArm) ) * mem%m_fb_u(i)
F_If(1:3) = iTerm
Expand Down Expand Up @@ -3037,7 +3042,7 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,
! Compute the distributed loads at the point of intersection between the member and the free surface !
!----------------------------------------------------------------------------------------------------!
! Get wave kinematics at the free-surface intersection. Set forceNodeInWater=.TRUE. to guarantee the free-surface intersection is in water.
CALL WaveField_GetNodeWaveKin( p%WaveField, m%SeaSt_Interp_m, Time, FSInt, .TRUE., nodeInWater, WaveElev1, WaveElev2, WaveElev, FDynP, FV, FA, FAMCF, ErrStat2, ErrMsg2 )
CALL WaveField_GetNodeWaveKin( p%WaveField, m%WaveField_m, Time, FSInt, .TRUE., nodeInWater, WaveElev1, WaveElev2, WaveElev, FDynP, FV, FA, FAMCF, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
FDynPFSInt = REAL(FDynP,ReKi)
FVFSInt = REAL(FV, ReKi)
Expand Down Expand Up @@ -3579,7 +3584,7 @@ SUBROUTINE GetTotalWaveElev( Time, pos, Zeta, ErrStat, ErrMsg )
ErrStat = ErrID_None
ErrMsg = ""

Zeta = WaveField_GetNodeTotalWaveElev( p%WaveField, m%SeaSt_Interp_m, Time, pos, ErrStat2, ErrMsg2 )
Zeta = WaveField_GetNodeTotalWaveElev( p%WaveField, m%WaveField_m, Time, pos, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )

END SUBROUTINE GetTotalWaveElev
Expand All @@ -3597,7 +3602,7 @@ SUBROUTINE GetFreeSurfaceNormal( Time, pos, r, n, ErrStat, ErrMsg)
ErrStat = ErrID_None
ErrMsg = ""

CALL WaveField_GetNodeWaveNormal( p%WaveField, m%SeaSt_Interp_m, Time, pos, r, n, ErrStat2, ErrMsg2 )
CALL WaveField_GetNodeWaveNormal( p%WaveField, m%WaveField_m, Time, pos, r, n, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )

END SUBROUTINE GetFreeSurfaceNormal
Expand Down Expand Up @@ -4212,7 +4217,7 @@ SUBROUTINE Morison_UpdateDiscState( Time, u, p, x, xd, z, OtherState, m, errStat
END IF

! Get fluid velocity at the joint
CALL WaveField_GetNodeWaveVel( p%WaveField, m%SeaSt_Interp_m, Time, pos, .FALSE., nodeInWater, FVTmp, ErrStat2, ErrMsg2 )
CALL WaveField_GetNodeWaveVel( p%WaveField, m%WaveField_m, Time, pos, .FALSE., nodeInWater, FVTmp, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
FV = REAL(FVTmp, ReKi)
vrel = ( FV - u%Mesh%TranslationVel(:,J) ) * nodeInWater
Expand Down
3 changes: 1 addition & 2 deletions modules/hydrodyn/src/Morison.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# ...... Include files (definitions from NWTC Library) ............................................................................
# make sure that the file name does not have any trailing white spaces!
include Registry_NWTC_Library.txt
usefrom SeaState_Interp.txt
usefrom SeaSt_WaveField.txt
#
#
Expand Down Expand Up @@ -323,7 +322,7 @@ typedef ^ ^ ReKi
typedef ^ ^ ReKi V_rel_n {:} - - "Normal relative flow velocity at joints" m/s
typedef ^ ^ ReKi V_rel_n_HiPass {:} - - "High-pass filtered normal relative flow velocity at joints" m/s
typedef ^ ^ MeshMapType VisMeshMap - - - "Mesh mapping for visualization mesh" -
typedef ^ ^ SeaSt_Interp_MiscVarType SeaSt_Interp_m - - - "misc var information from the SeaState Interpolation module" -
typedef ^ ^ SeaSt_WaveField_MiscVarType WaveField_m - - - "misc var information from the SeaState Interpolation module" -

# ..... Parameters ................................................................................................................
# Define parameters here:
Expand Down
11 changes: 5 additions & 6 deletions modules/hydrodyn/src/Morison_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
!! unpack routines associated with each defined data type. This code is automatically generated by the FAST Registry.
MODULE Morison_Types
!---------------------------------------------------------------------------------------------------------------------------------
USE SeaState_Interp_Types
USE SeaSt_WaveField_Types
USE NWTC_Library
IMPLICIT NONE
Expand Down Expand Up @@ -386,7 +385,7 @@ MODULE Morison_Types
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: V_rel_n !< Normal relative flow velocity at joints [m/s]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: V_rel_n_HiPass !< High-pass filtered normal relative flow velocity at joints [m/s]
TYPE(MeshMapType) :: VisMeshMap !< Mesh mapping for visualization mesh [-]
TYPE(SeaSt_Interp_MiscVarType) :: SeaSt_Interp_m !< misc var information from the SeaState Interpolation module [-]
TYPE(SeaSt_WaveField_MiscVarType) :: WaveField_m !< misc var information from the SeaState Interpolation module [-]
END TYPE Morison_MiscVarType
! =======================
! ========= Morison_ParameterType =======
Expand Down Expand Up @@ -3570,7 +3569,7 @@ subroutine Morison_CopyMisc(SrcMiscData, DstMiscData, CtrlCode, ErrStat, ErrMsg)
call NWTC_Library_CopyMeshMapType(SrcMiscData%VisMeshMap, DstMiscData%VisMeshMap, CtrlCode, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat >= AbortErrLev) return
call SeaSt_Interp_CopyMisc(SrcMiscData%SeaSt_Interp_m, DstMiscData%SeaSt_Interp_m, CtrlCode, ErrStat2, ErrMsg2)
call SeaSt_WaveField_CopyMisc(SrcMiscData%WaveField_m, DstMiscData%WaveField_m, CtrlCode, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat >= AbortErrLev) return
end subroutine
Expand Down Expand Up @@ -3654,7 +3653,7 @@ subroutine Morison_DestroyMisc(MiscData, ErrStat, ErrMsg)
end if
call NWTC_Library_DestroyMeshMapType(MiscData%VisMeshMap, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
call SeaSt_Interp_DestroyMisc(MiscData%SeaSt_Interp_m, ErrStat2, ErrMsg2)
call SeaSt_WaveField_DestroyMisc(MiscData%WaveField_m, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
end subroutine

Expand Down Expand Up @@ -3694,7 +3693,7 @@ subroutine Morison_PackMisc(RF, Indata)
call RegPackAlloc(RF, InData%V_rel_n)
call RegPackAlloc(RF, InData%V_rel_n_HiPass)
call NWTC_Library_PackMeshMapType(RF, InData%VisMeshMap)
call SeaSt_Interp_PackMisc(RF, InData%SeaSt_Interp_m)
call SeaSt_WaveField_PackMisc(RF, InData%WaveField_m)
if (RegCheckErr(RF, RoutineName)) return
end subroutine

Expand Down Expand Up @@ -3740,7 +3739,7 @@ subroutine Morison_UnPackMisc(RF, OutData)
call RegUnpackAlloc(RF, OutData%V_rel_n); if (RegCheckErr(RF, RoutineName)) return
call RegUnpackAlloc(RF, OutData%V_rel_n_HiPass); if (RegCheckErr(RF, RoutineName)) return
call NWTC_Library_UnpackMeshMapType(RF, OutData%VisMeshMap) ! VisMeshMap
call SeaSt_Interp_UnpackMisc(RF, OutData%SeaSt_Interp_m) ! SeaSt_Interp_m
call SeaSt_WaveField_UnpackMisc(RF, OutData%WaveField_m) ! WaveField_m
end subroutine

subroutine Morison_CopyParam(SrcParamData, DstParamData, CtrlCode, ErrStat, ErrMsg)
Expand Down
9 changes: 5 additions & 4 deletions modules/hydrodyn/src/SS_Excitation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
!
!**********************************************************************************************************************************
MODULE SS_Excitation
USE SeaState_Interp
USE SS_Excitation_Types
USE SS_Excitation_Types
use SeaSt_WaveField, only: WaveField_GetNodeTotalWaveElev
USE NWTC_Library

IMPLICIT NONE
Expand Down Expand Up @@ -110,8 +110,9 @@ function GetWaveElevation ( time, u_in, t_in, p, m, ErrStat, ErrMsg )
call SS_Exc_Input_ExtrapInterp(u_in, t_in, u_out, time, ErrStat2, ErrMsg2 )
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)

do iBody = 1, p%NBody
GetWaveElevation(iBody) = SeaSt_Interp_3D( time, u_out%PtfmPos(1:2,iBody), p%WaveField%WaveElev1, p%WaveField%SeaSt_interp_p, m%SeaSt_Interp_m%FirstWarn_Clamp, ErrStat2, ErrMsg2 )
do iBody = 1, p%NBody
!FIXME: this is the total wave elevation. Should it include second order, or should it only include first order?
GetWaveElevation(iBody) = WaveField_GetNodeTotalWaveElev(p%WaveField, m%WaveField_m, time, u_out%PtfmPos(1:2,iBody), ErrStat2, ErrMsg2 )
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
end do

Expand Down
11 changes: 5 additions & 6 deletions modules/hydrodyn/src/SS_Excitation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# (File) Revision #: $Rev$
# URL: $HeadURL$
###################################################################################################################################
usefrom SeaState_Interp.txt
usefrom SeaSt_WaveField.txt

typedef SS_Excitation/SS_Exc InitInputType CHARACTER(1024) InputFile - - - "Name of the input file" -
Expand All @@ -24,14 +23,14 @@ typedef ^ ^ R8Ki
typedef ^ ^ SeaSt_WaveFieldType *WaveField - - - "Pointer to SeaState wave field" -



typedef ^ InitOutputType CHARACTER(10) WriteOutputHdr {:} - - "Header of the output" -
typedef ^ InitOutputType CHARACTER(10) WriteOutputUnt {:} - - "Units of the output" -

typedef ^ ContinuousStateType R8Ki x {:} - - "Continuous States" -

typedef ^ DiscreteStateType SiKi DummyDiscState - - - "" -

# Define constraint states here:
typedef ^ ConstraintStateType SiKi DummyConstrState - - - "" -

Expand All @@ -44,7 +43,7 @@ typedef ^ ^ SS_Exc_ContinuousStateType
# Define any data that are used only for efficiency purposes (these variables are not associated with time):
# e.g. indices for searching in an array, large arrays that are local variables in any routine called multiple times, etc.
typedef ^ MiscVarType INTEGER LastIndWave - 1 - "last used index in the WaveTime array" -
typedef ^ ^ SeaSt_Interp_MiscVarType SeaSt_Interp_m - - - "misc var information from the SeaState Interpolation module" -
typedef ^ ^ SeaSt_WaveField_MiscVarType WaveField_m - - - "misc var information from the SeaState Interpolation module" -


# ..... Parameters .........................
Expand Down
Loading

0 comments on commit 434a759

Please sign in to comment.