###################################################################################################################################
# Registry for InflowWind, creates MODULE InflowWind_Types
# Module InflowWind_Types contains all of the user-defined types needed in InflowWind. It also contains copy, destroy, pack, and
# unpack routines associated with each defined data types.
###################################################################################################################################
# Entries are of the form
# keyword <InflowWind[/ModuleAbvr]> <TypeName>   <FieldType>    <FieldName>  <Dims>  <Ctrl> <DNAME> <DESCRIP> <UNITS>
###################################################################################################################################

usefrom IfW_UniformWind.txt
usefrom IfW_TSFFWind.txt
usefrom IfW_FFWind_Base.txt
usefrom IfW_BladedFFWind.txt
usefrom IfW_HAWCWind.txt
usefrom IfW_UserWind.txt
usefrom IfW_4Dext.txt
usefrom Lidar.txt

include Registry_NWTC_Library.txt


param    InflowWind/InflowWind   -                 IntKi             Undef_WindNumber     -     0     -     "This is the code for an undefined WindFileType"                           -
param    ^                       -                 IntKi             Steady_WindNumber    -     1     -     "Steady wind.  Calculated internally."                                     -
param    ^                       -                 IntKi             Uniform_WindNumber   -     2     -     "Uniform wind.  Formally known as a Hub-Height wind file."                 -
param    ^                       -                 IntKi             TSFF_WindNumber      -     3     -     "TurbSim full-field binary file."                                          -
param    ^                       -                 IntKi             BladedFF_WindNumber  -     4     -     "Bladed style binary full-field file.  Includes native bladed format"      -
param    ^                       -                 IntKi             HAWC_WindNumber      -     5     -     "HAWC wind file."                                                          -
param    ^                       -                 IntKi             User_WindNumber      -     6     -     "User defined wind."                                                       -
param    ^                       -                 IntKi             BladedFF_Shr_WindNumber  - 7     -     "Native Bladed binary full-field file."      -
param    ^                       -                 IntKi             FDext_WindNumber     -     8     -     "4D wind from external souce (i.e., FAST.Farm)."                                                       -
param    ^                       -                 IntKi             Highest_WindNumber   -     8     -     "Highest wind number supported."                                           -


#########################
# ..... WindFile metadata ........................................................................................................
# This is metadata about the windfile that is retrieved when InflowWind is initialized
# ................................................................................................................................
typedef  InflowWind/InflowWind   WindFileMetaData  CHARACTER(1024)   FileName          -     -     -     "Name of the windfile retrieved"                         -
typedef  ^                       ^                 IntKi             WindType          -     0     -     "Type of the windfile"                                   -
typedef  ^                       ^                 ReKi              RefHt             -     -     -     "Reference height given in file"                         meters
typedef  ^                       ^                 Logical           RefHt_Set         -     -     -     "Reference height was given in file"                     -
typedef  ^                       ^                 DbKi              DT                -     -     -     "TimeStep of the wind file -- zero value for none"       seconds
typedef  ^                       ^                 IntKi             NumTSteps         -     -     -     "Number of timesteps in the time range of wind file"     -
typedef  ^                       ^                 Logical           ConstantDT        -     -     -     "Timesteps are the same throughout file"                 -
typedef  ^                       ^                 ReKi              TRange            {2}   -     -     "Time range of the wind file"                            seconds
typedef  ^                       ^                 Logical           TRange_Limited    -     -     -     "TRange limits strictly enforced"                        -
typedef  ^                       ^                 ReKi              YRange            {2}   -     -     "Range in y direction"                                   meters
typedef  ^                       ^                 Logical           YRange_Limited    -     -     -     "YRange limits strictly enforced"                        -
typedef  ^                       ^                 ReKi              ZRange            {2}   -     -     "Range in z direction"                                   meters
typedef  ^                       ^                 Logical           ZRange_Limited    -     -     -     "ZRange limits strictly enforced"                        -
typedef  ^                       ^                 IntKi             BinaryFormat      -     -     -     "Binary format identifier"                               -
typedef  ^                       ^                 Logical           IsBinary          -     -     -     "Windfile is a binary file"                              -
typedef  ^                       ^                 ReKi              TI                {3}   -     -     "Turbulence intensity (U,V,W)"                           -
typedef  ^                       ^                 Logical           TI_listed         -     -     -     "Turbulence intesity given in file"                      -
typedef  ^                       ^                 ReKi              MWS               -     -     -     "Approximate mean wind speed"                            -


#########################
# ..... 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  InflowWind/InflowWind   InflowWind_InputFile   LOGICAL      EchoFlag          -     -     -     "Echo the input file"                                    -
typedef  ^                       ^                 IntKi             WindType          -     0     -     "Type of windfile"                                       -
typedef  ^                       ^                 ReKi              PropagationDir    -     -     -     "Direction of wind propagation (meteorological direction)"  (degrees)
typedef  ^                       ^                 ReKi              VFlowAngle        -     -     -     "Vertical (upflow) angle"                                degrees
typedef  ^                       ^                 IntKi             NWindVel          -     -     -     "Number of points to output the wind velocity (0 to 9)"
typedef  ^                       ^                 ReKi              WindVxiList       :     -     -     "List of X coordinates for wind velocity measurements"   meters
typedef  ^                       ^                 ReKi              WindVyiList       :     -     -     "List of Y coordinates for wind velocity measurements"   meters
typedef  ^                       ^                 ReKi              WindVziList       :     -     -     "List of Z coordinates for wind velocity measurements"   meters
typedef  ^                       ^                 ReKi              Steady_HWindSpeed -     -     -     "Steady wind -- horizontal windspeed"                    meters/s
typedef  ^                       ^                 ReKi              Steady_RefHt      -     -     -     "Steady wind -- reference height"                        meters
typedef  ^                       ^                 ReKi              Steady_PLexp      -     -     -     "Steady wind -- power law exponent"                      -
typedef  ^                       ^                 CHARACTER(1024)   Uniform_FileName  -     -     -     "Uniform wind -- filename"                               -
typedef  ^                       ^                 ReKi              Uniform_RefHt     -     -     -     "Uniform wind -- reference height"                       meters
typedef  ^                       ^                 ReKi              Uniform_RefLength -     -     -     "Uniform wind -- reference length"                       meters
typedef  ^                       ^                 CHARACTER(1024)   TSFF_FileName     -     -     -     "TurbSim Full-Field -- filename"                         -
typedef  ^                       ^                 CHARACTER(1024)   BladedFF_FileName -     -     -     "Bladed-style Full-Field -- filename"                    -
typedef  ^                       ^                 LOGICAL           BladedFF_TowerFile -    -     -     "Bladed-style Full-Field -- tower file exists"           -
typedef  ^                       ^                 LOGICAL           CTTS_CoherentTurb -     .FALSE.     -     "Coherent turbulence data exists"                        -
typedef  ^                       ^                 CHARACTER(1024)   CTTS_FileName     -     -     -     "Name of coherent turbulence file"                       -
typedef  ^                       ^                 CHARACTER(1024)   CTTS_Path         -     -     -     "Path to coherent turbulence binary data files"          -
typedef  ^                       ^                 CHARACTER(1024)   HAWC_FileName_u   -     -     -     "HAWC -- u component binary data file name"              -
typedef  ^                       ^                 CHARACTER(1024)   HAWC_FileName_v   -     -     -     "HAWC -- v component binary data file name"              -
typedef  ^                       ^                 CHARACTER(1024)   HAWC_FileName_w   -     -     -     "HAWC -- w component binary data file name"              -
typedef  ^                       ^                 IntKi             HAWC_nx           -     -     -     "HAWC -- number of grids in x direction"                 -
typedef  ^                       ^                 IntKi             HAWC_ny           -     -     -     "HAWC -- number of grids in y direction"                 -
typedef  ^                       ^                 IntKi             HAWC_nz           -     -     -     "HAWC -- number of grids in z direction"                 -
typedef  ^                       ^                 ReKi              HAWC_dx           -     -     -     "HAWC -- distance between points in x direction"         meters
typedef  ^                       ^                 ReKi              HAWC_dy           -     -     -     "HAWC -- distance between points in y direction"         meters
typedef  ^                       ^                 ReKi              HAWC_dz           -     -     -     "HAWC -- distance between points in z direction"         meters
typedef  ^                       ^                 LOGICAL           SumPrint          -     -     -     "Write summary info to a file <ROOTNAME>.IfW.Sum"        -
typedef  ^                       ^                 IntKi             NumOuts           -     -     -     "Number of parameters in the output list (number of outputs requested)" -
typedef  ^                       ^                 CHARACTER(ChanLen) OutList           :     -     -     "List of user-requested output channels"                 -
typedef  ^                       ^                 IntKi             SensorType        -  SensorType_None    -     "Sensor type (for lidar/sensor module)"                 -
typedef  ^                       ^                 IntKi             NumPulseGate      -     -     -     "the number of range gates to return wind speeds at"                 -
typedef  ^                       ^                 ReKi              RotorApexOffsetPos 3    -     -     "position of the lidar unit relative to the rotor apex of rotation"	m
typedef  ^                       ^                 LOGICAL           LidRadialVel      -     -     -     "TRUE => return radial component, FALSE => return 'x' direction estimate"	-
typedef  ^                       ^                 IfW_FFWind_InitInputType     FF                -     -     -     "scaling data" -



typedef  ^                       InitInputType     CHARACTER(1024)   InputFileName     -     -     -     "Name of the InflowWind input file to use"                                    -
typedef  ^                       ^                 LOGICAL           Linearize         -   .FALSE. -     "Flag that tells this module if the glue code wants to linearize." -
typedef  ^                       ^                 LOGICAL           Use4Dext          -   .FALSE. -     "Flag that tells this module if an external module will pass it 4-D velocity grids." -
typedef  ^                       ^                 IntKi             NumWindPoints     -     -     -     "Number of wind velocity points expected"                                     -
typedef  ^                       ^                 IntKi             TurbineID         -     0     -     "Wind turbine ID number in the fixed (DEFAULT) file name when FixedWindFileRootName = .TRUE. (used by FAST.Farm)"                                     -
typedef  ^                       ^                 LOGICAL           FixedWindFileRootName - .FALSE. -   "Do the wind data files have a fixed (DEFAULT) file name? (used by FAST.Farm)" -
typedef  ^                       ^                 LOGICAL           UseInputFile      -   .TRUE.  -     "Should we read everthing from an input file, or do we get it some other way" -
typedef  ^                       ^                 CHARACTER(1024)	RootName          -     -     -     "RootName for writing output files"
typedef  ^                       ^                 FileInfoType      PassedFileData    -     -     -     "If we don't use the input file, pass everything through this"                -
typedef  ^                       ^                 LOGICAL           WindType2UseInputFile    -     .TRUE.     -      "Flag for toggling file based IO in wind type 2."                -
typedef  ^                       ^                 FileInfoType      WindType2Data    -     -     -      "Optional slot for wind type 2 data if file IO is not used."                -
typedef  ^                       ^          Lidar_InitInputType      lidar             -     -     -     "InitInput for lidar data"                                             -
typedef  ^                       ^          IfW_4Dext_InitInputType  FDext             -     -     -     "InitInput for lidar data"                                             -


# Init Output
typedef  ^                       InitOutputType    CHARACTER(ChanLen)     WriteOutputHdr    :   -   -    "Names of output-to-file channels"                       -
typedef  ^                       ^                 CHARACTER(ChanLen)     WriteOutputUnt    :   -   -    "Units of output-to-file channels"                       -
typedef  ^                       ^                 ProgDesc               Ver               -   -   -    "Version information of InflowWind module"               -
typedef  ^                       ^                 WindFileMetaData       WindFileInfo      -   -   -    "Meta data from the wind file"                           -
typedef  ^                       InitOutputType    CHARACTER(LinChanLen)  LinNames_y       {:}  -   -    "Names of the outputs used in linearization" -
typedef  ^                       InitOutputType    CHARACTER(LinChanLen)  LinNames_u       {:}  -   -    "Names of the inputs used in linearization" -
typedef  ^                       InitOutputType    LOGICAL                RotFrame_y       {:}  -   -    "Flag that tells FAST/MBC3 if the outputs used in linearization are in the rotating frame" -
typedef  ^                       InitOutputType    LOGICAL                RotFrame_u       {:}  -   -    "Flag that tells FAST/MBC3 if the inputs used in linearization are in the rotating frame" -
typedef  ^                       InitOutputType    LOGICAL                IsLoad_u         {:}  -   -    "Flag that tells FAST if the inputs used in linearization are loads (for preconditioning matrix)" -


# ..... 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       IntKi             TimeIndex         -     0     -     "An Index into the TData array"                          -
typedef  ^                       ^      IfW_UniformWind_MiscVarType  UniformWind       -     -     -     "MiscVars from UniformWind"                 -
typedef  ^                       ^         IfW_TSFFWind_MiscVarType  TSFFWind          -     -     -     "MiscVars from TSFFWind"                              -
typedef  ^                       ^         IfW_HAWCWind_MiscVarType  HAWCWind          -     -     -     "MiscVars from HAWCWind"                              -
typedef  ^                       ^     IfW_BladedFFWind_MiscVarType  BladedFFWind      -     -     -     "MiscVars from BladedFFWind"                          -
typedef  ^                       ^         IfW_UserWind_MiscVarType  UserWind          -     -     -     "MiscVars from UserWind"                              -
typedef  ^                       ^            IfW_4Dext_MiscVarType  FDext             -     -     -     "MiscVars from FDext"                                -
typedef  ^                       ^                 ReKi              AllOuts           :     -     -     "An array holding the value of all of the calculated (not only selected) output channels" "see OutListParameters.xlsx spreadsheet"
typedef  ^                       ^                 ReKi              WindViUVW         ::    -     -     "List of UVW velocities for wind velocity measurements, 3xNWindVel. corresponds to ParamData%WindViXYZ"  meters/second


# ..... 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        CHARACTER(1024)   RootFileName      -     -     -     "Root of the InflowWind input   filename"                -
typedef  ^                       ^                 LOGICAL           CTTS_Flag         -  .FALSE.  -     "determines if coherent turbulence is used"              -
typedef  ^                       ^                 LOGICAL           RotateWindBox     -  .FALSE.  -     "determines if wind will be rotated"              -
typedef  ^                       ^                 DbKi              DT                -     -     -     "Time step for cont. state integration & disc. state update"   seconds
typedef  ^                       ^                 ReKi              PropagationDir    -     -     -     "Direction of wind propagation"                          radians
typedef  ^                       ^                 ReKi              VFlowAngle        -     -     -     "Vertical (upflow) angle"                                radians

typedef  ^                       ^                 ReKi              RotToWind        {3}{3} -     -     "Rotation matrix for rotating from the global XYZ coordinate system to the wind coordinate system (wind along X')"   -
typedef  ^                       ^                 ReKi              RotFromWind      {3}{3} -     -     "Rotation matrix for rotating from the wind coordinate system (wind along X') back to the global XYZ coordinate system.  Equal to TRANSPOSE(RotToWind)"   -
typedef  ^                       ^                 ReKi              WindViXYZprime    ::    -     -     "List of XYZ coordinates for velocity measurements, translated to the wind coordinate system (prime coordinates).  This equals MATMUL( RotToWind, ParamData%WindViXYZ )"  meters

typedef  ^                       ^                 IntKi             WindType          -     0     -     "Type of wind -- set to Undef_Wind initially"            -
typedef  ^                       ^                 ReKi              ReferenceHeight   -     -     -     "Height of the wind turbine"                             meters
typedef  ^                       ^                 ReKi              RefPosition       3     -     -     "Reference position (point where box is rotated)"        meters
typedef  ^                       ^                 IntKi             NWindVel          -     -     -     "Number of points in the wind velocity list"             -
typedef  ^                       ^                 ReKi              WindViXYZ         ::    -     -     "List of XYZ coordinates for wind velocity measurements, 3xNWindVel" meters
typedef  ^                       ^     IfW_UniformWind_ParameterType UniformWind       -     -     -     "Parameters from UniformWind"                            -
typedef  ^                       ^        IfW_TSFFWind_ParameterType TSFFWind          -     -     -     "Parameters from TSFFWind -- TurbSim full-field format"  -
typedef  ^                       ^    IfW_BladedFFWind_ParameterType BladedFFWind      -     -     -     "Parameters from BladedFFWind -- Bladed-style full-field format"  -
typedef  ^                       ^        IfW_HAWCWind_ParameterType HAWCWind          -     -     -     "Parameters from HAWCWind"                               -
typedef  ^                       ^        IfW_UserWind_ParameterType UserWind          -     -     -     "Parameters from UserWind"                               -
typedef  ^                       ^           IfW_4Dext_ParameterType FDext             -     -     -     "Parameters from FDext"                                  -
#typedef  ^                       ^          IfW_CTWind_ParameterType CTWind            -     -     -     "Parameters from CTWind"                                 -
typedef  ^                       ^                 IntKi             NumOuts           -     0     -     "Number of parameters in the output list (number of outputs requested)" -
typedef  ^                       ^                 OutParmType       OutParam          {:}   -     -     "Names and units (and other characteristics) of all requested output parameters" -
typedef  ^                       ^                 IntKi             OutParamLinIndx  {:}{:} -     -     "Index into WriteOutput for WindViXYZ in linearization analysis" -
typedef  ^                       ^          lidar_ParameterType      lidar             -     -     -     "Lidar parameter data"                                       -


# ..... Inputs ....................................................................................................................
# Define inputs that are not on this mesh here:
typedef  ^                    InputType            ReKi              PositionXYZ       ::    -     -     "Array holding the input positions at a given timestep"  meters
typedef  ^                       ^                 lidar_InputType   lidar             -     -     -     "Lidar data"                                       -


# ..... Outputs ...................................................................................................................
# Define outputs that are contained on the mesh here:
typedef  ^                    OutputType           ReKi              VelocityUVW       ::    -     -     "Array holding the U,V,W velocity for a given timestep"  meters/sec
typedef  ^                    OutputType           ReKi              WriteOutput       :     -     -     "Array with values to output to file"                    -
typedef  ^                       ^                 ReKi              DiskVel           {3}   -     -     "Vector holding the U,V,W average velocity of the disk"  meters/sec
typedef  ^                       ^              lidar_OutputType     lidar             -     -     -     "Lidar data"                                       -
#typedef  ^                       ^       IfW_UniformWind_OutputType  UniformWind       -     -     -     "uniform/steady wind operating point"

# ..... States not used by this module ...................................................................................................................
typedef  ^                    ContinuousStateType  ReKi              DummyContState    -     -     -     "Remove this variable if you have continuous states"     -
typedef  ^                    DiscreteStateType    ReKi              DummyDiscState    -     -     -     "Remove this variable if you have discrete states"       -
typedef  ^                    ConstraintStateType  ReKi              DummyConstrState  -     -     -     "Remove this variable if you have constraint states"     -
typedef  ^                    OtherStateType       ReKi              DummyOtherState   -     -     -     "Remove this variable if you have other states"     -
