FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
hecmw_adapt_new_mesh.f90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2! Copyright (c) 2019 FrontISTR Commons
3! This software is released under the MIT License, see LICENSE.txt
4!-------------------------------------------------------------------------------
6
7!C
8!C***
9!C*** hecmw_adapt_new_mesh
10!C***
11!C
12
13subroutine hecmw_adapt_new_mesh (hecMESH, hecMESHnew)
14
15 use hecmw_util
16 type (hecmwST_local_mesh) :: hecMESH
17 type (hecmwST_local_mesh) :: hecMESHnew
18
19 integer(kind=kint), pointer :: WORKaI(:)
20 real(kind=kreal), pointer :: workar(:)
21
22 !C
23 !C-- START.
24 if (hecmesh%my_rank.eq.3) write (*,'(/,a)') '#final mesh (n_node, nn_int, n_elem, ne_int)'
25 call mpi_barrier (hecmesh%MPI_COMM, ierr)
26
27 write (*,'(a,i5,4i8)') 'PE#', hecmesh%my_rank, &
28 & hecmesh%n_node, hecmesh%nn_internal, &
29 & hecmesh%n_elem, hecmesh%ne_internal
30
31 !C
32 !C-- 1. ENTIRE INFO.
33 hecmeshnew%hecmw_n_file= 0
34 hecmeshnew%header = hecmesh%header
35 hecmeshnew%hecmw_flag_adapt = hecmesh%hecmw_flag_adapt
36 hecmeshnew%hecmw_flag_initcon = hecmesh%hecmw_flag_initcon
37 hecmeshnew%hecmw_flag_parttype = hecmesh%hecmw_flag_parttype
38 hecmeshnew%hecmw_flag_partdepth= hecmesh%hecmw_flag_partdepth
39 hecmeshnew%hecmw_flag_version = hecmesh%hecmw_flag_version
40 hecmeshnew%zero_temp = hecmesh%zero_temp
41 hecmeshnew%gridfile = hecmesh%gridfile
42 hecmeshnew%hecmw_n_file = hecmesh%hecmw_n_file
43
44 !C
45 !C-- 2. NODE
46 hecmeshnew%n_node = hecmesh%n_node
47 hecmeshnew%nn_internal= hecmesh%nn_internal
48 hecmeshnew%n_dof = 3
49 hecmeshnew%n_dof_grp = 1
50
51 allocate (hecmeshnew%node (3*hecmeshnew%n_node))
52 allocate (hecmeshnew%node_ID(2*hecmeshnew%n_node))
53 allocate (hecmeshnew%global_node_ID(hecmeshnew%n_node))
54 hecmeshnew%global_node_ID= 1
55
56 do i= 1, hecmeshnew%n_node
57 in= hecmesh%adapt_OLDtoNEW_node(i)
58 hecmeshnew%node(3*in-2)= hecmesh%node(3*i-2)
59 hecmeshnew%node(3*in-1)= hecmesh%node(3*i-1)
60 hecmeshnew%node(3*in )= hecmesh%node(3*i )
61
62 hecmeshnew%node_ID(2*in-1)= hecmesh%node_ID(2*i-1)
63 hecmeshnew%node_ID(2*in )= hecmesh%node_ID(2*i )
64 enddo
65
66 deallocate (hecmesh%node_ID, hecmesh%node, hecmesh%global_node_ID)
67
68 allocate (hecmeshnew%node_dof_index(0:hecmeshnew%n_dof_grp))
69 hecmeshnew%node_dof_index(0)= 0
70 hecmeshnew%node_dof_index(1)= hecmeshnew%n_node
71 allocate (hecmeshnew%node_dof_item(1))
72 hecmeshnew%node_dof_item(1) = 3
73
74 !C
75 !C-- 3. ELEMENT
76 hecmeshnew%n_elem = hecmesh%n_elem
77 hecmeshnew%ne_internal= hecmesh%ne_internal
78 hecmeshnew%n_elem_type= hecmesh%n_elem_type
79
80 hecmeshnew%n_elem_mat_ID= hecmesh%n_elem
81
82 allocate (hecmeshnew%elem_type_index(0:hecmeshnew%n_elem_type))
83 hecmeshnew%elem_type_index= hecmesh%elem_type_index
84 allocate (hecmeshnew%elem_type_item(hecmeshnew%n_elem_type))
85
86 hecmeshnew%elem_type_item = hecmesh%elem_type_item
87 deallocate (hecmesh%elem_type_index, hecmesh%elem_type_item)
88
89 allocate (hecmeshnew%elem_type (hecmeshnew%n_elem))
90 allocate (hecmeshnew%section_ID (hecmeshnew%n_elem))
91 allocate (hecmeshnew%elem_mat_ID_item (hecmeshnew%n_elem))
92
93 do i= 1, hecmeshnew%n_elem
94 in= hecmesh%adapt_OLDtoNEW_elem(i)
95 hecmeshnew%elem_type (in)= hecmesh%elem_type (i)
96 hecmeshnew%section_ID (in)= hecmesh%section_ID (i)
97 hecmeshnew%elem_mat_ID_item(in)= hecmesh%elem_mat_ID_item(i)
98 enddo
99
100 allocate (hecmeshnew%elem_mat_ID_index (0:hecmeshnew%n_elem))
101 hecmeshnew%elem_mat_ID_index= 0
102 do i= 1, hecmeshnew%n_elem
103 hecmeshnew%elem_mat_ID_index(i)= i
104 enddo
105
106 deallocate (hecmesh%elem_type, hecmesh%section_ID)
107 deallocate (hecmesh%elem_mat_ID_index)
108 deallocate (hecmesh%elem_mat_ID_item )
109
110 nnn= hecmesh%elem_node_index(hecmesh%n_elem)
111 allocate (hecmeshnew%elem_node_index(0:hecmeshnew%n_elem))
112 allocate (hecmeshnew%elem_node_item (nnn))
113 hecmeshnew%elem_node_index= 0
114 hecmeshnew%elem_node_item = 0
115 do i= 1, hecmeshnew%n_elem
116 in= hecmesh%adapt_OLDtoNEW_elem(i)
117 hecmeshnew%elem_node_index(in)= hecmesh%elem_node_index(i) - hecmesh%elem_node_index(i-1)
118 enddo
119
120 do i= 1, hecmeshnew%n_elem
121 hecmeshnew%elem_node_index(i)= hecmeshnew%elem_node_index(i-1) + hecmeshnew%elem_node_index(i)
122 enddo
123
124 do i= 1, hecmeshnew%n_elem
125 in = hecmesh%adapt_OLDtoNEW_elem(i)
126 is = hecmesh%elem_node_index(i-1)
127 ie = hecmesh%elem_node_index(i )
128 is0= hecmeshnew%elem_node_index(in-1)
129 do k= is+1, ie
130 kk= k - is + is0
131 nodk= hecmesh%adapt_OLDtoNEW_node(hecmesh%elem_node_item(k))
132 hecmeshnew%elem_node_item(kk)= nodk
133 enddo
134 enddo
135 deallocate (hecmesh%elem_node_index, hecmesh%elem_node_item)
136
137 allocate (hecmeshnew%elem_ID(2*hecmeshnew%n_elem))
138 do i= 1, hecmeshnew%n_elem
139 in = hecmesh%adapt_OLDtoNEW_elem(i)
140 hecmeshnew%elem_ID(2*in-1)= hecmesh%elem_ID(2*i-1)
141 hecmeshnew%elem_ID(2*in )= hecmesh%elem_ID(2*i )
142 enddo
143 deallocate (hecmesh%elem_ID)
144 allocate (hecmeshnew%global_elem_ID(hecmeshnew%n_elem))
145 hecmeshnew%global_elem_ID= 1
146 deallocate (hecmesh%global_elem_ID)
147 allocate (hecmeshnew%elem_internal_list(hecmeshnew%ne_internal))
148 do i= 1, hecmesh%ne_internal
149 icel= hecmesh%elem_internal_list (i)
150 in = hecmesh%adapt_OLDtoNEW_elem(icel)
151 hecmeshnew%elem_internal_list(i)= in
152 enddo
153 deallocate (hecmesh%elem_internal_list)
154
155 !C
156 !C-- 5. COMMUNICATION
157 hecmeshnew%my_rank = hecmesh%my_rank
158 hecmeshnew%zero = hecmesh%zero
159 hecmeshnew%PETOT = hecmesh%PETOT
160 hecmeshnew%PEsmpTOT= hecmesh%PEsmpTOT
161
162 hecmeshnew%errnof = hecmesh%errnof
163
164 call mpi_comm_dup (hecmesh%MPI_COMM, hecmeshnew%MPI_COMM, ierr)
165
166 hecmeshnew%n_subdomain = hecmesh%n_subdomain
167 hecmeshnew%n_neighbor_pe= hecmesh%n_neighbor_pe
168
169 allocate (hecmeshnew%neighbor_pe(hecmeshnew%n_neighbor_pe))
170 hecmeshnew%neighbor_pe= hecmesh%neighbor_pe
171
172 nn1= hecmesh%adapt_import_new_index(hecmesh%n_neighbor_pe)
173 nn2= hecmesh%adapt_export_new_index(hecmesh%n_neighbor_pe)
174
175 allocate (hecmeshnew%import_index(0:hecmeshnew%n_neighbor_pe), hecmeshnew%import_item(nn1))
176 allocate (hecmeshnew%export_index(0:hecmeshnew%n_neighbor_pe), hecmeshnew%export_item(nn2))
177
178 hecmeshnew%import_index= 0
179 hecmeshnew%export_index= 0
180
181 do i= 1, hecmeshnew%n_neighbor_pe
182 hecmeshnew%import_index(i)= hecmesh%adapt_import_new_index(i)
183 hecmeshnew%export_index(i)= hecmesh%adapt_export_new_index(i)
184 enddo
185
186 do i= 1, nn1
187 hecmeshnew%import_item(i) = hecmesh%adapt_import_new_item(i)
188 enddo
189
190 do i= 1, nn2
191 hecmeshnew%export_item(i) = hecmesh%adapt_export_new_item(i)
192 enddo
193
194 allocate (hecmeshnew%shared_index(0:hecmeshnew%n_neighbor_pe))
195 hecmeshnew%shared_index= 0
196
197 !C
198 !C-- 6. GRID ADAPTATION
199 hecmeshnew%coarse_grid_level= hecmesh%coarse_grid_level
200 hecmeshnew%n_adapt = hecmesh%n_adapt
201
202 allocate (hecmeshnew%when_i_was_refined_node(hecmeshnew%n_node))
203 allocate (hecmeshnew%when_i_was_refined_elem(hecmeshnew%n_elem))
204 allocate (hecmeshnew%adapt_parent_type(hecmeshnew%n_elem))
205 allocate (hecmeshnew%adapt_type (hecmeshnew%n_elem))
206 allocate (hecmeshnew%adapt_level (hecmeshnew%n_elem))
207 allocate (hecmeshnew%adapt_parent (hecmeshnew%n_elem*2))
208 allocate (hecmeshnew%adapt_children_index (0: hecmeshnew%n_elem))
209 allocate (hecmeshnew%adapt_children_item (16*hecmeshnew%n_elem))
210
211 do i= 1, hecmeshnew%n_node
212 in= hecmesh%adapt_OLDtoNEW_node(i)
213 hecmeshnew%when_i_was_refined_node(in)= hecmesh%when_i_was_refined_node(i)
214 enddo
215
216 hecmeshnew%adapt_children_index= 0
217 hecmeshnew%adapt_children_item = 0
218 do i= 1, hecmeshnew%n_elem
219 in= hecmesh%adapt_OLDtoNEW_elem(i)
220 hecmeshnew%when_i_was_refined_elem(in)= hecmesh%when_i_was_refined_elem(i)
221 hecmeshnew%adapt_parent_type(in)= hecmesh%adapt_parent_type(i)
222 hecmeshnew%adapt_type (in)= hecmesh%adapt_type (i)
223 hecmeshnew%adapt_level (in)= hecmesh%adapt_level (i)
224
225 hecmeshnew%adapt_parent(2*in-1)= hecmesh%adapt_parent(2*i-1)
226 hecmeshnew%adapt_parent(2*in )= hecmesh%adapt_parent(2*i )
227
228 hecmeshnew%adapt_children_index(i)= hecmeshnew%adapt_children_index(i-1) + 8
229
230 isorg= (i -1)*16
231 isnew= (in-1)*16
232 do kk= 1, 16
233 hecmeshnew%adapt_children_item(isnew+kk)= hecmesh%adapt_children_item(isorg+kk)
234 enddo
235 enddo
236
237 deallocate (hecmesh%when_i_was_refined_node)
238 deallocate (hecmesh%when_i_was_refined_elem)
239 deallocate (hecmesh%adapt_type, hecmesh%adapt_parent_type, hecmesh%adapt_parent, hecmesh%adapt_level)
240 deallocate (hecmesh%adapt_children_index, hecmesh%adapt_children_item)
241
242 !C
243 !C-- 7. SECTION
244 hecmeshnew%section%n_sect= hecmesh%section%n_sect
245
246 allocate (hecmeshnew%section%sect_type(hecmeshnew%section%n_sect))
247 allocate (hecmeshnew%section%sect_opt (hecmeshnew%section%n_sect))
248 hecmeshnew%section%sect_type= hecmesh%section%sect_type
249 hecmeshnew%section%sect_opt = hecmesh%section%sect_opt
250
251 nnn= hecmesh%section%sect_mat_ID_index(hecmesh%section%n_sect)
252 allocate (hecmeshnew%section%sect_mat_ID_index(0:hecmeshnew%section%n_sect))
253 allocate (hecmeshnew%section%sect_mat_ID_item (nnn))
254 hecmeshnew%section%sect_mat_ID_index= hecmesh%section%sect_mat_ID_index
255 hecmeshnew%section%sect_mat_ID_item = hecmesh%section%sect_mat_ID_item
256
257 allocate (hecmeshnew%section%sect_I_index(0:hecmeshnew%section%n_sect))
258 allocate (hecmeshnew%section%sect_R_index(0:hecmeshnew%section%n_sect))
259 hecmeshnew%section%sect_I_index= 0
260 hecmeshnew%section%sect_R_index= 0
261
262 !C
263 !C-- 8. MATERIAL
264 hecmeshnew%material%n_mat = hecmesh%material%n_mat
265 hecmeshnew%material%n_mat_item = hecmesh%material%n_mat_item
266 hecmeshnew%material%n_mat_subitem= hecmesh%material%n_mat_subitem
267 hecmeshnew%material%n_mat_table = hecmesh%material%n_mat_table
268
269 n_mat = hecmeshnew%material%n_mat
270 n_item = hecmeshnew%material%n_mat_item
271 n_subitem= hecmeshnew%material%n_mat_subitem
272 nnn = hecmesh%material%mat_table_index(n_subitem)
273
274 allocate (hecmeshnew%material%mat_name(n_mat))
275 hecmeshnew%material%mat_name= hecmesh%material%mat_name
276
277 allocate (hecmeshnew%material%mat_item_index (0:n_mat))
278 allocate (hecmeshnew%material%mat_subitem_index(0:n_item))
279 allocate (hecmeshnew%material%mat_table_index (0:n_subitem))
280 hecmeshnew%material%mat_item_index = hecmesh%material%mat_item_index
281 hecmeshnew%material%mat_subitem_index= hecmesh%material%mat_subitem_index
282 hecmeshnew%material%mat_table_index = hecmesh%material%mat_table_index
283
284 allocate (hecmeshnew%material%mat_val(nnn), hecmeshnew%material%mat_temp(nnn))
285 hecmeshnew%material%mat_val = hecmesh%material%mat_val
286 hecmeshnew%material%mat_temp= hecmesh%material%mat_temp
287
288 !C
289 !C-- 9. MPC/AMPLITUDE
290 hecmeshnew%mpc%n_mpc= hecmesh%mpc%n_mpc
291 if (hecmesh%mpc%n_mpc.ne.0) then
292 nnn= hecmesh%mpc%mpc_index(hecmesh%mpc%n_mpc)
293 allocate (hecmeshnew%mpc%mpc_index(0:hecmeshnew%mpc%n_mpc))
294 allocate (hecmeshnew%mpc%mpc_item (nnn))
295 allocate (hecmeshnew%mpc%mpc_dof (nnn))
296 allocate (hecmeshnew%mpc%mpc_val (nnn))
297 hecmeshnew%mpc%mpc_index= hecmesh%mpc%mpc_index
298 hecmeshnew%mpc%mpc_item = hecmesh%mpc%mpc_item
299 hecmeshnew%mpc%mpc_dof = hecmesh%mpc%mpc_dof
300 hecmeshnew%mpc%mpc_val = hecmesh%mpc%mpc_val
301 endif
302
303 hecmeshnew%amp%n_amp= 0
304 if (hecmesh%amp%n_amp.ne.0) then
305 nnn= hecmesh%amp%amp_index(hecmesh%amp%n_amp)
306 allocate (hecmeshnew%amp%amp_type_definition(hecmeshnew%amp%n_amp))
307 allocate (hecmeshnew%amp%amp_type_time (hecmeshnew%amp%n_amp))
308 allocate (hecmeshnew%amp%amp_type_value (hecmeshnew%amp%n_amp))
309 allocate (hecmeshnew%amp%amp_index(0:hecmeshnew%amp%n_amp))
310 allocate (hecmeshnew%amp%amp_val (nnn))
311 allocate (hecmeshnew%amp%amp_table(nnn))
312 hecmeshnew%amp%amp_type_definition= hecmesh%amp%amp_type_definition
313 hecmeshnew%amp%amp_type_time = hecmesh%amp%amp_type_time
314 hecmeshnew%amp%amp_type_value = hecmesh%amp%amp_type_value
315 hecmeshnew%amp%amp_index = hecmesh%amp%amp_index
316 hecmeshnew%amp%amp_val = hecmesh%amp%amp_val
317 hecmeshnew%amp%amp_table = hecmesh%amp%amp_table
318 endif
319
320 !C
321 !C-- 10. NODE-GROUP
322 n_grp = hecmesh%node_group%n_grp
323
324 if (n_grp.ne.0) then
325 n_array= hecmesh%node_group%grp_index(n_grp)
326 hecmeshnew%node_group%n_grp= hecmesh%node_group%n_grp
327
328 allocate (hecmeshnew%node_group%grp_name ( n_grp))
329 allocate (hecmeshnew%node_group%grp_index(0:n_grp))
330 allocate (hecmeshnew%node_group%grp_item (n_array))
331
332 hecmeshnew%node_group%grp_name = hecmesh%node_group%grp_name
333 hecmeshnew%node_group%grp_index= hecmesh%node_group%grp_index
334
335 do i= 1, n_array
336 in0= hecmesh%node_group%grp_item(i)
337 hecmeshnew%node_group%grp_item(i)= hecmesh%adapt_OLDtoNEW_node(in0)
338 enddo
339 endif
340
341 !C
342 !C-- 11. ELEM-GROUP
343 n_grp = hecmesh%elem_group%n_grp
344
345 if (n_grp.ne.0) then
346 n_array= hecmesh%elem_group%grp_index(n_grp)
347 hecmeshnew%elem_group%n_grp= hecmesh%elem_group%n_grp
348
349 allocate (hecmeshnew%elem_group%grp_name ( n_grp))
350 allocate (hecmeshnew%elem_group%grp_index(0:n_grp))
351 allocate (hecmeshnew%elem_group%grp_item (n_array))
352
353 hecmeshnew%elem_group%grp_name = hecmesh%elem_group%grp_name
354 hecmeshnew%elem_group%grp_index= hecmesh%elem_group%grp_index
355
356 do i= 1, n_array
357 in0= hecmesh%elem_group%grp_item(i)
358 hecmeshnew%elem_group%grp_item(i)= hecmesh%adapt_OLDtoNEW_elem(in0)
359 enddo
360 endif
361
362 !C
363 !C-- 11. SURF-GROUP
364 n_grp = hecmesh%surf_group%n_grp
365
366 if (n_grp.ne.0) then
367 n_array= hecmesh%surf_group%grp_index(n_grp)
368 hecmeshnew%surf_group%n_grp= hecmesh%surf_group%n_grp
369
370 allocate (hecmeshnew%surf_group%grp_name ( n_grp))
371 allocate (hecmeshnew%surf_group%grp_index(0:n_grp))
372 allocate (hecmeshnew%surf_group%grp_item (2*n_array))
373
374 hecmeshnew%surf_group%grp_name = hecmesh%surf_group%grp_name
375 hecmeshnew%surf_group%grp_index= hecmesh%surf_group%grp_index
376
377 do i= 1, n_array
378 in0 = hecmesh%surf_group%grp_item(2*i-1)
379 isuf= hecmesh%surf_group%grp_item(2*i )
380 hecmeshnew%surf_group%grp_item(2*i-1)= hecmesh%adapt_OLDtoNEW_elem(in0)
381 hecmeshnew%surf_group%grp_item(2*i )= isuf
382 enddo
383 endif
384
385end subroutine hecmw_adapt_new_mesh
386
387
subroutine hecmw_adapt_new_mesh(hecmesh, hecmeshnew)
Adaptive Mesh Refinement.
I/O and Utility.
Definition: hecmw_util_f.F90:7
integer(kind=4), parameter kreal