-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathreadmsh.f90
192 lines (176 loc) · 7.14 KB
/
readmsh.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
181
182
183
184
185
186
187
188
189
190
191
192
subroutine readmsh
use globalvar
implicit none
!**************************************************************************************
!
! Function: read mesh and boundary conditions
!
!*************************************************************************************
! Local variables
integer, allocatable :: ncellm(:),nbsurfm(:)
integer :: i,j,k,l,ntemp1,ntemp2,ntemp3,ioput,nzone
logical :: mask(4)
ioput = 1200
open(ioput,file=trim(infile))
read(ioput,*)
read(ioput,*)
read(ioput,*)
read(ioput,*)
read(ioput,*) ntemp1,nzone,npoin,nvp
if(ntemp1 .ne. ndimn) then
write(*,*) "The mesh dimension is different with input file, please check!!!"
stop
end if
read(ioput,*)
allocate(ncellm(nzone),nbsurfm(nzone))
do i=1,nzone
read(ioput,*) ntemp1,ncellm(i),nbsurfm(i)
end do
! initialize some matries
nmet = ndimn+2
ncell = 0
nbsurf = 0
do i=1,nzone
ncell = ncell+ncellm(i)
nbsurf = nbsurf+nbsurfm(i)
end do
deallocate(ncellm,nbsurfm)
nvitgho = ncell+nbsurf
if(3 .eq. ndimn) then
allocate(cellinfo%vertex(4,ncell) ,cellinfo%neighbour(4,nvitgho), &
cellinfo%nflag(4,nell) ,cellinfo%facenorm(3,4,ncell), &
cellinfo%vol(nvitgho) ,cellinfo%cvar(nmet,nvitgho), &
cellinfo%cvar0(nmet,ncell) ,cellinfo%centroid(ndimn,ncell), &
cellinfo%cetomid(2,3,ncell) ,cellinfo%deltt(ncell), &
cellinfo%eigen(ndimn,2,ncell) ,cellinfo%pvar(nmet,ncell), &
coords(ndimn,npoin))
facetet(:,1) = [1,2,3]
facetet(:,2) = [2,4,3]
facetet(:,3) = [3,4,1]
facetet(:,4) = [4,2,1]
ncellface = 4
else if(2 .eq. ndimn) then
allocate(cellinfo%vertex(3,ncell) ,cellinfo%neighbour(3,nvitgho), &
cellinfo%nflag(3,nell) ,cellinfo%facenorm(2,3,ncell), &
cellinfo%vol(nvitgho) ,cellinfo%cvar(nmet,nvitgho), &
cellinfo%cvar0(nmet,ncell) ,cellinfo%centroid(ndimn,ncell), &
cellinfo%cetomid(2,3,ncell) ,cellinfo%deltt(ncell), &
cellinfo%eigen(ndimn,2,ncell) ,cellinfo%pvar(nmet,ncell), &
coords(ndimn,npoin))
facetri(:,1) = [1,2]
facetri(:,2) = [2,3]
facetri(:,3) = [3,1]
ncellface = 3
end if
cellinfo%nflag(:,:) = 0
cellinfo%neighbour(:,:) = 0
! read vertexes of every cell and its coordinates
read(ioput,*)
if(3. eq. ndimn) then
do i=1,ncell
read(ioput,*)ntemp1,ntemp2,cellinfo%vertex(1,i),cellinfo%vertex(2,i), &
cellinfo%vertex(3,i),cellinfo%vertex(4,i)
end do
read(ioput,*)
do i=1,npoin
read(ioput,*)coords(1,i),coords(2,i),coords(3,i)
end do
else if(2 .eq. ndimn) then
do i=1,ncell
read(ioput,*)ntemp1,ntemp2,cellinfo%vertex(1,i),cellinfo%vertex(2,i), &
cellinfo%vertex(3,i)
end do
read(ioput,*)
do i=1,npoin
read(ioput,*) coords(1,i),coords(2,i)
end do
end if
! read coordinates of every point
! find neighbour cells
if(3 .eq. ndimn) then ! 3-D meshes
do i=1,ncell
call progBar(i,ncell)
if(cellinfo%neighbour(1,i)==0 .or. cellinfo%neighbour(2,i)==0 .or. &
cellinfo%neighbour(3,i)==0 .or. cellinfo%neighbour(4,i)==0) then
do j=1,ncell
if(i .ne. j) then
mask(:) = .FALSE.
do k=1,4
if(cellinfo%vertex(k,i)==cellinfo%vertex(1,j) .or. &
cellinfo%vertex(k,i)==cellinfo%vertex(2,j) .or. &
cellinfo%vertex(k,i)==cellinfo%vertex(3,j) .or. &
cellinfo%vertex(k,i)==cellinfo%vertex(4,j)) then
mask(k)=.TRUE.
end if
end do
do k=1,4
if(mask(facetet(1,k) .and. mask(facetet(2,k)) .and. mask(facetet(3,k))) then
cellinfo%neighbour(k,i)=j
end if
end do
if(cellinfo%neighbour(1,i)/=0 .and. cellinfo%neighbour(2,i)/=0 .and. &
cellinfo%neighbour(3,i)/=0 .and. cellinfo%neighbour(4,i)/=0) then
exit
end if
end if
end do
end if
end do
else if(2 .eq. ndimn) then
do i=1,ncell
call progBar(i,ncell)
if(cellinfo%neighbour(1,i)==0 .or. cellinfo%neighbour(2,i)==0 .or. &
cellinfo%neighbour(3,i)==0) then
do j=1,ncell
if(i .ne. j) then
mask(:)=.FALSE.
do k=1,3
if(cellinfo%vertex(k,i)==cellinfo%vertex(1,j) .or. &
cellinfo%vertex(k,i)==cellinfo%vertex(2,j) .or. &
cellinfo%vertex(k,i)==cellinfo%vertex(3,j)) then
mask(k)=.TRUE.
end if
end do
do k=1,3
if(mask(facetri(1,k) .and. mask(facetri(2,k))) then
cellinfo%neighbour(k,i)=j
end if
end do
if(cellinfo%neighbour(1,i)/0 .and. cellinfo%neighbour(2,i)/=0 .and. &
cellinfo%neighbour(3,i)/=0) then
exit
end if
end if
end do
end if
end do
end if
! Boundary condition
! add dynamic arrays to store boundary cells
write(*,*)
read(ioput,*)
do i=1,nbsurf
read(ioput,*)ntemp1,ntemp2,ntemp3
if(ntemp1 .eq. 1000) then ! farfield
cellinfo%neighbour(ntemp3,ntemp2) = i+ncell
cellinfo%nflag(ntemp3,ntemp2) = 11
cellinfo%neighbour(1,i+ncell) = ntemp2
else if(ntemp .eq. 1001) then ! symmetry plane
cellinfo%neighbour(ntemp3,ntemp2) = i+ncell
cellinfo%nflag(ntemp3,ntemp2) = 12
cellinfo%neighbour(1,i+ncell) = ntemp2
else if(ntemp .eq. 1001) then ! inviscid surface
cellinfo%neighbour(ntemp3,ntemp2) = i+ncell
cellinfo%nflag(ntemp3,ntemp2) = 13
cellinfo%neighbour(1,i+ncell) = ntemp2
else if(ntemp .eq. 1001) then ! no-slip wall
cellinfo%neighbour(ntemp3,ntemp2) = i+ncell
cellinfo%nflag(ntemp3,ntemp2) = 14
cellinfo%neighbour(1,i+ncell) = ntemp2
else
write(*,*) "No specified boundary type!!!"
end if
end do
close(ioput)
return
end subroutine readmsh