subroutine WriteTecplot_DGModel3D_t(this,filename)
implicit none
class(DGModel3D_t),intent(inout) :: this
character(*),intent(in),optional :: filename
! Local
character(8) :: zoneID
integer :: fUnit
integer :: iEl,i,j,k,iVar
character(LEN=self_FileNameLength) :: tecFile
character(LEN=self_TecplotHeaderLength) :: tecHeader
character(LEN=self_FormatLength) :: fmat
character(13) :: timeStampString
character(5) :: rankString
type(Scalar3D) :: solution
type(Vector3D) :: solutionGradient
type(Vector3D) :: 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 solutionGradient%Init(interp, &
this%solution%nVar,this%solution%nElem)
call x%Init(interp,1,this%solution%nElem)
! Map the mesh positions to the target grid
call this%geometry%x%GridInterp(x%interior)
call this%solution%UpdateHost()
call this%solutionGradient%UpdateHost()
! Map the solution to the target grid
call this%solution%GridInterp(solution%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", "Z"'
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
write(fUnit,*) trim(tecHeader)
! Create format statement
write(fmat,*) 3*this%solution%nvar+3
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 k = 1,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,k,iEl,1,1), &
x%interior(i,j,k,iEl,1,2), &
x%interior(i,j,k,iEl,1,3), &
solution%interior(i,j,k,iEl,1:this%solution%nvar), &
solutionGradient%interior(i,j,k,iEl,1:this%solution%nvar,1), &
solutionGradient%interior(i,j,k,iEl,1:this%solution%nvar,2), &
solutionGradient%interior(i,j,k,iEl,1:this%solution%nvar,3)
enddo
enddo
enddo
enddo
close(UNIT=fUnit)
call x%Free()
call solution%Free()
call interp%Free()
endsubroutine WriteTecplot_DGModel3D_t