52
53
54
55
56
57
58
59
60
61
62
63 USE elbufdef_mod
65 USE multi_fvm_mod
68 USE multimat_param_mod , ONLY : m51_n0phas, m51_nvphas
69 USE matparam_def_mod, ONLY : matparam_struct_
70
71
72
73#include "implicit_f.inc"
74
75
76
77#include "com01_c.inc"
78#include "com04_c.inc"
79#include "com08_c.inc"
80#include "param_c.inc"
81#include "scr03_c.inc"
82#include "scr17_c.inc"
83#include "task_c.inc"
84#include "units_c.inc"
85#include "chara_c.inc"
86
87
88
89 INTEGER,INTENT(IN) :: ITAB(NUMNOD), IPART(LIPART1,*),IGEO(NPROPGI,NUMGEO), IXS(NIXS,NUMELS), IPART_STATE(NPART)
90
91INTEGER, INTENT(INOUT) :: NODTAG(NUMNOD),
92 . IPM(NPROPMI,*)
93 INTEGER, TARGET :: IPARTS(*),IPARTQ(*),IPARTTG(*)
94 my_real,
INTENT(IN) :: x(3,numnod),v(3,numnod)
95 my_real,
INTENT(IN),
TARGET :: bufmat(*)
96 TYPE (ELBUF_STRUCT_), DIMENSION(NGROUP), TARGET, INTENT(IN) :: ELBUF_TAB
97 TYPE(MULTI_FVM_STRUCT), INTENT(IN) :: MULTI_FVM
98 TYPE(MATPARAM_STRUCT_) ,DIMENSION(NUMMAT) ,INTENT(IN) :: MAT_PARAM
99
100
101
102 INTEGER I, N, JJ,J, IPRT0, IPRT, K, STAT_NUMELS_1, KK, INOD
103 INTEGER NG, NEL, NFT, LFT, LLT, ITY, ISOLNOD, IOFF,NPT
104 INTEGER NUM_CENTROIDS, MLW,IFORM,,NB2,ISUBMAT,NNOD,NNOD2
105 INTEGER NUVAR
106 TYPE(G_BUFEL_) ,POINTER :: GBUF
107 my_real min_x,min_y,min_z,max_x,max_y,max_z,p0(3),p0_inf(3),p0_sup(3),length
113 CHARACTER FILNAM*2048, SHORTNAME*128, CHSTAT*4
114 INTEGER XMIN_CELL_ID,YMIN_CELL_ID,ZMIN_CELL_ID,XMAX_CELL_ID,YMAX_CELL_ID,ZMAX_CELL_ID
115 INTEGER IS_ITY_1, IS_ITY_2, IS_ITY_7, LAST_CELL,FIRST_CELL,IMAT,NPAR,IADBUF
116 INTEGER, POINTER,DIMENSION(:) :: IPART_PTR
117 my_real,
POINTER,
DIMENSION(:) :: uparam
118 TYPE(BUF_MAT_) ,POINTER :: MBUF
119 INTEGER, ALLOCATABLE, DIMENSION(:,:) ::
120 INTEGER NPTS(NSPMD),NCELL(NSPMD),NPTS_TOT,NCELL_TOT
121 my_real,
DIMENSION(:,:),
ALLOCATABLE :: work
123 my_real :: shift_cy_min, shift_ny_min, shift_cz_min, shift_nz_min
124 INTEGER, ALLOCATABLE, DIMENSION(:) :: IDX, NODTAG_G
125 INTEGER :: CELL_ID
126 INTEGER :: LEN, LEN_TMP_NAME
127 CHARACTER :: TMP_NAME*2048
128 INTEGER :: IFILNAM(2048)
129
130
131
132 IF(n2d == 0)RETURN
133
134
135
136
137
138
140 num_centroids = 0
141 mlw=0
142
143 min_x = ep20
144 min_y = ep20
145 min_z = ep20
146 max_x = -ep20
147 max_y = -ep20
148 max_z = -ep20
149
150 is_ity_1 = 0
151 is_ity_2 = 0
152 is_ity_7 = 0
153
154
155
157 IF(ispmd/=0)THEN
159 ELSE
161 ENDIF
162 ENDIF
163
164
165
166 DO ng=1,ngroup
167 ity =iparg(5,ng
168 isolnod = iparg(28,ng)
169 nel =iparg(2,ng)
170 nft =iparg(3,ng)
171 gbuf => elbuf_tab(ng)%GBUF
172 mlw = iparg(1,ng)
173 lft=1
174 llt=nel
175 npt=0
176 IF(ity == 1) THEN
177
178 is_ity_1=1
179 npt=isolnod
180 ipart_ptr => iparts(1:numels)
181 ELSEIF(ity == 2)THEN
182
183 is_ity_2=1
184 npt=4
185 ipart_ptr => ipartq(1:numelq)
186 ELSEIF(ity == 7 .AND. n2d /= 0)THEN
187
188 is_ity_7=1
189 npt=3
190 ipart_ptr => iparttg(1:numeltg)
191 ENDIF
192 IF(npt /= 0)THEN
193 DO i=lft,llt
194 n = i + nft
195 iprt=ipart_ptr(n)
196 imat =ipart(1,iprt)
197 IF(ipart_state(iprt)==0)cycle
198 num_centroids = num_centroids +1
199 DO k=1,npt
200 IF(is_ity_1==1)inod=ixs(1+k,n)
201 IF(is_ity_2==1)inod=ixq(1+k,n)
202 IF(is_ity_7==1)inod=ixtg(1+k,n)
203 IF(is_ity_1==1)nodtag(ixs(1+k,n)) = 1
204 IF(is_ity_2==1)nodtag(ixq(1+k,n)) = 1
205 IF(is_ity_7==1)nodtag(ixtg(1+k,n)) = 1
206 IF(x(1,inod)<min_x)THEN
207 min_x=x(1,inod)
208 xmin_cell_id = n
209 ENDIF
210 IF(x(2,inod)<min_y)THEN
211 min_y=x(2,inod)
212 ymin_cell_id = n
213 ENDIF
214 IF(x(3,inod)<min_z)THEN
215 min_z=x(3,inod)
216 zmin_cell_id = n
217 ENDIF
218 IF(x(1,inod)>max_x)THEN
219 max_x=x(1,inod)
220 xmax_cell_id = n
221 ENDIF
222 IF(x(2,inod)>max_y)THEN
223 max_y=x(2,inod)
224 ymax_cell_id = n
225 ENDIF
226 IF(x(3,inod)>max_z)THEN
227 max_z=x(3,inod)
228 zmax_cell_id = n
229 ENDIF
230 ENDDO
231 END DO
232 ELSE
233
234 END IF
235 END do
236
237
238
241
242 nnod=0
243 DO i=1,numnod
244 IF(nodtag(i) == 1)THEN
245 nnod=nnod+1
246 ENDIF
247 ENDDO
248
249
250
254 IF(.NOT.ALLOCATED(get_cell_fom_centroid))THEN
255 ALLOCATE(get_cell_fom_centroid(2,num_centroids))
256 ENDIF
257
258 IF(num_centroids > 0)THEN
259
260
261 lx=max_x-min_x
262 ly=max_y-min_y
263 lz=max_z-min_z
264 vect(1:3)=(/lx,ly,lz/)
265 length = sqrt(vect(2)*vect(2) + vect(3)*vect(3))
266 IF(is_ity_1==1)THEN
267 p0_inf(2) = sum( x(2,ixs(2:9,ymin_cell_id)) ) / npt
268 p0_inf(3) = sum( x(3,ixs(2:9,zmin_cell_id)) ) / npt
269 ELSEIF(is_ity_2==1)THEN
270 p0_inf(2) = sum( x(2,ixq(2:5,ymin_cell_id)) ) / npt
271 p0_inf(3) = sum( x(3,ixq(2:5,zmin_cell_id)) ) / npt
272 ELSEIF(is_ity_7==1)THEN
273 p0_inf(2) = sum( x(2,ixtg(2:4,ymin_cell_id
274 p0_inf(3) = sum( x(3,ixtg(2:4,zmin_cell_id)) ) / npt
275 ENDIF
276 shift_cy = p0_inf(2)
277 shift_cz = p0_inf(3)
281 ELSE
285 ENDIF
286
287
288
289
290
291
292 shift_ny=min_y
293 shift_nz=min_z
296
297
298
299 ALLOCATE(work(num_centroids,3))
300 k=1
301 DO ng=1,ngroup
302 ity =iparg(5,ng)
303 isolnod = iparg(28,ng)
304 nel =iparg(2,ng)
305 nft =iparg(3,ng)
306 gbuf => elbuf_tab(ng)%GBUF
307 mlw = iparg(1,ng)
308 lft=1
309 llt=nel
310 IF(npt /= 0)THEN
311 DO i=lft,llt
312 n = i + nft
313 iprt=ipart_ptr(n)
314 IF(ipart_state(iprt)==0)cycle
315
316 IF(is_ity_1==1)THEN
317 p0(2) = sum( x(2,ixs(2:9,n)) ) / npt
318 p0(3) = sum( x(3,ixs(2:9,n)) ) / npt
319 cell_id = ixs(nixs,n)
320 ELSEIF(is_ity_2==1)THEN
321 p0(2) = sum( x(2,ixq(2:5,n)) ) / npt
322 p0(3) = sum( x(3,ixq(2:5,n)) ) / npt
323 cell_id = ixq(nixq,n)
324 ELSEIF(is_ity_7==1)THEN
325 p0(2) = sum( x(2,ixtg(2:4,n)) ) / npt
326 p0(3) = sum( x(3,ixtg(2:4,n)) ) / npt
327 cell_id = ixtg(nixtg,n)
328 ENDIF
329
330
331
332 work(k,1) = p0(2)
333 work(k,2) = p0(3)
334 work(k,3) = cell_id
335 get_cell_fom_centroid(1,k) = ng
336 get_cell_fom_centroid(2,k) = i
337 k=k+1
338 END DO
339 END IF
340 END do
341
342
343
344 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(num_centroids))
345 DO k=1,num_centroids ; idx(k)=k; ENDDO
346 IF(num_centroids>0)
CALL quicksort(work(:,3), idx, 1, num_centroids)
347
348 DO k=1,num_centroids
352 ENDDO
353 IF(ALLOCATED(work))DEALLOCATE(work)
354
355
356
357
358
359 IF(num_centroids > 0)THEN
360 IF(mlw==151)THEN
361 nbmat = multi_fvm%NBMAT
362 ELSEIF(mlw==51)THEN
363 nbmat = 4
364 ELSE
365 nbmat = 1
366 ENDIF
370 DO i=1,nbmat
375 ENDDO
376 IF(mlw==151)THEN
377
384
385 DO k=1, num_centroids
386 ng = get_cell_fom_centroid(1,idx(k))
387 i = get_cell_fom_centroid(2,idx(k))
388 nft = iparg(3,ng)
394 ENDDO
395
396 DO isubmat=1,nbmat
397 DO k=1, num_centroids
398 ng = get_cell_fom_centroid(1,idx(k))
399 i = get_cell_fom_centroid(2,idx(k))
400 nft = iparg(3,ng)
401 state_inimap_buf(1)%SUBMAT(isubmat)%VFRAC(k) = multi_fvm%PHASE_ALPHA(isubmat,i+nft)
402 state_inimap_buf(1)%SUBMAT(isubmat)%RHO(k) = multi_fvm%PHASE_RHO(isubmat,i+nft)
403 state_inimap_buf(1)%SUBMAT(isubmat)%E(k) = multi_fvm%PHASE_EINT(isubmat,i+nft)
405 ENDDO
406 ENDDO
407 ELSEIF(mlw==51)THEN
408 nb2=0
409 DO isubmat=1,nbmat
410 DO k=1, num_centroids
411 ng = get_cell_fom_centroid(1,idx(k))
412 i = get_cell_fom_centroid(2,idx(k))
413 nft = iparg(3,ng)
414 nel = iparg(2,ng)
415 n = i + nft
416 iprt=ipart_ptr(n)
417 imat =ipart(1,iprt)
418 IF(mat_param(imat)%MULTIMAT%MID(isubmat) == 0)EXIT
419 nb2=
max(nb2,ipm(5,imat))
420 iadbuf = ipm(7,imat)
421 npar = ipm(9,imat)
422 nuvar = ipm(8,imat)
423 uparam => bufmat(iadbuf:iadbuf+npar)
424 kk = m51_n0phas + (uparam(276+isubmat)-1)*m51_nvphas
425 mbuf => elbuf_tab(ng)%BUFLY(1)%MAT(1,1,1)
430 ENDDO
431 ENDDO
433 ELSE
434 DO k=1, num_centroids
435 ng = get_cell_fom_centroid(1,idx(k))
436 i = get_cell_fom_centroid(2,idx(k))
437 gbuf => elbuf_tab(ng)%GBUF
438 nel =iparg(2,ng)
443 ENDDO
444 ENDIF
445 ENDIF
446
447
448
449 IF(num_centroids > 0)THEN
450 IF(mlw /= 151)THEN
451 ALLOCATE(work(numnod,4))
452
458 nnod=0
459 DO i=1,numnod
460 IF(nodtag(i) == 1)THEN
461 nnod=nnod+1
462
463
464
465
466 work(nnod,1) = x(2,i)
467 work(nnod,2) = x(3,i)
468 work(nnod,3) = v(2,i)
469 work(nnod,4) = v(3,i)
471 ENDIF
472 ENDDO
474
475 IF(ALLOCATED(idx))DEALLOCATE(idx)
476 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(nnod))
477 DO k=1,nnod ; idx(k)=k; ENDDO
479 DO k=1,nnod
484 ENDDO
485 IF(ALLOCATED(work))DEALLOCATE(work)
486
487
488 ELSE
489
490
491 ENDIF
492 ENDIF
493
494
495
496
497 IF(nspmd > 1)THEN
500
501 IF(ispmd == 0)THEN
506 DO i=2,nspmd
512 ENDDO
517 ENDIF
518 ENDIF
519
520
521
522
525 IF(ispmd == 0 .AND. nspmd > 1)THEN
526
527
528 npts_tot = 0
529 ncell_tot = 0
530 len_tot = zero
531 DO i=1,nspmd
533 npts(i)=0
534 len_(i)=zero
535 ncell(i)=0
536 cycle
537 ENDIF
539 npts_tot=npts_tot+npts(i)
541 len_tot=len_tot+len_(i)
543 ncell_tot = ncell_tot + ncell(i)
544 ENDDO
545 ALLOCATE(work(npts_tot,5))
546
547
548
549 j=0
550 DO i=1,nspmd
551 DO k=1,npts(i
552 j=j+1
558 ENDDO
559 ENDDO
560
561
562 IF(ALLOCATED(idx))DEALLOCATE(idx)
563 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(npts_tot))
564 DO k=1,npts_tot ; idx(k)=k; ENDDO
565 CALL quicksort(work(:,5), idx, 1, npts_tot)
566
567
568
569
570
571 IF(mlw /= 151)THEN
572 ALLOCATE(nodtag_g(npts_tot))
573 nodtag_g(1:npts_tot)=1
574 k=0
575 DO j=2,npts_tot
576 IF(work(j,5) == work(j-1,5))THEN
577 nodtag_g(j)=0
578 k=k+1
579 ENDIF
580 ENDDO
581 ELSE
582 k=npts_tot
583 ENDIF
584
585
586
596 j=0
597 DO k=1,npts_tot
598 IF(mlw /= 151)THEN
599 IF(nodtag_g(k)==0)cycle
600 ENDIF
601 j=j+1
607 ENDDO
608 npts_tot = j
610 IF(ALLOCATED(work))DEALLOCATE(work)
611 IF(ALLOCATED(nodtag_g))DEALLOCATE(nodtag_g)
612
614 ALLOCATE(work(ncell_tot,3+4*nbmat))
615
616
617
618 j=0
619 DO i=1,nspmd
620 DO k=1,ncell(i)
621 j=j+1
626 DO jj=1,nbmat
631 ENDDO
632 ENDDO
633 ENDDO
634
635
636
641 DO jj=1,nbmat
646 ENDDO
650 DO jj=1,nbmat
655 ENDDO
656
657 IF(ALLOCATED(idx))DEALLOCATE(idx)
658 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(ncell_tot))
659 DO k=1,ncell_tot ; idx(k)=k; ENDDO
660 CALL quicksort(work(:,3), idx, 1, ncell_tot)
661
662 DO j=1,ncell_tot
667 DO jj=1,nbmat
672 ENDDO
673 ENDDO
676
677 endif
678
679 IF(ispmd == 0)THEN
680 IF(ncell_tot == 0 .OR. len_tot == zero)THEN
681 CALL ancmsg(msgid=284,anmode=aninfo,c1=
" -- 2D DOMAIN IS NOT DETECTED : CHECK X-PROJECTION")
682 return
683 ELSEIF(len_tot > 0 .AND. ncell_tot > 0)THEN
684 IF(lx/len_tot > em06)THEN
685 CALL ancmsg(msgid=284,anmode=aninfo,c1=
" -- 2D DOMAIN IS NOT DETECTED.")
686 return
687 ENDIF
688 ENDIF
689 ENDIF
690
691
692
693
694
695
696
697 IF(ispmd == 0)THEN
700
701 filnam=rootnam(1:rootlen)//'_2D_'//chstat//'.inimap'
702 shortname=rootnam(1:rootlen)//'_2D_'//chstat//'.inimap'
703 len = rootlen+11+4
706 DO i=1,len_tmp_name
707 ifilnam(i)=ichar(tmp_name(i:i))
708 END DO
710 CALL open_c(ifilnam,len_tmp_name,6)
711
718 ENDIF
719
720 IF(ispmd == 0)THEN
721
728
729
732
733
734 DO isubmat = 1,nbmat
736 ENDDO
737
738
739 DO isubmat = 1,nbmat
741 ENDDO
742
743
744 DO isubmat = 1,nbmat
746 ENDDO
747
748
749
753 ELSE
758 ENDIF
759 ENDIF
760
761
762
763
764 IF(ispmd == 0)THEN
765
766
767 shortname=shortname//'.gz'
768 WRITE (iout,500) shortname(1:len_trim(trim(shortname)))
769 WRITE (istdo,500) shortname(1:len_trim(trim(shortname
771
772
773 IF(ALLOCATED(get_cell_fom_centroid))DEALLOCATE
774 DO jj=1,nspmd
777 DO i=1,nbmat
781 ENDDO
782 ENDIF
792 ENDDO
793
794 ENDIF
795
797
798
799
800
801 500 FORMAT (4x,' STATE FILE:',1x,a,' WRITTEN')
802
803 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)