-
Notifications
You must be signed in to change notification settings - Fork 0
/
visit.f90
180 lines (156 loc) · 6.34 KB
/
visit.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
!Crown Copyright 2012 AWE.
!
! This file is part of CloverLeaf.
!
! CloverLeaf is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the
! Free Software Foundation, either version 3 of the License, or (at your option)
! any later version.
!
! CloverLeaf is distributed in the hope that it will be useful, but
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! CloverLeaf. If not, see http://www.gnu.org/licenses/.
!> @brief Generates graphics output files.
!> @author Wayne Gaudin
!> @details The field data over all mesh chunks is written to a .vtk files and
!> the .visit file is written that defines the time for each set of vtk files.
!> The ideal gas and viscosity routines are invoked to make sure this data is
!> up to data with the current energy, density and velocity.
SUBROUTINE visit
USE clover_module
USE update_halo_module
USE viscosity_module
USE ideal_gas_module
IMPLICIT NONE
INTEGER :: j,k,c,err,get_unit,u,dummy,tile
INTEGER :: nxc,nyc,nxv,nyv,nblocks
REAL(KIND=8) :: temp_var
CHARACTER(len=80) :: name
CHARACTER(len=10) :: chunk_name,tile_name,step_name
CHARACTER(len=90) :: filename
LOGICAL, SAVE :: first_call=.TRUE.
INTEGER :: fields(NUM_FIELDS)
REAL(KIND=8) :: kernel_time,timer
name = 'clover'
IF ( parallel%boss ) THEN
IF(first_call) THEN
nblocks=number_of_chunks*tiles_per_chunk
filename = "clover.visit"
u=get_unit(dummy)
OPEN(UNIT=u,FILE=filename,STATUS='UNKNOWN',IOSTAT=err)
WRITE(u,'(a,i5)')'!NBLOCKS ',nblocks
CLOSE(u)
first_call=.FALSE.
ENDIF
ENDIF
IF(profiler_on) kernel_time=timer()
DO tile=1,tiles_per_chunk
CALL ideal_gas(tile,.FALSE.)
ENDDO
IF(profiler_on) profiler%ideal_gas=profiler%ideal_gas+(timer()-kernel_time)
fields=0
fields(FIELD_PRESSURE)=1
fields(FIELD_XVEL0)=1
fields(FIELD_YVEL0)=1
CALL update_halo(fields,1)
IF(profiler_on) kernel_time=timer()
CALL viscosity()
IF(profiler_on) profiler%viscosity=profiler%viscosity+(timer()-kernel_time)
IF ( parallel%boss ) THEN
filename = "clover.visit"
u=get_unit(dummy)
OPEN(UNIT=u,FILE=filename,STATUS='UNKNOWN',POSITION='APPEND',IOSTAT=err)
DO c = 0, parallel%max_task -1
WRITE(chunk_name, '(i6)') c+100000
chunk_name(1:1) = "."
DO tile = 1, tiles_per_chunk
WRITE(tile_name, '(i6)') tile+100000
tile_name(1:1) = "."
WRITE(step_name, '(i6)') step+100000
step_name(1:1) = "."
filename = trim(trim(name)//trim(chunk_name)//trim(tile_name)//trim(step_name))//".vtk"
WRITE(u,'(a)')TRIM(filename)
ENDDO
ENDDO
CLOSE(u)
ENDIF
IF(profiler_on) kernel_time=timer()
DO tile = 1, tiles_per_chunk
IF(chunk%task.EQ.parallel%task) THEN
nxc=chunk%tiles(tile)%t_xmax-chunk%tiles(tile)%t_xmin+1
nyc=chunk%tiles(tile)%t_ymax-chunk%tiles(tile)%t_ymin+1
nxv=nxc+1
nyv=nyc+1
WRITE(chunk_name, '(i6)') parallel%task+100000
chunk_name(1:1) = "."
WRITE(tile_name, '(i6)') tile+100000
tile_name(1:1) = "."
WRITE(step_name, '(i6)') step+100000
step_name(1:1) = "."
filename = trim(trim(name) //trim(chunk_name)//trim(tile_name)//trim(step_name))//".vtk"
u=get_unit(dummy)
OPEN(UNIT=u,FILE=filename,STATUS='UNKNOWN',IOSTAT=err)
WRITE(u,'(a)')'# vtk DataFile Version 3.0'
WRITE(u,'(a)')'vtk output'
WRITE(u,'(a)')'ASCII'
WRITE(u,'(a)')'DATASET RECTILINEAR_GRID'
WRITE(u,'(a,2i12,a)')'DIMENSIONS',nxv,nyv,' 1'
WRITE(u,'(a,i5,a)')'X_COORDINATES ',nxv,' double'
DO j=chunk%tiles(tile)%t_xmin,chunk%tiles(tile)%t_xmax+1
WRITE(u,'(e12.4)')chunk%tiles(tile)%field%vertexx(j)
ENDDO
WRITE(u,'(a,i5,a)')'Y_COORDINATES ',nyv,' double'
DO k=chunk%tiles(tile)%t_ymin,chunk%tiles(tile)%t_ymax+1
WRITE(u,'(e12.4)')chunk%tiles(tile)%field%vertexy(k)
ENDDO
WRITE(u,'(a)')'Z_COORDINATES 1 double'
WRITE(u,'(a)')'0'
WRITE(u,'(a,i20)')'CELL_DATA ',nxc*nyc
WRITE(u,'(a)')'FIELD FieldData 4'
WRITE(u,'(a,i20,a)')'density 1 ',nxc*nyc,' double'
DO k=chunk%tiles(tile)%t_ymin,chunk%tiles(tile)%t_ymax
WRITE(u,'(e12.4)')(chunk%tiles(tile)%field%density0(j,k),j=chunk%tiles(tile)%t_xmin,chunk%tiles(tile)%t_xmax)
ENDDO
WRITE(u,'(a,i20,a)')'energy 1 ',nxc*nyc,' double'
DO k=chunk%tiles(tile)%t_ymin,chunk%tiles(tile)%t_ymax
WRITE(u,'(e12.4)')(chunk%tiles(tile)%field%energy0(j,k),j=chunk%tiles(tile)%t_xmin,chunk%tiles(tile)%t_xmax)
ENDDO
WRITE(u,'(a,i20,a)')'pressure 1 ',nxc*nyc,' double'
DO k=chunk%tiles(tile)%t_ymin,chunk%tiles(tile)%t_ymax
WRITE(u,'(e12.4)')(chunk%tiles(tile)%field%pressure(j,k),j=chunk%tiles(tile)%t_xmin,chunk%tiles(tile)%t_xmax)
ENDDO
WRITE(u,'(a,i20,a)')'viscosity 1 ',nxc*nyc,' double'
DO k=chunk%tiles(tile)%t_ymin,chunk%tiles(tile)%t_ymax
DO j=chunk%tiles(tile)%t_xmin,chunk%tiles(tile)%t_xmax
temp_var=0.0
IF(chunk%tiles(tile)%field%viscosity(j,k).GT.0.00000001) temp_var=chunk%tiles(tile)%field%viscosity(j,k)
WRITE(u,'(e12.4)') temp_var
ENDDO
ENDDO
WRITE(u,'(a,i20)')'POINT_DATA ',nxv*nyv
WRITE(u,'(a)')'FIELD FieldData 2'
WRITE(u,'(a,i20,a)')'x_vel 1 ',nxv*nyv,' double'
DO k=chunk%tiles(tile)%t_ymin,chunk%tiles(tile)%t_ymax+1
DO j=chunk%tiles(tile)%t_xmin,chunk%tiles(tile)%t_xmax+1
temp_var=0.0
IF(ABS(chunk%tiles(tile)%field%xvel0(j,k)).GT.0.00000001) temp_var=chunk%tiles(tile)%field%xvel0(j,k)
WRITE(u,'(e12.4)') temp_var
ENDDO
ENDDO
WRITE(u,'(a,i20,a)')'y_vel 1 ',nxv*nyv,' double'
DO k=chunk%tiles(tile)%t_ymin,chunk%tiles(tile)%t_ymax+1
DO j=chunk%tiles(tile)%t_xmin,chunk%tiles(tile)%t_xmax+1
temp_var=0.0
IF(ABS(chunk%tiles(tile)%field%yvel0(j,k)).GT.0.00000001) temp_var=chunk%tiles(tile)%field%yvel0(j,k)
WRITE(u,'(e12.4)') temp_var
ENDDO
ENDDO
CLOSE(u)
ENDIF
ENDDO
IF(profiler_on) profiler%visit=profiler%visit+(timer()-kernel_time)
END SUBROUTINE visit