52
53
54
55
56
57
58
59
60
61
62
64 USE elbufdef_mod
66 USE multi_fvm_mod
68 USE multimat_param_mod , ONLY : m51_n0phas, m51_nvphas
69 USE matparam_def_mod, ONLY : matparam_struct_
70 use element_mod , only : nixs,nixq,nixtg
71
72
73
74#include "implicit_f.inc"
75
76
77
78#include "com01_c.inc"
79#include "com04_c.inc"
80#include "com08_c.inc"
81#include "param_c.inc"
82#include "scr03_c.inc"
83#include "scr17_c.inc"
84#include "task_c.inc"
85#include "units_c.inc"
86#include "chara_c.inc"
87
88
89
90 INTEGER,INTENT(IN) :: ITAB(NUMNOD), IPART(LIPART1,*),IGEO(NPROPGI,NUMGEO), IXS(NIXS,NUMELS), IPART_STATE(NPART)
91
92INTEGER, INTENT(INOUT) :: NODTAG(NUMNOD),
93 . IPM(NPROPMI,*)
94 INTEGER, TARGET :: IPARTS(*),IPARTQ(*),IPARTTG(*)
95 my_real,
INTENT(IN) :: x(3,numnod),v(3,numnod)
96 my_real,
INTENT(IN),
TARGET :: bufmat(*)
97 TYPE (ELBUF_STRUCT_), DIMENSION(NGROUP), TARGET, INTENT(IN) :: ELBUF_TAB
98 TYPE(MULTI_FVM_STRUCT), INTENT(IN) :: MULTI_FVM
99 TYPE(MATPARAM_STRUCT_) ,DIMENSION(NUMMAT) ,INTENT(IN) :: MAT_PARAM
100
101
102
103 INTEGER I, N, JJ,J, IPRT, K, KK
104 INTEGER NG, NEL, NFT, LFT, LLT, ITY, ISOLNOD,NPT
105 INTEGER NUM_CENTROIDS, IPOS,MLW,NBMAT,NB2,ISUBMAT,NNOD,NNOD2
106 INTEGER NUVAR
107 TYPE(G_BUFEL_) ,POINTER :: GBUF
108 my_real p0(3),p0_inf(3),p0_sup(3),shift_c,shift_n,length
109 my_real max_xc,max_yc,max_zc,min_xc,min_yc,min_zc
112 my_real dotprod,tol,xyz(3),vel(3),dist
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, ALLOCATABLE, DIMENSION(:) :: IDX
117 INTEGER, POINTER,DIMENSION(:) :: IPART_PTR
118 my_real,
POINTER,
DIMENSION(:) :: uparam
119 TYPE(BUF_MAT_) ,POINTER :: MBUF
120 my_real,
ALLOCATABLE,
DIMENSION(:,:) :: map_nodes
121 INTEGER, ALLOCATABLE, DIMENSION(:,:) :: GET_CELL_FOM_CENTROID
122 INTEGER NPTS(NSPMD),NCELL(NSPMD),NPTS_TOT,NCELL_TOT
123 my_real,
DIMENSION(:,:),
ALLOCATABLE :: work
124 INTEGER, DIMENSION(:), ALLOCATABLE :: WORK_INDX
125 my_real :: len_(nspmd),len_tot,shift_c_min,shift_n_min
126 INTEGER :: LEN, LEN_TMP_NAME
127 CHARACTER :: TMP_NAME*2048
128 INTEGER :: IFILNAM(2048)
129
130
131
132
133
134
136 num_centroids = 0
137 mlw=0
138
139 min_xc = ep20
140 min_yc = ep20
141 min_zc = ep20
142 max_xc = -ep20
143 max_yc = -ep20
144 max_zc = -ep20
145
146 is_ity_1 = 0
147 is_ity_2 = 0
148 is_ity_7 = 0
149
150
151
153 IF(ispmd/=0)THEN
155 ELSE
157 ENDIF
158 ENDIF
159
160
161
162 DO ng=1,ngroup
163 ity =iparg(5,ng)
164 isolnod = iparg(28,ng)
165 nel =iparg(2,ng)
166 nft =iparg(3,ng)
167 gbuf => elbuf_tab(ng)%GBUF
168 mlw = iparg(1,ng)
169 lft=1
170 llt=nel
171 npt=0
172 IF(ity == 1) THEN
173
174 is_ity_1=1
175 npt=isolnod
176 ipart_ptr => iparts(1:numels)
177 ELSEIF(ity == 2)THEN
178
179 is_ity_2=1
180 npt=4
181 ipart_ptr => ipartq(1:numelq)
182 ELSEIF(ity == 7 .AND. n2d /= 0)THEN
183
184 is_ity_7=1
185 npt=3
186 ipart_ptr => iparttg(1:numeltg)
187 ENDIF
188 IF(npt /= 0)THEN
189 DO i=lft,llt
190 n = i + nft
191 iprt=ipart_ptr(n)
192 imat =ipart(1,iprt)
193 IF(ipart_state(iprt)==0)cycle
194 num_centroids = num_centroids +1
195 IF(is_ity_1==1)THEN
196 p0(1) = sum( x(1,ixs(2:9,n)) ) / npt
197 p0(2) = sum( x(2,ixs(2:9,n)) ) / npt
198 p0(3) = sum( x(3,ixs(2:9,n)) ) / npt
199 ELSEIF(is_ity_2==1)THEN
200 p0(1) = sum( x(1,ixq(2:5,n)) ) / npt
201 p0(2) = sum( x(2,ixq(2:5,n)) ) / npt
202 p0(3) = sum( x(3,ixq(2:5,n)) ) / npt
203 ENDIF
204 IF(min_xc>p0(1))THEN
205 min_xc=p0(1)
206 xmin_cell_id = n
207 ENDIF
208 IF(min_yc>p0(2))THEN
209 min_yc=p0(2)
210 ymin_cell_id = n
211 ENDIF
212 IF(min_zc>p0(3))THEN
213 min_zc=p0(3)
214 zmin_cell_id = n
215 ENDIF
216 IF(max_xc<p0(1))THEN
217 max_xc=p0(1)
218 xmax_cell_id = n
219 ENDIF
220 IF(max_yc<p0(2))THEN
221 max_yc=p0(2)
222 ymax_cell_id = n
223 ENDIF
224 IF(max_zc<p0(3))THEN
225 max_zc=p0(3)
226 zmax_cell_id = n
227 ENDIF
228 END DO
229 ELSE
230
231 END IF
232 END do
233
234
235
238
239 nnod=0
240 DO i=1,numnod
241 IF(nodtag(i) == 1)THEN
242 nnod=nnod+1
243 ENDIF
244 ENDDO
245
246
247
248 IF(.NOT.ALLOCATED(map_nodes))ALLOCATE(map_nodes(3,nnod))
250 IF(.NOT.ALLOCATED(get_cell_fom_centroid))THEN
251 ALLOCATE(get_cell_fom_centroid(2,num_centroids))
252 ENDIF
253
254 IF(num_centroids > 0)THEN
255
256
257 lx=max_xc-min_xc
258 ly=max_yc-min_yc
259 lz=max_zc-min_zc
260 vect(1:3)=(/lx,ly,lz/)
261
262 ipos = maxloc(vect(1:3),1)
263 SELECT CASE(ipos)
264 CASE(1)
265 first_cell = xmin_cell_id
266 last_cell = xmax_cell_id
267 CASE(2)
268 first_cell = ymin_cell_id
269 last_cell = ymax_cell_id
270 CASE(3)
271 first_cell = zmin_cell_id
272 last_cell = zmax_cell_id
273 END SELECT
274
275 IF(is_ity_1==1)THEN
276 p0_inf(1) = sum( x(1,ixs(2:9,first_cell)) ) / npt
277 p0_inf(2) = sum( x(2,ixs(2:9,first_cell)) ) / npt
278 p0_inf(3) = sum( x(3,ixs(2:9,first_cell)) ) / npt
279 p0_sup(
280 p0_sup(2) = sum( x(2,ixs(2:9,last_cell)) ) / npt
281 p0_sup(3) = sum( x(3,ixs(2:9,last_cell)) ) / npt
282 ELSEIF(is_ity_2==1)THEN
283 p0_inf(1) = sum( x(1,ixq(2:5,first_cell)) ) / npt
284 p0_inf(2) = sum( x(2,ixq(2:5,first_cell)) ) / npt
285 p0_inf(3) = sum( x(3,ixq(2:5,first_cell)) ) / npt
286 p0_sup(1) = sum( x(1,ixq(2:5,last_cell)) ) / npt
287 p0_sup(2) = sum( x(2,ixq(2:5,last_cell)) ) / npt
288 p0_sup(3) = sum( x(3,ixq(2:5,last_cell)) ) / npt
289 ENDIF
290
291 vect(1:3)=(/p0_sup(1)-p0_inf(1),p0_sup(2)-p0_inf(2),p0_sup(3)-p0_inf(3)/)
292 lx=vect(1)
293 ly=vect(2)
294 lz=vect(3)
295 length = sqrt(vect(1)*vect(1) + vect(2)*vect(2) + vect(3)*vect(3))
296 shift_c=zero
297 IF(length > zero)shift_c = (p0_inf(1)*lx + p0_inf(2)*ly + p0_inf(3)*lz) / length
301 ELSE
305 ENDIF
306
307
308 IF(is_ity_7 > 0)THEN
309 CALL ancmsg(msgid=284,anmode=aninfo,c1=
" -- 1D DOMAIN MUST BE MESHED WITH BRICKS OR QUADS ONLY"
310 return
311 ENDIF
312
313
314
315
316
317
318 IF(is_ity_1==1)THEN
319 dx = x(1,ixs(2,first_cell))
320 dy = x(2,ixs(2,first_cell))
321 dz = x(3,ixs(2,first_cell))
322 DO jj=3,npt
323 IF(x(1,ixs(jj,first_cell)) < dx)dx=x(1,ixs(jj,first_cell))
324 IF(x(2,ixs(jj,first_cell)) < dy)dy=x(2,ixs(jj,first_cell))
325 IF(x(3,ixs(jj,first_cell)) < dz)dz=x(3,ixs(jj,first_cell))
326 ENDDO
327 ELSEIF(is_ity_2==1)THEN
328 dx = x(1,ixq(2,first_cell))
329 dy = x(2,ixq(2,first_cell))
330 dz = x(3,ixq(2,first_cell))
331 DO jj=3,npt
332 IF(x(1,ixq(jj,first_cell)) < dx)dx=x(1,ixq(jj,first_cell))
333 IF(x(2,ixq(jj,first_cell)) < dx)dy=x(2,ixq(jj,first_cell))
334 IF(x(3,ixq(jj,first_cell)) < dx)dz=x(3,ixq(jj,first_cell))
335 ENDDO
336 ENDIF
337
338 shift_n = zero
339 IF(length > zero)shift_n=(dx*lx + dy*ly + dz*lz) / length
342
343
344
345 k=1
346 DO ng=1,ngroup
347 ity =iparg(5,ng)
348 isolnod = iparg(28,ng)
349 nel =iparg(2,ng)
350 nft =iparg(3,ng)
351 gbuf => elbuf_tab(ng)%GBUF
352 mlw = iparg(1,ng)
353 lft=1
354 llt=nel
355 IF(npt /= 0)THEN
356 DO i=lft,llt
357 n = i + nft
358 iprt=ipart_ptr(n)
359 IF(ipart_state(iprt)==0)cycle
360 IF(is_ity_1==1)THEN
361 p0(1) = sum( x(1,ixs(2:9,n)) ) / npt
362 p0(2) = sum( x(2,ixs(2:9,n)) ) / npt
363 p0(3) = sum( x(3,ixs(2:9,n)) ) / npt
364 ELSEIF(is_ity_2==1)THEN
365 p0(1) = sum( x(1,ixq(2:5,n)) ) / npt
366 p0(2) = sum( x(2,ixq(2:5,n)) ) / npt
367 p0(3) = sum( x(3,ixq(2:5,n)) ) / npt
368 ENDIF
369 dx = p0(1)-p0_inf(1)
370 dy = p0(2)-p0_inf(2)
371 dz = p0(3)-p0_inf(3)
372
373 dotprod = zero
374 IF(length > zero)dotprod = (lx*dx + ly*dy + lz*dz) / length
376 get_cell_fom_centroid(1,k) = ng
377 get_cell_fom_centroid(2,k) = i
378 k=k+1
379 END DO
380 END IF
381 END do
382
383 IF(.NOT.ALLOCATED(idx))ALLOCATE(idx(num_centroids))
384 DO k=1,num_centroids ; idx(k)=k; ENDDO
386
387
388
389
390 IF(num_centroids > 0)THEN
391 IF(mlw==151)THEN
392 nbmat = multi_fvm%NBMAT
393 ELSEIF(mlw==51)THEN
394 nbmat = 4
395 ELSE
396 nbmat = 1
397 ENDIF
401 DO i=1,nbmat
406 ENDDO
407 IF(mlw==151)THEN
408
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)
417 xyz(1:3) = multi_fvm%VEL(1:3,i+nft)
418 dotprod=zero
419 IF(length > zero)dotprod = (lx*xyz(1) + ly*xyz(2) + lz*xyz(3)) / length
421 ENDDO
422
423 DO isubmat=1,nbmat
424 DO k=1, num_centroids
425 ng = get_cell_fom_centroid(1,idx(k))
426 i = get_cell_fom_centroid(2,idx(k))
427 nft = iparg(3,ng)
428 state_inimap_buf(1)%SUBMAT(isubmat)%VFRAC(k) = multi_fvm%PHASE_ALPHA(isubmat,i+nft)
429 state_inimap_buf(1)%SUBMAT(isubmat)%RHO(k) = multi_fvm%PHASE_RHO(isubmat,i+nft)
430 state_inimap_buf(1)%SUBMAT(isubmat)%E(k) = multi_fvm%PHASE_EINT(isubmat,i+nft)
432 ENDDO
433 ENDDO
434 ELSEIF(mlw==51)THEN
435 nb2=0
436 DO isubmat=1,nbmat
437 DO k=1, num_centroids
438 ng = get_cell_fom_centroid(1,idx(k))
439 i = get_cell_fom_centroid(2,idx(k))
440 nft = iparg(3,ng)
441 nel = iparg(2,ng)
442 n = i + nft
443 iprt=ipart_ptr(n)
444 imat =ipart(1,iprt)
445 IF(mat_param(imat)%MULTIMAT%MID(isubmat) == 0)EXIT
446 nb2=
max(nb2,ipm(5,imat))
447 iadbuf = ipm(7,imat)
448 npar = ipm(9,imat)
449 nuvar = ipm(8,imat)
450 uparam => bufmat(iadbuf:iadbuf+npar-1)
451 kk = m51_n0phas + (uparam(276+isubmat)-1)*m51_nvphas
452 mbuf => elbuf_tab(ng)%BUFLY(1)%MAT(1,1,1)
457 ENDDO
458 ENDDO
460 ELSE
461 DO k=1, num_centroids
462 ng = get_cell_fom_centroid(1,idx(k))
463 i = get_cell_fom_centroid(2,idx(k))
464 gbuf => elbuf_tab(ng)%GBUF
468 state_inimap_buf(1)%SUBMAT(1)%PRES(k) = -third * (gbuf%SIG(i) + gbuf%SIG(i + nel) + gbuf%SIG(i + 2 * nel))
469 ENDDO
470 ENDIF
471 ENDIF
472
473
474
475
476
477
478
479
480 IF(num_centroids > 0)THEN
481 IF(mlw /= 151)THEN
482 k=1
483 DO i=1,numnod
484 IF(nodtag(i) == 1)THEN
485 map_nodes(1,k)=i
486 xyz(1:3)=x(1:3,i)
487 dotprod=zero
488 IF(length > zero)dotprod = (lx*xyz(1) + ly*xyz(2) + lz*xyz(3)) / length
489 map_nodes(2,k)
490 k=k+1
491 ENDIF
492 ENDDO
493 IF(ALLOCATED(idx))DEALLOCATE(idx)
494 ALLOCATE(idx(nnod))
495 DO k=1,nnod ; idx(k)=k; ENDDO
496 CALL quicksort(map_nodes(2,:), idx, 1, nnod)
497 tol=em10*length
498
499 nnod2=nnod
500 DO i=2,nnod
501 dist = abs(map_nodes(2,i)-map_nodes(2,i-1))
502 IF(dist <= tol) map_nodes(1,idx(i)) = zero
503 ENDDO
504 k=0
505 DO i=1,nnod
506 IF(map_nodes(1,idx(i)) /= zero)THEN
507 k=k+1
508 ENDIF
509 ENDDO
510
513 k=0
514 DO i=1,nnod
515 IF(map_nodes(1,idx(i)) /= zero)THEN
516 k=k+1
518 vel(1:3)=v(1:3,int(map_nodes(1,idx(i))))
519 dotprod=zero
520 IF(length > zero)dotprod = (lx*vel(1) + ly*vel(2) + lz*vel(3)) / length
522 ENDIF
523 ENDDO
525 ELSE
526
527 ENDIF
528 ENDIF
529
530
531
532
533 IF(nspmd > 1)THEN
536
537 IF(ispmd == 0)THEN
540 DO i=2,nspmd
543 shift_n_min =
min(shift_n_min
544 ENDDO
547 ENDIF
548 ENDIF
549
550
551
552
555 IF(ispmd == 0 .AND. nspmd > 1)THEN
556
557
558 npts_tot = 0
559 ncell_tot = 0
560 len_tot = zero
561 DO i=1,nspmd
563 npts(i)=0
564 len_(i)=zero
565 ncell(i)=0
566 cycle
567 ENDIF
569 npts_tot=npts_tot+npts(i)
571 len_tot=len_tot+len_(i)
573 ncell_tot = ncell_tot + ncell(i)
574 ENDDO
575 ALLOCATE(work(npts_tot,3),work_indx(npts_tot))
576
577
578
579 j=0
580 DO i=1,nspmd
581 DO k=1,npts(i)
582 j=j+1
585 ENDDO
586 ENDDO
587
588
589
590 work_indx(1:npts_tot) = (/(j,j=1,npts_tot)/)
591 CALL quicksort(work(:,1), work_indx, 1, npts_tot)
592
593 DO i=1,npts_tot
594 work(i,2)=work(work_indx(i),3)
595 ENDDO
596 tol=em10*len_tot
597 work_indx(1:npts_tot) = 0
598
599
600
601
602 IF(mlw /= 151)THEN
603 DO i=2,npts_tot
604 dist = abs(work(i,1)-work(i-1,1))
605 IF(dist <= tol) THEN
606 work_indx(i) = 1
607 ENDIF
608 ENDDO
609 k=0
610 DO i=1,npts_tot
611 IF(work_indx(i) ==0 )THEN
612 k=k+1
613 work(k,1)=work(i,1)
614 work(k,2)=work(i,2)
615 ENDIF
616 ENDDO
617 DO i=k+1,npts_tot ; work(i,1:2)=zero ; ENDDO
618 npts_tot=k
619 ENDIF
620
621
622
630 IF(ALLOCATED(work))DEALLOCATE(work)
631 IF(ALLOCATED(work_indx))DEALLOCATE(work_indx
632
633
635 ALLOCATE(work(ncell_tot,1+4*nbmat))
636 ALLOCATE(work_indx(ncell_tot))
637
638
639
640 j=0
641 DO i=1,nspmd
642 DO k=1,ncell(i)
643 j=j+1
646 DO jj=1,nbmat
651 ENDDO
652 ENDDO
653 ENDDO
654
655
656
657 work_indx(1:ncell_tot) = (/(j,j=1,ncell_tot)/)
658 CALL quicksort(work(:,1), work_indx, 1, ncell_tot)
659
660
661
664 DO jj=1,nbmat
669 ENDDO
671 DO jj=1,nbmat
676 ENDDO
677 DO j=1,ncell_tot
679 DO jj=1,nbmat
684 ENDDO
685 ENDDO
688
689
690 endif
691
692 IF(ispmd == 0)THEN
693 IF(ncell_tot == 0 .OR. len_tot == zero)THEN
694 print *, "** ERROR WITH /STATE/INIMAP"
695 print *, " -- SITUATION NOT EXPECTED"
696 print *, " -- 1D DOMAIN IS NOT DETECTED."
697 return
698 ENDIF
699 ENDIF
700
701
702
703
704
705 IF(ispmd == 0)THEN
708 filnam=rootnam(1:rootlen)//'_1D_'//chstat//'.inimap'
709 shortname=rootnam(1:rootlen)//'_1D_'//chstat//'.inimap'
710 len = rootlen+11+4
713 DO i=1,len_tmp_name
714 ifilnam(i)=ichar(tmp_name(i:i))
715 END DO
717 CALL open_c(ifilnam,len_tmp_name,6)
718
725 ENDIF
726
727 IF(ispmd == 0)THEN
728
733
736
737
738 ipos=0
739 DO isubmat = 1,nbmat
741 ENDDO
742
743 DO isubmat = 1,nbmat
745 ENDDO
746
747 DO isubmat = 1,nbmat
749 ENDDO
750
753 ELSE
756 ENDIF
757 ENDIF
758
759
760
761
762 IF(ispmd == 0)THEN
763
764 shortname=shortname//'.gz'
765 WRITE (iout,500) shortname(1:len_trim(trim(shortname)))
766 WRITE (istdo,500) shortname(1:len_trim(trim(shortname)))
768
769 IF(ALLOCATED(map_nodes))DEALLOCATE(map_nodes)
770 IF(ALLOCATED(get_cell_fom_centroid))DEALLOCATE(get_cell_fom_centroid)
771 IF(ALLOCATED(idx))DEALLOCATE(idx)
772 DO jj=1,nspmd
775 DO i=1,nbmat
780 ENDDO
781 ENDIF
787 ENDDO
788 ENDIF
789
791
792
793
794
795 500 FORMAT (4x,' STATE FILE:',1x,a,' WRITTEN')
796
797 RETURN
character(len=outfile_char_len) outfile_name
integer state_inimap_call_number
type(map_struct), dimension(:), allocatable state_inimap_buf
recursive subroutine quicksort(a, idx, first, last)
subroutine spmd_state_inimap1d_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)