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

IfW: add VTK output of slice in XY to driver #1643

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions modules/inflowwind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if (GENERATE_TYPES)
generate_f90_types(src/InflowWind_IO.txt ${CMAKE_CURRENT_LIST_DIR}/src/InflowWind_IO_Types.f90 -noextrap)
generate_f90_types(src/Lidar.txt ${CMAKE_CURRENT_LIST_DIR}/src/Lidar_Types.f90)
generate_f90_types(src/InflowWind.txt ${CMAKE_CURRENT_LIST_DIR}/src/InflowWind_Types.f90)
generate_f90_types(src/InflowWind_Driver_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/InflowWind_Driver_Types.f90 -noextrap)
endif()

# InflowWind object library
Expand Down
110 changes: 48 additions & 62 deletions modules/inflowwind/src/InflowWind_Driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -412,25 +412,10 @@ PROGRAM InflowWind_Driver
! Set flag to calculate accelerations if requested
InflowWind_InitInp%OutputAccel = SettingsFlags%OutputAccel

CALL InflowWind_Init( InflowWind_InitInp, InflowWind_u1, InflowWind_p, &
CALL inflowwind_init( InflowWind_InitInp, InflowWind_u1, InflowWind_p, &
InflowWind_x, InflowWind_xd, InflowWind_z, InflowWind_OtherState, &
InflowWind_y1, InflowWind_MiscVars, Settings%DT, InflowWind_InitOut, ErrStat, ErrMsg )


! Make sure no errors occured that give us reason to terminate now.
IF ( ErrStat >= AbortErrLev ) THEN
CALL DriverCleanup()
CALL ProgAbort( ErrMsg )
ELSEIF ( ErrStat /= ErrID_None ) THEN
IF ( IfWDriver_Verbose >= 7_IntKi ) THEN
CALL WrScr(NewLine//' InflowWind_Init returned: ErrStat: '//TRIM(Num2LStr(ErrStat))// &
NewLine//' ErrMsg: '//TRIM(ErrMsg)//NewLine)
ELSEIF ( ErrStat >= ErrID_Warn ) THEN
CALL ProgWarn( ErrMsg )
ELSE
CALL WrScr(TRIM(ErrMsg))
ENDIF
ENDIF
call CheckCallErr('InflowWind_Init')



Expand All @@ -441,68 +426,53 @@ PROGRAM InflowWind_Driver
! Convert InflowWind file to HAWC format
IF (SettingsFlags%WrHAWC) THEN
CALL IfW_WriteHAWC( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg )
IF (ErrStat > ErrID_None) THEN
CALL WrScr( TRIM(ErrMsg) )
IF ( ErrStat >= AbortErrLev ) THEN
CALL DriverCleanup()
CALL ProgAbort( ErrMsg )
ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN
CALL WrScr(NewLine//' IfW_WriteHAWC returned: ErrStat: '//TRIM(Num2LStr(ErrStat)))
END IF
ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN
CALL WrScr(NewLine//'IfW_WriteHAWC CALL returned without errors.'//NewLine)
END IF
call CheckCallErr('IfW_WriteHAWC')
END IF


! Convert InflowWind file to Native Bladed format
IF (SettingsFlags%WrBladed) THEN
CALL IfW_WriteBladed( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg )
IF (ErrStat > ErrID_None) THEN
CALL WrScr( TRIM(ErrMsg) )
IF ( ErrStat >= AbortErrLev ) THEN
CALL DriverCleanup()
CALL ProgAbort( ErrMsg )
ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN
CALL WrScr(NewLine//' InflowWind_Convert2Bladed returned: ErrStat: '//TRIM(Num2LStr(ErrStat)))
END IF
ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN
CALL WrScr(NewLine//'InflowWind_Convert2Bladed CALL returned without errors.'//NewLine)
END IF
call CheckCallErr('IfW_WriteBladed')
END IF


IF (SettingsFlags%WrVTK) THEN
CALL IfW_WriteVTK( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg )
IF (ErrStat > ErrID_None) THEN
CALL WrScr( TRIM(ErrMsg) )
IF ( ErrStat >= AbortErrLev ) THEN
CALL DriverCleanup()
CALL ProgAbort( ErrMsg )
ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN
CALL WrScr(NewLine//' IfW_WriteVTK returned: ErrStat: '//TRIM(Num2LStr(ErrStat)))
END IF
ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN
CALL WrScr(NewLine//'IfW_WriteVTK CALL returned without errors.'//NewLine)
END IF

call CheckCallErr('IfW_WriteVTK')
END IF


IF (SettingsFlags%WrUniform) THEN
CALL IfW_WriteUniform( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg )
IF (ErrStat > ErrID_None) THEN
CALL WrScr( TRIM(ErrMsg) )
IF ( ErrStat >= AbortErrLev ) THEN
CALL DriverCleanup()
CALL ProgAbort( ErrMsg )
ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN
CALL WrScr(NewLine//' IfW_WriteUniform returned: ErrStat: '//TRIM(Num2LStr(ErrStat)))
END IF
ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN
CALL WrScr(NewLine//'IfW_WriteUniform CALL returned without errors.'//NewLine)
END IF
call CheckCallErr('IfW_WriteUniform')
END IF


IF (Settings%NOutWindXY>0) THEN
do i=1,Settings%NOutWindXY
CALL IfW_WriteXYslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, Settings%OutWindZ(i), ErrStat, ErrMsg )
call CheckCallErr('IfW_WriteXYslice'//trim(Num2LStr(i)))
enddo
END IF


IF (Settings%NOutWindXZ>0) THEN
do i=1,Settings%NOutWindXZ
! CALL IfW_WriteXZslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, Settings%OutWindY(i), ErrStat, ErrMsg )
! call CheckCallErr('IfW_WriteXZslice'//trim(Num2LStr(i)))
enddo
END IF


IF (Settings%NOutWindYZ>0) THEN
do i=1,Settings%NOutWindYZ
! CALL IfW_WriteYZslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, Settings%OutWindX(i), ErrStat, ErrMsg )
! call CheckCallErr('IfW_WriteYZslice'//trim(Num2LStr(i)))
enddo
END IF


!--------------------------------------------------------------------------------------------------------------------------------
!-=-=- Other Setup -=-=-
!--------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -941,6 +911,22 @@ SUBROUTINE DriverCleanup()

END SUBROUTINE DriverCleanup

subroutine CheckCallErr(RoutineName)
character(*), intent(in) :: RoutineName
if (ErrStat > ErrID_None) then
call WrScr( trim(ErrMsg) )
if ( ErrStat >= AbortErrLev ) then
call DriverCleanup()
call ProgAbort( ErrMsg )
elseif ( IfWDriver_Verbose >= 7_IntKi ) then
call WrScr(NewLine//' '//trim(RoutineName)//' returned: ErrStat: '//TRIM(Num2LStr(ErrStat)))
endif
elseif ( IfWDriver_Verbose >= 5_IntKi ) then
CALL WrScr(NewLine//trim(RoutineName)//' CALL returned without errors.'//NewLine)
endif
end subroutine CheckCallErr


END PROGRAM InflowWind_Driver


Expand Down
91 changes: 91 additions & 0 deletions modules/inflowwind/src/InflowWind_Driver_Registry.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#----------------------------------------------------------------------------------------------------------------------------------
# Registry for IfW_Interp, creates MODULE IfW_Interp_Types
# Module IfW_Interp_Types contains all of the user-defined types needed in IfW_FF. It also contains copy, destroy, pack, and
# unpack routines associated with each defined data types.
#----------------------------------------------------------------------------------------------------------------------------------
# keyword <Module> <TypeName> <FieldType> <FieldName> <Dims> <Ctrl> <DNA ME> <DESCRIP> <UNITS>
#----------------------------------------------------------------------------------------------------------------------------------

include Registry_NWTC_Library.txt

#----------------------------------------------------------------------------------------------------------------------------------
typedef InflowWind_Driver OutputFile character(1024) Name - "" - "Filename for output from points read in from points file" -
typedef ^ ^ integer Unit - -1 - "Unit number for the output file for the Points file output" -
typedef ^ ^ logical Initialized - .false. - "Flag indicating that file has been initialized" -

# This contains flags to note if the settings were made. This same data structure is
# used both during the driver input file and the command line options.
#
# NOTE: The WindFileType is only set if it is given as a command line option. Otherwise
# it is handled internally by InflowWInd.
#
# NOTE: The wind direction is specified by the InflowWind input file.
#----------------------------------------------------------------------------------------------------------------------------------
typedef InflowWind_Driver IfWDriver_Flags logical DvrIptFile - .false. - "Was an input file name given on the command line?" -
typedef ^ ^ logical IfWIptFile - .false. - "Was an InflowWind input file requested?" -
typedef ^ ^ logical Summary - .false. - "create a summary at command line? (data extents in the wind file)" -
typedef ^ ^ logical SummaryFile - .false. - "create a summary file of the output?" -
typedef ^ ^ logical TStart - .false. - "specified a start time" -
typedef ^ ^ logical NumTimeSteps - .false. - "specified a number of timesteps to process" -
typedef ^ ^ logical NumTimeStepsDefault - .false. - "specified a 'DEFAULT' for number of timesteps to process" -
typedef ^ ^ logical DT - .false. - "specified a resolution in time" -
typedef ^ ^ logical DTDefault - .false. - "specified a 'DEFAULT' for the time resolution" -

typedef ^ ^ logical FFTcalc - .false. - "do an FFT" -

typedef ^ ^ logical WindGrid - .false. - "Requested output of wind data on a grid -- input file option only" -
typedef ^ ^ logical XRange - .false. - "specified a range of x -- command line option only -- stored as GridCtrCoord and GridDelta" -
typedef ^ ^ logical YRange - .false. - "specified a range of y -- command line option only -- stored as GridCtrCoord and GridDelta" -
typedef ^ ^ logical ZRange - .false. - "specified a range of z -- command line option only -- stored as GridCtrCoord and GridDelta" -
typedef ^ ^ logical Dx - .false. - "specified a resolution in x -- command line option only, 0.0 otherwise" -
typedef ^ ^ logical Dy - .false. - "speficied a resolution in y" -
typedef ^ ^ logical Dz - .false. - "specified a resolution in z" -

typedef ^ ^ logical PointsFile - .false. - "points filename to read in" -
typedef ^ ^ logical OutputAccel - .false. - "flag to calculate and output wind acceleration in addition to velocity" -

typedef ^ ^ logical Verbose - .false. - "Verbose error reporting" -
typedef ^ ^ logical VVerbose - .false. - "Very Verbose error reporting" -
typedef ^ ^ logical BoxExceedAllowF - .false. - "set flag to allow exceeding wind box boundaries for FF files (for diagnostic purposes)" -

typedef ^ ^ logical WrHAWC - .false. - "Requested file conversion to HAWC2 format?" -
typedef ^ ^ logical WrBladed - .false. - "Requested file conversion to Bladed format?" -
typedef ^ ^ logical WrVTK - .false. - "Requested file output as VTK?" -
typedef ^ ^ logical WrUniform - .false. - "Requested file output as Uniform wind format?" -

typedef ^ ^ logical XYslice - .false. - "Take XY slice at one elevation" -



# This contains all the settings (possible passed in arguments).
#----------------------------------------------------------------------------------------------------------------------------------
typedef InflowWind_Driver IfWDriver_Settings character(1024) DvrIptFileName - "" - "Driver input file name" -
typedef ^ ^ character(1024) IfWIptFileName - "" - "Filename of InflowWind input file to read (if no driver input file)" -
typedef ^ ^ character(1024) SummaryFileName - "" - "Filename for the summary information output" -

typedef ^ ^ character(1024) PointsFileName - "" - "Filename of points file to read in" -

typedef ^ ^ IntKi NumTimeSteps - 0 - "Number of timesteps" -
typedef ^ ^ DbKi DT - 0.0_DbKi - "resolution of time" s
typedef ^ ^ DbKi TStart - 0.0_DbKi - "range of time -- end time converted from TRange (command line option only)" s

typedef ^ ^ ReKi FFTcoord(1:3) - 0.0_ReKi - "(x,y,z) coordinate to do an FFT at" (m)

typedef ^ ^ ReKi GridDelta(1:3) - 0.0_ReKi - "(GridDx,GridDy,GridDz) -- grid point spacing" (m)
typedef ^ ^ IntKi GridN(1:3) - 1_IntKi - "(GridNx,GridNy,GridNz) -- number of grid points" -

typedef ^ ^ ReKi XRange(1:2) - 0.0_ReKi - "Range in the x-direction for the gridded data" (m)
typedef ^ ^ ReKi YRange(1:2) - 0.0_ReKi - "Range in the y-direction for the gridded data" (m)
typedef ^ ^ ReKi ZRange(1:2) - 0.0_ReKi - "Range in the z-direction for the gridded data" (m)

typedef ^ ^ ProgDesc ProgInfo - - - "Program info" -
typedef ^ ^ OutputFile WindGridOutput - - - "Wind grid file handling" -
typedef ^ ^ OutputFile FFTOutput - - - "FFT file handling" -
typedef ^ ^ OutputFile PointsVelOutput - - - "Points output velocity file handling" -

typedef ^ ^ IntKi NOutWindXY - 0 - "Number of XY planes for output <RootName>.XY<loc>.t<n>.vtk [0 to 9]" -
typedef ^ ^ ReKi OutWindZ : - - "Z coordinates of XY planes for output [1 to NOutWindXY] [unused for NOutWindXY=0]" (m)
typedef ^ ^ IntKi NOutWindXZ - 0 - "Number of YZ planes for output <RootName>.YZ<loc>.t<n>.vtk [0 to 9]" -
typedef ^ ^ ReKi OutWindY : - - "Y coordinates of YZ planes for output [1 to NOutWindYZ] [unused for NOutWindYZ=0]" (m)
typedef ^ ^ IntKi NOutWindYZ - 0 - "Number of YZ planes for output <RootName>.YZ<loc>.t<n>.vtk [0 to 9]" -
typedef ^ ^ ReKi OutWindX : - - "X coordinates of YZ planes for output [1 to NOutWindYZ] [unused for NOutWindYZ=0]" (m)
Loading