###################################################################################################################################
###################################################################################################################################
# Registry for HydroDyn in the FAST Modularization Framework
# This Registry file is used to create MODULE HydroDyn  which contains all of the user-defined types needed in HydroDyn.
# It also contains copy, destroy, pack,  and unpack routines associated with each defined data types.
# See NWTC Programmer's Handbook for further information on the format/contents of this file.
#
# Entries are of the form
# <keyword>  <ModuleName/ModName>      <TypeName>                   <FieldType>              <FieldName>                 <Dims>       <IO>       <DNAME>     <DESCRIP> <UNITS>
#
# Use ^ as a shortcut for the value in the same column from the previous line.
###################################################################################################################################

# ...... 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   Conv_Radiation.txt
usefrom   SS_Radiation.txt
usefrom   SS_Excitation.txt
usefrom   WAMIT.txt
usefrom   WAMIT2.txt
usefrom   Morison.txt
usefrom   SeaSt_WaveField.txt

param     HydroDyn/HydroDyn            unused                        INTEGER                  MaxHDOutputs                    -          510        -         "The maximum number of output channels supported by this module"    -
param     HydroDyn/HydroDyn            unused                        INTEGER                  MaxUserOutputs                  -         5150        -         " Total possible number of output channels:  SS_Excitation = 7 + SS_Radiation = 7 + Morison= 4626 + HydroDyn=510   =  5150" -

#########################
# ..... Input file data ...........................................................................................................
# This is data defined in the Input File for this module (or could otherwise be passed in)
# ..... Primary Input file data ...................................................................................................
typedef  HydroDyn/HydroDyn    HydroDyn_InputFile   LOGICAL      EchoFlag          -     -     -     "Echo the input file"                                    -
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"    -
typedef   ^                            ^                             ReKi                     AddBQuad                        {:}{:}{:}   -          -         "Additional quadratic damping (drag) matrix"    -
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" -
typedef   ^                            ^                             INTEGER                  NBody                           -          -          -         "[>=1; only used when PotMod=1. If NBodyMod=1, the WAMIT data contains a vector of size 6*NBody x 1 and matrices of size 6*NBody x 6*NBody; if NBodyMod>1, there are NBody sets of WAMIT data each with a vector of size 6 x 1 and matrices of size 6 x 6]" -
typedef   ^                            ^                             INTEGER                  NBodyMod                        -          -          -         "Body coupling model {1: include coupling terms between each body and NBody in HydroDyn equals NBODY in WAMIT, 2: neglect coupling terms between each body and NBODY=1 with XBODY=0 in WAMIT, 3: Neglect coupling terms between each body and NBODY=1 with XBODY=/0 in WAMIT} (switch) [only used when PotMod=1]" -
typedef   ^                            ^                             ReKi                     PtfmVol0                        {:}        -          -         ""    -
typedef   ^                            ^                             LOGICAL                  HasWAMIT                        -          -          -         ".TRUE. if using WAMIT model, .FALSE. otherwise"    -
typedef   ^                            ^                             ReKi                     WAMITULEN                       {:}        -          -         ""    -
typedef   ^                            ^                             ReKi                     PtfmRefxt                       {:}        -          -         "The xt offset of the body reference point(s) from (0,0,0)  [1 to NBody; only used when PotMod=1; must be 0.0 if NBodyMod=2 ]"  (m)
typedef   ^                            ^                             ReKi                     PtfmRefyt                       {:}        -          -         "The yt offset of the body reference point(s) from (0,0,0)  [1 to NBody; only used when PotMod=1; must be 0.0 if NBodyMod=2 ]"  (m)
typedef   ^                            ^                             ReKi                     PtfmRefzt                       {:}        -          -         "The zt offset of the body reference point(s) from (0,0,0)  [1 to NBody; only used when PotMod=1; must be 0.0 if NBodyMod=2 ]"  (m)
typedef   ^                            ^                             R8Ki                     PtfmRefztRot                    {:}        -          -         "The rotation about zt of the body reference frame(s) from xt/yt" radians 
typedef   ^                            ^                             ReKi                     PtfmCOBxt                       {:}        -          -         ""    -
typedef   ^                            ^                             ReKi                     PtfmCOByt                       {:}        -          -         ""    -
typedef   ^                            ^                             WAMIT_InitInputType      WAMIT                           -          -          -         "Initialization data for WAMIT module"    -
typedef   ^                            ^                             WAMIT2_InitInputType     WAMIT2                          -          -          -         "Initialization data for WAMIT2 module"    -
typedef   ^                            ^                             Morison_InitInputType    Morison                         -          -          -         "Initialization data for Morison module"    -
typedef   ^                            ^                             LOGICAL                  Echo                            -          -          -         "Echo the input files to a file with the same name as the input but with a .echo extension [T/F]"    -
typedef   ^                            ^                             INTEGER                  PotMod                          -          -          -         "1 if using WAMIT model, 0 if no potential flow model, or 2 if FIT model"    -
typedef   ^                            ^                             INTEGER                  NUserOutputs                    -          -          -         "Number of Hydrodyn-level requested output channels" -
typedef   ^                            ^                             CHARACTER(ChanLen)       UserOutputs                     {:}        -          -         "This should really be dimensioned with MaxOutPts"    -
typedef   ^                            ^                             INTEGER                  OutSwtch                        -          -          -         "Output requested channels to: [1=Hydrodyn.out 2=GlueCode.out  3=both files]"    -
typedef   ^                            ^                             LOGICAL                  OutAll                          -          -          -         "Output all user-specified member and joint loads (only at each member end, not interior locations) [T/F]"    -
typedef   ^                            ^                             INTEGER                  NumOuts                         -          -          -         "The number of outputs for this module as requested in the input file"    -
typedef   ^                            ^                             CHARACTER(ChanLen)       OutList                         {:}       -          -         "The user-requested output channel labels for this modules. This should really be dimensioned with MaxOutPts"    -
typedef   ^                            ^                             LOGICAL                  HDSum                           -          -          -         "Generate a HydroDyn summary file [T/F]"    -
typedef   ^                            ^                             INTEGER                  UnSum                           -          -          -         "File unit for the HydroDyn summary file [-1 = no summary file]"    -
typedef   ^                            ^                             CHARACTER(20)            OutFmt                          -          -          -         "Output format for numerical results"    -
typedef   ^                            ^                             CHARACTER(20)            OutSFmt                         -          -          -         "Output format for header strings"    -
typedef   ^                            ^                             INTEGER                  PtfmYMod                        -          -          -         "Large yaw model" - 
typedef   ^                            ^                             ReKi                     PtfmRefY                        -          -          -         "Initial reference yaw offset" (rad)
typedef   ^                            ^                             ReKi                     PtfmYCutoff                     -          -          -          "Low-pass cutoff frequency for filtering the platform yaw motion to obtain the reference yaw offset"   (Hz)
#
typedef   HydroDyn/HydroDyn            InitInputType                 CHARACTER(1024)          InputFile                       -          -          -         "Supplied by Driver:  full path and filename for the HydroDyn module"    -
typedef   ^                            ^                             LOGICAL                  UseInputFile                    -       .TRUE.        -         "Supplied by Driver:  .TRUE. if using a input file, .FALSE. if all inputs are being passed in by the caller"    -
typedef   ^                            ^                             FileInfoType             PassedFileData                  -          -          -         "If we don't use the input file, pass everything through this"   -
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   ^                            ^                             DbKi                     TMax                            -          -          -         "Supplied by Driver:  The total simulation time"    "(sec)"
typedef   ^                            ^                             logical                  VisMeshes                       -       .false.       -         "Output visualization meshes" -
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" -
typedef   ^                            ^                             ReKi                     PlatformPos                    {6}         -          -         "Initial platform position (6 DOFs)"
#
#
# Define outputs from the initialization routine here:
#
typedef   ^                            InitOutputType                Morison_InitOutputType   Morison                         -          -        -         "Initialization output from the Morison module"    -
typedef   ^                            InitOutputType                CHARACTER(ChanLen)       WriteOutputHdr                  {:}        -        -         "The is the list of all HD-related output channel header strings (includes all sub-module channels)"    -
typedef   ^                            ^                             CHARACTER(ChanLen)       WriteOutputUnt                  {:}        -        -         "The is the list of all HD-related output channel unit strings (includes all sub-module channels)"    -
typedef   ^                            ^                             ProgDesc                 Ver                             -          -        -         "Version of HydroDyn"
typedef   ^                            ^                             CHARACTER(LinChanLen)    LinNames_y                      {:}        -        -         "Names of the outputs used in linearization"	-
typedef   ^                            ^                             CHARACTER(LinChanLen)    LinNames_x                      {:}        -        -         "Names of the continuous states used in linearization"	-
typedef   ^                            ^                             CHARACTER(LinChanLen)    LinNames_u                      {:}        -        -         "Names of the inputs used in linearization"	-
typedef   ^                            InitOutputType                INTEGER                  DerivOrder_x                    {:}        -        -         "Integer that tells FAST/MBC3 the maximum derivative order of continuous states used in linearization"	-
typedef   ^                            ^                             LOGICAL                  IsLoad_u                        {:}        -        -         "Flag that tells FAST if the inputs used in linearization are loads (for preconditioning matrix)" -
# ..... HD_ModuleMapType ....................................................................................................................
typedef   ^                            HD_ModuleMapType              MeshMapType              uW_P_2_PRP_P                     -         -        -         "Mesh mapping data: WAMIT body kinematics to PRP node at (0,0,0)" -
typedef   ^                            HD_ModuleMapType              MeshMapType              W_P_2_PRP_P                      -         -        -         "Mesh mapping data: WAMIT loads to PRP node at (0,0,0)" -
typedef   ^                            HD_ModuleMapType              MeshMapType              M_P_2_PRP_P                      -         -        -         "Mesh mapping data: lumped Morison loads to PRP node at (0,0,0)" -
#
#
# ..... States ....................................................................................................................
# Define continuous (differentiable) states here:
#
typedef   ^                            ContinuousStateType           WAMIT_ContinuousStateType            WAMIT               {:}        -          -         "continuous states from the wamit module"        -
typedef   ^                            ContinuousStateType           Morison_ContinuousStateType          Morison             -          -          -         "continuous states from the Morison module"        -
#
#
# Define discrete (nondifferentiable) states here:
#
typedef   ^                            DiscreteStateType             WAMIT_DiscreteStateType              WAMIT               {:}        -          -         "discrete states from the wamit module"        -
typedef   ^                            DiscreteStateType             Morison_DiscreteStateType            Morison             -          -          -         "discrete states from the Morison module"        -
typedef   ^                            DiscreteStateType             ReKi                                 PtfmRefY            {:}        -          -         "Reference yaw position of the PRP relative to the inertial frame - Current step and two previous steps" (radians)
#
#
# Define constraint states here:
#
typedef   ^                            ConstraintStateType           WAMIT_ConstraintStateType           WAMIT  -        -          -                      "constraint states from WAMIT (may be empty)"        -
typedef   ^                            ConstraintStateType           Morison_ConstraintStateType         Morison -         -          -                      "constraint states from the Morison module"        -
#
#
# Define any other states here:
#
typedef   ^                            OtherStateType                WAMIT_OtherStateType     WAMIT                           {:}        -          -         "OtherState information from the WAMIT module"   -
typedef   ^                            ^                             Morison_OtherStateType   Morison                         -          -          -         "OtherState information from the Morison module"   -
# ..... Misc/Optimization variables.................................................................................................
# 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                   MeshType                 AllHdroOrigin                   -          -          -         "An intermediate mesh used to transfer hydrodynamic loads from the various HD-related meshes to the AllHdroOrigin mesh" -
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   ^                            ^                             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)"   -
typedef   ^                            ^                             WAMIT_MiscVarType        WAMIT                           {:}        -          -          "misc var information from the WAMIT module"   -
typedef   ^                            ^                             WAMIT2_MiscVarType       WAMIT2                          {:}        -          -         "misc var information from the WAMIT2 module"   -
typedef   ^                            ^                             Morison_MiscVarType      Morison                         -          -          -         "misc var information from the Morison module"   -
typedef   ^                            ^                             WAMIT_InputType          u_WAMIT                        {:}         -          -         "WAMIT module inputs" -
# ..... Parameters ................................................................................................................
# Define parameters here:
# Time step for integration of continuous states (if a fixed-step integrator is used) and update of discrete states:
#
typedef   ^                            ParameterType                 INTEGER                  nWAMITObj                       -          -          -         "number of WAMIT input files and matrices.  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" -
typedef   ^                            ^                             WAMIT_ParameterType      WAMIT                           {:}        -          -         "Parameter data for the WAMIT module"  -
typedef   ^                            ^                             WAMIT2_ParameterType     WAMIT2                          {:}        -          -         "Parameter data for the WAMIT2 module"  -
typedef   ^                            ^                             LOGICAL                  WAMIT2used                      -          .FALSE.    -         "Indicates when WAMIT2 is used.  Shortcuts some calculations" -
typedef   ^                            ^                             Morison_ParameterType    Morison                         -          -          -         "Parameter data for the Morison module"        -
typedef   ^                            ^                             INTEGER                  PotMod                          -          -          -         "1 if using WAMIT model, 0 if no potential flow model, or 2 if FIT model"    -
typedef   ^                            ^                             INTEGER                  NBody                           -          -          -         "[>=1; only used when PotMod=1. If NBodyMod=1, the WAMIT data contains a vector of size 6*NBody x 1 and matrices of size 6*NBody x 6*NBody; if NBodyMod>1, there are NBody sets of WAMIT data each with a vector of size 6 x 1 and matrices of size 6 x 6]" -
typedef   ^                            ^                             INTEGER                  NBodyMod                        -          -          -         "Body coupling model {1: include coupling terms between each body and NBody in HydroDyn equals NBODY in WAMIT, 2: neglect coupling terms between each body and NBODY=1 with XBODY=0 in WAMIT, 3: Neglect coupling terms between each body and NBODY=1 with XBODY=/0 in WAMIT} (switch) [only used when PotMod=1]" -
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   ^                            ^                             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"    -
typedef   ^                            ^                             ReKi                     AddBQuad                    {:}{:}{:}      -          -         "Additional quadratic damping (drag) matrix"    -
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   ^                            ^                             OutParmType              OutParam                       {:}         -          -         ""        -
typedef   ^                            ^                             INTEGER                  NumOuts                         -          -          -         "Number of HydroDyn module-level outputs (not the total number including sub-modules"        -
typedef   ^                            ^                             INTEGER                  NumTotalOuts                    -          -          -         "Number of all requested outputs including sub-modules"        -
typedef   ^                            ^                             INTEGER                  OutSwtch                        -          -          -         "Output requested channels to: [1=Hydrodyn.out 2=GlueCode.out  3=both files]"    -
typedef   ^                            ^                             CHARACTER(20)            OutFmt                          -          -          -         "Output format for numerical results"    -
typedef   ^                            ^                             CHARACTER(20)            OutSFmt                         -          -          -         "Output format for header strings"    -
typedef   ^                            ^                             CHARACTER(ChanLen)       Delim                           -          -          -         "Delimiter string for outputs, defaults to tab-delimiters"        -
typedef   ^                            ^                             INTEGER                  UnOutFile                       -          -          -         "File unit for the HydroDyn outputs"        -
typedef   ^                            ^                             INTEGER                  OutDec                          -          -          -         "Write every OutDec time steps"  -
typedef	  ^                            ^                             Integer	              Jac_u_indx                  {:}{:}         -          -	      "matrix to help fill/pack the u vector in computing the jacobian"	-
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   ^                            ^                             logical                  VisMeshes                       -       .false.       -         "Output visualization meshes" -
typedef   ^                            ^                             SeaSt_WaveFieldType     *WaveField                       -          -          -         "Pointer to SeaState wave field" -
typedef   ^                            ^                             INTEGER                  PtfmYMod                        -          -          -         "Large yaw model" - 
typedef   ^                            ^                             ReKi                     CYawFilt                        -          -          -         "Low-pass filter constant for reference platform yaw position PtfmRefY"   -
#
#
# ..... Inputs ....................................................................................................................
# Define inputs that are contained on the mesh here:
#
typedef   ^                            InputType                     Morison_InputType        Morison                         -          -          -         "Morison module inputs" -
typedef   ^                            InputType                     MeshType                 WAMITMesh                       -          -          -         "Motions at the WAMIT reference point(s) in the inertial frame" -
typedef   ^                            InputType                     MeshType                 PRPMesh                         -          -          -         "Motions at the Platform reference point in the inertial frame" -
#
#
# ..... Outputs ...................................................................................................................
# Define outputs that are contained on the mesh here:
typedef   ^                            OutputType                   WAMIT_OutputType          WAMIT                           {:}        -          -         "WAMIT module outputs"  -
typedef   ^                            OutputType                   WAMIT2_OutputType         WAMIT2                          {:}        -          -         "WAMIT2 module outputs"  -
typedef   ^                            ^                            Morison_OutputType        Morison                         -          -          -         "Morison module outputs"  -
typedef   ^                            OutputType                   MeshType                  WAMITMesh                       -        -          -           "Point Loads at the WAMIT reference point(s) in the inertial frame" -
typedef   ^                            ^                            ReKi                      WriteOutput                    {:}         -          -         "Outputs to be written to the output file(s)"  -
