subroutine WriteTecplot_DGModel2D_t(this,filename)
implicit none
class(DGModel2D_t),intent(inout) :: this
character(*),intent(in),optional :: filename
! Local
character(8) :: zoneID
integer :: fUnit
integer :: iEl,i,j,iVar
character(LEN=self_FileNameLength) :: tecFile
character(LEN=self_TecplotHeaderLength) :: tecHeader
character(LEN=self_FormatLength) :: fmat
character(13) :: timeStampString
character(5) :: rankString
type(Scalar2D) :: solution
type(Scalar2D) :: dsdt
type(Vector2D) :: solutionGradient
type(Vector2D) :: x
type(Lagrange),target :: interp
if(present(filename)) then
tecFile = filename
else
write(timeStampString,'(I13.13)') this%ioIterate
if(this%mesh%decomp%mpiEnabled) then
write(rankString,'(I5.5)') this%mesh%decomp%rankId
tecFile = 'solution.'//rankString//'.'//timeStampString//'.tec'
else
tecFile = 'solution.'//timeStampString//'.tec'
endif
endif
! Create an interpolant for the uniform grid
call interp%Init(this%solution%interp%M, &
this%solution%interp%targetNodeType, &
this%solution%interp%N, &
this%solution%interp%controlNodeType)
call solution%Init(interp, &
this%solution%nVar,this%solution%nElem)
call dsdt%Init(interp, &
this%solution%nVar,this%solution%nElem)
call solutionGradient%Init(interp, &
this%solution%nVar,this%solution%nElem)
call x%Init(interp,1,this%solution%nElem)
call this%solution%UpdateHost()
call this%solutionGradient%UpdateHost()
call this%dsdt%UpdateHost()
! Map the mesh positions to the target grid
call this%geometry%x%GridInterp(x%interior)
! Map the solution to the target grid
call this%solution%GridInterp(solution%interior)
call this%dsdt%GridInterp(dsdt%interior)
! Map the solution to the target grid
call this%solutionGradient%GridInterp(solutionGradient%interior)
open(UNIT=NEWUNIT(fUnit), &
FILE=trim(tecFile), &
FORM='formatted', &
STATUS='replace')
tecHeader = 'VARIABLES = "X", "Y"'
do iVar = 1,this%solution%nVar
tecHeader = trim(tecHeader)//', "'//trim(this%solution%meta(iVar)%name)//'"'
enddo
do iVar = 1,this%solution%nVar
tecHeader = trim(tecHeader)//', "d/dx('//trim(this%solution%meta(iVar)%name)//')"'
enddo
do iVar = 1,this%solution%nVar
tecHeader = trim(tecHeader)//', "d/dy('//trim(this%solution%meta(iVar)%name)//')"'
enddo
do iVar = 1,this%solution%nVar
tecHeader = trim(tecHeader)//', "d/dt('//trim(this%solution%meta(iVar)%name)//')"'
enddo
write(fUnit,*) trim(tecHeader)
! Create format statement
write(fmat,*) 4*this%solution%nvar+2
fmat = '('//trim(fmat)//'(ES16.7E3,1x))'
do iEl = 1,this%solution%nElem
! TO DO :: Get the global element ID
write(zoneID,'(I8.8)') iEl
write(fUnit,*) 'ZONE T="el'//trim(zoneID)//'", I=',this%solution%interp%M+1, &
', J=',this%solution%interp%M+1
do j = 1,this%solution%interp%M+1
do i = 1,this%solution%interp%M+1
write(fUnit,fmat) x%interior(i,j,iEl,1,1), &
x%interior(i,j,iEl,1,2), &
solution%interior(i,j,iEl,1:this%solution%nvar), &
solutionGradient%interior(i,j,iEl,1:this%solution%nvar,1), &
solutionGradient%interior(i,j,iEl,1:this%solution%nvar,2), &
dsdt%interior(i,j,iEl,1:this%solution%nvar)
enddo
enddo
enddo
close(UNIT=fUnit)
call x%Free()
call solution%Free()
call dsdt%Free()
call interp%Free()
endsubroutine WriteTecplot_DGModel2D_t