Skip to content

Commit

Permalink
Merge pull request #1804 from luwang00/dev-unstable-pointers
Browse files Browse the repository at this point in the history
Bug Fix with MSL2SWL
  • Loading branch information
andrew-platt authored Oct 23, 2023
2 parents bb9a8aa + b6b7561 commit f36dab9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
13 changes: 2 additions & 11 deletions modules/hydrodyn/src/Morison.f90
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,7 @@ SUBROUTINE WriteSummaryFile( UnSum, MSL2SWL, numJoints, numNodes, nodes, numMemb
totalMGVol = totalMGVol + mem%Vouter - mem%Vinner
totalDisplVol = totalDisplVol + mem%Vsubmerged
totalFillVol = totalFillVol + mem%Vballast

! IF ( node2%Position(3) <= MSL2SWL .AND. node1%Position(3) >= -WtrDpth) totalDisplVol = totalDisplVol + elementVol



do i = 1, mem%NElements
totalMGMass = totalMGMass + mem%m_mg_l(i)
totalMGMass = totalMGMass + mem%m_mg_u(i)
Expand Down Expand Up @@ -2128,7 +2125,7 @@ SUBROUTINE Morison_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, In
tMG = -999.0
An_drag = 0.0

IF ( InitInp%InpJoints(i)%Position(3) >= -p%WtrDpth ) THEN
IF ( (InitInp%InpJoints(i)%Position(3)-p%MSL2SWL) >= -p%WtrDpth ) THEN

! loop through each member attached to the joint, getting the radius of its appropriate end
DO J = 1, InitInp%InpJoints(I)%NConnections
Expand Down Expand Up @@ -2560,7 +2557,6 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,
REAL(ReKi) :: FDynPFSInt
REAL(ReKi) :: vrelFSInt(3)
REAL(ReKi) :: pos1Prime(3)
REAL(ReKi) :: WtrDpth
REAL(ReKi) :: FAMCFFSInt(3)
INTEGER(IntKi) :: MemSubStat, NumFSX
REAL(DbKi) :: theta1, theta2
Expand All @@ -2575,7 +2571,6 @@ SUBROUTINE Morison_CalcOutput( Time, u, p, x, xd, z, OtherState, y, m, errStat,
errMsg = ""
Imat = 0.0_ReKi
g = p%Gravity
WtrDpth = p%WtrDpth + p%MSL2SWL ! Water depth measured from the still water level

!===============================================================================================
! Get displaced positions of the hydrodynamic nodes
Expand Down Expand Up @@ -4155,7 +4150,6 @@ SUBROUTINE Morison_UpdateDiscState( Time, u, p, x, xd, z, OtherState, m, errStat
CHARACTER(*), INTENT( OUT) :: errMsg !< Error message if errStat /= ErrID_None
INTEGER(IntKi) :: J
INTEGER(IntKi) :: nodeInWater
REAL(ReKi) :: WtrDpth
REAL(ReKi) :: pos(3), vrel(3), FV(3), vmag, vmagf
REAL(SiKi) :: FVTmp(3)
INTEGER(IntKi) :: errStat2
Expand All @@ -4165,9 +4159,6 @@ SUBROUTINE Morison_UpdateDiscState( Time, u, p, x, xd, z, OtherState, m, errStat
! Initialize errStat
errStat = ErrID_None
errMsg = ""

! Water depth measured from the free surface
WtrDpth = p%WtrDpth + p%MSL2SWL

! Update state of the relative normal velocity high-pass filter at each joint
DO J = 1, p%NJoints
Expand Down
24 changes: 13 additions & 11 deletions modules/seastate/src/SeaState.f90
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,16 @@ SUBROUTINE SeaSt_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Init
p%OutSFmt = InputFileData%OutSFmt
p%NumOuts = InputFileData%NumOuts

! Define initialization-routine output here:
! Define initialization-routine output here:
InitOut%Ver = SeaSt_ProgDesc
! These three come directly from processing the inputs, and so will exist even if not using Morison elements:
InitOut%WtrDens = InputFileData%Waves%WtrDens
InitOut%WtrDpth = InputFileData%Waves%WtrDpth
p%WaveStMod = InputFileData%Waves%WaveStMod
InitOut%MSL2SWL = InputFileData%MSL2SWL
p%WtrDpth = InitOut%WtrDpth
! These three come directly from processing the inputs, and so will exist even if not using Morison elements:
InitOut%WtrDens = InputFileData%Waves%WtrDens
InitOut%WtrDpth = InputFileData%Waves%WtrDpth - InputFileData%MSL2SWL
InitOut%EffWtrDpth = InputFileData%Waves%WtrDpth
InitOut%MSL2SWL = InputFileData%MSL2SWL
p%WaveStMod = InputFileData%Waves%WaveStMod
p%WtrDpth = InitOut%WtrDpth
p%EffWtrDpth = InitOut%EffWtrDpth

InitOut%WaveMultiDir = InputFileData%Waves%WaveMultiDir
InitOut%MCFD = InputFileData%Waves%MCFD
Expand Down Expand Up @@ -543,15 +545,15 @@ SUBROUTINE SeaSt_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Init
InitOut%WvHiCOffS = InputFileData%Waves2%WvHiCOffS
InitOut%WaveDirMod = InputFileData%Waves%WaveDirMod
InitOut%WaveDir = InputFileData%Waves%WaveDir ! For WAMIT for use in SS_Excitation
InitOut%WtrDens = InputFileData%Waves%WtrDens
InitOut%WtrDpth = InputFileData%Waves%WtrDpth
InitOut%MSL2SWL = InputFileData%MSL2SWL
! InitOut%WtrDens = InputFileData%Waves%WtrDens
! InitOut%WtrDpth = InputFileData%Waves%WtrDpth
! InitOut%MSL2SWL = InputFileData%MSL2SWL

InitOut%SeaSt_Interp_p = p%seast_interp_p

! Build WaveField
p%WaveField%MSL2SWL = InitOut%MSL2SWL
p%WaveField%EffWtrDpth = p%WtrDpth + InitOut%MSL2SWL ! Effective water depth measured from the SWL
p%WaveField%EffWtrDpth = p%EffWtrDpth ! Effective water depth measured from the SWL
p%WaveField%WaveStMod = p%WaveStMod
! p%WaveField%WaveTime => Waves_InitOut%WaveTime
! p%WaveField%WaveElev1 => Waves_InitOut%WaveElev
Expand Down
2 changes: 2 additions & 0 deletions modules/seastate/src/SeaState.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ typedef ^ ^ CHARACTER(ChanLen) Wri
typedef ^ ^ ProgDesc Ver - - - "Version of SeaState"
typedef ^ ^ ReKi WtrDens - - - "Water density, this is necessary to inform glue-code what the module is using for WtrDens (may not be the glue-code's default)" (kg/m^3)
typedef ^ ^ ReKi WtrDpth - - - "Water depth, this is necessary to inform glue-code what the module is using for WtrDpth (may not be the glue-code's default)" (m)
typedef ^ ^ ReKi EffWtrDpth - - - "Effective water depth equal to the sum of input WtrDpth and MSL2SWL" (m)
typedef ^ ^ ReKi MSL2SWL - - - "Offset between still-water level and mean sea level, this is necessary to inform glue-code what the module is using for MSL2SWL (may not be the glue-code's default)" (m)
typedef ^ ^ SiKi WaveElevC0 {*}{*} - - "Discrete Fourier transform of the instantaneous elevation of incident waves at the platform reference point. First column is real part, second column is imaginary part" (meters)
typedef ^ ^ SiKi WaveElevC {*}{*}{*} - - "Discrete Fourier transform of the instantaneous elevation of incident waves at all grid points. First column is real part, second column is imaginary part" (meters)
Expand Down Expand Up @@ -175,6 +176,7 @@ typedef ^ ^ SiKi Wav
typedef ^ ^ SiKi WaveKinyi {:} - - "yi-coordinates for points where the incident wave kinematics can be output; these are relative to the mean sea level" (meters)
typedef ^ ^ SiKi WaveKinzi {:} - - "zi-coordinates for points where the incident wave kinematics can be output; these are relative to the mean sea level" (meters)
typedef ^ ^ ReKi WtrDpth - - - "Water depth" (m)
typedef ^ ^ ReKi EffWtrDpth - - - "Effective water depth equal to the sum of input WtrDpth and MSL2SWL" (m)
typedef ^ ^ DbKi DT - - - "Time step in seconds for integration of continuous states (if a fixed-step integrator is used) and update of discrete states" -
typedef ^ ^ IntKi WaveStMod - - - "Wave stretching model" -
typedef ^ ^ OutParmType OutParam {:} - - "" -
Expand Down
2 changes: 1 addition & 1 deletion modules/seastate/src/SeaState_Input.f90
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ subroutine SeaSt_ParseInput( InputFileName, OutRootName, defWtrDens, defWtrDpth,
if (Failed()) return;

! Z_Depth - Depth of the domain the Z direction.
call ParseVarWDefault ( FileInfo_In, CurLine, 'Z_Depth', InputFileData%Z_Depth, defWtrDpth, ErrStat2, ErrMsg2, UnEc )
call ParseVarWDefault ( FileInfo_In, CurLine, 'Z_Depth', InputFileData%Z_Depth, defWtrDpth+InputFileData%MSL2SWL, ErrStat2, ErrMsg2, UnEc )
if (Failed()) return;

! NX - Number of nodes in half of the X-direction domain.
Expand Down
10 changes: 10 additions & 0 deletions modules/seastate/src/SeaState_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ MODULE SeaState_Types
TYPE(ProgDesc) :: Ver !< Version of SeaState [-]
REAL(ReKi) :: WtrDens = 0.0_ReKi !< Water density, this is necessary to inform glue-code what the module is using for WtrDens (may not be the glue-code's default) [(kg/m^3)]
REAL(ReKi) :: WtrDpth = 0.0_ReKi !< Water depth, this is necessary to inform glue-code what the module is using for WtrDpth (may not be the glue-code's default) [(m)]
REAL(ReKi) :: EffWtrDpth = 0.0_ReKi !< Effective water depth equal to the sum of input WtrDpth and MSL2SWL [(m)]
REAL(ReKi) :: MSL2SWL = 0.0_ReKi !< Offset between still-water level and mean sea level, this is necessary to inform glue-code what the module is using for MSL2SWL (may not be the glue-code's default) [(m)]
REAL(SiKi) , DIMENSION(:,:), POINTER :: WaveElevC0 => NULL() !< Discrete Fourier transform of the instantaneous elevation of incident waves at the platform reference point. First column is real part, second column is imaginary part [(meters)]
REAL(SiKi) , DIMENSION(:,:,:), POINTER :: WaveElevC => NULL() !< Discrete Fourier transform of the instantaneous elevation of incident waves at all grid points. First column is real part, second column is imaginary part [(meters)]
Expand Down Expand Up @@ -195,6 +196,7 @@ MODULE SeaState_Types
REAL(SiKi) , DIMENSION(:), ALLOCATABLE :: WaveKinyi !< yi-coordinates for points where the incident wave kinematics can be output; these are relative to the mean sea level [(meters)]
REAL(SiKi) , DIMENSION(:), ALLOCATABLE :: WaveKinzi !< zi-coordinates for points where the incident wave kinematics can be output; these are relative to the mean sea level [(meters)]
REAL(ReKi) :: WtrDpth = 0.0_ReKi !< Water depth [(m)]
REAL(ReKi) :: EffWtrDpth = 0.0_ReKi !< Effective water depth equal to the sum of input WtrDpth and MSL2SWL [(m)]
REAL(DbKi) :: DT = 0.0_R8Ki !< Time step in seconds for integration of continuous states (if a fixed-step integrator is used) and update of discrete states [-]
INTEGER(IntKi) :: WaveStMod = 0_IntKi !< Wave stretching model [-]
TYPE(OutParmType) , DIMENSION(:), ALLOCATABLE :: OutParam !< [-]
Expand Down Expand Up @@ -738,6 +740,7 @@ subroutine SeaSt_CopyInitOutput(SrcInitOutputData, DstInitOutputData, CtrlCode,
if (ErrStat >= AbortErrLev) return
DstInitOutputData%WtrDens = SrcInitOutputData%WtrDens
DstInitOutputData%WtrDpth = SrcInitOutputData%WtrDpth
DstInitOutputData%EffWtrDpth = SrcInitOutputData%EffWtrDpth
DstInitOutputData%MSL2SWL = SrcInitOutputData%MSL2SWL
DstInitOutputData%WaveElevC0 => SrcInitOutputData%WaveElevC0
DstInitOutputData%WaveElevC => SrcInitOutputData%WaveElevC
Expand Down Expand Up @@ -850,6 +853,7 @@ subroutine SeaSt_PackInitOutput(Buf, Indata)
call NWTC_Library_PackProgDesc(Buf, InData%Ver)
call RegPack(Buf, InData%WtrDens)
call RegPack(Buf, InData%WtrDpth)
call RegPack(Buf, InData%EffWtrDpth)
call RegPack(Buf, InData%MSL2SWL)
call RegPack(Buf, associated(InData%WaveElevC0))
if (associated(InData%WaveElevC0)) then
Expand Down Expand Up @@ -1049,6 +1053,8 @@ subroutine SeaSt_UnPackInitOutput(Buf, OutData)
if (RegCheckErr(Buf, RoutineName)) return
call RegUnpack(Buf, OutData%WtrDpth)
if (RegCheckErr(Buf, RoutineName)) return
call RegUnpack(Buf, OutData%EffWtrDpth)
if (RegCheckErr(Buf, RoutineName)) return
call RegUnpack(Buf, OutData%MSL2SWL)
if (RegCheckErr(Buf, RoutineName)) return
if (associated(OutData%WaveElevC0)) deallocate(OutData%WaveElevC0)
Expand Down Expand Up @@ -1800,6 +1806,7 @@ subroutine SeaSt_CopyParam(SrcParamData, DstParamData, CtrlCode, ErrStat, ErrMsg
DstParamData%WaveKinzi = SrcParamData%WaveKinzi
end if
DstParamData%WtrDpth = SrcParamData%WtrDpth
DstParamData%EffWtrDpth = SrcParamData%EffWtrDpth
DstParamData%DT = SrcParamData%DT
DstParamData%WaveStMod = SrcParamData%WaveStMod
if (allocated(SrcParamData%OutParam)) then
Expand Down Expand Up @@ -2051,6 +2058,7 @@ subroutine SeaSt_PackParam(Buf, Indata)
call RegPack(Buf, InData%WaveKinzi)
end if
call RegPack(Buf, InData%WtrDpth)
call RegPack(Buf, InData%EffWtrDpth)
call RegPack(Buf, InData%DT)
call RegPack(Buf, InData%WaveStMod)
call RegPack(Buf, allocated(InData%OutParam))
Expand Down Expand Up @@ -2496,6 +2504,8 @@ subroutine SeaSt_UnPackParam(Buf, OutData)
end if
call RegUnpack(Buf, OutData%WtrDpth)
if (RegCheckErr(Buf, RoutineName)) return
call RegUnpack(Buf, OutData%EffWtrDpth)
if (RegCheckErr(Buf, RoutineName)) return
call RegUnpack(Buf, OutData%DT)
if (RegCheckErr(Buf, RoutineName)) return
call RegUnpack(Buf, OutData%WaveStMod)
Expand Down

0 comments on commit f36dab9

Please sign in to comment.