53
54
55
56
57
58
59
60
61
62
63
64 USE elbufdef_mod
66 USE multi_fvm_mod
69 USE multimat_param_mod , ONLY : m51_n0phas, m51_nvphas
70 USE matparam_def_mod, ONLY : matparam_struct_
71 use element_mod , only : nixs,nixq,nixtg
72
73
74
75#include "implicit_f.inc"
76
77
78
79#include "com01_c.inc"
80#include "com04_c.inc"
81#include "com08_c.inc"
82#include "param_c.inc"
83#include "scr03_c.inc"
84#include "scr17_c.inc"
85#include "task_c.inc"
86#include "units_c.inc"
87#include "chara_c.inc"
88
89
90
91 INTEGER,INTENT(IN) :: ITAB(NUMNOD), IPART(LIPART1,*),IGEO(NPROPGI,NUMGEO), IXS(NIXS,NUMELS),
92
93INTEGER, INTENT(INOUT) :: NODTAG(NUMNOD),
94 . IPM(NPROPMI,*)
95 INTEGER, TARGET :: IPARTS(*),IPARTQ(*),IPARTTG(*)
96 my_real,
INTENT(IN) :: x(3,numnod),v(3,numnod)
97 my_real,
INTENT(IN),
TARGET :: bufmat(*)
98 TYPE (ELBUF_STRUCT_), DIMENSION(NGROUP), TARGET, INTENT(IN) :: ELBUF_TAB
99 TYPE(MULTI_FVM_STRUCT), INTENT(IN) :: MULTI_FVM
100 TYPE(MATPARAM_STRUCT_) ,DIMENSION(NUMMAT) ,INTENT(IN) :: MAT_PARAM
101
102
103
104 INTEGER I, N, JJ, J, IPRT, K, KK, INOD
105 INTEGER NG, NEL, NFT, LFT, LLT, ITY, ISOLNOD, NPT
106 INTEGER NUM_CENTROIDS, MLW, NBMAT, NB2, ISUBMAT, NNOD
107 INTEGER NUVAR
108 TYPE(G_BUFEL_) ,POINTER :: GBUF
109 my_real min_x,min_y,min_z,max_x,max_y,max_z,p0(3),p0_inf(3),p0_sup(3),length
114 my_real dotprod,tol,xyz(3),vel(3),dist,vect(3)
115 CHARACTER FILNAM*2048, SHORTNAME*128, CHSTAT*4
116 INTEGER XMIN_CELL_ID,YMIN_CELL_ID,ZMIN_CELL_ID,XMAX_CELL_ID,YMAX_CELL_ID,ZMAX_CELL_ID
117 INTEGER IS_ITY_1, IS_ITY_2, IS_ITY_7, IMAT, NPAR, IADBUF
118 INTEGER, POINTER,DIMENSION(:) :: IPART_PTR
119 my_real,
POINTER,
DIMENSION(:) :: uparam
120 TYPE(BUF_MAT_) ,POINTER :: MBUF
121 INTEGER, ALLOCATABLE, DIMENSION(:,:) :: GET_CELL_FOM_CENTROID
122 INTEGER NPTS(NSPMD),NCELL(NSPMD),NPTS_TOT,NCELL_TOT
123 my_real,
DIMENSION(:,:),
ALLOCATABLE :: work
125 my_real :: shift_cy_min, shift_ny_min, shift_cz_min, shift_nz_min
126 INTEGER, ALLOCATABLE, DIMENSION(:) :: IDX, NODTAG_G
127 INTEGER :: CELL_ID
128 INTEGER :: LEN, LEN_TMP_NAME
129 CHARACTER :: TMP_NAME*2048
130 INTEGER :: IFILNAM(2048)
131
132
133
134 IF(n2d == 0)RETURN
135
136
137
138
139
140
142 num_centroids = 0
143 mlw=0
144
145 min_x = ep20
146 min_y = ep20
147 min_z = ep20
148 max_x = -ep20
149 max_y = -ep20
150 max_z = -ep20
151
152 is_ity_1 = 0
153 is_ity_2 = 0
154 is_ity_7 = 0
155
156
157
159 IF(ispmd/=0)THEN
161 ELSE
163 ENDIF
164 ENDIF
165
166
167
168 DO ng=1,ngroup
169 ity =iparg(5,ng)
170 isolnod = iparg(28,ng)
171 nel =iparg(2,ng)
172 nft =iparg(3,ng)
173 gbuf => elbuf_tab(ng)%GBUF
174 mlw = iparg(1,ng)
175 lft=1
176 llt=nel
177 npt=0
178 IF(ity == 1) THEN
179
180 is_ity_1=1
181 npt=isolnod
182 ipart_ptr => iparts(1:numels)
183 ELSEIF(ity == 2)THEN
184
185 is_ity_2=1
186 npt=4
187 ipart_ptr => ipartq(1:numelq)
188 ELSEIF(ity == 7 .AND. n2d /= 0)THEN
189
190 is_ity_7=1
191 npt=3
192 ipart_ptr => iparttg(1:numeltg)
193 ENDIF
194 IF(npt /= 0)THEN
195 DO i=lft,llt
196 n = i + nft
197 iprt=ipart_ptr(n)
198 imat =ipart(1,iprt)
199 IF(ipart_state(iprt)==0)cycle
200 num_centroids = num_centroids +1
201 DO k=1,npt
202 IF(is_ity_1==1)inod=ixs(1+k,n)
203 IF(is_ity_2==1)inod=ixq(1+k,n)
204 IF(is_ity_7==1)inod=ixtg(1+k,n)
205 IF(is_ity_1==1)nodtag(ixs(1+k,n)) = 1
206 IF(is_ity_2==1)nodtag(ixq(1+k,n)) = 1
207 IF(is_ity_7==1)nodtag(ixtg(1+k,n)) = 1
208 IF(x(1,inod)<min_x)THEN
209 min_x=x(1,inod)
210 xmin_cell_id = n
211 ENDIF
212 IF(x(2,inod)<min_y)THEN
213 min_y=x(2,inod)
214 ymin_cell_id = n
215 ENDIF
216 IF(x(3,inod)<min_z)THEN
217 min_z=x(3,inod)
218 zmin_cell_id = n
219 ENDIF
220 IF(x(1,inod)>max_x)THEN
221 max_x=x(1,inod)
222 xmax_cell_id = n
223 ENDIF
224 IF(x(2,inod)>max_y)THEN
225 max_y=x(2,inod)
226 ymax_cell_id = n
227 ENDIF
228 IF(x(3,inod)>max_z)THEN
229 max_z=x(3,inod)
230 zmax_cell_id = n
231 ENDIF
232 ENDDO
233 END DO
234 ELSE
235
236 END IF
237 END do
238
239
240
243
244 nnod=0
245 DO i=1,numnod
246 IF(nodtag(i) == 1)THEN
247 nnod=nnod+1
248 ENDIF
249 ENDDO
250
251
252
256 IF(.NOT.ALLOCATED(get_cell_fom_centroid))THEN
257 ALLOCATE(get_cell_fom_centroid(2,num_centroids))
258 ENDIF
259
260 IF(num_centroids > 0)THEN
261
262
263 lx=max_x-min_x
264 ly=max_y-min_y
265 lz=max_z-min_z
266 vect(1:3)=(/lx,ly,lz/)
267 length = sqrt(vect(2)*vect(2) + vect(3)*vect(3))
268 IF(is_ity_1==1)THEN
269 p0_inf(2) = sum( x(2,ixs(2:9,ymin_cell_id)) ) / npt
270 p0_inf(3) = sum( x(3,ixs(2:9,zmin_cell_id)) ) / npt
271 ELSEIF(is_ity_2==1)THEN
272 p0_inf(2) = sum( x(2,ixq
273 p0_inf(3) = sum( x(3,ixq(2:5,zmin_cell_id)) ) / npt
274 ELSEIF(is_ity_7==1)THEN
275 p0_inf(2) = sum( x(2,ixtg(2:4,ymin_cell_id)) ) / npt
276 p0_inf(3) = sum( x(3,ixtg(2:4,zmin_cell_id)) ) / npt
277 ENDIF
278 shift_cy = p0_inf(2)
279 shift_cz = p0_inf(3)
283 ELSE
287 ENDIF
288
289
290
291
292
293
294 shift_ny=min_y
295 shift_nz=min_z
298
299
300
301 ALLOCATE(work(num_centroids,3))
302 k=1
303 DO ng=1,ngroup
304 ity =iparg(5,ng)
305 isolnod = iparg(28,ng)
306 nel =iparg(2,ng)
307 nft =iparg(3,ng)
308 gbuf => elbuf_tab(ng)%GBUF
309 mlw = iparg(1,ng)
310 lft=1
311 llt=nel
312 IF(npt /= 0)THEN
313 DO i=lft,llt
314 n = i + nft
315 iprt=ipart_ptr(n)
316 IF(ipart_state(iprt)==0)cycle
317
318 IF(is_ity_1==1)THEN
319 p0(2) = sum( x(2,ixs(2:9,n)) ) / npt
320 p0(3) = sum( x(3,ixs(2:9,n)) ) / npt
321 cell_id = ixs(nixs,n)
322 ELSEIF(is_ity_2==1)THEN
323 p0(2) = sum( x(2,ixq(2:5,n)) ) / npt
324 p0(3) = sum( x(3,ixq(2:5,n)) ) / npt
325 cell_id = ixq(nixq,n)
326 ELSEIF(is_ity_7==1)THEN
327 p0(2) = sum( x(2,ixtg(2:4,n)) ) / npt
328 p0(3) = sum( x(3,ixtg(2:4,n)) ) / npt
329 cell_id = ixtg(nixtg,n)
330 ENDIF
331
332
333
334 work(k,1) = p0(2)
335 work(k,2) = p0(3)
336 work(k,3) = cell_id
337 get_cell_fom_centroid(1,k) = ng
338 get_cell_fom_centroid(2,k) = i
339 k=k+1
340 END DO
341 END IF
342 END do
343
344
345
346 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(num_centroids))
347 DO k=1,num_centroids ; idx(k)=k; ENDDO
348 IF(num_centroids>0)
CALL quicksort(work(:,3), idx, 1, num_centroids)
349
350 DO k=1,num_centroids
354 ENDDO
355 IF(ALLOCATED(work))DEALLOCATE(work)
356
357
358
359
360
361 IF(num_centroids > 0)THEN
362 IF(mlw==151)THEN
363 nbmat = multi_fvm%NBMAT
364 ELSEIF(mlw==51)THEN
365 nbmat = 4
366 ELSE
367 nbmat = 1
368 ENDIF
372 DO i=1,nbmat
377 ENDDO
378 IF(mlw==151)THEN
379
386
387 DO k=1, num_centroids
388 ng = get_cell_fom_centroid(1,idx(k))
389 i = get_cell_fom_centroid(2,idx(k))
390 nft = iparg(3,ng)
396 ENDDO
397
398 DO isubmat=1,nbmat
399 DO k=1, num_centroids
400 ng = get_cell_fom_centroid(1,idx(k))
401 i = get_cell_fom_centroid(2,idx(k))
402 nft = iparg(3,ng)
403 state_inimap_buf(1)%SUBMAT(isubmat)%VFRAC(k) = multi_fvm%PHASE_ALPHA(isubmat,i+nft)
404 state_inimap_buf(1)%SUBMAT(isubmat)%RHO(k) = multi_fvm%PHASE_RHO(isubmat,i+nft)
405 state_inimap_buf(1)%SUBMAT(isubmat)%E(k) = multi_fvm%PHASE_EINT(isubmat,i+nft)
407 ENDDO
408 ENDDO
409 ELSEIF(mlw==51)THEN
410 nb2=0
411 DO isubmat=1,nbmat
412 DO k=1, num_centroids
413 ng = get_cell_fom_centroid(1,idx(k))
414 i = get_cell_fom_centroid(2,idx(k))
415 nft = iparg(3,ng)
416 nel = iparg(2,ng)
417 n = i + nft
418 iprt=ipart_ptr(n)
419 imat =ipart(1,iprt)
420 IF(mat_param(imat)%MULTIMAT%MID(isubmat) == 0)EXIT
421 nb2=
max(nb2,ipm(5,imat))
422 iadbuf = ipm(7,imat)
423 npar = ipm(9,imat)
424 nuvar = ipm(8,imat)
425 uparam => bufmat(iadbuf:iadbuf+npar-1)
426 kk = m51_n0phas + (uparam(276+isubmat)-1)*m51_nvphas
427 mbuf => elbuf_tab(ng)%BUFLY(1)%MAT(1,1,1)
432 ENDDO
433 ENDDO
435 ELSE
436 DO k=1, num_centroids
437 ng = get_cell_fom_centroid(1,idx(k))
438 i = get_cell_fom_centroid(2,idx(k))
439 gbuf => elbuf_tab(ng)%GBUF
440 nel =iparg(2,ng)
444 state_inimap_buf(1)%SUBMAT(1)%PRES(k) = -third * (gbuf%SIG(i) + gbuf%SIG(i + nel) + gbuf%SIG(i + 2 * nel))
445 ENDDO
446 ENDIF
447 ENDIF
448
449
450
451 IF(num_centroids > 0)THEN
452 IF(mlw /= 151)THEN
453 ALLOCATE(work(numnod,4))
454
460 nnod=0
461 DO i=1,numnod
462 IF(nodtag(i) == 1)THEN
463 nnod=nnod+1
464
465
466
467
468 work(nnod,1) = x(2,i)
469 work(nnod,2) = x(3,i)
470 work(nnod,3) = v(2,i)
471 work(nnod,4) = v(3,i)
473 ENDIF
474 ENDDO
476
477 IF(ALLOCATED(idx))DEALLOCATE(idx)
478 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(nnod))
479 DO k=1,nnod ; idx(k)=k; ENDDO
481 DO k=1,nnod
486 ENDDO
487 IF(ALLOCATED(work))DEALLOCATE(work)
488
489
490 ELSE
491
492
493 ENDIF
494 ENDIF
495
496
497
498
499 IF(nspmd > 1)THEN
502
503 IF(ispmd == 0)THEN
508 DO i=2,nspmd
514 ENDDO
519 ENDIF
520 ENDIF
521
522
523
524
527 IF(ispmd == 0 .AND. nspmd > 1)THEN
528
529
530 npts_tot = 0
531 ncell_tot = 0
532 len_tot = zero
533 DO i=1,nspmd
535 npts(i)=0
536 len_(i)=zero
537 ncell(i)=0
538 cycle
539 ENDIF
541 npts_tot=npts_tot+npts(i)
543 len_tot=len_tot+len_(i)
545 ncell_tot = ncell_tot + ncell(i)
546 ENDDO
547 ALLOCATE(work(npts_tot,5))
548
549
550
551 j=0
552 DO i=1,nspmd
553 DO k=1,npts(i)
554 j=j+1
560 ENDDO
561 ENDDO
562
563
564 IF(ALLOCATED(idx))DEALLOCATE(idx)
565 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(npts_tot))
566 DO k=1,npts_tot ; idx(k)=k; ENDDO
567 CALL quicksort(work(:,5), idx, 1, npts_tot)
568
569
570
571
572
573 IF(mlw /= 151)THEN
574 ALLOCATE(nodtag_g(npts_tot))
575 nodtag_g(1:npts_tot)=1
576 k=0
577 DO j=2,npts_tot
578 IF(work(j,5) == work(j-1,5))THEN
579 nodtag_g(j)=0
580 k=k+1
581 ENDIF
582 ENDDO
583 ELSE
584 k=npts_tot
585 ENDIF
586
587
588
598 j=0
599 DO k=1,npts_tot
600 IF(mlw /= 151)THEN
601 IF(nodtag_g(k)==0)cycle
602 ENDIF
603 j=j+1
609 ENDDO
610 npts_tot = j
612 IF(ALLOCATED(work))DEALLOCATE(work)
613 IF(ALLOCATED(nodtag_g))DEALLOCATE(nodtag_g)
614
616 ALLOCATE(work(ncell_tot,3+4*nbmat))
617
618
619
620 j=0
621 DO i=1,nspmd
622 DO k=1,ncell(i)
623 j=j+1
628 DO jj=1,nbmat
633 ENDDO
634 ENDDO
635 ENDDO
636
637
638
643 DO jj=1,nbmat
648 ENDDO
652 DO jj=1,nbmat
657 ENDDO
658
659 IF(ALLOCATED(idx))DEALLOCATE(idx)
660 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(ncell_tot))
661 DO k=1,ncell_tot ; idx(k ENDDO
662 CALL quicksort(work(:,3), idx, 1, ncell_tot)
663
664 DO j=1,ncell_tot
669 DO jj=1,nbmat
674 ENDDO
675 ENDDO
678
679 endif
680
681 IF(ispmd == 0)THEN
682 IF(ncell_tot == 0 .OR. len_tot == zero)THEN
683 CALL ancmsg(msgid=284,anmode=aninfo,c1=
" -- 2D DOMAIN IS NOT DETECTED : CHECK X-PROJECTION")
684 return
685 ELSEIF(len_tot > 0 .AND. ncell_tot > 0)THEN
686 IF(lx/len_tot > em06)THEN
687 CALL ancmsg(msgid=284,anmode=aninfo,c1
" -- 2D DOMAIN IS NOT DETECTED.")
688 return
689 ENDIF
690 ENDIF
691 ENDIF
692
693
694
695
696
697
698
699 IF(ispmd == 0)THEN
702
703 filnam=rootnam(1:rootlen)//'_2D_'//chstat//'.inimap'
704 shortname=rootnam(1:rootlen)//'_2D_'//chstat//'.inimap'
705 len = rootlen+11+4
708 DO i=1,len_tmp_name
709 ifilnam(i)=ichar(tmp_name(i:i))
710 END DO
712 CALL open_c(ifilnam,len_tmp_name,6)
713
720 ENDIF
721
722 IF(ispmd == 0)THEN
723
730
731
734
735
736 DO isubmat = 1,nbmat
738 ENDDO
739
740
741 DO isubmat = 1,nbmat
743 ENDDO
744
745
746 DO isubmat = 1,nbmat
748 ENDDO
749
750
751
755 ELSE
760 ENDIF
761 ENDIF
762
763
764
765
766 IF(ispmd == 0)THEN
767
768
769 shortname=shortname//'.gz'
770 WRITE (iout,500) shortname(1:len_trim(trim(shortname)))
771 WRITE (istdo,500) shortname(1:len_trim(trim(shortname)))
773
774
775 IF(ALLOCATED(get_cell_fom_centroid))DEALLOCATE(get_cell_fom_centroid)
776 DO jj=1,nspmd
779 DO i=1,nbmat
783 ENDDO
784 ENDIF
794 ENDDO
795
796 ENDIF
797
799
800
801
802
803 500 FORMAT (4x,' STATE FILE:',1x,a,' WRITTEN')
804
805 RETURN
character(len=outfile_char_len) outfile_name
integer state_inimap_call_number
type(map_struct), dimension(:), allocatable state_inimap_buf
recursive subroutine quicksort_i2(a, idx, first, last)
recursive subroutine quicksort(a, idx, first, last)
subroutine spmd_state_inimap2d_exch_data()
subroutine spmd_state_inimap_exch_siz()
subroutine ancmsg(msgid, msgtype, anmode, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, r1, r2, r3, r4, r5, r6, r7, r8, r9, c1, c2, c3, c4, c5, c6, c7, c8, c9, prmode)
subroutine write_db(a, n)
void write_i_c(int *w, int *len)
void open_c(int *ifil, int *len, int *mod)