-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparaview.f90
88 lines (73 loc) · 2.9 KB
/
paraview.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
module paraview
use Structures, only : grid_object
implicit none
contains
subroutine exportcsv(grid)
type(grid_object) :: grid
Integer :: n, i, j, Imax, Jmax
open(UNIT = 4, FILE = 'algebric grid 90x15.csv', STATUS = 'REPLACE')
write(4,*)'x coord, y coord, z coord, scalar'
Imax = grid%Imax
Jmax = grid%Jmax
do n = 1, Imax*Jmax
j = CEILING(real(n)/real(Imax))
i = n - Imax * (j -1)
write(4,*) grid%nodes(i,j)%x,', ', grid%nodes(i,j)%y,', 0', ', ', n-1
end do
end subroutine exportcsv
subroutine exportvtk(grid, fileName, format)
type(grid_object) :: grid
character (*) :: fileName, format
Integer :: n, i, j, Imax, Jmax
real(8) :: RVALUE1, RVALUE2
character (len = 16) :: CVAL1, CVAL2
Imax = grid%Imax
Jmax = grid%Jmax
open(UNIT = 4, FILE = fileName, STATUS = 'REPLACE')
write(4,"(a)")'# vtk DataFile Version 3.0'
write(4,"(a)")'Grid Generated by StrGridBump'
write(4,"(a)")'ASCII'
write(4,*)''
if (format == "STRUCTURED_GRID") then
write(4,"(a)")'DATASET STRUCTURED_GRID'
write(4,"(a,i6,i6,i6)")'DIMENSIONS ', Imax, Jmax, 1
write(4,"(a,i9,a)")'POINTS ', Imax*Jmax,' FLOAT'
do n = 1, Imax*Jmax
j = CEILING(real(n)/real(Imax))
i = n - Imax * (j -1)
RVALUE1 = grid%nodes(i,j)%x
RVALUE2 = grid%nodes(i,j)%y
WRITE(CVAL1, "(F16.14)") RVALUE1
WRITE(CVAL2, "(F16.14)") RVALUE2
write(4,"(4a)") CVAL1,' ', CVAL2,' 0'
end do
else if (format == "UNSTRUCTURED_GRID") then
write(4,"(a)")'DATASET UNSTRUCTURED_GRID'
write(4,"(a,i9,a)")'POINTS ', Imax*Jmax,' FLOAT'
do n = 1, Imax*Jmax
j = CEILING(real(n)/real(Imax))
i = n - Imax * (j -1)
RVALUE1 = grid%nodes(i,j)%x
RVALUE2 = grid%nodes(i,j)%y
WRITE(CVAL1, "(F16.14)") RVALUE1
WRITE(CVAL2, "(F16.14)") RVALUE2
write(4,"(4a)") CVAL1,' ', CVAL2,' 0'
end do
write(4,*)''
write(4,"(a,i9,a,i9)")'CELLS ', (Imax-1)*(Jmax-1),' ', 5*(Imax-1)*(Jmax-1)
do j = 0, Jmax-2
do i = 0, Imax-2
n = i+j*Imax
write(4,"(2a,i9,a,i9,a,i9,a,i9)") '4',' ', n,' ', n+1,' ', n+Imax+1,' ', n+Imax
end do
end do
write(4,*)''
write(4,"(a,i9)")'CELL_TYPES ', (Imax-1)*(Jmax-1)
do n = 1, (Imax-1)*(Jmax-1)
write(4,"(a)") '9'
end do
else
print *, "Indicated format is not listed!!"
end if
end subroutine exportvtk
end module paraview