Skip to content

Commit

Permalink
Merge pull request #1864 from bjonkman/f/WaveField_cleanup
Browse files Browse the repository at this point in the history
Cleanup HydroDyn and SeaState code
  • Loading branch information
andrew-platt authored Nov 17, 2023
2 parents 2474693 + 67c77c4 commit 897d6ee
Show file tree
Hide file tree
Showing 51 changed files with 1,865 additions and 6,059 deletions.
3 changes: 0 additions & 3 deletions modules/hydrodyn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ if(APPLE OR UNIX)
endif()


#add_executable(ss_radiation
# src/SS_Radiation_DriverCode.f90)
#target_link_libraries(ss_radiation hydrodynlib nwtclibs)

install(TARGETS hydrodynlib hydrodyn_driver hydrodyn_driver_subs hydrodyn_c_binding
EXPORT "${CMAKE_PROJECT_NAME}Libraries"
Expand Down
3 changes: 1 addition & 2 deletions modules/hydrodyn/src/Conv_Radiation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ SUBROUTINE Conv_Rdtn_Init( InitInp, u, p, x, xd, z, OtherState, y, m, InitOut, E
m%LastIndRdtn = 0
OtherState%IndRdtn = 0

! bjj: these initializations don't matter, but I don't like seeing the compilation warning in IVF:
! bjj: these initializations don't matter, but I don't like seeing the compilation warning in Intel Fortran:
x%DummyContState = 0.0
z%DummyConstrState = 0.0
y%F_Rdtn = 0.0
Expand Down Expand Up @@ -632,7 +632,6 @@ SUBROUTINE Conv_Rdtn_UpdateDiscState( Time, n, u, p, x, xd, z, OtherState, m, Er
! with the newest values:
! NOTE: When IndRdtn > LastIndRdtn, IndRdtn will equal LastIndRdtn + 1 if DT <= RdtnDT;
! When IndRdtn > LastIndRdtn, IndRdtn will be greater than LastIndRdtn + 1 if DT > RdtnDT.
!BJJ: this needs a better check so that it is ALWAYS done (MATLAB/Simulink could possibly avoid this step by starting at Time>0, OR there may be some numerical issues where this is NOT EXACTLY zero)

IF ( OtherState%IndRdtn < (p%NStepRdtn) ) THEN
DO J = 1,6*p%NBody ! Loop through all platform DOFs
Expand Down
110 changes: 27 additions & 83 deletions modules/hydrodyn/src/HydroDyn.f90

Large diffs are not rendered by default.

36 changes: 3 additions & 33 deletions modules/hydrodyn/src/HydroDyn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ typedef ^ ^ ReKi
typedef ^ ^ ReKi AddCLin {:}{:}{:} - - "Additional stiffness matrix" -
typedef ^ ^ ReKi AddBLin {:}{:}{:} - - "Additional linear damping matrix" -
typedef ^ ^ ReKi AddBQuad {:}{:}{:} - - "Additional quadratic damping (drag) matrix" -
typedef ^ ^ SeaSt_InitInputType SeaState - - - "Initialization data for SeaState module" -
typedef ^ ^ CHARACTER(1024) PotFile {:} - - "The name of the root potential flow file (without extension for WAMIT, complete name for FIT)" -
typedef ^ ^ INTEGER nWAMITObj - - - "number of WAMIT input files. If NBodyMod = 1 then nPotFiles will be 1 even if NBody > 1" -
typedef ^ ^ INTEGER vecMultiplier - - - "multiplier for the WAMIT vectors and matrices. If NBodyMod=1 then this = NBody, else 1" -
Expand Down Expand Up @@ -72,36 +71,11 @@ typedef ^ ^ FileInfoTyp
typedef ^ ^ CHARACTER(1024) OutRootName - - - "Supplied by Driver: The name of the root file (without extension) including the full path" -
typedef ^ ^ Logical Linearize - .FALSE. - "Flag that tells this module if the glue code wants to linearize." -
typedef ^ ^ ReKi Gravity - - - "Supplied by Driver: Gravitational acceleration" "(m/s^2)"
typedef ^ ^ ReKi WtrDens - - - "Water density from the driver; may be overwritten " "(kg/m^3)"
typedef ^ ^ ReKi WtrDpth - - - "Water depth from the driver; may be overwritten " "m"
typedef ^ ^ ReKi MSL2SWL - - - "Mean sea level to still water level from the driver; may be overwritten" "m"
typedef ^ ^ DbKi TMax - - - "Supplied by Driver: The total simulation time" "(sec)"
typedef ^ ^ ReKi PtfmLocationX - - - "Supplied by Driver: X coordinate of platform location in the wave field" "m"
typedef ^ ^ ReKi PtfmLocationY - - - "Supplied by Driver: Y coordinate of platform location in the wave field" "m"
typedef ^ ^ logical VisMeshes - .false. - "Output visualization meshes" -
#
typedef ^ ^ INTEGER NStepWave - 0 - "Total number of frequency components = total number of time steps in the incident wave" -
typedef ^ ^ INTEGER NStepWave2 - 0 - "NStepWave / 2" -
typedef ^ ^ SiKi RhoXg - - - "= WtrDens*Gravity" -
typedef ^ ^ INTEGER WaveMod - - - "Incident wave kinematics model {0: none=still water, 1: plane progressive (regular), 2: JONSWAP/Pierson-Moskowitz spectrum (irregular), 3: white-noise spectrum, 4: user-defind spectrum from routine UserWaveSpctrm (irregular), 5: GH BLADED }" -
typedef ^ ^ INTEGER WaveStMod - - - "Model for stretching incident wave kinematics to instantaneous free surface {0: none=no stretching, 1: vertical stretching, 2: extrapolation stretching, 3: Wheeler stretching}" -
typedef ^ ^ INTEGER WaveDirMod - - - "Directional wave spreading function {0: none, 1: COS2S} [only used if WaveMod=6]" -
typedef ^ ^ SiKi WvLowCOff - - - "Low cut-off frequency or lower frequency limit of the wave spectrum beyond which the wave spectrum is zeroed. [used only when WaveMod=2,3,4]" (rad/s)
typedef ^ ^ SiKi WvHiCOff - - - "High cut-off frequency or upper frequency limit of the wave spectrum beyond which the wave spectrum is zeroed. [used only when WaveMod=2,3,4]" (rad/s)
typedef ^ ^ SiKi WvLowCOffD - - - "Minimum frequency used in the difference methods [Ignored if all difference methods = 0]" (rad/s)
typedef ^ ^ SiKi WvHiCOffD - - - "Maximum frequency used in the difference methods [Ignored if all difference methods = 0]" (rad/s)
typedef ^ ^ SiKi WvLowCOffS - - - "Minimum frequency used in the sum-QTF method [Ignored if SumQTF = 0]" (rad/s)
typedef ^ ^ SiKi WvHiCOffS - - - "Maximum frequency used in the sum-QTF method [Ignored if SumQTF = 0]" (rad/s)
typedef ^ ^ LOGICAL InvalidWithSSExctn - - - "Whether SeaState configuration is invalid with HydroDyn's state-space excitation (ExctnMod=2)" (-)
typedef ^ ^ SiKi WaveElev0 {:} - - "Instantaneous elevation time-series of incident waves at the platform reference point" (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)
typedef ^ ^ SiKi WaveDirMin - - - "Minimum wave direction." (degrees)
typedef ^ ^ SiKi WaveDirMax - - - "Maximum wave direction." (degrees)
typedef ^ ^ SiKi WaveDir - - - "Incident wave propagation heading direction" (degrees)
typedef ^ ^ LOGICAL WaveMultiDir - - - "Indicates the waves are multidirectional -- set by HydroDyn_Input" -
typedef ^ ^ SiKi WaveDOmega - - - "Frequency step for incident wave calculations" (rad/s)
typedef ^ ^ SiKi MCFD - - - "Diameter of MacCamy-Fuchs members" (meters)
typedef ^ ^ SeaSt_WaveFieldType *WaveField - - - "Pointer to SeaState wave field" -
typedef ^ ^ LOGICAL InvalidWithSSExctn - - - "Whether SeaState configuration is invalid with HydroDyn's state-space excitation (ExctnMod=2)" (-)
typedef ^ ^ SeaSt_WaveFieldType *WaveField - - - "Pointer to SeaState wave field" -
#
#
# Define outputs from the initialization routine here:
Expand Down Expand Up @@ -151,7 +125,6 @@ typedef ^ MiscVarType MeshType
typedef ^ ^ HD_ModuleMapType HD_MeshMap - - -
typedef ^ ^ INTEGER Decimate - - - "The output decimation counter" -
typedef ^ ^ DbKi LastOutTime - - - "Last time step which was written to the output file (sec)" -
typedef ^ ^ INTEGER LastIndWave - - - "The last index used in the wave kinematics arrays, used to optimize interpolation" -
typedef ^ ^ ReKi F_PtfmAdd {:} - - "The total forces and moments due to additional pre-load, stiffness, and damping" -
typedef ^ ^ ReKi F_Hydro {6} - - "The total hydrodynamic forces and moments integrated about the (0,0,0) platform reference point" -
typedef ^ ^ ReKi F_Waves {:} - - "The total waves forces on a WAMIT body calculated by first and second order methods (WAMIT and WAMIT2 modules)" -
Expand All @@ -175,9 +148,6 @@ typedef ^ ^ INTEGER
typedef ^ ^ INTEGER totalStates - - - "Number of excitation and radiation states for all WAMIT bodies" -
typedef ^ ^ INTEGER totalExctnStates - - - "Number of excitation states for all WAMIT bodies" -
typedef ^ ^ INTEGER totalRdtnStates - - - "Number of radiation states for all WAMIT bodies" -
typedef ^ ^ SiKi WaveTime {*} - - "Array of time samples, (sec)" -
typedef ^ ^ INTEGER NStepWave - - - "Number of data points in the wave kinematics arrays" -
typedef ^ ^ ReKi WtrDpth - - - "Water depth" (m)
typedef ^ ^ ReKi AddF0 {:}{:} - - "Additional pre-load forces and moments (N,N,N,N-m,N-m,N-m)" -
typedef ^ ^ ReKi AddCLin {:}{:}{:} - - "Additional stiffness matrix" -
typedef ^ ^ ReKi AddBLin {:}{:}{:} - - "Additional linear damping matrix" -
Expand All @@ -196,8 +166,8 @@ typedef ^ ^ Integer
typedef ^ ^ R8Ki du {:} - - "vector that determines size of perturbation for u (inputs)" -
typedef ^ ^ R8Ki dx {:} - - "vector that determines size of perturbation for x (continuous states)" -
typedef ^ ^ Integer Jac_ny - - - "number of outputs in jacobian matrix" -
typedef ^ ParameterType LOGICAL PointsToSeaState - .TRUE. - "Flag that determines if the data contains pointers to SeaState module or if new copies (from restart)" -
typedef ^ ^ logical VisMeshes - .false. - "Output visualization meshes" -
typedef ^ ^ SeaSt_WaveFieldType *WaveField - - - "Pointer to SeaState wave field" -
#
#
# ..... Inputs ....................................................................................................................
Expand Down
40 changes: 9 additions & 31 deletions modules/hydrodyn/src/HydroDyn_C_Binding.f90
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ SUBROUTINE HydroDyn_C_Init( OutRootName_C,
SeaSt%InitInp%defMSL2SWL = REAL(defMSL2SWL_C, ReKi) ! use values from SeaState
SeaSt%InitInp%TMax = REAL(TMax_C, DbKi)

! Platform reference position
! This is only specified as an (X,Y) position (no Z).
SeaSt%InitInp%PtfmLocationX = REAL(PtfmRefPtPositionX_C, ReKi)
SeaSt%InitInp%PtfmLocationY = REAL(PtfmRefPtPositionY_C, ReKi)


! Wave elevation output
! Wave elevations can be exported for a set of points (grid or any other layout).
! This feature is used only in the driver codes for exporting for visualization
Expand Down Expand Up @@ -398,41 +404,13 @@ SUBROUTINE HydroDyn_C_Init( OutRootName_C,

! Values passed in
HD%InitInp%Gravity = REAL(Gravity_C, ReKi)
HD%InitInp%WtrDens = REAL(defWtrDens_C, ReKi) ! use values from SeaState
HD%InitInp%WtrDpth = REAL(defWtrDpth_C, ReKi) ! use values from SeaState
HD%InitInp% MSL2SWL = REAL(defMSL2SWL_C, ReKi) ! use values from SeaState
HD%InitInp%TMax = REAL(TMax_C, DbKi)

! Transfer data from SeaState
! Need to set up other module's InitInput data here because we will also need to clean up SeaState data and would rather not defer that cleanup
HD%InitInp%NStepWave = SeaSt%InitOutData%NStepWave
HD%InitInp%NStepWave2 = SeaSt%InitOutData%NStepWave2
HD%InitInp%RhoXg = SeaSt%InitOutData%RhoXg
HD%InitInp%WaveMod = SeaSt%InitOutData%WaveMod
HD%InitInp%WaveStMod = SeaSt%InitOutData%WaveStMod
HD%InitInp%WaveDirMod = SeaSt%InitOutData%WaveDirMod
HD%InitInp%WvLowCOff = SeaSt%InitOutData%WvLowCOff
HD%InitInp%WvHiCOff = SeaSt%InitOutData%WvHiCOff
HD%InitInp%WvLowCOffD = SeaSt%InitOutData%WvLowCOffD
HD%InitInp%WvHiCOffD = SeaSt%InitOutData%WvHiCOffD
HD%InitInp%WvLowCOffS = SeaSt%InitOutData%WvLowCOffS
HD%InitInp%WvHiCOffS = SeaSt%InitOutData%WvHiCOffS
HD%InitInp%InvalidWithSSExctn = SeaSt%InitOutData%InvalidWithSSExctn

HD%InitInp%WaveDirMin = SeaSt%InitOutData%WaveDirMin
HD%InitInp%WaveDirMax = SeaSt%InitOutData%WaveDirMax
HD%InitInp%WaveDir = SeaSt%InitOutData%WaveDir
HD%InitInp%WaveMultiDir = SeaSt%InitOutData%WaveMultiDir
HD%InitInp%WaveDOmega = SeaSt%InitOutData%WaveDOmega
HD%InitInp%MCFD = SeaSt%InitOutData%MCFD

if(associated(SeaSt%InitOutData%WaveField )) HD%InitInp%WaveField => SeaSt%InitOutData%WaveField

! Platform reference position
! The HD model uses this for building the moddel. This is only specified as an (X,Y)
! position (no Z).
HD%InitInp%PtfmLocationX = REAL(PtfmRefPtPositionX_C, ReKi)
HD%InitInp%PtfmLocationY = REAL(PtfmRefPtPositionY_C, ReKi)
HD%InitInp%WaveField => SeaSt%InitOutData%WaveField ! can be set regardless of association(); if not associated, HD shouldn't work


!-------------------------------------------------------------
Expand Down Expand Up @@ -700,15 +678,15 @@ subroutine CheckDepth(ErrStat3,ErrMsg3)
real(ReKi) :: tmpZpos !< temporary z-position
ErrStat3 = ErrID_None
ErrMsg3 = ""
tmpZpos=-0.001_ReKi*abs(HD%p%WtrDpth) ! Initial comparison value close to surface
tmpZpos=-0.001_ReKi*abs(HD%p%WaveField%EffWtrDpth) ! Initial comparison value close to surface
if ( NumNodePts == 1 .and. HD%u(1)%Morison%Mesh%Committed ) then
do i=1,HD%u(1)%Morison%Mesh%Nnodes
! Find lowest Morison node
if (HD%u(1)%Morison%Mesh%Position(3,i) < tmpZpos) then
tmpZpos = HD%u(1)%Morison%Mesh%Position(3,i)
endif
enddo
if (tmpZpos < -abs(HD%p%WtrDpth)*0.9_ReKi) then ! within 10% of the seafloor
if (tmpZpos < -abs(HD%p%WaveField%EffWtrDpth)*0.9_ReKi) then ! within 10% of the seafloor
ErrStat3 = ErrID_Severe
ErrMsg3 = "Inconsistent model"//NewLine//" -- Single library input node for simulating rigid floating structure."// &
NewLine//" -- Lowest Morison node is is in lowest 10% of water depth indicating fixed bottom structure from HydroDyn."// &
Expand Down
Loading

0 comments on commit 897d6ee

Please sign in to comment.