-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmod_write_vtk.f90
144 lines (108 loc) · 3.8 KB
/
mod_write_vtk.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
module mod_write_vtk
use mod_read_gmsh, only: nbelm, nbnode, coord_nodes, id_nodes, fname
use mod_cell_2D
use mod_detect_nearest_neighbor
implicit none
contains
subroutine write_mesh_vtk
implicit none
integer(4) :: i
character(300) :: foutput
foutput = trim(fname)//'.vtk'
open(unit = 21, file = foutput, status = 'replace')
write(21,'(a)') '# vtk DataFile Version 2.0'
write(21,'(a)') 'VTK format for unstructured mesh'
write(21,'(a)') 'ASCII'
write(21,'(a)') 'DATASET POLYDATA'
write(21,1) nbnode
do i = 1, nbnode
write(21,*) coord_nodes(i)%p%x, coord_nodes(i)%p%y, coord_nodes(i)%p%z
end do
write(21,2) nbelm, 5*nbelm
do i = 1, nbelm
write(21,*) 4,id_nodes(i)%pn%id_node(6:9)-1
end do
write(21,3) nbelm
write(21,'(a)') 'SCALARS CELL_IDENT integer 1'
write(21,'(a)') 'LOOKUP_TABLE default '
do i = 1, nbelm
write(21,*) id_nodes(i)%pn%id_node(1)
end do
write(21,'(a)') 'SCALARS NEIGHBOR1 integer 1'
write(21,'(a)') 'LOOKUP_TABLE default '
do i = 1, nbelm
if (associated(cell(i)%p%neighbor1)) then
write(21,*) cell(i)%p%neighbor1%ident
else
write(21,*) 0
endif
end do
write(21,'(a)') 'SCALARS NEIGHBOR2 integer 1'
write(21,'(a)') 'LOOKUP_TABLE default '
do i = 1, nbelm
if (associated(cell(i)%p%neighbor2)) then
write(21,*) cell(i)%p%neighbor2%ident
else
write(21,*) 0
endif
end do
write(21,'(a)') 'SCALARS NEIGHBOR3 integer 1'
write(21,'(a)') 'LOOKUP_TABLE default '
do i = 1, nbelm
if (associated(cell(i)%p%neighbor3)) then
write(21,*) cell(i)%p%neighbor3%ident
else
write(21,*) 0
endif
end do
write(21,'(a)') 'SCALARS NEIGHBOR4 integer 1'
write(21,'(a)') 'LOOKUP_TABLE default '
do i = 1, nbelm
if (associated(cell(i)%p%neighbor4)) then
write(21,*) cell(i)%p%neighbor4%ident
else
write(21,*) 0
endif
end do
close(unit = 21)
1 format('POINTS',i9,' float')
2 format('POLYGONS ',2i9)
3 format('CELL_DATA',i9)
end subroutine
subroutine write_mesh_tecplot
implicit none
integer(4) :: i
character(300) :: foutput
foutput = trim(fname)//'.dat'
open(unit = 21, file = foutput, status = 'replace')
!write(21,'(a)') 'VARIABLES=X,Y,CELL_IDENT,NEIGHBOR1,NEIGHBOR2,NEIGHBOR3,NEIGHBOR4' ! coming soon
write(21,'(a)') 'VARIABLES=X,Y'
write(21,'(a)') 'ZONE T="UNSTRUCTURED-COUNTOUR"'
write(21,'(a)') 'ZONETYPE=FEPOLYGON'
write(21,*) 'NODES=',nbnode
write(21,*) 'ELEMENTS=',nbelm
write(21,*) 'FACES=',nbelm*4
write(21,*) 'NumConnectedBoundaryFaces=0'
write(21,*) 'TotalNumBoundaryConnections=0'
do i = 1, nbnode
write(21,*) coord_nodes(i)%p%x
end do
do i = 1, nbnode
write(21,*) coord_nodes(i)%p%y
end do
! Node indexes
do i = 1, nbelm
write(21,*) id_nodes(i)%pn%id_node(6), id_nodes(i)%pn%id_node(7)
write(21,*) id_nodes(i)%pn%id_node(7), id_nodes(i)%pn%id_node(8)
write(21,*) id_nodes(i)%pn%id_node(8), id_nodes(i)%pn%id_node(9)
write(21,*) id_nodes(i)%pn%id_node(9), id_nodes(i)%pn%id_node(6)
enddo
do i = 1, nbelm
write(21,*) i,i,i,i
enddo
do i = 1, nbelm
write(21,*) 0,0,0,0
enddo
close(unit = 21)
end subroutine
end module