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

BeamDyn driver visualization, and bugfix #1474

Merged
merged 4 commits into from
Mar 2, 2023
Merged
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
66 changes: 64 additions & 2 deletions modules/beamdyn/src/Driver_Beam.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ PROGRAM BeamDyn_Driver_Program
REAL(DbKi) :: t_global ! global-loop time marker
INTEGER(IntKi) :: n_t_final ! total number of time steps
INTEGER(IntKi) :: n_t_global ! global-loop time counter
INTEGER(IntKi) :: n_t_vtk ! global vtk step counter
INTEGER(IntKi), parameter :: BD_interp_order = 1 ! order of interpolation/extrapolation

! Module1 Derived-types variables; see Registry_Module1.txt for details
Expand Down Expand Up @@ -99,9 +100,9 @@ PROGRAM BeamDyn_Driver_Program
! initialize the BD_InitInput values not in the driver input file
BD_InitInput%RootName = TRIM(BD_Initinput%InputFile)
BD_InitInput%RootName = TRIM(RootName)//'.BD'
BD_InitInput%RootDisp = 0.d0
BD_InitInput%RootDisp = MATMUL(BD_InitInput%GlbPos(:),DvrData%RootRelInit) - BD_InitInput%GlbPos(:)
BD_InitInput%DynamicSolve = DvrData%DynamicSolve ! QuasiStatic options handled within the BD code.

t_global = DvrData%t_initial
n_t_final = ((DvrData%t_final - DvrData%t_initial) / dt_global )

Expand Down Expand Up @@ -157,6 +158,21 @@ PROGRAM BeamDyn_Driver_Program
CALL CheckError()
END DO

! Write VTK reference if requested (ref is (0,0,0)
if (DvrData%WrVTK > 0) then
call SetVTKvars()
call MeshWrVTKreference( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Output%BldMotion, trim(DvrData%VTK_OutFileRoot)//'_BldMotion', ErrStat, ErrMsg ); call CheckError()
call MeshWrVTKreference( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Input(1)%PointLoad, trim(DvrData%VTK_OutFileRoot)//'_PointLoad', ErrStat, ErrMsg ); call CheckError()
call MeshWrVTKreference( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Input(1)%DistrLoad, trim(DvrData%VTK_OutFileRoot)//'_DistrLoad', ErrStat, ErrMsg ); call CheckError()
endif
! Write VTK reference if requested (ref is (0,0,0)
if (DvrData%WrVTK == 2) then
n_t_vtk = 0
call MeshWrVTK( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Output%BldMotion, trim(DvrData%VTK_OutFileRoot)//'_BldMotion', n_t_vtk, .true., ErrStat, ErrMsg, DvrData%VTK_tWidth )
call MeshWrVTK( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Input(1)%PointLoad, trim(DvrData%VTK_OutFileRoot)//'_PointLoad', n_t_vtk, .true., ErrStat, ErrMsg, DvrData%VTK_tWidth )
call MeshWrVTK( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Input(1)%DistrLoad, trim(DvrData%VTK_OutFileRoot)//'_DistrLoad', n_t_vtk, .true., ErrStat, ErrMsg, DvrData%VTK_tWidth )
call CheckError()
endif


!.........................
Expand Down Expand Up @@ -208,6 +224,18 @@ PROGRAM BeamDyn_Driver_Program

CALL Dvr_WriteOutputLine(t_global,DvrOut,BD_Parameter%OutFmt,BD_Output)

! Write VTK reference if requested (ref is (0,0,0)
if (DvrData%WrVTK == 2) then
if ( MOD( n_t_global, DvrData%n_VTKTime ) == 0 ) then
n_t_vtk = n_t_vtk + 1
call MeshWrVTK( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Output%BldMotion, trim(DvrData%VTK_OutFileRoot)//'_BldMotion', n_t_vtk, .true., ErrStat, ErrMsg, DvrData%VTK_tWidth )
call MeshWrVTK( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Input(1)%PointLoad, trim(DvrData%VTK_OutFileRoot)//'_PointLoad', n_t_vtk, .true., ErrStat, ErrMsg, DvrData%VTK_tWidth )
call MeshWrVTK( (/0.0_SiKi, 0.0_SiKi, 0.0_SiKi /), BD_Input(1)%DistrLoad, trim(DvrData%VTK_OutFileRoot)//'_DistrLoad', n_t_vtk, .true., ErrStat, ErrMsg, DvrData%VTK_tWidth )
call CheckError()
endif
endif


if ( MOD( n_t_global + 1, 100 ) == 0 ) call SimStatus( TiLstPrn, PrevClockTime, t_global, DvrData%t_final )
ENDDO

Expand Down Expand Up @@ -264,4 +292,38 @@ subroutine CheckError()

end subroutine CheckError

subroutine SetVTKvars()
real(R8Ki) :: TmpTime
real(R8Ki) :: TmpRate
real(R8Ki) :: TotalTime

DvrData%VTK_OutFileRoot = trim(BD_InitInput%RootName)
n_t_vtk = 0 ! first VTK output number

! convert frames-per-second to seconds per sample:
TotalTime = DvrData%t_final - DvrData%t_initial
if ( DvrData%VTK_fps == 0 ) then
TmpTime = TotalTime + dt_global
else
TmpTime = 1.0_R8Ki / DvrData%VTK_fps
endif

! now save the number of time steps between VTK file output:
if (TmpTime > TotalTime) then
DvrData%n_VTKTime = HUGE(DvrData%n_VTKTime)
else
DvrData%n_VTKTime = NINT( TmpTime / dt_global )
! I'll warn if p%n_VTKTime*p%DT is not TmpTime
IF (DvrData%WrVTK == 2) THEN
TmpRate = DvrData%n_VTKTime*dt_global
if (.not. EqualRealNos(TmpRate, TmpTime)) then
call WrScr('1/VTK_fps is not an integer multiple of DT. FAST will output VTK information at '//&
trim(num2lstr(1.0_DbKi/TmpRate))//' fps, the closest rate possible.')
end if
end if
end if

DvrData%VTK_tWidth = CEILING( log10( real(n_t_final, ReKi) / DvrData%n_VTKTime ) ) + 1
end subroutine SetVTKvars

END PROGRAM BeamDyn_Driver_Program
Loading