Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModEdgeList.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 ! ******************************************************************************
24 !
25 ! Purpose: Suite of routines to build edge list.
26 !
27 ! Description: None.
28 !
29 ! Notes:
30 ! 1. There is no routine called RFLU_CreateEdgeList - as might be expected -
31 ! because the sizes of the various arrays is not known in advance and
32 ! splitting the routine becomes cumbersome.
33 !
34 ! ******************************************************************************
35 !
36 ! $Id: RFLU_ModEdgeList.F90,v 1.13 2008/12/06 08:44:21 mtcampbe Exp $
37 !
38 ! Copyright: (c) 2002-2005 by the University of Illinois
39 !
40 ! ******************************************************************************
41 
43 
44  USE modglobal, ONLY: t_global
45  USE moddatatypes
46  USE modparameters
47  USE moderror
48  USE modbndpatch, ONLY: t_patch
49  USE moddatastruct, ONLY: t_region
50  USE modgrid, ONLY: t_grid
51  USE modmpi
52 
53  IMPLICIT NONE
54 
55  PRIVATE
56  PUBLIC :: rflu_nullifyedgelist, &
64 
65  SAVE
66 
67 ! ******************************************************************************
68 ! Declarations and definitions
69 ! ******************************************************************************
70 
71  CHARACTER(CHRLEN) :: &
72  RCSIdentString = '$RCSfile: RFLU_ModEdgeList.F90,v $ $Revision: 1.13 $'
73  INTEGER, PRIVATE :: ekCntr(EDGE_KIND_AA:EDGE_KIND_VV), &
74  ekOffs(EDGE_KIND_AA:EDGE_KIND_VV), &
75  ekStrt(EDGE_KIND_AA:EDGE_KIND_VV)
76  INTEGER, DIMENSION(:,:), ALLOCATABLE, PRIVATE :: degr,strt
77 
78 ! ******************************************************************************
79 ! Routines
80 ! ******************************************************************************
81 
82  CONTAINS
83 
84 
85 
86 ! ******************************************************************************
87 !
88 ! Purpose: Nullify edge list.
89 !
90 ! Description: None.
91 !
92 ! Input:
93 ! pRegion Pointer to region
94 !
95 ! Output: None.
96 !
97 ! Notes: None.
98 !
99 ! ******************************************************************************
100 
101  SUBROUTINE rflu_nullifyedgelist(pRegion)
102 
103  IMPLICIT NONE
104 
105 ! ******************************************************************************
106 ! Declarations and definitions
107 ! ******************************************************************************
108 
109 ! ==============================================================================
110 ! Arguments
111 ! ==============================================================================
112 
113  TYPE(t_region), POINTER :: pregion
114 
115 ! ==============================================================================
116 ! Locals
117 ! ==============================================================================
118 
119  TYPE(t_grid), POINTER :: pgrid
120  TYPE(t_global), POINTER :: global
121 
122 ! ******************************************************************************
123 ! Start
124 ! ******************************************************************************
125 
126  global => pregion%global
127 
128  CALL registerfunction(global,'RFLU_NullifyEdgeList',&
129  'RFLU_ModEdgeList.F90')
130 
131  IF ( global%myProcid == masterproc .AND. &
132  global%verbLevel >= verbose_high ) THEN
133  WRITE(stdout,'(A,1X,A)') solver_name,'Nullifying edge list...'
134  END IF ! global%verbLevel
135 
136 ! ******************************************************************************
137 ! Set grid pointer
138 ! ******************************************************************************
139 
140  pgrid => pregion%grid
141 
142 ! ******************************************************************************
143 ! Nullify memory
144 ! ******************************************************************************
145 
146  nullify(pgrid%e2v)
147 
148 ! ******************************************************************************
149 ! End
150 ! ******************************************************************************
151 
152  IF ( global%myProcid == masterproc .AND. &
153  global%verbLevel >= verbose_high ) THEN
154  WRITE(stdout,'(A,1X,A)') solver_name,'Nullifying edge list done.'
155  END IF ! global%verbLevel
156 
157  CALL deregisterfunction(global)
158 
159  END SUBROUTINE rflu_nullifyedgelist
160 
161 
162 
163 
164 
165 ! ******************************************************************************
166 !
167 ! Purpose: Nullify edge-to-cell list.
168 !
169 ! Description: None.
170 !
171 ! Input:
172 ! pRegion Pointer to region
173 !
174 ! Output: None.
175 !
176 ! Notes: None.
177 !
178 ! ******************************************************************************
179 
180  SUBROUTINE rflu_nullifyedge2celllist(pRegion)
181 
182  IMPLICIT NONE
183 
184 ! ******************************************************************************
185 ! Declarations and definitions
186 ! ******************************************************************************
187 
188 ! ==============================================================================
189 ! Arguments
190 ! ==============================================================================
191 
192  TYPE(t_region), POINTER :: pregion
193 
194 ! ==============================================================================
195 ! Locals
196 ! ==============================================================================
197 
198  TYPE(t_grid), POINTER :: pgrid
199  TYPE(t_global), POINTER :: global
200 
201 ! ******************************************************************************
202 ! Start
203 ! ******************************************************************************
204 
205  global => pregion%global
206 
207  CALL registerfunction(global,'RFLU_NullifyEdge2CellList',&
208  'RFLU_ModEdgeList.F90')
209 
210  IF ( global%myProcid == masterproc .AND. &
211  global%verbLevel >= verbose_high ) THEN
212  WRITE(stdout,'(A,1X,A)') solver_name,'Nullifying edge-to-cell list...'
213  END IF ! global%verbLevel
214 
215 ! ******************************************************************************
216 ! Set grid pointer
217 ! ******************************************************************************
218 
219  pgrid => pregion%grid
220 
221 ! ******************************************************************************
222 ! Nullify memory
223 ! ******************************************************************************
224 
225  nullify(pgrid%e2cStrt)
226  nullify(pgrid%e2cDegr)
227 
228 ! ******************************************************************************
229 ! End
230 ! ******************************************************************************
231 
232  IF ( global%myProcid == masterproc .AND. &
233  global%verbLevel >= verbose_high ) THEN
234  WRITE(stdout,'(A,1X,A)') solver_name, &
235  'Nullifying edge-to-cell list done.'
236  END IF ! global%verbLevel
237 
238  CALL deregisterfunction(global)
239 
240  END SUBROUTINE rflu_nullifyedge2celllist
241 
242 
243 
244 
245 
246 
247 
248 
249 ! ******************************************************************************
250 !
251 ! Purpose: Create edge list.
252 !
253 ! Description: None.
254 !
255 ! Input:
256 ! pRegion Pointer to region
257 !
258 ! Output: None.
259 !
260 ! Notes: None.
261 !
262 ! ******************************************************************************
263 
264  SUBROUTINE rflu_createedgelist(pRegion)
265 
266  IMPLICIT NONE
267 
268 ! ******************************************************************************
269 ! Declarations and definitions
270 ! ******************************************************************************
271 
272 ! ==============================================================================
273 ! Arguments
274 ! ==============================================================================
275 
276  TYPE(t_region), POINTER :: pregion
277 
278 ! ==============================================================================
279 ! Locals
280 ! ==============================================================================
281 
282  INTEGER :: errorflag,ieg,ipatch,nbfaces,nfacesest
283  TYPE(t_grid), POINTER :: pgrid
284  TYPE(t_patch), POINTER :: ppatch
285  TYPE(t_global), POINTER :: global
286 
287 ! ******************************************************************************
288 ! Start
289 ! ******************************************************************************
290 
291  global => pregion%global
292 
293  CALL registerfunction(global,'RFLU_CreateEdgeList',&
294  'RFLU_ModEdgeList.F90')
295 
296  IF ( global%myProcid == masterproc .AND. &
297  global%verbLevel >= verbose_high ) THEN
298  WRITE(stdout,'(A,1X,A)') solver_name,'Creating edge list...'
299  END IF ! global%verbLevel
300 
301 ! ******************************************************************************
302 ! Nullify memory
303 ! ******************************************************************************
304 
305  CALL rflu_nullifyedgelist(pregion)
306 
307 ! ******************************************************************************
308 ! Set grid pointer
309 ! ******************************************************************************
310 
311  pgrid => pregion%grid
312 
313 ! ******************************************************************************
314 ! Estimate number of edges for allocation of hash table. The estimation
315 ! formula shown below assumes that boundary effects are negligible, so for
316 ! very small grids, where boundary edges dominate the total number of edges,
317 ! need a kludge. Kludge is also needed if running in parallel and boundary
318 ! edges become a significant fraction of total number of edges, and when
319 ! running code with periodic hack, where the missing boundaries mean that
320 ! number of edges is underestimated.
321 ! ******************************************************************************
322 
323  nbfaces = 0
324 
325  DO ipatch = 1,pgrid%nPatches
326  ppatch => pregion%patches(ipatch)
327 
328  nbfaces = nbfaces + ppatch%nBTrisTot + ppatch%nBQuadsTot
329  END DO ! iPatch
330 
331  nfacesest = nbfaces + 2*pgrid%nTetsTot + 3*pgrid%nHexsTot &
332  + 5*pgrid%nPrisTot/2
333 
334  pgrid%nEdgesEst = nbfaces + pgrid%nTetsTot + 2*pgrid%nHexsTot + &
335  3*pgrid%nPrisTot/2 + pgrid%nVertTot - pgrid%nPyrsTot
336 
337  IF ( nbfaces/REAL(nFacesEst,KIND=RFREAL) > 0.8_rfreal .OR. &
338  nbfaces/REAL(nFacesEst,KIND=RFREAL) < 0.2_rfreal ) then
339  pgrid%nEdgesEst = 2*pgrid%nEdgesEst
340 
341  IF ( global%myProcid == masterproc .AND. &
342  global%verbLevel >= verbose_high) THEN
343  WRITE(stdout,'(A,3X,A)') solver_name,'Corrected estimate of '// &
344  'number of edges.'
345  END IF ! global%verbLevel
346  END IF ! nBFaces
347 
348  IF ( global%myProcid == masterproc .AND. &
349  global%verbLevel >= verbose_high ) THEN
350  WRITE(stdout,'(A,3X,A,3X,I9)') solver_name,'Estimated number of '// &
351  'edges: ',pgrid%nEdgesEst
352  END IF ! global%verbLevel
353 
354  ALLOCATE(pgrid%e2v(2,pgrid%nEdgesEst),stat=errorflag)
355  global%error = errorflag
356  IF ( global%error /= err_none ) THEN
357  CALL errorstop(global,err_allocate,__line__,'pGrid%e2vTemp')
358  END IF ! global%error
359 
360  DO ieg = 1,pgrid%nEdgesEst ! Explicit loop because of ASCI White
361  pgrid%e2v(1,ieg) = 0
362  pgrid%e2v(2,ieg) = 0
363  END DO ! ieg
364 
365 ! ******************************************************************************
366 ! End
367 ! ******************************************************************************
368 
369  IF ( global%myProcid == masterproc .AND. &
370  global%verbLevel >= verbose_high ) THEN
371  WRITE(stdout,'(A,1X,A)') solver_name,'Creating edge list done.'
372  END IF ! global%verbLevel
373 
374  CALL deregisterfunction(global)
375 
376  END SUBROUTINE rflu_createedgelist
377 
378 
379 
380 
381 
382 ! ******************************************************************************
383 !
384 ! Purpose: Create edge-to-cell list.
385 !
386 ! Description: None.
387 !
388 ! Input:
389 ! pRegion Pointer to region
390 !
391 ! Output: None.
392 !
393 ! Notes: None.
394 !
395 ! ******************************************************************************
396 
397  SUBROUTINE rflu_createedge2celllist(pRegion)
398 
399  IMPLICIT NONE
400 
401 ! ******************************************************************************
402 ! Declarations and definitions
403 ! ******************************************************************************
404 
405 ! ==============================================================================
406 ! Arguments
407 ! ==============================================================================
408 
409  TYPE(t_region), POINTER :: pregion
410 
411 ! ==============================================================================
412 ! Locals
413 ! ==============================================================================
414 
415  INTEGER :: errorflag
416  TYPE(t_grid), POINTER :: pgrid
417  TYPE(t_global), POINTER :: global
418 
419 ! ******************************************************************************
420 ! Start
421 ! ******************************************************************************
422 
423  global => pregion%global
424 
425  CALL registerfunction(global,'RFLU_CreateEdge2CellList',&
426  'RFLU_ModEdgeList.F90')
427 
428  IF ( global%myProcid == masterproc .AND. &
429  global%verbLevel >= verbose_high ) THEN
430  WRITE(stdout,'(A,1X,A)') solver_name,'Creating edge-to-cell list...'
431  END IF ! global%verbLevel
432 
433 ! ******************************************************************************
434 ! Set grid pointer
435 ! ******************************************************************************
436 
437  pgrid => pregion%grid
438 
439 ! ******************************************************************************
440 ! Nullify memory
441 ! ******************************************************************************
442 
443  CALL rflu_nullifyedge2celllist(pregion)
444 
445 ! ******************************************************************************
446 ! Allocate memory
447 ! ******************************************************************************
448 
449  ALLOCATE(pgrid%e2cStrt(pgrid%nEdgesTot),stat=errorflag)
450  global%error = errorflag
451  IF ( global%error /= err_none ) THEN
452  CALL errorstop(global,err_allocate,__line__,'pGrid%e2cStrt')
453  END IF ! global%error
454 
455  pgrid%e2cStrt(1) = 1 ! Initial value important
456 
457  ALLOCATE(pgrid%e2cDegr(pgrid%nEdgesTot),stat=errorflag)
458  global%error = errorflag
459  IF ( global%error /= err_none ) THEN
460  CALL errorstop(global,err_allocate,__line__,'pGrid%e2cDegr')
461  END IF ! global%error
462 
463 ! ******************************************************************************
464 ! End
465 ! ******************************************************************************
466 
467  IF ( global%myProcid == masterproc .AND. &
468  global%verbLevel >= verbose_high ) THEN
469  WRITE(stdout,'(A,1X,A)') solver_name,'Creating edge-to-cell list done.'
470  END IF ! global%verbLevel
471 
472  CALL deregisterfunction(global)
473 
474  END SUBROUTINE rflu_createedge2celllist
475 
476 
477 
478 
479 
480 
481 
482 ! ******************************************************************************
483 !
484 ! Purpose: Build edge list.
485 !
486 ! Description: None.
487 !
488 ! Input:
489 ! pRegion Pointer to region
490 !
491 ! Output: None.
492 !
493 ! Notes: None.
494 !
495 ! ******************************************************************************
496 
497  SUBROUTINE rflu_buildedgelist(pRegion)
498 
499  USE modsortsearch
500 
502  USE rflu_modgrid
504 
505  IMPLICIT NONE
506 
507 ! ******************************************************************************
508 ! Declarations and definitions
509 ! ******************************************************************************
510 
511 ! ==============================================================================
512 ! Arguments
513 ! ==============================================================================
514 
515  TYPE(t_region), POINTER :: pregion
516 
517 ! ==============================================================================
518 ! Locals
519 ! ==============================================================================
520 
521  INTEGER :: ecntr,edgetype,eksum,errorflag,ieg,iegb,iege,iek,iel,icl, &
522  ivg,key,nedges,vsize,v1,v2
523  INTEGER :: v(2)
524 
525  TYPE(t_grid), POINTER :: pgrid
526  TYPE(t_patch), POINTER :: ppatch
527  TYPE(t_global), POINTER :: global
528 
529 ! ******************************************************************************
530 ! Start
531 ! ******************************************************************************
532 
533  global => pregion%global
534 
535  CALL registerfunction(global,'RFLU_BuildEdgeList',&
536  'RFLU_ModEdgeList.F90')
537 
538  IF ( global%myProcid == masterproc .AND. &
539  global%verbLevel >= verbose_high ) THEN
540  WRITE(stdout,'(A,1X,A)') solver_name,'Building edge list...'
541  WRITE(stdout,'(A,3X,A)') solver_name,'Building hash table...'
542  END IF ! global%verbLevel
543 
544 ! ******************************************************************************
545 ! Set grid pointer and initialize nEdgesTot
546 ! ******************************************************************************
547 
548  pgrid => pregion%grid
549 
550  pgrid%nEdgesTot = 0
551 
552 ! ******************************************************************************
553 ! Create hash table
554 ! ******************************************************************************
555 
556  CALL rflu_createhashtable(global,pgrid%nEdgesEst)
557 
558  IF ( global%myProcid == masterproc .AND. &
559  global%verbLevel >= verbose_high ) THEN
560  WRITE(stdout,'(A,5X,A,1X,I9)') solver_name,'Hash table size: '// &
561  ' ',hashtablesize
562  END IF ! global%verbLevel
563 
564 ! ******************************************************************************
565 ! Loop over cell types, construct hash table of faces
566 ! ******************************************************************************
567 
568  vsize = 2 ! Edges have only two vertices
569  nedges = 0
570 
571  IF ( global%myProcid == masterproc .AND. &
572  global%verbLevel >= verbose_high) THEN
573  WRITE(stdout,'(A,5X,A)') solver_name,'Looping over cell types...'
574  END IF ! global%verbLevel
575 
576 ! ==============================================================================
577 ! Tetrahedra
578 ! ==============================================================================
579 
580  IF ( pgrid%nTetsTot /= 0 ) THEN
581  IF ( global%myProcid == masterproc .AND. &
582  global%verbLevel >= verbose_high) THEN
583  WRITE(stdout,'(A,7X,A)') solver_name,'Tetrahedra...'
584  END IF ! global%verbLevel
585  END IF ! pGrid%nTetsTot
586 
587  DO icl = 1,pgrid%nTetsTot
588  DO iel = 1,6
589  v(1) = pgrid%tet2v(ce2vtet(1,iel),icl)
590  v(2) = pgrid%tet2v(ce2vtet(2,iel),icl)
591 
592  CALL quicksortinteger(v(1:vsize),vsize)
593  CALL rflu_hashbuildkey(v(1:2),2,key)
594  CALL rflu_hashedge(global,key,pgrid,v(1:2),edgetype)
595 
596  IF ( edgetype == edge_type_new ) THEN
597  nedges = nedges + 1
598  END IF ! edgeType
599  END DO ! iel
600  END DO ! icl
601 
602 ! ==============================================================================
603 ! Hexahedra
604 ! ==============================================================================
605 
606  IF ( pgrid%nHexsTot /= 0 ) THEN
607  IF ( global%myProcid == masterproc .AND. &
608  global%verbLevel >= verbose_high) THEN
609  WRITE(stdout,'(A,7X,A)') solver_name,'Hexahedra...'
610  END IF ! global%verbLevel
611  END IF ! pGrid%nHexsTot
612 
613  DO icl = 1,pgrid%nHexsTot
614  DO iel = 1,12
615  v(1) = pgrid%hex2v(ce2vhex(1,iel),icl)
616  v(2) = pgrid%hex2v(ce2vhex(2,iel),icl)
617 
618  CALL quicksortinteger(v(1:vsize),vsize)
619  CALL rflu_hashbuildkey(v(1:2),2,key)
620  CALL rflu_hashedge(global,key,pgrid,v(1:2),edgetype)
621 
622  IF ( edgetype == edge_type_new ) THEN
623  nedges = nedges + 1
624  END IF ! edgeType
625  END DO ! ifl
626  END DO ! icl
627 
628 ! ==============================================================================
629 ! Prisms
630 ! ==============================================================================
631 
632  IF ( pgrid%nPrisTot /= 0 ) THEN
633  IF ( global%myProcid == masterproc .AND. &
634  global%verbLevel >= verbose_high) THEN
635  WRITE(stdout,'(A,7X,A)') solver_name,'Prisms...'
636  END IF ! global%verbLevel
637  END IF ! pGrid%nPrisTot
638 
639  DO icl = 1,pgrid%nPrisTot
640  DO iel = 1,9
641  v(1) = pgrid%pri2v(ce2vpri(1,iel),icl)
642  v(2) = pgrid%pri2v(ce2vpri(2,iel),icl)
643 
644  CALL quicksortinteger(v(1:vsize),vsize)
645  CALL rflu_hashbuildkey(v(1:2),2,key)
646  CALL rflu_hashedge(global,key,pgrid,v(1:2),edgetype)
647 
648  IF ( edgetype == edge_type_new ) THEN
649  nedges = nedges + 1
650  END IF ! edgeType
651  END DO ! ifl
652  END DO ! icl
653 
654 ! ==============================================================================
655 ! Pyramids
656 ! ==============================================================================
657 
658  IF ( pgrid%nPyrsTot /= 0 ) THEN
659  IF ( global%myProcid == masterproc .AND. &
660  global%verbLevel >= verbose_high) THEN
661  WRITE(stdout,'(A,7X,A)') solver_name,'Pyramids...'
662  END IF ! global%verbLevel
663  END IF ! pGrid%nPyrsTot
664 
665  DO icl = 1,pgrid%nPyrsTot
666  DO iel = 1,8
667  v(1) = pgrid%pyr2v(ce2vpyr(1,iel),icl)
668  v(2) = pgrid%pyr2v(ce2vpyr(2,iel),icl)
669 
670  CALL quicksortinteger(v(1:vsize),vsize)
671  CALL rflu_hashbuildkey(v(1:2),2,key)
672  CALL rflu_hashedge(global,key,pgrid,v(1:2),edgetype)
673 
674  IF ( edgetype == edge_type_new ) THEN
675  nedges = nedges + 1
676  END IF ! edgeType
677  END DO ! ifl
678  END DO ! icl
679 
680 ! ******************************************************************************
681 ! Set number of edges, print some info, and destroy hash table
682 ! ******************************************************************************
683 
684  pgrid%nEdgesTot = nedges
685 
686  IF ( global%myProcid == masterproc .AND. &
687  global%verbLevel >= verbose_high) THEN
688  WRITE(stdout,'(A,5X,A,6X,I9)') solver_name,'Hash table collisions:', &
689  hashtablecollisions
690  END IF ! global%verbLevel
691 
692  CALL rflu_destroyhashtable(global)
693 
694 ! ******************************************************************************
695 ! Determine edge kinds and set counter offsets
696 ! ******************************************************************************
697 
698  ekcntr(edge_kind_aa) = 0
699  ekcntr(edge_kind_av) = 0
700  ekcntr(edge_kind_vv) = 0
701 
702  DO ieg = 1,pgrid%nEdgesTot
703  v1 = pgrid%e2v(1,ieg)
704  v2 = pgrid%e2v(2,ieg)
705 
706  SELECT CASE (rflu_getedgekind(global,pgrid,v1,v2))
707  CASE (edge_kind_aa)
708  ekcntr(edge_kind_aa) = ekcntr(edge_kind_aa) + 1
709  CASE (edge_kind_av)
710  ekcntr(edge_kind_av) = ekcntr(edge_kind_av) + 1
711  CASE (edge_kind_vv)
712  ekcntr(edge_kind_vv) = ekcntr(edge_kind_vv) + 1
713  CASE default
714  CALL errorstop(global,err_reached_default,__line__)
715  END SELECT ! RFLU_GetEdgeKind
716  END DO ! ie
717 
718  ekoffs(edge_kind_aa) = 0
719  ekoffs(edge_kind_av) = ekcntr(edge_kind_aa)
720  ekoffs(edge_kind_vv) = ekcntr(edge_kind_av) + ekoffs(edge_kind_av)
721 
722 ! ==============================================================================
723 ! Set nEdges. NOTE that it contains only those edges which link two actual
724 ! vertices. This is done for parallel grid motion, in which each region only
725 ! smooths by looping over the edges linking actual vertices.
726 ! ==============================================================================
727 
728 ! pGrid%nEdges = ekCntr(EDGE_KIND_AA) + ekCntr(EDGE_KIND_AV)
729  pgrid%nEdges = ekcntr(edge_kind_aa)
730 
731 ! ==============================================================================
732 ! Print info
733 ! ==============================================================================
734 
735  IF ( global%myProcid == masterproc .AND. &
736  global%verbLevel >= verbose_high ) THEN
737  !IF ( global%verbLevel >= VERBOSE_LOW ) THEN
738  WRITE(stdout,'(A,5X,A)') solver_name,'Edge-type statistics:'
739  WRITE(stdout,'(A,7X,A,4X,I9)') solver_name,'Total edges: ', &
740  pgrid%nEdgesTot
741  WRITE(stdout,'(A,5X,A)') solver_name,'Edge-kind statistics:'
742  WRITE(stdout,'(A,7X,A,4X,I9)') solver_name,'Actual-actual edges: ', &
743  ekcntr(edge_kind_aa)
744  WRITE(stdout,'(A,7X,A,4X,I9)') solver_name,'Actual-virtual edges: ', &
745  ekcntr(edge_kind_av)
746  WRITE(stdout,'(A,7X,A,4X,I9)') solver_name,'Virtual-virtual edges:', &
747  ekcntr(edge_kind_vv)
748  !END IF ! global%verbLevel
749  END IF ! global%myProcid
750 
751 ! ******************************************************************************
752 ! Build actual edgelist
753 ! ******************************************************************************
754 
755 ! ==============================================================================
756 ! Allocate and build helper arrays for sorting. The helper arrays are needed
757 ! so that within each edge kind, have edges sorted according to increasing
758 ! origination vertices and increasing destination vertices.
759 ! ==============================================================================
760 
761  ALLOCATE(strt(edge_kind_aa:edge_kind_vv,pgrid%nVertTot),stat=errorflag)
762  global%error = errorflag
763  IF ( global%error /= err_none ) THEN
764  CALL errorstop(global,err_allocate,__line__,'strt')
765  END IF ! global%error
766 
767  ALLOCATE(degr(edge_kind_aa:edge_kind_vv,pgrid%nVertTot),stat=errorflag)
768  global%error = errorflag
769  IF ( global%error /= err_none ) THEN
770  CALL errorstop(global,err_allocate,__line__,'degr')
771  END IF ! global%error
772 
773  DO ivg = 1,pgrid%nVertTot ! Explicit loop because of ASCI White problems
774  degr(edge_kind_aa,ivg) = 0
775  degr(edge_kind_av,ivg) = 0
776  degr(edge_kind_vv,ivg) = 0
777  END DO ! ivg
778 
779  DO ieg = 1,pgrid%nEdgesTot
780  v1 = pgrid%e2v(1,ieg)
781  v2 = pgrid%e2v(2,ieg)
782 
783  iek = rflu_getedgekind(global,pgrid,v1,v2)
784 
785  degr(iek,v1) = degr(iek,v1) + 1
786  END DO ! ieg
787 
788  strt(edge_kind_aa:edge_kind_vv,1) = 1
789 
790  DO ivg = 2,pgrid%nVertTot
791  strt(edge_kind_aa,ivg) = strt(edge_kind_aa,ivg-1) &
792  + degr(edge_kind_aa,ivg-1)
793  strt(edge_kind_av,ivg) = strt(edge_kind_av,ivg-1) &
794  + degr(edge_kind_av,ivg-1)
795  strt(edge_kind_vv,ivg) = strt(edge_kind_vv,ivg-1) &
796  + degr(edge_kind_vv,ivg-1)
797  END DO ! ivg
798 
799 ! ==============================================================================
800 ! Transfer provisional edge-array into temporary array. Sort so edge kinds
801 ! actual-actual and actual-virtual are listed before virtual-virtual ones.
802 ! Within each edge-kind segment, sort according to increasing origination
803 ! vertices.
804 ! ==============================================================================
805 
806  ekcntr(edge_kind_aa) = 0 ! Reinitialize
807  ekcntr(edge_kind_av) = 0
808  ekcntr(edge_kind_vv) = 0
809 
810  DO ivg = 1,pgrid%nVertTot ! Explicit loop because of ASCI White
811  degr(edge_kind_aa,ivg) = 0
812  degr(edge_kind_av,ivg) = 0
813  degr(edge_kind_vv,ivg) = 0
814  END DO ! ivg
815 
816  ALLOCATE(pgrid%e2vTemp(2,pgrid%nEdgesTot),stat=errorflag)
817  global%error = errorflag
818  IF ( global%error /= err_none ) THEN
819  CALL errorstop(global,err_allocate,__line__,'pGrid%e2vTemp')
820  END IF ! global%error
821 
822  DO ieg = 1,pgrid%nEdgesTot
823  v1 = pgrid%e2v(1,ieg)
824  v2 = pgrid%e2v(2,ieg)
825 
826  iek = rflu_getedgekind(global,pgrid,v1,v2)
827 
828  ecntr = strt(iek,v1) + degr(iek,v1) + ekoffs(iek)
829  degr(iek,v1) = degr(iek,v1) + 1
830  ekcntr(iek) = ekcntr(iek) + 1 ! used below for consistency check
831 
832  pgrid%e2vTemp(1,ecntr) = pgrid%e2v(1,ieg)
833  pgrid%e2vTemp(2,ecntr) = pgrid%e2v(2,ieg)
834  END DO ! ieg
835 
836  eksum = ekcntr(edge_kind_aa) + ekcntr(edge_kind_av) + ekcntr(edge_kind_vv)
837 
838  IF ( eksum /= pgrid%nEdgesTot ) THEN ! Consistency check
839  CALL errorstop(global,err_nedges_wrong,__line__)
840  END IF ! ekSum
841 
842 ! ==============================================================================
843 ! Finally sort within each edge-kind segment and each origination vertex
844 ! segment so that destination vertices are listed in increasing order. Note
845 ! because edges within each segment are already sorted according to
846 ! origination vertices, need to sort here only according to destination
847 ! vertices for each range of origination vertices.
848 ! ==============================================================================
849 
850  DO ivg = 1,pgrid%nVertTot
851 
852 ! ------------------------------------------------------------------------------
853 ! Actual-actual edges
854 ! ------------------------------------------------------------------------------
855 
856  iek = edge_kind_aa
857  iegb = ekoffs(iek) + strt(iek,ivg)
858  iege = ekoffs(iek) + strt(iek,ivg) + degr(iek,ivg) - 1
859 
860  IF ( iege > iegb ) THEN
861  CALL quicksortinteger(pgrid%e2vTemp(2,iegb:iege),iege-iegb+1)
862  END IF ! iege
863 
864 ! ------------------------------------------------------------------------------
865 ! Actual-virtual edges
866 ! ------------------------------------------------------------------------------
867 
868  iek = edge_kind_av
869  iegb = ekoffs(iek) + strt(iek,ivg)
870  iege = ekoffs(iek) + strt(iek,ivg) + degr(iek,ivg) - 1
871 
872  IF ( iege > iegb ) THEN
873  CALL quicksortinteger(pgrid%e2vTemp(2,iegb:iege),iege-iegb+1)
874  END IF ! iege
875 
876 ! ------------------------------------------------------------------------------
877 ! Virtual-virtual edges
878 ! ------------------------------------------------------------------------------
879 
880  iek = edge_kind_vv
881  iegb = ekoffs(iek) + strt(iek,ivg)
882  iege = ekoffs(iek) + strt(iek,ivg) + degr(iek,ivg) - 1
883 
884  IF ( iege > iegb ) THEN
885  CALL quicksortinteger(pgrid%e2vTemp(2,iegb:iege),iege-iegb+1)
886  END IF ! iege
887  END DO ! ivg
888 
889 ! ==============================================================================
890 ! Deallocate helper arrays
891 ! ==============================================================================
892 
893  DEALLOCATE(strt,stat=errorflag)
894  global%error = errorflag
895  IF ( global%error /= err_none ) THEN
896  CALL errorstop(global,err_deallocate,__line__,'strt')
897  END IF ! global%error
898 
899  DEALLOCATE(degr,stat=errorflag)
900  global%error = errorflag
901  IF ( global%error /= err_none ) THEN
902  CALL errorstop(global,err_deallocate,__line__,'degr')
903  END IF ! global%error
904 
905 ! ==============================================================================
906 ! Allocate actual edge array and copy from temporary array
907 ! ==============================================================================
908 
909  DEALLOCATE(pgrid%e2v,stat=errorflag)
910  global%error = errorflag
911  IF ( global%error /= err_none ) THEN
912  CALL errorstop(global,err_deallocate,__line__,'pGrid%e2v')
913  END IF ! global%error
914 
915  ALLOCATE(pgrid%e2v(2,pgrid%nEdgesTot),stat=errorflag)
916  global%error = errorflag
917  IF ( global%error /= err_none ) THEN
918  CALL errorstop(global,err_allocate,__line__,'pGrid%e2v')
919  END IF ! global%error
920 
921  DO ieg = 1,pgrid%nEdgesTot ! Explicit loop because of ASCI White
922  pgrid%e2v(1,ieg) = pgrid%e2vTemp(1,ieg)
923  pgrid%e2v(2,ieg) = pgrid%e2vTemp(2,ieg)
924  END DO ! ieg
925 
926 ! ==============================================================================
927 ! Deallocate temporary array
928 ! ==============================================================================
929 
930  DEALLOCATE(pgrid%e2vTemp,stat=errorflag)
931  global%error = errorflag
932  IF ( global%error /= err_none ) THEN
933  CALL errorstop(global,err_deallocate,__line__,'pGrid%e2v')
934  END IF ! global%error
935 
936 ! ******************************************************************************
937 ! End
938 ! ******************************************************************************
939 
940  IF ( global%myProcid == masterproc .AND. &
941  global%verbLevel >= verbose_high ) THEN
942  WRITE(stdout,'(A,1X,A)') solver_name,'Building edge list done.'
943  END IF ! global%verbLevel
944 
945  CALL deregisterfunction(global)
946 
947  END SUBROUTINE rflu_buildedgelist
948 
949 
950 
951 
952 
953 
954 
955 
956 
957 ! ******************************************************************************
958 !
959 ! Purpose: Build edge-to-cell list.
960 !
961 ! Description: None.
962 !
963 ! Input:
964 ! pRegion Pointer to region
965 !
966 ! Output: None.
967 !
968 ! Notes: None.
969 !
970 ! ******************************************************************************
971 
972  SUBROUTINE rflu_buildedge2celllist(pRegion)
973 
974  USE modsortsearch
975 
977  USE rflu_modgrid
978 
979  IMPLICIT NONE
980 
981 ! ******************************************************************************
982 ! Declarations and definitions
983 ! ******************************************************************************
984 
985 ! ==============================================================================
986 ! Arguments
987 ! ==============================================================================
988 
989  TYPE(t_region), POINTER :: pregion
990 
991 ! ==============================================================================
992 ! Locals
993 ! ==============================================================================
994 
995  INTEGER :: errorflag,e2csize,icl,ieg,iegb,iege,iek,iel,iloc,ipass, &
996  ivg,vsize,v1,v2
997  INTEGER :: v(2)
998  TYPE(t_grid), POINTER :: pgrid
999  TYPE(t_global), POINTER :: global
1000 
1001 ! ******************************************************************************
1002 ! Start
1003 ! ******************************************************************************
1004 
1005  global => pregion%global
1006 
1007  CALL registerfunction(global,'RFLU_BuildEdge2CellList',&
1008  'RFLU_ModEdgeList.F90')
1009 
1010  IF ( global%myProcid == masterproc .AND. &
1011  global%verbLevel >= verbose_high ) THEN
1012  WRITE(stdout,'(A,1X,A)') solver_name,'Building edge-to-cell list...'
1013  END IF ! global%verbLevel
1014 
1015  pgrid => pregion%grid
1016 
1017 ! ******************************************************************************
1018 ! Build access lists for edge kinds, allows easy access of e2v list based on
1019 ! edge kinds
1020 ! ******************************************************************************
1021 
1022  ekcntr(edge_kind_aa) = 0
1023  ekcntr(edge_kind_av) = 0
1024  ekcntr(edge_kind_vv) = 0
1025 
1026  DO ieg = 1,pgrid%nEdgesTot
1027  v1 = pgrid%e2v(1,ieg)
1028  v2 = pgrid%e2v(2,ieg)
1029 
1030  SELECT CASE (rflu_getedgekind(global,pgrid,v1,v2))
1031  CASE (edge_kind_aa)
1032  ekcntr(edge_kind_aa) = ekcntr(edge_kind_aa) + 1
1033  CASE (edge_kind_av)
1034  ekcntr(edge_kind_av) = ekcntr(edge_kind_av) + 1
1035  CASE (edge_kind_vv)
1036  ekcntr(edge_kind_vv) = ekcntr(edge_kind_vv) + 1
1037  CASE default
1038  CALL errorstop(global,err_reached_default,__line__)
1039  END SELECT ! RFLU_GetEdgeKind
1040  END DO ! ie
1041 
1042  ekoffs(edge_kind_aa) = 0
1043  ekoffs(edge_kind_av) = ekcntr(edge_kind_aa)
1044  ekoffs(edge_kind_vv) = ekcntr(edge_kind_av) + ekoffs(edge_kind_av)
1045 
1046  ekstrt(edge_kind_aa) = 1
1047  ekstrt(edge_kind_av) = ekstrt(edge_kind_aa) + ekcntr(edge_kind_aa)
1048  ekstrt(edge_kind_vv) = ekstrt(edge_kind_av) + ekcntr(edge_kind_av)
1049 
1050 ! ******************************************************************************
1051 ! Allocate and build helper arrays for sorting. The helper arrays are needed
1052 ! so that within each edge kind, have edges sorted according to increasing
1053 ! origination vertices and increasing destination vertices.
1054 ! ******************************************************************************
1055 
1056  ALLOCATE(strt(edge_kind_aa:edge_kind_vv,pgrid%nVertTot),stat=errorflag)
1057  global%error = errorflag
1058  IF ( global%error /= err_none ) THEN
1059  CALL errorstop(global,err_allocate,__line__,'strt')
1060  END IF ! global%error
1061 
1062  ALLOCATE(degr(edge_kind_aa:edge_kind_vv,pgrid%nVertTot),stat=errorflag)
1063  global%error = errorflag
1064  IF ( global%error /= err_none ) THEN
1065  CALL errorstop(global,err_allocate,__line__,'degr')
1066  END IF ! global%error
1067 
1068  DO ivg = 1,pgrid%nVertTot ! Explicit loop because of ASCI White
1069  degr(edge_kind_aa,ivg) = 0
1070  degr(edge_kind_av,ivg) = 0
1071  degr(edge_kind_vv,ivg) = 0
1072  END DO ! ivg
1073 
1074  DO ieg = 1,pgrid%nEdgesTot
1075  v1 = pgrid%e2v(1,ieg)
1076  v2 = pgrid%e2v(2,ieg)
1077 
1078  iek = rflu_getedgekind(global,pgrid,v1,v2)
1079 
1080  degr(iek,v1) = degr(iek,v1) + 1
1081  END DO ! ieg
1082 
1083  strt(edge_kind_aa,1) = 1
1084  strt(edge_kind_av,1) = 1
1085  strt(edge_kind_vv,1) = 1
1086 
1087  DO ivg = 2,pgrid%nVertTot
1088  strt(edge_kind_aa,ivg) = strt(edge_kind_aa,ivg-1) &
1089  + degr(edge_kind_aa,ivg-1)
1090  strt(edge_kind_av,ivg) = strt(edge_kind_av,ivg-1) &
1091  + degr(edge_kind_av,ivg-1)
1092  strt(edge_kind_vv,ivg) = strt(edge_kind_vv,ivg-1) &
1093  + degr(edge_kind_vv,ivg-1)
1094  END DO ! ivg
1095 
1096 ! ******************************************************************************
1097 ! Loop over passes. In first pass, determine how many cells meet at a given
1098 ! edge, and use this information to allocate the properly dimensioned e2c
1099 ! array. In the second pass, fill the e2c array.
1100 ! ******************************************************************************
1101 
1102  DO ipass = 1,2
1103  IF ( global%myProcid == masterproc .AND. &
1104  global%verbLevel >= verbose_high) THEN
1105  WRITE(stdout,'(A,3X,A,1X,I1)') solver_name,'Pass:',ipass
1106  END IF ! global%verbLevel
1107 
1108 ! ==============================================================================
1109 ! Loop over cell types
1110 ! ==============================================================================
1111 
1112  vsize = 2
1113 
1114  DO ieg = 1,pgrid%nEdgesTot ! Explicit loop because of ASCI White
1115  pgrid%e2cDegr(ieg) = 0
1116  END DO ! ieg
1117 
1118 ! ------------------------------------------------------------------------------
1119 ! Tetrahedra
1120 ! ------------------------------------------------------------------------------
1121 
1122  IF ( pgrid%nTetsTot /= 0 ) THEN
1123  IF ( global%myProcid == masterproc .AND. &
1124  global%verbLevel >= verbose_high) THEN
1125  WRITE(stdout,'(A,5X,A)') solver_name,'Tetrahedra...'
1126  END IF ! global%verbLevel
1127  END IF ! pGrid%nTetsTot
1128 
1129  DO icl = 1,pgrid%nTetsTot
1130  DO iel = 1,6
1131  v(1) = pgrid%tet2v(ce2vtet(1,iel),icl)
1132  v(2) = pgrid%tet2v(ce2vtet(2,iel),icl)
1133 
1134  CALL quicksortinteger(v(1:vsize),vsize)
1135 
1136  iek = rflu_getedgekind(global,pgrid,v(1),v(2))
1137  iegb = ekoffs(iek) + strt(iek,v(1))
1138  iege = ekoffs(iek) + strt(iek,v(1)) + degr(iek,v(1)) - 1
1139 
1140  CALL binarysearchinteger(pgrid%e2v(2,iegb:iege),iege-iegb+1,v(2), &
1141  iloc)
1142 
1143  IF ( iloc /= element_not_found ) THEN
1144  ieg = iloc + iegb - 1
1145 
1146  IF ( pgrid%e2v(1,ieg) /= v(1) .OR. pgrid%e2v(2,ieg) /= v(2) ) THEN
1147  CALL errorstop(global,err_edgelist_invalid,__line__)
1148  END IF ! pGrid%e2v
1149 
1150  pgrid%e2cDegr(ieg) = pgrid%e2cDegr(ieg) + 1
1151 
1152  IF ( ipass == 2 ) THEN
1153  iloc = pgrid%e2cStrt(ieg) + pgrid%e2cDegr(ieg) - 1
1154  pgrid%e2c(iloc) = pgrid%tet2CellGlob(icl)
1155  END IF ! iPass
1156  ELSE
1157  CALL errorstop(global,err_edgelist_invalid,__line__)
1158  END IF ! iloc
1159  END DO ! iel
1160  END DO ! icl
1161 
1162 ! ------------------------------------------------------------------------------
1163 ! Hexahedra
1164 ! ------------------------------------------------------------------------------
1165 
1166  IF ( pgrid%nHexsTot /= 0 ) THEN
1167  IF ( global%myProcid == masterproc .AND. &
1168  global%verbLevel >= verbose_high) THEN
1169  WRITE(stdout,'(A,5X,A)') solver_name,'Hexahedra...'
1170  END IF ! global%verbLevel
1171  END IF ! pGrid%nHexsTot
1172 
1173  DO icl = 1,pgrid%nHexsTot
1174  DO iel = 1,12
1175  v(1) = pgrid%hex2v(ce2vhex(1,iel),icl)
1176  v(2) = pgrid%hex2v(ce2vhex(2,iel),icl)
1177 
1178  CALL quicksortinteger(v(1:vsize),vsize)
1179 
1180  iek = rflu_getedgekind(global,pgrid,v(1),v(2))
1181  iegb = ekoffs(iek) + strt(iek,v(1))
1182  iege = ekoffs(iek) + strt(iek,v(1)) + degr(iek,v(1)) - 1
1183 
1184  CALL binarysearchinteger(pgrid%e2v(2,iegb:iege),iege-iegb+1,v(2), &
1185  iloc)
1186 
1187  IF ( iloc /= element_not_found ) THEN
1188  ieg = iloc + iegb - 1
1189 
1190  IF ( pgrid%e2v(1,ieg) /= v(1) .OR. pgrid%e2v(2,ieg) /= v(2) ) THEN
1191  CALL errorstop(global,err_edgelist_invalid,__line__)
1192  END IF ! pGrid%e2v
1193 
1194  pgrid%e2cDegr(ieg) = pgrid%e2cDegr(ieg) + 1
1195 
1196  IF ( ipass == 2 ) THEN
1197  iloc = pgrid%e2cStrt(ieg) + pgrid%e2cDegr(ieg) - 1
1198  pgrid%e2c(iloc) = pgrid%hex2CellGlob(icl)
1199  END IF ! iPass
1200  ELSE
1201  CALL errorstop(global,err_edgelist_invalid,__line__)
1202  END IF ! iloc
1203  END DO ! iel
1204  END DO ! icl
1205 
1206 ! ------------------------------------------------------------------------------
1207 ! Prisms
1208 ! ------------------------------------------------------------------------------
1209 
1210  IF ( pgrid%nPrisTot /= 0 ) THEN
1211  IF ( global%myProcid == masterproc .AND. &
1212  global%verbLevel >= verbose_high) THEN
1213  WRITE(stdout,'(A,5X,A)') solver_name,'Prisms...'
1214  END IF ! global%verbLevel
1215  END IF ! pGrid%nPrisTot
1216 
1217  DO icl = 1,pgrid%nPrisTot
1218  DO iel = 1,9
1219  v(1) = pgrid%pri2v(ce2vpri(1,iel),icl)
1220  v(2) = pgrid%pri2v(ce2vpri(2,iel),icl)
1221 
1222  CALL quicksortinteger(v(1:vsize),vsize)
1223 
1224  iek = rflu_getedgekind(global,pgrid,v(1),v(2))
1225  iegb = ekoffs(iek) + strt(iek,v(1))
1226  iege = ekoffs(iek) + strt(iek,v(1)) + degr(iek,v(1)) - 1
1227 
1228  CALL binarysearchinteger(pgrid%e2v(2,iegb:iege),iege-iegb+1,v(2), &
1229  iloc)
1230 
1231  IF ( iloc /= element_not_found ) THEN
1232  ieg = iloc + iegb - 1
1233 
1234  IF ( pgrid%e2v(1,ieg) /= v(1) .OR. pgrid%e2v(2,ieg) /= v(2) ) THEN
1235  CALL errorstop(global,err_edgelist_invalid,__line__)
1236  END IF ! pGrid%e2v
1237 
1238  pgrid%e2cDegr(ieg) = pgrid%e2cDegr(ieg) + 1
1239 
1240  IF ( ipass == 2 ) THEN
1241  iloc = pgrid%e2cStrt(ieg) + pgrid%e2cDegr(ieg) - 1
1242  pgrid%e2c(iloc) = pgrid%pri2CellGlob(icl)
1243  END IF ! iPass
1244  ELSE
1245  CALL errorstop(global,err_edgelist_invalid,__line__)
1246  END IF ! iloc
1247  END DO ! iel
1248  END DO ! icl
1249 
1250 ! ------------------------------------------------------------------------------
1251 ! Pyramids
1252 ! ------------------------------------------------------------------------------
1253 
1254  IF ( pgrid%nPyrsTot /= 0 ) THEN
1255  IF ( global%myProcid == masterproc .AND. &
1256  global%verbLevel >= verbose_high) THEN
1257  WRITE(stdout,'(A,5X,A)') solver_name,'Pyramids...'
1258  END IF ! global%verbLevel
1259  END IF ! pGrid%nPyrTot
1260 
1261  DO icl = 1,pgrid%nPyrsTot
1262  DO iel = 1,8
1263  v(1) = pgrid%pyr2v(ce2vpyr(1,iel),icl)
1264  v(2) = pgrid%pyr2v(ce2vpyr(2,iel),icl)
1265 
1266  CALL quicksortinteger(v(1:vsize),vsize)
1267 
1268  iek = rflu_getedgekind(global,pgrid,v(1),v(2))
1269  iegb = ekoffs(iek) + strt(iek,v(1))
1270  iege = ekoffs(iek) + strt(iek,v(1)) + degr(iek,v(1)) - 1
1271 
1272  CALL binarysearchinteger(pgrid%e2v(2,iegb:iege),iege-iegb+1,v(2), &
1273  iloc)
1274 
1275  IF ( iloc /= element_not_found ) THEN
1276  ieg = iloc + iegb - 1
1277 
1278  IF ( pgrid%e2v(1,ieg) /= v(1) .OR. pgrid%e2v(2,ieg) /= v(2) ) THEN
1279  CALL errorstop(global,err_edgelist_invalid,__line__)
1280  END IF ! pGrid%e2v
1281 
1282  pgrid%e2cDegr(ieg) = pgrid%e2cDegr(ieg) + 1
1283 
1284  IF ( ipass == 2 ) THEN
1285  iloc = pgrid%e2cStrt(ieg) + pgrid%e2cDegr(ieg) - 1
1286  pgrid%e2c(iloc) = pgrid%pyr2CellGlob(icl)
1287  END IF ! iPass
1288  ELSE
1289  CALL errorstop(global,err_edgelist_invalid,__line__)
1290  END IF ! iloc
1291  END DO ! iel
1292  END DO ! icl
1293 
1294 ! ==============================================================================
1295 ! Determine total size of e2c array, build e2cStrt array
1296 ! ==============================================================================
1297 
1298  IF ( ipass == 1 ) THEN
1299  e2csize = 0
1300 
1301  DO ieg = 1,pgrid%nEdgesTot
1302  e2csize = e2csize + pgrid%e2cDegr(ieg)
1303 
1304  IF ( ieg > 1 ) THEN
1305  pgrid%e2cStrt(ieg) = pgrid%e2cStrt(ieg-1) + pgrid%e2cDegr(ieg-1)
1306  END IF ! ieg
1307  END DO ! ieg
1308 
1309  IF ( global%myProcid == masterproc .AND. &
1310  global%verbLevel >= verbose_high) THEN
1311  WRITE(stdout,'(A,5X,A,1X,I9)') solver_name,'Size:',e2csize
1312  END IF ! global%myProcid
1313 
1314  ALLOCATE(pgrid%e2c(e2csize),stat=errorflag)
1315  global%error = errorflag
1316  IF ( global%error /= err_none ) THEN
1317  CALL errorstop(global,err_allocate,__line__,'pGrid%e2c')
1318  END IF ! global%error
1319 
1320  pgrid%e2c(1:e2csize) = 0
1321  END IF ! iPass
1322  END DO ! iPass
1323 
1324 ! ******************************************************************************
1325 ! Deallocate helper arrays
1326 ! ******************************************************************************
1327 
1328  DEALLOCATE(strt,stat=errorflag)
1329  global%error = errorflag
1330  IF ( global%error /= err_none ) THEN
1331  CALL errorstop(global,err_deallocate,__line__,'strt')
1332  END IF ! global%error
1333 
1334  DEALLOCATE(degr,stat=errorflag)
1335  global%error = errorflag
1336  IF ( global%error /= err_none ) THEN
1337  CALL errorstop(global,err_deallocate,__line__,'degr')
1338  END IF ! global%error
1339 
1340 ! ******************************************************************************
1341 ! End
1342 ! ******************************************************************************
1343 
1344  IF ( global%myProcid == masterproc .AND. &
1345  global%verbLevel >= verbose_high ) THEN
1346  WRITE(stdout,'(A,1X,A)') solver_name,'Building edge-to-cell list done.'
1347  END IF ! global%verbLevel
1348 
1349  CALL deregisterfunction(global)
1350 
1351  END SUBROUTINE rflu_buildedge2celllist
1352 
1353 
1354 
1355 
1356 
1357 
1358 
1359 
1360 ! ******************************************************************************
1361 !
1362 ! Purpose: Destroy edge list.
1363 !
1364 ! Description: None.
1365 !
1366 ! Input:
1367 ! pRegion Pointer to region
1368 !
1369 ! Output: None.
1370 !
1371 ! Notes: None.
1372 !
1373 ! ******************************************************************************
1374 
1375  SUBROUTINE rflu_destroyedgelist(pRegion)
1376 
1377  IMPLICIT NONE
1378 
1379 ! ******************************************************************************
1380 ! Declarations and definitions
1381 ! ******************************************************************************
1382 
1383 ! ==============================================================================
1384 ! Arguments
1385 ! ==============================================================================
1386 
1387  TYPE(t_region), POINTER :: pregion
1388 
1389 ! ==============================================================================
1390 ! Locals
1391 ! ==============================================================================
1392 
1393  INTEGER :: errorflag
1394  TYPE(t_grid), POINTER :: pgrid
1395  TYPE(t_global), POINTER :: global
1396 
1397 ! ******************************************************************************
1398 ! Start
1399 ! ******************************************************************************
1400 
1401  global => pregion%global
1402 
1403  CALL registerfunction(global,'RFLU_DestroyEdgeList',&
1404  'RFLU_ModEdgeList.F90')
1405 
1406  IF ( global%myProcid == masterproc .AND. &
1407  global%verbLevel >= verbose_high ) THEN
1408  WRITE(stdout,'(A,1X,A)') solver_name,'Destroying edge list...'
1409  END IF ! global%verbLevel
1410 
1411 ! ******************************************************************************
1412 ! Set grid pointer
1413 ! ******************************************************************************
1414 
1415  pgrid => pregion%grid
1416 
1417 ! ******************************************************************************
1418 ! Deallocate memory
1419 ! ******************************************************************************
1420 
1421  DEALLOCATE(pgrid%e2v,stat=errorflag)
1422  global%error = errorflag
1423  IF ( global%error /= err_none ) THEN
1424  CALL errorstop(global,err_deallocate,__line__,'pGrid%e2v')
1425  END IF ! global%error
1426 
1427 ! ******************************************************************************
1428 ! Nullify memory
1429 ! ******************************************************************************
1430 
1431  CALL rflu_nullifyedgelist(pregion)
1432 
1433 ! ******************************************************************************
1434 ! End
1435 ! ******************************************************************************
1436 
1437  IF ( global%myProcid == masterproc .AND. &
1438  global%verbLevel >= verbose_high ) THEN
1439  WRITE(stdout,'(A,1X,A)') solver_name,'Destroying edge list done.'
1440  END IF ! global%verbLevel
1441 
1442  CALL deregisterfunction(global)
1443 
1444  END SUBROUTINE rflu_destroyedgelist
1445 
1446 
1447 
1448 
1449 
1450 
1451 ! ******************************************************************************
1452 !
1453 ! Purpose: Destroy edge-to-cell list.
1454 !
1455 ! Description: None.
1456 !
1457 ! Input:
1458 ! pRegion Pointer to region
1459 !
1460 ! Output: None.
1461 !
1462 ! Notes:
1463 ! 1. Test for association status of e2c because it is not created with other
1464 ! arrays in RFLU_CreateEdge2CellList, but simply allocated in
1465 ! RFLU_BuildEdge2CellList. This is done because the size is not known at
1466 ! time of creation.
1467 !
1468 ! ******************************************************************************
1469 
1470  SUBROUTINE rflu_destroyedge2celllist(pRegion)
1471 
1472  IMPLICIT NONE
1473 
1474 ! ******************************************************************************
1475 ! Declarations and definitions
1476 ! ******************************************************************************
1477 
1478 ! ==============================================================================
1479 ! Arguments
1480 ! ==============================================================================
1481 
1482  TYPE(t_region), POINTER :: pregion
1483 
1484 ! ==============================================================================
1485 ! Locals
1486 ! ==============================================================================
1487 
1488  INTEGER :: errorflag
1489  TYPE(t_grid), POINTER :: pgrid
1490  TYPE(t_global), POINTER :: global
1491 
1492 ! ==============================================================================
1493 ! Start
1494 ! ==============================================================================
1495 
1496  global => pregion%global
1497 
1498  CALL registerfunction(global,'RFLU_DestroyEdge2CellList',&
1499  'RFLU_ModEdgeList.F90')
1500 
1501  IF ( global%myProcid == masterproc .AND. &
1502  global%verbLevel >= verbose_high ) THEN
1503  WRITE(stdout,'(A,1X,A)') solver_name,'Destroying edge-to-cell list...'
1504  END IF ! global%verbLevel
1505 
1506 ! ******************************************************************************
1507 ! Set grid pointer
1508 ! ******************************************************************************
1509 
1510  pgrid => pregion%grid
1511 
1512 ! ******************************************************************************
1513 ! Deallocate memory
1514 ! ******************************************************************************
1515 
1516  DEALLOCATE(pgrid%e2cDegr,stat=errorflag)
1517  global%error = errorflag
1518  IF ( global%error /= err_none ) THEN
1519  CALL errorstop(global,err_deallocate,__line__,'pGrid%e2cDegr')
1520  END IF ! global%error
1521 
1522  DEALLOCATE(pgrid%e2cStrt,stat=errorflag)
1523  global%error = errorflag
1524  IF ( global%error /= err_none ) THEN
1525  CALL errorstop(global,err_deallocate,__line__,'pGrid%e2cStrt')
1526  END IF ! global%error
1527 
1528  IF ( ASSOCIATED(pgrid%e2c) .EQV. .true. ) THEN
1529  DEALLOCATE(pgrid%e2c,stat=errorflag)
1530  global%error = errorflag
1531  IF ( global%error /= err_none ) THEN
1532  CALL errorstop(global,err_deallocate,__line__,'pGrid%e2c')
1533  END IF ! global%error
1534  END IF ! ASSOCIATED
1535 
1536 ! ******************************************************************************
1537 ! Nullify memory
1538 ! ******************************************************************************
1539 
1540  CALL rflu_nullifyedge2celllist(pregion)
1541 
1542 ! ******************************************************************************
1543 ! End
1544 ! ******************************************************************************
1545 
1546  IF ( global%myProcid == masterproc .AND. &
1547  global%verbLevel >= verbose_high ) THEN
1548  WRITE(stdout,'(A,1X,A)') solver_name, &
1549  'Destroying edge-to-cell list done.'
1550  END IF ! global%verbLevel
1551 
1552  CALL deregisterfunction(global)
1553 
1554  END SUBROUTINE rflu_destroyedge2celllist
1555 
1556 
1557 
1558 
1559 
1560 ! ******************************************************************************
1561 ! End
1562 ! ******************************************************************************
1563 
1564 END MODULE rflu_modedgelist
1565 
1566 
1567 ! ******************************************************************************
1568 !
1569 ! RCS Revision history:
1570 !
1571 ! $Log: RFLU_ModEdgeList.F90,v $
1572 ! Revision 1.13 2008/12/06 08:44:21 mtcampbe
1573 ! Updated license.
1574 !
1575 ! Revision 1.12 2008/11/19 22:17:32 mtcampbe
1576 ! Added Illinois Open Source License/Copyright
1577 !
1578 ! Revision 1.11 2005/04/15 15:06:51 haselbac
1579 ! Removed Charm/FEM stuff and RFLU_XyzEdge2RegionDegrList routines
1580 !
1581 ! Revision 1.10 2004/10/19 19:27:52 haselbac
1582 ! Substantial clean-up
1583 !
1584 ! Revision 1.9 2004/07/06 15:14:36 haselbac
1585 ! Adapted to changes in libflu and modflu, cosmetics
1586 !
1587 ! Revision 1.8 2004/01/22 16:03:59 haselbac
1588 ! Made contents of modules PRIVATE, only procs PUBLIC, to avoid errors on ALC
1589 ! and titan
1590 !
1591 ! Revision 1.7 2004/01/11 02:17:35 jiao
1592 ! Eliminated some redundant trailing spaces that made some lines too long.
1593 ! This changed was necessary to compile with NAG F90 compiler.
1594 !
1595 ! Revision 1.6 2003/08/18 15:30:36 haselbac
1596 ! Changed initialization to solve possible problem on Frost
1597 !
1598 ! Revision 1.5 2003/06/04 22:08:30 haselbac
1599 ! Added Nullify routines, some cosmetics
1600 !
1601 ! Revision 1.4 2003/04/02 17:27:35 haselbac
1602 ! Changed limits of modified estimate of no of edges
1603 !
1604 ! Revision 1.3 2003/03/15 18:05:15 haselbac
1605 ! New routines (|| gm), deleted params, bug fix for pyrs
1606 !
1607 ! Revision 1.2 2003/01/28 16:27:58 haselbac
1608 ! Added creation and destruction, removed renumbering (bcos of
1609 ! RFLU_InitFlowSolver changes)
1610 !
1611 ! Revision 1.1 2002/10/27 19:08:52 haselbac
1612 ! Initial revision
1613 !
1614 ! ******************************************************************************
1615 
1616 
1617 
1618 
1619 
1620 
1621 
1622 
1623 
1624 
1625 
1626 
1627 
1628 
subroutine, public rflu_buildedge2celllist(pRegion)
subroutine, public rflu_createhashtable(global, size)
subroutine, public rflu_hashedge(global, key, pGrid, v, edgeType)
subroutine, public rflu_destroyhashtable(global)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine, public rflu_hashbuildkey(a, aSize, key)
IndexType nedges() const
Definition: Mesh.H:564
subroutine, public rflu_destroyedgelist(pRegion)
subroutine quicksortinteger(a, n)
INTEGER function, public rflu_getedgekind(global, pGrid, v1, v2)
subroutine binarysearchinteger(a, n, v, i, j)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
subroutine, public rflu_createedgelist(pRegion)
subroutine, public rflu_buildedgelist(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
static T_Key key
Definition: vinci_lass.c:76
subroutine, public rflu_nullifyedgelist(pRegion)
subroutine, public rflu_nullifyedge2celllist(pRegion)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine, public rflu_createedge2celllist(pRegion)
subroutine, public rflu_destroyedge2celllist(pRegion)