SPEED
READ_FILEMESH.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
50
51 subroutine read_filemesh(gridfile,nb_mat,lab_mat,&
52 nb_diriX,lab_dirX,nb_diriY,lab_dirY,nb_diriZ,lab_dirZ,&
53 nb_neuX,lab_neuX,nb_neuY,lab_neuY,nb_neuZ,lab_neuZ,&
54 nb_neuN,lab_neuN,&
55 nb_abc,lab_abc,&
56 nb_dg,lab_dg,&
57 nb_node,xx,yy,zz,nb_hexa,con_hexa,nb_quad,con_quad)
58
59 implicit none
60
61 character*110 :: inline
62 character*20 :: el_code
63 character*70 :: gridfile
64
65 integer*4 :: nb_mat,nb_diriX,nb_diriY,nb_diriZ,nb_neuX,nb_neuY,nb_neuZ,nb_abc,nb_dg
66 integer*4 :: nb_neuN
67 integer*4 :: nb_node,nb_hexa,nb_quad
68 integer*4 :: inode,ihexa,iquad
69 integer*4 :: nb_elem,ie,i,j,mat_code,ileft,iright,sl,trash,status,control
70
71 integer*4, dimension(nb_mat) :: lab_mat
72 integer*4, dimension(nb_diriX) :: lab_dirX
73 integer*4, dimension(nb_diriY) :: lab_dirY
74 integer*4, dimension(nb_diriZ) :: lab_dirZ
75 integer*4, dimension(nb_neuX) :: lab_neuX
76 integer*4, dimension(nb_neuY) :: lab_neuY
77 integer*4, dimension(nb_neuZ) :: lab_neuZ
78 integer*4, dimension(nb_neuN) :: lab_neuN
79 integer*4, dimension(nb_abc) :: lab_abc
80 integer*4, dimension(nb_dg) :: lab_dg
81
82 integer*4, dimension(nb_hexa,9) :: con_hexa
83 integer*4, dimension(nb_quad,5) :: con_quad
84
85 real*8 :: xx,yy,zz
86
87 inode = 0
88 ihexa = 0
89 iquad = 0
90
91 status = 0
92
93 open(40,file=gridfile)
94
95 do
96 read(40,'(A)') inline
97 if (inline(1:1) .ne. '#') exit
98 enddo
99
100 read(inline,*)nb_node,nb_elem
101
102 do i = 1,nb_node
103 read(40,*)inode,xx,yy,zz
104
105 if (inode.ne.i) then
106 status = 1
107 endif
108 enddo
109
110 do ie = 1,nb_elem
111 read(40,'(A)')inline
112
113 sl = len(inline)
114 ileft = 0
115 iright = 0
116 do i = 1,sl
117 if (inline(i:i).ge.'A') exit
118 enddo
119 ileft = i
120 do i = ileft,sl
121 if (inline(i:i).lt.'A') exit
122 enddo
123 iright = i
124
125 el_code = inline(ileft:iright)
126
127 read(inline(1:ileft),*)trash,mat_code
128
129 if ((el_code.eq.'hex').or.(el_code.eq.'HEX')) then
130 control = 0
131 do i = 1,nb_mat
132 if (lab_mat(i).eq.mat_code) control = 1
133 enddo
134 !
135 if (control.ne.0) then
136 ihexa = ihexa + 1
137 con_hexa(ihexa,1) = mat_code
138 read(inline(iright:sl),*)(con_hexa(ihexa,j),j=2,9)
139 endif
140 !
141 elseif ((el_code.eq.'quad').or.(el_code.eq.'QUAD')) then
142 control = 0
143 do i = 1,nb_dirix
144 if (lab_dirx(i).eq.mat_code) control = 1
145 enddo
146 do i = 1,nb_diriy
147 if (lab_diry(i).eq.mat_code) control = 1
148 enddo
149 do i = 1,nb_diriz
150 if (lab_dirz(i).eq.mat_code) control = 1
151 enddo
152 do i = 1,nb_neux
153 if (lab_neux(i).eq.mat_code) control = 1
154 enddo
155 do i = 1,nb_neuy
156 if (lab_neuy(i).eq.mat_code) control = 1
157 enddo
158 do i = 1,nb_neuz
159 if (lab_neuz(i).eq.mat_code) control = 1
160 enddo
161 do i = 1,nb_neun
162 if (lab_neun(i).eq.mat_code) control = 1
163 enddo
164 do i = 1,nb_abc
165 if (lab_abc(i).eq.mat_code) control = 1
166 enddo
167 do i = 1,nb_dg
168 if (lab_dg(i).eq.mat_code) control = 1
169 enddo
170
171
172 if (control .ne. 0) then
173 iquad = iquad +1
174 con_quad(iquad,1) = mat_code
175 read(inline(iright:sl),*)(con_quad(iquad,j),j=2,5)
176 endif
177
178 endif
179 enddo
180
181 close(40)
182
183 return
184
185 end subroutine read_filemesh
186
subroutine read_filemesh(gridfile, nb_mat, lab_mat, nb_dirix, lab_dirx, nb_diriy, lab_diry, nb_dir
Reads dimensions in gridfile (*.mesh)