Skip to content

Commit

Permalink
Merge pull request #11 from andrew-platt/f/SeaState_C_Bindings_update
Browse files Browse the repository at this point in the history
HD_C_Bindings updated for SeaState
  • Loading branch information
luwang00 authored May 23, 2023
2 parents 7880713 + c2ce211 commit a6efeb3
Show file tree
Hide file tree
Showing 8 changed files with 369 additions and 215 deletions.
2 changes: 1 addition & 1 deletion modules/hydrodyn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ target_link_libraries(hydrodyn_driver hydrodyn_driver_subs versioninfolib)
add_library(hydrodyn_c_binding SHARED
src/HydroDyn_C_Binding.f90
)
target_link_libraries(hydrodyn_c_binding hydrodynlib versioninfolib)
target_link_libraries(hydrodyn_c_binding hydrodynlib seastlib versioninfolib)
if(APPLE OR UNIX)
target_compile_definitions(hydrodyn_c_binding PRIVATE IMPLICIT_DLLEXPORT)
endif()
Expand Down
23 changes: 15 additions & 8 deletions modules/hydrodyn/python-lib/hydrodyn_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ def __init__(self, library_path):
def _initialize_routines(self):
self.HydroDyn_C_Init.argtypes = [
POINTER(c_char), # OutRootName
POINTER(c_char_p), # input file string
POINTER(c_int), # input file string length
POINTER(c_char_p), # SeaState input file string
POINTER(c_int), # SeaState input file string length
POINTER(c_char_p), # HydroDyn input file string
POINTER(c_int), # HydroDyn input file string length
POINTER(c_float), # gravity
POINTER(c_float), # defWtrDens
POINTER(c_float), # defWtrDpth
Expand Down Expand Up @@ -216,14 +218,17 @@ def _initialize_routines(self):
self.HydroDyn_C_End.restype = c_int

# hydrodyn_init ------------------------------------------------------------------------------------------------------------
def hydrodyn_init(self, input_string_array):
def hydrodyn_init(self, seast_input_string_array, hd_input_string_array):
# nodePositions -- N x 6 array -- position info as [x1,y1,z1,Rx1,Ry1,Rz1]

# Primary input file will be passed as a single string joined by
# C_NULL_CHAR.
input_string = '\x00'.join(input_string_array)
input_string = input_string.encode('utf-8')
input_string_length = len(input_string)
seast_input_string = '\x00'.join(seast_input_string_array)
seast_input_string = seast_input_string.encode('utf-8')
seast_input_string_length = len(seast_input_string)
hd_input_string = '\x00'.join(hd_input_string_array)
hd_input_string = hd_input_string.encode('utf-8')
hd_input_string_length = len(hd_input_string)

self._numChannels_c = c_int(0)

Expand Down Expand Up @@ -264,8 +269,10 @@ def hydrodyn_init(self, input_string_array):
# call HydroDyn_C_Init
self.HydroDyn_C_Init(
_outRootName_c, # IN: rootname for HD file writing
c_char_p(input_string), # IN: input file string
byref(c_int(input_string_length)), # IN: input file string length
c_char_p(seast_input_string), # IN: SeaState input file string
byref(c_int(seast_input_string_length)),# IN: SeaState input file string length
c_char_p(hd_input_string), # IN: HydroDyn input file string
byref(c_int(hd_input_string_length)), # IN: HydroDyn input file string length
byref(c_float(self.gravity)), # IN: gravity
byref(c_float(self.defWtrDens)), # IN: default water density
byref(c_float(self.defWtrDpth)), # IN: default water depth
Expand Down
4 changes: 2 additions & 2 deletions modules/hydrodyn/src/HydroDyn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ typedef ^ ^ DbKi
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 ^ ^ INTEGER NStepWave - - - "Total number of frequency components = total number of time steps in the incident wave" -
typedef ^ ^ INTEGER NStepWave2 - - - "NStepWave / 2" -
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}" -
Expand Down
Loading

0 comments on commit a6efeb3

Please sign in to comment.