My Project
Functions/Subroutines
tge.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine triangle_grid_edge
 

Function/Subroutine Documentation

◆ triangle_grid_edge()

subroutine triangle_grid_edge ( )

Definition at line 41 of file tge.f90.

41 
42 ! NEEDS UPDATE TO FIX ERROR MESSAGES
43 
44 !==============================================================================!
45 ! This program is used to define the non-overlapped, unstructured !
46 ! triangular meshes used for flux computations. The mesh could be !
47 ! created using the commerical software called "sms8.0" or other !
48 ! mesh generation programs. The mesh file generated by sms8.0 can !
49 ! be directly used for this subroutine, while the mesh file !
50 ! generated using other programs must be coverted the data format !
51 ! to meet the required format used here. !
52 !==============================================================================!
53 ! variable list: !
54 ! vx(m) :: vx(i) = x-coordinate of node i (input from mesh) !
55 ! vy(m) :: vy(i) = y-coordinate of node i (input from mesh) !
56 ! nv(n,3) :: nv(i:1-3) = 3 node numbers of element i !
57 ! xc(n) :: xc(i) = x-coordinate of element i (calculated from vx) !
58 ! yc(n) :: yc(i) = y-coordinate of element i (calculated from vy) !
59 ! cor(n) :: cor(i) = f plane coriolis at element i !
60 ! !
61 ! nbe(n,3) :: nbe(i,1->3) = element index of 1->3 neighbors of element i !
62 ! isbce(n) :: flag if element is on the boundary, see below for values !
63 ! isonb(m) :: flag is node is on the boundary, see below for values !
64 ! !
65 ! ntve(m) :: the number of neighboring elements of node m !
66 ! nbve(m,ntve(m)) :: nbve(i,1->ntve(i)) = ntve elements containing node i !
67 ! nbvt(m,ntve(m)) :: nbvt(i,j) = the node number of node i in element !
68 ! nbve(i,j) (has a value of 1,2,or 3) !
69 ! !
70 ! ne :: number of unique element edges !
71 ! iec(ne,2) :: nbe(i,1->2) cell number of cell(s) connected to edge i !
72 ! isbc(ne) :: flag marking edge property !
73 ! isbc(i) = 0: element edge i is in the interior !
74 ! isbc(i) = 1: element edge i is on the boundary !
75 !ienode(ne,2):: ienode(i,1->2) node numbers at each end of element edge i !
76 ! xijc(ne) :: xijc(i) = x-coordinate of mid point of element edge i !
77 ! yijc(ne) :: yijc(i) = y-coordinate of mid point of element edge i !
78 ! dltxyc(ne):: dltxyc(i) = length of element edge i !
79 ! dltxc(ne) :: dltxc(i) = deltax (x-projection) of element edge i !
80 ! dltyc(ne) :: dltyc(i) = deltay (y-projection) of element edge i !
81 ! sitac(ne) :: sitac(i) = arctg(dltyc,dltxc) (angle of inclination of edge) !
82 ! !
83 !==============================================================================!
84 ! classification of the triangles nodes, and edges !
85 ! !
86 ! isonb(i)=0: node in the interior computational domain !
87 ! isonb(i)=1: node on the solid boundary !
88 ! isonb(i)=2: node on the open boundary !
89 ! !
90 ! isbce(i)=0: element in the interior computational domain !
91 ! isbce(i)=1: element on the solid boundary !
92 ! isbce(i)=2: element on the open boundary !
93 ! isbce(i)=3: element with 2 solid boundary edges !
94 ! !
95 ! isbc(i)=0: element edge in interior !
96 ! isbc(i)=1: element edge on boundary !
97 !==============================================================================!
98 
99 
100 !==============================================================================|
101 ! FIND NEIGHBORING ELEMENTS, MARK BOUNDARY NODES AND ELEMENTS |
102 ! |
103 ! NBE(N,3) : NBE(I,J) = IDENTITY OF NBOR ELMNT TO TRI I ON EDGE J |
104 ! IBCE(N) : DESCRIBED IN SUBROUTINE HEADING |
105 ! ISONB(M): DESCRIBED IN SUBROUTINE HEADING |
106 !==============================================================================|
107  USE all_vars
108  USE mod_spherical
109 
110 
111  USE mod_par
112 
113  USE mod_obcs
114  IMPLICIT NONE
115  INTEGER, ALLOCATABLE, DIMENSION(:,:) :: TEMP,TEMP2,NB_TMP,ISET
116  INTEGER I,J,DIF1,DIF2,DIF3,II,JJ,NTMP,NCNT,INEY,NFLAG
117  INTEGER ITMP1,ITMP2,ITMP3,JN,JJB,IBCETMP,NCTMP,NCETMP,NPT
118  INTEGER, ALLOCATABLE :: CELLS(:,:),CELLCNT(:),NBET(:,:)
119  REAL(SP) DTMP
120  INTEGER N1,N2,N3,J1,J2,J3,SBUF, IERR
121 
122  ! STORAGE FOR ISONB, ISBCE TO RUN EXCHANGE AND SET HALO'S
123  REAL(SP), ALLOCATABLE :: FTEMP(:)
124 
125  Character(len=8) :: tmpstr
126  Character(len=200):: errstr
127 
128 
129  REAL(SP) DELTX,DELTY,ALPHA1,ALPHA2
130 
131 !----------------------------REPORT--------------------------------------------!
132  IF (dbg_set(dbg_log))THEN
133  WRITE(ipt,* )'!'
134  WRITE(ipt,*)'! SETTING UP TRIS/ELEMENTS/EDGES/CVS '
135  WRITE(ipt,* )'!'
136  END IF
137 !----------------------------INITIALIZE----------------------------------------!
138 
139  isbce = 0
140  isonb = 0
141  nbe = 0
142 
143 !
144 !----DETERMINE NBE(i=1:n,j=1:3): INDEX OF 1 to 3 NEIGHBORING ELEMENTS----------!
145 !
146  ALLOCATE(nbet(nt,3)) ; nbet = 0
147  ALLOCATE(cells(mt,50)) ; cells = 0
148  ALLOCATE(cellcnt(mt)) ; cellcnt = 0
149  DO i=1,nt
150  n1 = nv(i,1) ; cellcnt(n1) = cellcnt(n1)+1
151  n2 = nv(i,2) ; cellcnt(n2) = cellcnt(n2)+1
152  n3 = nv(i,3) ; cellcnt(n3) = cellcnt(n3)+1
153  cells(nv(i,1),cellcnt(n1)) = i
154  cells(nv(i,2),cellcnt(n2)) = i
155  cells(nv(i,3),cellcnt(n3)) = i
156  END DO
157  if(maxval(cellcnt) > 50)write(ipt,*)'bad',maxval(cellcnt)
158  DO i=1,nt
159  n1 = nv(i,1)
160  n2 = nv(i,2)
161  n3 = nv(i,3)
162  DO j1 = 1,cellcnt(n1)
163  DO j2 = 1,cellcnt(n2)
164  IF((cells(n1,j1) == cells(n2,j2)).AND. cells(n1,j1) /= i)nbe(i,3) = cells(n1,j1)
165  END DO
166  END DO
167  DO j2 = 1,cellcnt(n2)
168  DO j3 = 1,cellcnt(n3)
169  IF((cells(n2,j2) == cells(n3,j3)).AND. cells(n2,j2) /= i)nbe(i,1) = cells(n2,j2)
170  END DO
171  END DO
172  DO j1 = 1,cellcnt(n1)
173  DO j3 = 1,cellcnt(n3)
174  IF((cells(n1,j1) == cells(n3,j3)).AND. cells(n1,j1) /= i)nbe(i,2) = cells(n3,j3)
175  END DO
176  END DO
177  END DO
178  DEALLOCATE(cells,cellcnt)
179 
180  ! OLD - USED TO MAKE GLOBAL INDEX ARRAYS TO SAVE PARALLEL OUTPUT
181  ! REPLACED IN MOD_NCDIO WITH MORE GENERIC TYPE GRID DATA!
182 ! IF (PAR) THEN
183 ! ALLOCATE(NBEGL(0:NT,3)); NBEGL = 0
184 ! DO I = 1,NT
185 ! NBEGL(I,:) = EGID_X(NBE(I,:))
186 ! END DO
187 ! ELSE
188 ! NBEGL => NBE
189 ! END IF
190 
191  IF (dbg_set(dbg_log))WRITE(ipt,*) '! NEIGHBOR FINDING : COMPLETE'
192 !
193 !--ENSURE ALL ELEMENTS HAVE AT LEAST ONE NEIGHBOR------------------------------!
194 !
195  nflag = 0
196  DO i=1,nt
197  IF(sum(nbe(i,1:3))==0)THEN
198  nflag = 1
199  WRITE(ipt,*)'ELEMENT ',i,' AT ',xc(i),yc(i),' HAS NO NEIGHBORS'
200  CALL pstop
201  END IF
202  END DO
203  IF(nflag == 1) CALL pstop
204 
205 !
206 !----IF ELEMENT ON BOUNDARY SET ISBCE(I)=1 AND ISONB(J)=1 FOR BOUNDARY NODES J-!
207 !
208 
209  DO i=1,nt
210  IF(min(nbe(i,1),nbe(i,2),nbe(i,3))==0)THEN !!ELEMENT ON BOUNDARY
211  isbce(i) = 1
212  IF(nbe(i,1) == 0)THEN
213  isonb(nv(i,2)) = 1 ; isonb(nv(i,3)) = 1
214  END IF
215  IF(nbe(i,2) ==0) THEN
216  isonb(nv(i,1)) = 1 ; isonb(nv(i,3)) = 1
217  END IF
218  IF(nbe(i,3) ==0) THEN
219  isonb(nv(i,1)) = 1 ; isonb(nv(i,2)) = 1
220  END IF
221  END IF
222  END DO
223  IF (dbg_set(dbg_log)) WRITE(ipt,*) '! ISONB SETTING : COMPLETE'
224 
225 !==============================================================================|
226 ! DEFINE NTVE, NBVE, NBVT !
227 ! !
228 ! ntve(1:m): total number of the surrounding triangles !
229 ! connected to the given node !
230 ! nbve(1:m, 1:ntve+1): the identification number of surrounding !
231 ! triangles with a common node (counted clockwise) !
232 ! nbvt(1:m,ntve(1:m)): the idenfication number of a given node over !
233 ! each individual surrounding triangle(counted !
234 ! clockwise) !
235 ! ntsn(1:m): total number of surrounding nodes !
236 ! nbsn(1:m, ntsn): the identification number of surrounding nodes !
237 ! (counted clockwise) !
238 ! nbse(1:m,2*ntsn): the identification number of control volume s !
239 ! edges between two neighbor nodes !
240 !==============================================================================|
241 
242 !
243 !----DETERMINE MAX NUMBER OF SURROUNDING ELEMENTS------------------------------!
244 !
245  mx_nbr_elem = 0
246  DO i=1,m
247  ncnt = 0
248  DO j=1,nt
249 ! IF( (NV(J,1)-I)*(NV(J,2)-I)*(NV(J,3)-I)==0) NCNT = NCNT + 1
250 ! IF( (NV(J,1)-I) ==0 .OR. (NV(J,2)-I) ==0 .OR. (NV(J,3)-I)==0) NCNT = NCNT + 1
251  IF( float(nv(j,1)-i)*float(nv(j,2)-i)*float(nv(j,3)-i) == 0.0_sp) &
252  ncnt = ncnt + 1
253  END DO
254  mx_nbr_elem = max(mx_nbr_elem,ncnt)
255  END DO
256 ! WRITE(IPT,*) 'MAXIMUM NUMBER OF NEIGHBOR ELEMENTS',MX_NBR_ELEM
257 
258 
259 !
260 !----ALLOCATE ARRAYS BASED ON MX_NBR_ELEM--------------------------------------!
261 !
262  ALLOCATE(nbve(m,mx_nbr_elem+1)); nbve = 0
263  ALLOCATE(nbvt(m,mx_nbr_elem+1)); nbvt = 0
264 ! ALLOCATE(NBSN(M,MX_NBR_ELEM+2))
265  ALLOCATE(nbsn(m,mx_nbr_elem+3)); nbsn = 0
266 !
267 !--DETERMINE NUMBER OF SURROUNDING ELEMENTS FOR NODE I = NTVE(I)---------------!
268 !--DETERMINE NBVE - INDICES OF NEIGHBORING ELEMENTS OF NODE I------------------!
269 !--DETERMINE NBVT - INDEX (1,2, or 3) OF NODE I IN NEIGHBORING ELEMENT---------!
270 !
271 
272  DO i=1,m
273  ncnt=0
274  DO j=1,nt
275 ! IF( (NV(J,1)-I) == 0 .OR. (NV(J,2)-I) == 0 .OR. (NV(J,3)-I) == 0)THEN
276  IF (float(nv(j,1)-i)*float(nv(j,2)-i)*float(nv(j,3)-i) == 0.0_sp)THEN
277  ncnt = ncnt+1
278  nbve(i,ncnt)=j
279  IF((nv(j,1)-i) == 0) nbvt(i,ncnt)=1
280  IF((nv(j,2)-i) == 0) nbvt(i,ncnt)=2
281  IF((nv(j,3)-i) == 0) nbvt(i,ncnt)=3
282  END IF
283  ENDDO
284  ntve(i)=ncnt
285  ENDDO
286 !
287 !--Reorder Order Elements Surrounding a Node to Go in a Cyclical Procession----!
288 !--Determine NTSN = Number of Nodes Surrounding a Node (+1)-------------------!
289 !--Determine NBSN = Node Numbers of Nodes Surrounding a Node------------------!
290 !
291 !Lettmann&JQI ALLOCATE(NB_TMP(M,MX_NBR_ELEM+1))
292  ALLOCATE(nb_tmp(mx_nbr_elem+1,2))
293  DO i=1,m
294  IF(isonb(i) == 0) THEN
295  nb_tmp(1,1)=nbve(i,1)
296  nb_tmp(1,2)=nbvt(i,1)
297  DO j=2,ntve(i)+1
298  ii=nb_tmp(j-1,1)
299  jj=nb_tmp(j-1,2)
300  nb_tmp(j,1)=nbe(ii,jj+1-int((jj+1)/4)*3)
301  jj=nb_tmp(j,1)
302  IF((nv(jj,1)-i) == 0) nb_tmp(j,2)=1
303  IF((nv(jj,2)-i) == 0) nb_tmp(j,2)=2
304  IF((nv(jj,3)-i) == 0) nb_tmp(j,2)=3
305  ENDDO
306 
307  DO j=2,ntve(i)+1
308  nbve(i,j)=nb_tmp(j,1)
309  ENDDO
310 
311  DO j=2,ntve(i)+1
312  nbvt(i,j)=nb_tmp(j,2)
313  ENDDO
314 
315  ntmp=ntve(i)+1
316  IF(nbve(i,1) /= nbve(i,ntmp)) THEN
317  print*, myid,ngid(i),ntmp,'NBVE(I,nTMP) NOT CORRECT!!'
318  print*, "NBVE(I,:)=",egid(nbve(i,:))
319  CALL pstop
320  ENDIF
321 
322  IF(nbvt(i,1) /= nbvt(i,ntmp)) THEN
323  print*, ngid(i),'NBVT(I) NOT CORRECT!!'
324  print*, "NBVT(I,:)=",nbvt(i,:)
325  CALL pstop
326  END IF
327 
328  ntsn(i)=ntve(i)
329 
330  DO j=1,ntsn(i)
331  ii=nbve(i,j)
332  jj=nbvt(i,j)
333  nbsn(i,j)=nv(ii,jj+1-int((jj+1)/4)*3)
334  ENDDO
335 
336  ntsn(i)=ntsn(i)+1
337  nbsn(i,ntsn(i))=nbsn(i,1)
338 
339  ELSE
340  jjb=0
341 
342  DO j=1,ntve(i)
343  jj=nbvt(i,j)
344  IF(nbe(nbve(i,j),jj+2-int((jj+2)/4)*3) == 0) THEN
345  jjb=jjb+1
346  nb_tmp(jjb,1)=nbve(i,j)
347  nb_tmp(jjb,2)=nbvt(i,j)
348  END IF
349  ENDDO
350 
351  IF(jjb /= 1) THEN
352  WRITE(ipt,*) 'ERROR IN ISONB !,I,J', i,j
353  CALL fatal_error("ERROR IN TGE DETERMINING ISONB")
354  END IF
355 
356  DO j=2,ntve(i)
357  ii=nb_tmp(j-1,1)
358  jj=nb_tmp(j-1,2)
359  nb_tmp(j,1)=nbe(ii,jj+1-int((jj+1)/4)*3)
360  jj=nb_tmp(j,1)
361  IF((nv(jj,1)-i) == 0) nb_tmp(j,2)=1
362  IF((nv(jj,2)-i) == 0) nb_tmp(j,2)=2
363  IF((nv(jj,3)-i) == 0) nb_tmp(j,2)=3
364  ENDDO
365 
366  DO j=1,ntve(i)
367  nbve(i,j)=nb_tmp(j,1)
368  nbvt(i,j)=nb_tmp(j,2)
369  ENDDO
370 
371  nbve(i,ntve(i)+1)=0
372  ntsn(i)=ntve(i)+1
373  nbsn(i,1)=i
374 
375  DO j=1,ntsn(i)-1
376  ii=nbve(i,j)
377  jj=nbvt(i,j)
378  nbsn(i,j+1)=nv(ii,jj+1-int((jj+1)/4)*3)
379  ENDDO
380 
381  j=ntsn(i)
382  ii=nbve(i,j-1)
383  jj=nbvt(i,j-1)
384  nbsn(i,j+1)=nv(ii,jj+2-int((jj+2)/4)*3)
385  ntsn(i)=ntsn(i)+2
386  nbsn(i,ntsn(i))=i
387  END IF
388  END DO
389  DEALLOCATE(nb_tmp)
390  IF(mx_nbr_elem+3 -maxval(ntsn) < 0)THEN
391  WRITE(ipt,*)'CHECK NTSN/NBSN',maxval(ntsn),mx_nbr_elem+3
392  CALL pstop
393  END IF
394 
395 
396  ! OLD - USED TO MAKE GLOBAL INDEX ARRAYS TO SAVE PARALLEL OUTPUT
397  ! REPLACED IN MOD_NCDIO WITH MORE GENERIC TYPE GRID DATA!
398 ! IF(PAR) THEN
399 ! ALLOCATE(NBSNGL(M,MX_NBR_ELEM+3))
400 ! ALLOCATE(NBVEGL(M,MX_NBR_ELEM+1))
401 ! DO I = 1,M
402 ! NBVEGL(I,:)=EGID_X(NBVE(I,:))
403 !
404 ! NBSNGL(I,:) = NGID_X(NBSN(I,:))
405 ! END DO
406 ! ELSE
407 ! NBVEGL => NBVE
408 !
409 ! NBSNGL =>NBSN
410 ! END IF
411 
412  IF (dbg_set(dbg_log))WRITE(ipt,*) '! NBVE/NBVT : COMPLETE'
413 
414 
415 !==============================================================================!
416 ! Define the parameters of each triangular edge !
417 ! !
418 ! ne : number of unique element edges !
419 ! iec(1:ne,1:2): counting number identifying two connected cells !
420 ! isbc(1:ne): 0: triangle s edge in the interior !
421 ! 1: triangle s edge on the boundary !
422 ! ienode(1:ne,1:2): the identification number of two end points of a !
423 ! edge !
424 ! xijc(1:ne): the x-coordinate location of the middle points !
425 ! of a edge !
426 ! yijc(1:ne): the y-coordinate location of the middle points !
427 ! of a edge !
428 ! dltxyc(1:ne): length of the edge !
429 ! dltxc(1:ne): vx(ienode(i,2))-vx(idnode(i,1)) !
430 ! dltyc(1:ne): vy(ienode(i,2))-vy(idnode(i,1)) !
431 ! sitac(1:ne): arctg(dltyc,dltxc) !
432 !==============================================================================!
433 
434  ALLOCATE(iset(nt,3),temp((nt)*3,2),temp2((nt)*3,2))
435  iset = 0
436  ne = 0
437  temp = 0
438  temp2 = 0
439  DO i=1,nt
440  DO j=1,3
441  IF(iset(i,j) == 0)THEN
442  ne = ne + 1
443  iney = nbe(i,j)
444  iset(i,j) = 1
445  DO jn=1,3
446  IF(i == nbe(iney,jn)) iset(iney,jn) = 1
447  END DO
448  temp(ne,1) = i ; temp(ne,2) = iney
449  temp2(ne,1) = nv(i,j+1-int((j+1)/4)*3)
450  temp2(ne,2) = nv(i,j+2-int((j+2)/4)*3)
451  END IF
452  END DO
453  END DO
454  DEALLOCATE(iset)
455 !
456 !--ALLOCATE ARRAYS REQUIRING NUMBER OF EDGES-----------------------------------!
457 !
458  ALLOCATE(iec(ne,2))
459  ALLOCATE(ienode(ne,2))
460  ALLOCATE(xijc(ne))
461  ALLOCATE(yijc(ne))
462  ALLOCATE(dltxyc(ne))
463  ALLOCATE(dltxc(ne))
464  ALLOCATE(dltyc(ne))
465  ALLOCATE(sitac(ne))
466  ALLOCATE(isbc(ne))
467 
468 
469  iec(:,1) = temp(1:ne,1)
470  iec(:,2) = temp(1:ne,2)
471  ienode(:,1) = temp2(1:ne,1)
472  ienode(:,2) = temp2(1:ne,2)
473 
474 
475  DEALLOCATE(temp,temp2)
476 
477 
478 !
479 !------MARK ELEMENT EDGES THAT ARE ON THE BOUNDARY-----------------------------!
480 !
481  isbc = 0
482  DO i=1,ne
483  IF((iec(i,1) == 0) .OR. (iec(i,2) == 0)) isbc(i) = 1
484  END DO
485 
486 !
487 !------CALCULATE ELEMENT EDGE METRICS------------------------------------------!
488 !
489  DO i=1,ne
490  dltxc(i) = vx(ienode(i,2))-vx(ienode(i,1))
491  dltyc(i) = vy(ienode(i,2))-vy(ienode(i,1))
492  xijc(i) = (vx(ienode(i,1))+vx(ienode(i,2)))/2.0_sp
493  yijc(i) = (vy(ienode(i,1))+vy(ienode(i,2)))/2.0_sp
494  dltxyc(i)= sqrt(dltxc(i)**2+dltyc(i)**2)
495  sitac(i) = atan2(dltyc(i),dltxc(i))
496  END DO
497  IF (dbg_set(dbg_log))WRITE(ipt,*) '! EDGE SETUP : COMPLETE'
498 
499 
500 !==============================================================================!
501 ! read triangular mesh parameters on open boundary : !
502 ! iobce: number of open boundary cells. !
503 ! isbcn: number of open boundary nodes. !
504 ! i_obc_e: counter number of open boundary cells !
505 ! i_obc_n: counter number of open boundary nodes !
506 !==============================================================================!
507 
508 !
509 !----TRAVERSE BOUNDARY NODE NUMBERS AND SET ISONB(NODE)=2---------------------!
510 !
511  DO i=1,iobcn
512  isonb(i_obc_n(i))=2
513  ENDDO
514 
515 !
516 !---- SET HALO VALUES IF PAR
517 !
518 
519 
520 !
521 !----DETERMINE IF ELEMENT IS ON OPEN BOUNDARY (CONTAINS EDGE ON OPEN BOUNDARY)-!
522 !
523  ibcetmp=0
524  DO i=1,n
525  itmp1=isonb(nv(i,1))
526  itmp2=isonb(nv(i,2))
527  itmp3=isonb(nv(i,3))
528 
529  IF(sum(isonb(nv(i,1:3))) == 4) THEN
530  isbce(i)=2
531  ibcetmp =ibcetmp+1
532  ELSE IF(sum(isonb(nv(i,1:3))) > 4) THEN
533  print*,'SORRY, THE BOUNDARY CELL',i,'IS NOT GOOD FOR MODEL.'
534  print*,'IT HAS EITHER TWO SIDES OF OPEN BOUNDARY OR ONE OPEN BOUNDARY'
535  print*,'AND ONE SOLID BOUNDARY. PLEASE CHECK AND MODIFIED IT.'
536  print*,'THIS MESSAGE IS IN SUBROUTINE TRIANGLE_GRID_EDGE (TGE.F)'
537  print*,'STOP RUNNING...'
538  CALL pstop
539 
540  END IF
541  END DO
542 
543  DO i=1,nt
544  IF((nbe(i,1)+nbe(i,2)+nbe(i,3) == 0).AND.(isbce(i) /= 2)) isbce(i)=3
545  IF((nbe(i,1)+nbe(i,2) == 0).AND.(isbce(i) /= 2)) isbce(i)=3
546  IF((nbe(i,2)+nbe(i,3) == 0).AND.(isbce(i) /= 2)) isbce(i)=3
547  IF((nbe(i,1)+nbe(i,3) == 0).AND.(isbce(i) /= 2)) isbce(i)=3
548  ENDDO
549 
550 ! SET HALO VALUES IF PAR
551 
552 
553 !==============================================================================!
554 ! xije(1:nc,1:2): the x coordinate locations of starting and ending !
555 ! points of the control volumes edges !
556 ! yije(1:nc,1:2): the y coordinate locations of starting and ending !
557 ! points of the control volumes edges !
558 ! niec(1:nc,1:2): the counting number of left and right nodes !
559 ! conected to this control volumes edge from !
560 ! starting point to ending point !
561 ! dltxe(1:nc): the x distance of individual edges !
562 ! dltye(1:nc) the y distance of individual edges !
563 ! dltxye(1:nc): the length of individual edges !
564 ! ntrg(1:nc) : element associated with this control volume edge !
565 !==============================================================================!
566  nctmp = 0
567  ncetmp = 0
568 
569  DO i=1,ne
570  IF(isbc(i) == 0) THEN
571  IF(iec(i,1) <= n)THEN
572  nctmp=nctmp+1
573  npt =nctmp
574  ELSE
575  ncetmp = ncetmp + 1
576  npt = ncetmp+(3*n)
577  END IF
578  xije(npt,1) = xc(iec(i,1))
579  yije(npt,1) = yc(iec(i,1))
580  xije(npt,2) = xijc(i)
581  yije(npt,2) = yijc(i)
582  niec(npt,1) = ienode(i,1)
583  niec(npt,2) = ienode(i,2)
584  ntrg(npt) = iec(i,1)
585  dltxe(npt) = xije(npt,2)-xije(npt,1)
586  dltye(npt) = yije(npt,2)-yije(npt,1)
587  dtmp = dltxe(npt)*dltxe(npt)+dltye(npt)*dltye(npt)
588  dltxye(npt) = sqrt(dtmp)
589  sitae(npt) = atan2(dltye(npt),dltxe(npt))
590 
591  IF(iec(i,2) <= n)THEN
592  nctmp=nctmp+1
593  npt =nctmp
594  ELSE
595  ncetmp = ncetmp + 1
596  npt = ncetmp+(3*n)
597  END IF
598  xije(npt,1)=xc(iec(i,2))
599  yije(npt,1)=yc(iec(i,2))
600  xije(npt,2)=xijc(i)
601  yije(npt,2)=yijc(i)
602  niec(npt,1)=ienode(i,2)
603  niec(npt,2)=ienode(i,1)
604  ntrg(npt)=iec(i,2)
605  dltxe(npt)=xije(npt,2)-xije(npt,1)
606  dltye(npt)=yije(npt,2)-yije(npt,1)
607  dtmp=dltxe(npt)*dltxe(npt)+dltye(npt)*dltye(npt)
608  dltxye(npt)=sqrt(dtmp)
609  sitae(npt)=atan2(dltye(npt),dltxe(npt))
610  ELSE IF(isbc(i) == 1) THEN
611  IF(iec(i,1) <= n)THEN
612  nctmp=nctmp+1
613  npt =nctmp
614  ELSE
615  ncetmp = ncetmp + 1
616  npt = ncetmp+(3*n)
617  END IF
618  IF(iec(i,1) == 0) THEN
619  print*, i,'IEC(I,1)===0'
620  CALL pstop
621  END IF
622  xije(npt,1)=xc(iec(i,1))
623  yije(npt,1)=yc(iec(i,1))
624  xije(npt,2)=xijc(i)
625  yije(npt,2)=yijc(i)
626  niec(npt,1)=ienode(i,1)
627  niec(npt,2)=ienode(i,2)
628  ntrg(npt)=iec(i,1)
629  dltxe(npt)=xije(npt,2)-xije(npt,1)
630  dltye(npt)=yije(npt,2)-yije(npt,1)
631  dtmp=dltxe(npt)*dltxe(npt)+dltye(npt)*dltye(npt)
632  dltxye(npt)=sqrt(dtmp)
633  sitae(npt)=atan2(dltye(npt),dltxe(npt))
634  ELSE
635  WRITE(ipt,*) 'ISBC(I) NOT CORRECT, I==',i
636  CALL pstop
637  END IF
638  ENDDO
639 
640  ncv_i = nctmp
641  ncv = ncetmp+nctmp
642 
643  IF(ncv /= 3*(nt)) THEN
644  print*,'NCV IS NOT CORRECT, PLEASE CHECK THE SETUP'
645  CALL pstop
646  END IF
647  IF(ncv_i /= 3*n) THEN
648  print*,'NCV_I IS NOT CORRECT, PLEASE CHECK THE SETUP'
649  CALL pstop
650  END IF
651 
652  DO i=1,ncv_i
653  IF(niec(i,1) > m .OR. niec(i,2) > m)THEN
654  write(ipt,*)'problemas',niec(i,1),niec(i,2),m
655  CALL pstop
656  END IF
657  END DO
658 
659 !==============================================================================!
660 ! nisbce_1/nisbce_2/nisbce_3: number of elements with isbce of 1,2,3 !
661 ! lisbce_1/lisbce_2/lisbce_3: list of elements with isbce of 1,2,3 !
662 ! epor : element porosity (=0 if isbce = 2) !
663 !==============================================================================!
664 
665 !
666 !--COUNT NUMBER OF ELEMENTS OF EACH TYPE (ISBCE=1,2,3)-------------------------!
667 !
668  nisbce_1 = 0 ; nisbce_2 = 0 ; nisbce_3 = 0
669  DO i=1,n
670  IF(isbce(i) == 1) nisbce_1 = nisbce_1 + 1
671  IF(isbce(i) == 2) nisbce_2 = nisbce_2 + 1
672  IF(isbce(i) == 3) nisbce_3 = nisbce_3 + 1
673  END DO
674 
675 !
676 !--ALLOCATE ELEMENT TYPE ARRAYS LISBCE_1,LISBCE_2,LISBCE_3---------------------!
677 !
678  IF(nisbce_1 > 0)THEN
679  ALLOCATE( lisbce_1(nisbce_1) )
680  ELSE
681 ! WRITE(IPT,*) '! WARNING : NO ELEMENTS WITH ISBCE=1'
682  END IF
683 
684  IF(nisbce_2 > 0)THEN
685  ALLOCATE( lisbce_2(nisbce_2) )
686  ELSE
687 ! WRITE(IPT,*) '! WARNING : NO ELEMENTS WITH ISBCE=2'
688  END IF
689 
690  IF(nisbce_3 > 0)THEN
691  ALLOCATE( lisbce_3(nisbce_3) )
692  ELSE
693 ! WRITE(IPT,*) '! WARNING : NO ELEMENTS WITH ISBCE=3'
694  END IF
695 
696 !
697 !--LOAD ELEMENT TYPE ARRAYS LISBCE_1,LISBCE_2,LISBCE_3--------------------------!
698 !
699  nisbce_1 = 0 ; nisbce_2 = 0 ; nisbce_3 = 0
700  DO i=1,n
701  IF(isbce(i) == 1) THEN
702  nisbce_1 = nisbce_1 + 1
703  lisbce_1(nisbce_1) = i
704  END IF
705  IF(isbce(i) == 2) THEN
706  nisbce_2 = nisbce_2 + 1
707  lisbce_2(nisbce_2) = i
708  END IF
709  IF(isbce(i) == 3) THEN
710  nisbce_3 = nisbce_3 + 1
711  lisbce_3(nisbce_3) = i
712  END IF
713  END DO
714 
715 !
716 !--SET ELEMENT POROSITY---------------------------------------------------------!
717 !
718  ALLOCATE(epor(0:nt)) ; epor = 1.0_sp
719  DO i=1,n
720  IF(isbce(i) == 2) epor(i) = 0.0_sp
721  END DO
722 
723  IF (dbg_set(dbg_log))WRITE(ipt,*) '! NISBCE/LISBCE/EPOR : COMPLETE'
724  IF (dbg_set(dbg_log))WRITE(ipt,*) '! TRIS/EDGES/CVOLS : COMPLETE'
725 
726  RETURN
integer, dimension(:,:), allocatable, target ienode
Definition: mod_main.f90:1029
integer, dimension(:), allocatable, target ntsn
Definition: mod_main.f90:1023
real(sp), dimension(:), allocatable, target epor
Definition: mod_main.f90:1056
integer ne
Definition: mod_main.f90:73
real(sp), dimension(:,:), allocatable, target yije
Definition: mod_main.f90:1048
integer mt
Definition: mod_main.f90:78
integer, dimension(:), allocatable, target lisbce_1
Definition: mod_main.f90:1037
logical function dbg_set(vrb)
Definition: mod_utils.f90:182
integer myid
Definition: mod_main.f90:67
integer ncv
Definition: mod_main.f90:74
real(sp), dimension(:), allocatable, target yc
Definition: mod_main.f90:1004
real(sp), dimension(:), allocatable, target dltxye
Definition: mod_main.f90:1052
real(sp), dimension(:), allocatable, target dltxc
Definition: mod_main.f90:1040
integer ncv_i
Definition: mod_main.f90:76
real(sp), dimension(:,:), allocatable, target xije
Definition: mod_main.f90:1047
integer m
Definition: mod_main.f90:56
real(sp), dimension(:), allocatable, target sitac
Definition: mod_main.f90:1053
integer, dimension(:), allocatable, target ntrg
Definition: mod_main.f90:1033
integer, dimension(:), allocatable, target isbc
Definition: mod_main.f90:1026
integer, dimension(:,:), allocatable, target iec
Definition: mod_main.f90:1028
integer, dimension(:,:), allocatable, target niec
Definition: mod_main.f90:1032
integer, dimension(:,:), allocatable, target nbvt
Definition: mod_main.f90:1036
real(sp), dimension(:), allocatable, target vx
Definition: mod_main.f90:1001
real(sp), dimension(:), allocatable, target dltye
Definition: mod_main.f90:1051
integer iobcn
Definition: mod_main.f90:1777
subroutine pstop
Definition: mod_utils.f90:273
integer n
Definition: mod_main.f90:55
real(sp), dimension(:), allocatable, target vy
Definition: mod_main.f90:1002
integer, dimension(:), allocatable, target ntve
Definition: mod_main.f90:1022
integer, dimension(:,:), allocatable, target nbe
Definition: mod_main.f90:1020
integer, dimension(:), allocatable i_obc_n
Definition: mod_main.f90:1779
integer nisbce_2
Definition: mod_main.f90:61
integer, dimension(:,:), allocatable, target nv
Definition: mod_main.f90:1018
real(sp), dimension(:), allocatable, target xijc
Definition: mod_main.f90:1044
real(sp), dimension(:), allocatable, target dltyc
Definition: mod_main.f90:1041
real(sp), dimension(:), allocatable, target sitae
Definition: mod_main.f90:1043
integer mx_nbr_elem
Definition: mod_main.f90:79
real(sp), dimension(:), allocatable, target yijc
Definition: mod_main.f90:1045
integer nisbce_3
Definition: mod_main.f90:62
integer, dimension(:,:), allocatable, target nbve
Definition: mod_main.f90:1034
subroutine fatal_error(ER1, ER2, ER3, ER4)
Definition: mod_utils.f90:230
real(sp), dimension(:), allocatable, target xc
Definition: mod_main.f90:1003
integer, dimension(:), allocatable, target lisbce_2
Definition: mod_main.f90:1038
integer, dimension(:), allocatable, target lisbce_3
Definition: mod_main.f90:1039
real(sp), dimension(:), allocatable, target dltxyc
Definition: mod_main.f90:1042
integer nisbce_1
Definition: mod_main.f90:60
integer, dimension(:), allocatable, target isbce
Definition: mod_main.f90:1027
integer, dimension(:,:), allocatable, target nbsn
Definition: mod_main.f90:1030
integer, dimension(:), pointer ngid
Definition: mod_par.f90:61
integer ipt
Definition: mod_main.f90:922
real(sp), dimension(:), allocatable, target dltxe
Definition: mod_main.f90:1050
integer, dimension(:), allocatable, target isonb
Definition: mod_main.f90:1024
integer nt
Definition: mod_main.f90:77
integer, dimension(:), pointer egid
Definition: mod_par.f90:60
integer, parameter dbg_log
Definition: mod_utils.f90:65
Here is the caller graph for this function: