Skip to content

Commit

Permalink
IfW: add path handling for xyslice output (hardcoded for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-platt committed Nov 12, 2024
1 parent c2ea7e1 commit 8187648
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
9 changes: 6 additions & 3 deletions modules/inflowwind/src/InflowWind_Driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ PROGRAM InflowWind_Driver
TYPE( ProgDesc ), PARAMETER :: ProgInfo = ProgDesc("InflowWind_Driver","","")
INTEGER(IntKi) :: IfWDriver_Verbose = 5 ! Verbose level. 0 = none, 5 = some, 10 = lots

! output paths hard coded
CHARACTER(*), PARAMETER :: VTKsliceDir = "vtk" ! Directory to place the output VTK slices

! Types needed here (from InflowWind module)
TYPE(InflowWind_InitInputType) :: InflowWind_InitInp ! Data for initialization -- this is where the input info goes
TYPE(InflowWind_InputType) :: InflowWind_u1 ! input -- contains xyz coords of interest -- set 1
Expand Down Expand Up @@ -464,23 +467,23 @@ PROGRAM InflowWind_Driver

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 IfW_WriteXYslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, VTKsliceDir, 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 IfW_WriteXZslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, VTKsliceDir, 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 IfW_WriteYZslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, VTKsliceDir, Settings%OutWindX(i), ErrStat, ErrMsg )
! call CheckCallErr('IfW_WriteYZslice'//trim(Num2LStr(i)))
enddo
END IF
Expand Down
29 changes: 15 additions & 14 deletions modules/inflowwind/src/InflowWind_Driver_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2376,18 +2376,19 @@ subroutine IfW_WriteVTK(FF, FileRootName, ErrStat, ErrMsg)
end subroutine IfW_WriteVTK


subroutine IfW_WriteXYslice(FF, FileRootName, XYslice_height, ErrStat, ErrMsg)
type(FlowFieldType), intent(in) :: FF !< Parameters
character(*), intent(in) :: FileRootName !< RootName for output files
real(ReKi), intent(in) :: XYslice_height
integer(IntKi), intent(out) :: ErrStat !< Error status of the operation
character(*), intent(out) :: ErrMsg !< Error message if ErrStat /= ErrID_None

character(*), parameter :: RoutineName = "IfW_WriteXYslice"
type(Grid3DFieldType) :: G3D
integer(IntKi) :: unit
integer(IntKi) :: ErrStat2
character(ErrMsgLen) :: ErrMsg2
subroutine IfW_WriteXYslice(FF, FileRootName, vtk_dir, XYslice_height, ErrStat, ErrMsg)
type(FlowFieldType), intent(in ) :: FF !< Parameters
character(*), intent(in ) :: FileRootName !< RootName for output files
character(*), intent(in ) :: vtk_dir !< Directory for vtk slice outputs
real(ReKi), intent(in ) :: XYslice_height
integer(IntKi), intent( out) :: ErrStat !< Error status of the operation
character(*), intent( out) :: ErrMsg !< Error message if ErrStat /= ErrID_None

character(*), parameter :: RoutineName = "IfW_WriteXYslice"
type(Grid3DFieldType) :: G3D
integer(IntKi) :: unit
integer(IntKi) :: ErrStat2
character(ErrMsgLen) :: ErrMsg2

ErrStat = ErrID_None
ErrMsg = ""
Expand All @@ -2404,12 +2405,12 @@ subroutine IfW_WriteXYslice(FF, FileRootName, XYslice_height, ErrStat, ErrMsg)
call Uniform_to_Grid3D(FF%Uniform, FF%VelInterpCubic, G3D, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat < AbortErrLev) then
call Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrStat2, ErrMsg2)
call Grid3D_WriteVTKsliceXY(G3D, FileRootName, vtk_dir, XYslice_height, unit, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
end if

case (Grid3D_FieldType)
call Grid3D_WriteVTKsliceXY(FF%Grid3D, FileRootName, XYslice_height, unit, ErrStat, ErrMsg)
call Grid3D_WriteVTKsliceXY(FF%Grid3D, FileRootName, vtk_dir, XYslice_height, unit, ErrStat, ErrMsg)

case default
ErrStat = ErrID_Warn
Expand Down
37 changes: 20 additions & 17 deletions modules/inflowwind/src/InflowWind_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2945,23 +2945,21 @@ subroutine Grid3D_WriteHAWC(G3D, FileRootName, unit, ErrStat, ErrMsg)
end subroutine Grid3D_WriteHAWC


subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrStat, ErrMsg)

type(Grid3DFieldType), intent(in) :: G3D !< Parameters
character(*), intent(in) :: FileRootName !< RootName for output files
real(ReKi), intent(in) :: XYslice_height
integer(IntKi), intent(in) :: unit !< Error status of the operation
integer(IntKi), intent(out) :: ErrStat !< Error status of the operation
character(*), intent(out) :: ErrMsg !< Error message if ErrStat /= ErrID_None
subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, vtk_dir, XYslice_height, unit, ErrStat, ErrMsg)
type(Grid3DFieldType), intent(in ) :: G3D !< Parameters
character(*), intent(in ) :: FileRootName !< RootName for output files
character(*), intent(in ) :: vtk_dir !< directory for vtk file for output files
real(ReKi), intent(in ) :: XYslice_height
integer(IntKi), intent(in ) :: unit !< Error status of the operation
integer(IntKi), intent( out) :: ErrStat !< Error status of the operation
character(*), intent( out) :: ErrMsg !< Error message if ErrStat /= ErrID_None

character(*), parameter :: RoutineName = 'Grid3D_WriteVTKsliceXY'
character(1024) :: RootPathName
character(1024) :: FileName
character(3) :: ht_str
integer :: it !< time index for slice
integer :: ix
integer :: iy
integer :: iz
character(8) :: t_str, t_fmt
integer :: it, ix, iy, iz, twidth
real(ReKi) :: time !< time for this slice
real(ReKi) :: ht !< nearest grid slice elevation
integer(IntKi) :: ErrStat2
Expand All @@ -2971,13 +2969,17 @@ subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrSt
ErrMsg = ""

call GetPath(FileRootName, RootPathName)
RootPathName = trim(RootPathName)//PathSep//"vtk"
RootPathName = trim(RootPathName)//PathSep//vtk_dir
call MkDir(trim(RootPathName)) ! make this directory if it doesn't already exist

! get indices for this slice
iz = nint((G3D%GridBase + XYslice_height)*G3D%InvDZ)
ht = real(iz,ReKi) / G3D%InvDZ + G3D%GridBase ! nearest height index
write(ht_str,'(i3)') nint(ht)
write(ht_str,'(i0.3)') nint(ht)

! get width of string for time
twidth=ceiling(log10(real(G3D%NSteps)))
t_fmt='(i0.'//trim(Num2LStr(twidth))//')'

! check for errors in slice height
if (iz <= 0_IntKi .or. iz > G3D%NZGrids) then
Expand All @@ -2987,11 +2989,13 @@ subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrSt

! Loop through time steps
do it = 1, G3D%NSteps

time = real(it - 1, ReKi)*G3D%DTime

! time string
write(t_str,t_fmt) it

! Create the output vtk file with naming <WindFilePath>/vtk/DisYZ.t<i>.vtk
FileName = trim(RootPathName)//PathSep//"DisXY.Z"//ht_str//".t"//trim(num2lstr(it))//".vtp"
FileName = trim(RootPathName)//PathSep//"DisXY.Z"//ht_str//".t"//trim(t_str)//".vtp"

! see WrVTK_SP_header
call OpenFOutFile(unit, TRIM(FileName), ErrStat2, ErrMsg2)
Expand Down Expand Up @@ -3019,7 +3023,6 @@ subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, XYslice_height, unit, ErrSt

close (unit)
enddo

end subroutine Grid3D_WriteVTKsliceXY

end module InflowWind_IO

0 comments on commit 8187648

Please sign in to comment.