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

Cleanup HydroDyn and SeaState code #1864

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b46e9bd
Cleanup HD InitInputs and some VS build projects
bjonkman Oct 30, 2023
1d1a6f0
SeaSt/HD: remove extra copies of `WaveTime`
bjonkman Oct 30, 2023
9a1c41b
SeaSt: remove extra copies of `WaveElevC0`
bjonkman Oct 30, 2023
02b049b
SeaSt: remove extra copies of `WaveDirArr`
bjonkman Oct 30, 2023
e3a00f7
HD: replace pointers to individual arrays with pointer to WaveField
bjonkman Oct 30, 2023
24c4c8e
HD: removed commented-out subroutines
bjonkman Oct 30, 2023
ca755c2
SeaSt: remove extra `WaveDynP` pointers
bjonkman Oct 31, 2023
c332e92
SeaSt: remove extra `PWaveAccMCF0` pointers
bjonkman Oct 31, 2023
06c79dd
SeaSt: remove extra `WaveAccMCF` pointers
bjonkman Oct 31, 2023
9d59f19
SeaSt: remove extra `PWaveVel0` pointers
bjonkman Oct 31, 2023
1cd3397
SeaSt: remove extra `PWaveDynP0` pointers
bjonkman Oct 31, 2023
36b5b95
SeaSt: remove extra `PWaveAcc0` pointers
bjonkman Oct 31, 2023
73ef856
SeaSt: remove extra `WaveElev1` and `WaveElev2` pointers
bjonkman Oct 31, 2023
82aa4dc
SeaSt: fix bug in ca755c20
bjonkman Oct 31, 2023
0d14ff3
SeaSt: remove extra `WaveAcc` pointers
bjonkman Oct 31, 2023
b8c7001
SeaSt: remove extra `WaveVel` pointers
bjonkman Oct 31, 2023
5923994
SeaSt: remove extra `WaveElev0` pointers
bjonkman Oct 31, 2023
a72a35d
SeaSt: remove extra `WaveElevC` pointers
bjonkman Oct 31, 2023
e0e9fea
SeaSt: remove extra copies of `EffWtrDpth`
bjonkman Oct 31, 2023
7d60227
HD/SeaSt: remove extra copies of `MSL2SWL`
bjonkman Oct 31, 2023
eb93c94
HD/SeaSt: remove extra `WaveStMod` copies
bjonkman Nov 1, 2023
2dd9c06
HD C bindings: fix HD initializations
bjonkman Nov 1, 2023
976e9a7
Fix MSL2SWL input to IceDyn
bjonkman Nov 1, 2023
3aa1690
HD/SeaSt: remove extra `WtrDens` and `RhoXg` copies
bjonkman Nov 1, 2023
c4da885
HD/SeaSt: `WaveDir`, `WaveDirMin`, `WaveDirMax`, and `WaveMultiDir`
bjonkman Nov 1, 2023
3109eaa
SeaSt: remove unused `WaveElev` pointer
bjonkman Nov 2, 2023
37ac2fe
HD: remove unused SS Excitation & Radiation driver codes
bjonkman Nov 2, 2023
49344ea
HD: remove unnecessary `WaveElev0`, `WaveElevC`, and `WaveElev1` vars
bjonkman Nov 2, 2023
b6f6b51
HD/SeaSt: move `MCFD` to WaveField data structure
bjonkman Nov 2, 2023
bc1de35
HD/SeaSt: move WvLowCOff & WvHiCOff to WaveField
bjonkman Nov 2, 2023
ec98379
HD/SeaSt: WvLowCOffD, WvHiCOffD, WvLowCOffS, WvHiCOffS cleanup
bjonkman Nov 2, 2023
a8e2e9c
HD/SeaSt: `WaveDOmega` now in WaveField type
bjonkman Nov 3, 2023
0296905
HD/SeaSt: cleanup `WaveDirMod` usage
bjonkman Nov 3, 2023
4923a59
HD/SeaSt: `WtrDpth` level 1
bjonkman Nov 6, 2023
2bda79f
HD/SeaSt: cleanup SeaSt_Interp
bjonkman Nov 6, 2023
ee52170
SeaSt: use `WtrDpth` and `EffWtrDpth`
bjonkman Nov 6, 2023
9add32c
HD: use `EffWtrDpth` from WaveField instead of modified `WtrDpth`
bjonkman Nov 6, 2023
3ec0b5f
HD/SeaSt: cleanup `WaveMod`
bjonkman Nov 7, 2023
f86ffc0
SeaSt: remove extra `WaveSeed` arrays
bjonkman Nov 7, 2023
827f2d2
HD: additional cleanup of MSL2SWL
bjonkman Nov 7, 2023
ea8b3e6
SeaSt: cleanup `WvDiffQTFF` and `WvSumQTFF`
bjonkman Nov 8, 2023
fc08556
SeaState: Fix typo in message about adjusting WvHiCoff based on WaveDT
luwang00 Nov 8, 2023
dca5165
HD/SeaSt: `NStepWave` and `NStepWave2` stored in WaveField
bjonkman Nov 8, 2023
5f68c31
HD/SeaSt: remove unused variables
bjonkman Nov 8, 2023
76202a1
SeaSt: remove extra copy of `Z_Depth`
bjonkman Nov 8, 2023
a16dae5
SeaSt: fix bug in SeaSt driver from dca516
bjonkman Nov 8, 2023
df658dc
SeaSt: remove extra HalfWidth parameters
bjonkman Nov 9, 2023
ff7a7b9
SeaSt: cleanup file read of WavePkShp and WaveMod
bjonkman Nov 9, 2023
09bdd38
HD/SeaSt: cleanup unused variables
bjonkman Nov 9, 2023
b159e92
Merge branch 'dev' into f/WaveField_cleanup
bjonkman Nov 9, 2023
5c34683
HD: fix potential memory issue if no outputs were requested
bjonkman Nov 9, 2023
e1c1c4e
HD: fix bug in ff7a7b
bjonkman Nov 9, 2023
67c77c4
HD/SeaSt: Address review comments
bjonkman Nov 16, 2023
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
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