Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModInCellTest.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 related to in-cell test.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModInCellTest.F90,v 1.4 2008/12/06 08:44:22 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2005 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE modparameters
42  USE moddatatypes
43  USE moderror
44  USE modglobal, ONLY: t_global
45  USE moddatastruct, ONLY: t_region
46  USE modgrid, ONLY: t_grid
47  USE modbndpatch, ONLY: t_patch
48  USE modmpi
49 
50  IMPLICIT NONE
51 
52  PRIVATE
53  PUBLIC :: rflu_ict_computetolerance, &
59 
60 ! ******************************************************************************
61 ! Declarations and definitions
62 ! ******************************************************************************
63 
64  CHARACTER(CHRLEN), PRIVATE :: &
65  RCSIdentString = '$RCSfile: RFLU_ModInCellTest.F90,v $ $Revision: 1.4 $'
66 
67 ! ******************************************************************************
68 ! Routines
69 ! ******************************************************************************
70 
71  CONTAINS
72 
73 
74 
75 
76 
77 ! *****************************************************************************
78 !
79 ! Purpose: Compute tolerance for quadrilateral faces for in-cell test.
80 !
81 ! Description: None.
82 !
83 ! Input:
84 ! pRegion Pointer to region data
85 !
86 ! Output: None.
87 !
88 ! Notes: None.
89 !
90 ! *****************************************************************************
91 
92 SUBROUTINE rflu_ict_computetolerance(pRegion)
93 
94  IMPLICIT NONE
95 
96 ! *****************************************************************************
97 ! Declarations and definitions
98 ! *****************************************************************************
99 
100 ! =============================================================================
101 ! Arguments
102 ! =============================================================================
103 
104  TYPE(t_region), POINTER :: pregion
105 
106 ! =============================================================================
107 ! Locals
108 ! =============================================================================
109 
110  INTEGER :: ifg,ifl,ipatch,ivg,ivl
111  REAL(RFREAL) :: eps,epsmax,nx,ny,nz,safetyfactor,xc,yc,zc
112  TYPE(t_global), POINTER :: global
113  TYPE(t_grid), POINTER :: pgrid
114  TYPE(t_patch), POINTER :: ppatch
115 
116 ! *****************************************************************************
117 ! Start
118 ! *****************************************************************************
119 
120  global => pregion%global
121 
122  CALL registerfunction(global,'RFLU_ICT_ComputeTolerance',&
123  'RFLU_ModInCellTest.F90')
124 
125  IF ( global%myProcid == masterproc .AND. &
126  global%verbLevel > verbose_low ) THEN
127  WRITE(stdout,'(A,1X,A)') solver_name, &
128  'Computing tolerance for in-cell test...'
129  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
130  pregion%iRegionGlobal
131  END IF ! global%myProcid
132 
133 ! =============================================================================
134 ! Set grid pointer and initialize variables
135 ! =============================================================================
136 
137  pgrid => pregion%grid
138 
139  epsmax = -huge(1.0_rfreal)
140 
141  safetyfactor = 2.0_rfreal
142 
143 ! *****************************************************************************
144 ! Compute plane equation defect
145 ! *****************************************************************************
146 
147  DO ifg = 1,pgrid%nFaces
148  IF ( pgrid%f2v(4,ifg) /= vert_none ) THEN
149  xc = pgrid%fc(xcoord,ifg)
150  yc = pgrid%fc(ycoord,ifg)
151  zc = pgrid%fc(zcoord,ifg)
152 
153  nx = pgrid%fn(xcoord,ifg)
154  ny = pgrid%fn(ycoord,ifg)
155  nz = pgrid%fn(zcoord,ifg)
156 
157  DO ivl = 1,4
158  ivg = pgrid%f2v(ivl,ifg)
159 
160  eps = (pgrid%xyz(xcoord,ivg) - xc)*nx &
161  + (pgrid%xyz(ycoord,ivg) - yc)*ny &
162  + (pgrid%xyz(zcoord,ivg) - zc)*nz
163 
164  epsmax = max(eps,epsmax)
165  END DO ! ivl
166  END IF ! pGrid%f2v
167  END DO ! ifg
168 
169  DO ipatch = 1,pgrid%nPatches
170  ppatch => pregion%patches(ipatch)
171 
172  DO ifl = 1,ppatch%nBFaces
173  IF ( ppatch%bf2v(4,ifl) /= vert_none ) THEN
174  xc = ppatch%fc(xcoord,ifl)
175  yc = ppatch%fc(ycoord,ifl)
176  zc = ppatch%fc(zcoord,ifl)
177 
178  nx = ppatch%fn(xcoord,ifl)
179  ny = ppatch%fn(ycoord,ifl)
180  nz = ppatch%fn(zcoord,ifl)
181 
182  DO ivl = 1,4
183  ivg = ppatch%bv(ppatch%bf2v(ivl,ifl))
184 
185  eps = (pgrid%xyz(xcoord,ivg) - xc)*nx &
186  + (pgrid%xyz(ycoord,ivg) - yc)*ny &
187  + (pgrid%xyz(zcoord,ivg) - zc)*nz
188 
189  epsmax = max(eps,epsmax)
190  END DO ! ivl
191  END IF ! pPatch%bf2v
192  END DO ! ifl
193  END DO ! iPatch
194 
195 ! *****************************************************************************
196 ! Write info
197 ! *****************************************************************************
198 
199  IF ( global%myProcid == masterproc .AND. &
200  global%verbLevel > verbose_low ) THEN
201  WRITE(stdout,'(A,3X,A,1X,E13.6)') solver_name, &
202  'Maximum face planarity defect:',epsmax
203  END IF ! global%myProcid
204 
205 ! *****************************************************************************
206 ! Set new tolerance
207 ! *****************************************************************************
208 
209  IF ( epsmax > pregion%mixtInput%tolerICT ) THEN
210  pregion%mixtInput%tolerICT = safetyfactor*epsmax
211 
212  IF ( global%myProcid == masterproc .AND. &
213  global%verbLevel > verbose_low ) THEN
214  WRITE(stdout,'(A,3X,A,12X,E13.6)') solver_name,'Tolerance reset to:', &
215  pregion%mixtInput%tolerICT
216  END IF ! global%myProcid
217  END IF ! epsMax
218 
219 ! *****************************************************************************
220 ! End
221 ! *****************************************************************************
222 
223  IF ( global%myProcid == masterproc .AND. &
224  global%verbLevel > verbose_low ) THEN
225  WRITE(stdout,'(A,1X,A)') solver_name, &
226  'Computing tolerance for in-cell test done.'
227  END IF ! global%myProcid
228 
229  CALL deregisterfunction(global)
230 
231 END SUBROUTINE rflu_ict_computetolerance
232 
233 
234 
235 
236 
237 
238 
239 ! *****************************************************************************
240 !
241 ! Purpose: Compute contribution to in-cell test from planar triangular or
242 ! quadrilateral face.
243 !
244 ! Description: Compute dot product of face normal vector and relative vector
245 ! between face centroid and location in question.
246 !
247 ! Input:
248 ! pRegion Pointer to region data
249 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
250 ! icg Global cell index
251 ! iPatch Patch index
252 ! ifg Face index
253 !
254 ! Output:
255 ! dotp Dot product
256 !
257 ! Notes:
258 ! 1. Only applicable to planar faces.
259 !
260 ! *****************************************************************************
261 
262 SUBROUTINE rflu_ict_testfaceplanar(pRegion,xLoc,yLoc,zLoc,icg,iPatch,ifg,dotp)
263 
264  IMPLICIT NONE
265 
266 ! *****************************************************************************
267 ! Declarations and definitions
268 ! *****************************************************************************
269 
270 ! =============================================================================
271 ! Arguments
272 ! =============================================================================
273 
274  INTEGER, INTENT(IN) :: icg,ifg,ipatch
275  REAL(RFREAL), INTENT(IN) :: xloc,yloc,zloc
276  REAL(RFREAL), INTENT(OUT) :: dotp
277  TYPE(t_region), POINTER :: pregion
278 
279 ! =============================================================================
280 ! Locals
281 ! =============================================================================
282 
283  INTEGER :: c1,c2
284  REAL(RFREAL) :: fnx,fny,fnz,xcofg,ycofg,zcofg
285  TYPE(t_global), POINTER :: global
286  TYPE(t_grid), POINTER :: pgrid
287  TYPE(t_patch), POINTER :: ppatch
288 
289 ! *****************************************************************************
290 ! Start
291 ! *****************************************************************************
292 
293  global => pregion%global
294 
295  CALL registerfunction(global,'RFLU_ICT_TestFacePlanar',&
296  'RFLU_ModInCellTest.F90')
297 
298 ! =============================================================================
299 ! Set grid pointer
300 ! =============================================================================
301 
302  pgrid => pregion%grid
303 
304 ! *****************************************************************************
305 ! Compute dot product
306 ! *****************************************************************************
307 
308  IF ( ipatch == 0 ) THEN ! interior face
309  c1 = pgrid%f2c(1,ifg)
310  c2 = pgrid%f2c(2,ifg)
311 
312  xcofg = pgrid%fc(xcoord,ifg)
313  ycofg = pgrid%fc(ycoord,ifg)
314  zcofg = pgrid%fc(zcoord,ifg)
315 
316  IF ( c1 == icg ) THEN
317  fnx = pgrid%fn(xcoord,ifg)
318  fny = pgrid%fn(ycoord,ifg)
319  fnz = pgrid%fn(zcoord,ifg)
320  ELSE IF ( c2 == icg ) THEN
321  fnx = -pgrid%fn(xcoord,ifg)
322  fny = -pgrid%fn(ycoord,ifg)
323  fnz = -pgrid%fn(zcoord,ifg)
324  ELSE ! defensive programming
325  CALL errorstop(global,err_reached_default,__line__)
326  END IF ! c1
327  ELSE ! boundary face
328  ppatch => pregion%patches(ipatch)
329 
330  xcofg = ppatch%fc(xcoord,ifg)
331  ycofg = ppatch%fc(ycoord,ifg)
332  zcofg = ppatch%fc(zcoord,ifg)
333 
334  fnx = ppatch%fn(xcoord,ifg)
335  fny = ppatch%fn(ycoord,ifg)
336  fnz = ppatch%fn(zcoord,ifg)
337  END IF ! iPatch
338 
339  dotp = (xcofg-xloc)*fnx + (ycofg-yloc)*fny + (zcofg-zloc)*fnz
340 
341 ! *****************************************************************************
342 ! End
343 ! *****************************************************************************
344 
345  CALL deregisterfunction(global)
346 
347 END SUBROUTINE rflu_ict_testfaceplanar
348 
349 
350 
351 
352 
353 
354 ! ******************************************************************************
355 !
356 ! Purpose: Compute contribution to in-cell test from bilinear quadrilateral
357 ! face.
358 !
359 ! Description: A point is located inside a cell if the dot products of the
360 ! outward-facing face normal vectors and the relative vector of the face-
361 ! centroids and the point in question are all positive.
362 !
363 ! Input:
364 ! pRegion Pointer to region data
365 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
366 ! iPatch Patch index
367 ! ifg Face index
368 !
369 ! Output:
370 ! dotp Dot product indicating whether point inside cell
371 !
372 ! Notes:
373 ! 1. Return from this routine early if detect negative dot product.
374 !
375 ! ******************************************************************************
376 
377 SUBROUTINE rflu_ict_testfacequadbilinear(pRegion,xLoc,yLoc,zLoc,iPatch,ifg,dotp)
378 
380 
381  IMPLICIT NONE
382 
383 ! ******************************************************************************
384 ! Declarations and definitions
385 ! ******************************************************************************
386 
387 ! ==============================================================================
388 ! Arguments
389 ! ==============================================================================
390 
391  INTEGER, INTENT(IN) :: ifg,ipatch
392  REAL(RFREAL), INTENT(IN) :: xloc,yloc,zloc
393  REAL(RFREAL), INTENT(OUT) :: dotp
394  TYPE(t_region), POINTER :: pregion
395 
396 ! ==============================================================================
397 ! Locals
398 ! ==============================================================================
399 
400  INTEGER :: v1,v2,v3,v4
401  REAL(RFREAL) :: ax,ay,az,bx,by,bz,cx,cy,cz,dx,dy,dz,nx,ny,nz,u,v,x,x1,x2, &
402  x3,x4,y,y1,y2,y3,y4,z,z1,z2,z3,z4
403  TYPE(t_global), POINTER :: global
404  TYPE(t_grid), POINTER :: pgrid
405  TYPE(t_patch), POINTER :: ppatch
406 
407 ! ******************************************************************************
408 ! Start
409 ! ******************************************************************************
410 
411  global => pregion%global
412 
413  CALL registerfunction(global,'RFLU_ICT_TestFaceQuadBilinear',&
414  'RFLU_ModInCellTest.F90')
415 
416 ! ******************************************************************************
417 ! Set pointer
418 ! ******************************************************************************
419 
420  pgrid => pregion%grid
421 
422 ! ******************************************************************************
423 ! Get vertices
424 ! ******************************************************************************
425 
426  IF ( ipatch == 0 ) THEN ! interior face
427  v1 = pgrid%f2v(1,ifg)
428  v2 = pgrid%f2v(2,ifg)
429  v3 = pgrid%f2v(3,ifg)
430  v4 = pgrid%f2v(4,ifg)
431 
432  IF ( v4 == vert_none ) THEN ! defensive coding
433 ! TEMPORARY
434  WRITE(*,*) 'ERROR!'
435  stop
436 ! END TEMPORARY
437  END IF ! v4
438  ELSE ! boundary face
439  ppatch => pregion%patches(ipatch)
440 
441  v1 = ppatch%bv(ppatch%bf2v(1,ifg))
442  v2 = ppatch%bv(ppatch%bf2v(2,ifg))
443  v3 = ppatch%bv(ppatch%bf2v(3,ifg))
444 
445  IF ( ppatch%bf2v(4,ifg) == vert_none ) THEN ! defensive coding
446 ! TEMPORARY
447  WRITE(*,*) 'ERROR!'
448  stop
449 ! END TEMPORARY
450  END IF ! pPatch%bf2v(4,ifg)
451 
452  v4 = ppatch%bv(ppatch%bf2v(4,ifg))
453  END IF ! iloc
454 
455  x1 = pgrid%xyz(xcoord,v1)
456  x2 = pgrid%xyz(xcoord,v2)
457  x3 = pgrid%xyz(xcoord,v3)
458  x4 = pgrid%xyz(xcoord,v4)
459 
460  y1 = pgrid%xyz(ycoord,v1)
461  y2 = pgrid%xyz(ycoord,v2)
462  y3 = pgrid%xyz(ycoord,v3)
463  y4 = pgrid%xyz(ycoord,v4)
464 
465  z1 = pgrid%xyz(zcoord,v1)
466  z2 = pgrid%xyz(zcoord,v2)
467  z3 = pgrid%xyz(zcoord,v3)
468  z4 = pgrid%xyz(zcoord,v4)
469 
470 ! ******************************************************************************
471 ! Compute geometric terms of parametric patch representation
472 ! ******************************************************************************
473 
474  ax = x1 - x2 - x4 + x3
475  ay = y1 - y2 - y4 + y3
476  az = z1 - z2 - z4 + z3
477 
478  bx = x2 - x1
479  by = y2 - y1
480  bz = z2 - z1
481 
482  cx = x4 - x1
483  cy = y4 - y1
484  cz = z4 - z1
485 
486  dx = x1
487  dy = y1
488  dz = z1
489 
490 ! ******************************************************************************
491 ! Compute closest point on bilinear patch
492 ! ******************************************************************************
493 
494  CALL rflu_blin_findclosestpoint(global,ax,ay,az,bx,by,bz,cx,cy,cz, &
495  dx,dy,dz,xloc,yloc,zloc,u,v,x,y,z)
496 
497 ! ******************************************************************************
498 ! Compute intersection distance (here referred to simply as dot product)
499 ! ******************************************************************************
500 
501  IF ( (u < 0.0_rfreal .OR. u > 1.0_rfreal) .OR. &
502  (v < 0.0_rfreal .OR. v > 1.0_rfreal) ) THEN
503  dotp = crazy_value_int ! Must be large negative number
504  ELSE
505  CALL rflu_blin_computenormal(global,ax,ay,az,bx,by,bz,cx,cy,cz, &
506  dx,dy,dz,u,v,nx,ny,nz)
507 
508  dotp = (x-xloc)*nx + (y-yloc)*ny + (z-zloc)*nz
509  END IF ! u
510 
511 ! ******************************************************************************
512 ! End
513 ! ******************************************************************************
514 
515  CALL deregisterfunction(global)
516 
517 END SUBROUTINE rflu_ict_testfacequadbilinear
518 
519 
520 
521 
522 
523 
524 ! ******************************************************************************
525 !
526 ! Purpose: Determine whether point is inside cell.
527 !
528 ! Description: None.
529 !
530 ! Input:
531 ! pRegion Pointer to region data
532 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
533 ! icg Global cell index
534 !
535 ! Output:
536 ! RFLU_ICT_TestInCell = .TRUE. if point inside cell
537 ! RFLU_ICT_TestInCell = .FALSE. if point outside cell
538 !
539 ! Notes:
540 ! 1. Return from this routine early if detect negative dot product.
541 !
542 ! ******************************************************************************
543 
544 LOGICAL FUNCTION rflu_ict_testincell(pRegion,xLoc,yLoc,zLoc,icg)
545 
546  IMPLICIT NONE
547 
548 ! ******************************************************************************
549 ! Declarations and definitions
550 ! ******************************************************************************
551 
552 ! ==============================================================================
553 ! Arguments
554 ! ==============================================================================
555 
556  INTEGER, INTENT(IN) :: icg
557  REAL(RFREAL), INTENT(IN) :: xloc,yloc,zloc
558  TYPE(t_region), POINTER :: pregion
559 
560 ! ==============================================================================
561 ! Locals
562 ! ==============================================================================
563 
564  INTEGER :: cntr,icl,ict,ifg,ifl,ipatch,nfaces,v4
565  REAL(RFREAL) :: dotp,toler
566  TYPE(t_global), POINTER :: global
567  TYPE(t_grid), POINTER :: pgrid
568  TYPE(t_patch), POINTER :: ppatch
569 
570 ! ******************************************************************************
571 ! Start
572 ! ******************************************************************************
573 
574  global => pregion%global
575 
576  CALL registerfunction(global,'RFLU_ICT_TestInCell',&
577  'RFLU_ModInCellTest.F90')
578 
579 ! ==============================================================================
580 ! Set grid pointer and initialize
581 ! ==============================================================================
582 
583  pgrid => pregion%grid
584 
585  rflu_ict_testincell = .false.
586 
587  toler = -pregion%mixtInput%tolerICT
588 
589 ! ******************************************************************************
590 ! Check whether point is inside cell
591 ! ******************************************************************************
592 
593  ict = pgrid%cellGlob2Loc(1,icg) ! cell type
594  icl = pgrid%cellGlob2Loc(2,icg) ! local cell index
595 
596  cntr = 0
597 
598  SELECT CASE ( ict )
599 
600 ! ==============================================================================
601 ! Tetrahedron
602 ! ==============================================================================
603 
604  CASE ( cell_type_tet )
605  nfaces = 4
606 
607  DO ifl = 1,nfaces
608  ipatch = pgrid%tet2f(1,ifl,icl)
609  ifg = pgrid%tet2f(2,ifl,icl)
610 
611  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg,dotp)
612 
613  IF ( dotp >= toler ) THEN
614  cntr = cntr + 1
615  ELSE
616  CALL deregisterfunction(global)
617  RETURN
618  END IF ! dotp
619  END DO ! ifc
620 
621 ! ==============================================================================
622 ! Hexahedron
623 ! ==============================================================================
624 
625  CASE ( cell_type_hex )
626  nfaces = 6
627 
628  DO ifl = 1,nfaces
629  ipatch = pgrid%hex2f(1,ifl,icl)
630  ifg = pgrid%hex2f(2,ifl,icl)
631 
632 ! TEMPORARY
633  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg,dotp)
634 ! CALL RFLU_ICT_TestFaceQuadBilinear(pRegion,xLoc,yLoc,zLoc,iPatch,ifg, &
635 ! dotp)
636 ! END TEMPORARY
637 
638  IF ( dotp > toler ) THEN
639  cntr = cntr + 1
640  ELSE
641  CALL deregisterfunction(global)
642  RETURN
643  END IF ! dotp
644  END DO ! ifc
645 
646 ! ==============================================================================
647 ! Prism
648 ! ==============================================================================
649 
650  CASE ( cell_type_pri )
651  nfaces = 5
652 
653  DO ifl = 1,nfaces
654  ipatch = pgrid%pri2f(1,ifl,icl)
655  ifg = pgrid%pri2f(2,ifl,icl)
656 
657  IF ( ipatch == 0 ) THEN
658  v4 = pgrid%f2v(4,ifg)
659  ELSE IF ( ipatch > 0 ) THEN
660  ppatch => pregion%patches(ipatch)
661 
662  v4 = ppatch%bf2v(4,ifg)
663  ELSE
664  CALL errorstop(global,err_reached_default,__line__)
665  END IF ! iPatch
666 
667  IF ( v4 == vert_none ) THEN
668  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg, &
669  dotp)
670  ELSE
671 ! TEMPORARY
672  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg, &
673  dotp)
674 ! CALL RFLU_ICT_TestFaceQuadBilinear(pRegion,xLoc,yLoc,zLoc,iPatch, &
675 ! ifg,dotp)
676 ! END TEMPORARY
677  END IF ! v4
678 
679  IF ( dotp > toler ) THEN
680  cntr = cntr + 1
681  ELSE
682  CALL deregisterfunction(global)
683  RETURN
684  END IF ! dotp
685  END DO ! ifc
686 
687 ! ==============================================================================
688 ! Pyramid
689 ! ==============================================================================
690 
691  CASE ( cell_type_pyr )
692  nfaces = 5
693 
694  DO ifl = 1,nfaces
695  ipatch = pgrid%pyr2f(1,ifl,icl)
696  ifg = pgrid%pyr2f(2,ifl,icl)
697 
698  IF ( ipatch == 0 ) THEN
699  v4 = pgrid%f2v(4,ifg)
700  ELSE IF ( ipatch > 0 ) THEN
701  ppatch => pregion%patches(ipatch)
702 
703  v4 = ppatch%bf2v(4,ifg)
704  ELSE
705  CALL errorstop(global,err_reached_default,__line__)
706  END IF ! iPatch
707 
708  IF ( v4 == vert_none ) THEN
709  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg, &
710  dotp)
711  ELSE
712 ! TEMPORARY
713  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg, &
714  dotp)
715 ! CALL RFLU_ICT_TestFaceQuadBilinear(pRegion,xLoc,yLoc,zLoc,iPatch, &
716 ! ifg,dotp)
717 ! END TEMPORARY
718  END IF ! v4
719 
720  IF ( dotp > toler ) THEN
721  cntr = cntr + 1
722  ELSE
723  CALL deregisterfunction(global)
724  RETURN
725  END IF ! dotp
726  END DO ! ifc
727 
728 ! ==============================================================================
729 ! Default
730 ! ==============================================================================
731 
732  CASE default
733  CALL errorstop(global,err_reached_default,__line__)
734  END SELECT ! ict
735 
736 ! ==============================================================================
737 ! Set RFLU_ICT_TestInCell to TRUE if have nFaces positive dot products
738 ! ==============================================================================
739 
740  IF ( cntr == nfaces ) THEN
741  rflu_ict_testincell = .true.
742  END IF ! cntr
743 
744 ! ******************************************************************************
745 ! End
746 ! ******************************************************************************
747 
748  CALL deregisterfunction(global)
749 
750 END FUNCTION rflu_ict_testincell
751 
752 
753 
754 
755 
756 
757 
758 ! *****************************************************************************
759 !
760 ! Purpose: Determine whether point is inside cell and return information about
761 ! which face which might have lead to failure.
762 !
763 ! Description: None.
764 !
765 ! Input:
766 ! pRegion Pointer to region data
767 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
768 ! icg Global cell index
769 !
770 ! Output:
771 ! testInCell True if location in cell, false otherwise
772 ! iPatchOut Patch index of face which failed test
773 ! ifgOut Global index of face which failed test
774 !
775 ! Notes:
776 ! 1. Return from this routine early if detect negative dot product.
777 !
778 ! *****************************************************************************
779 
780 SUBROUTINE rflu_ict_testincellfancy(pRegion,xLoc,yLoc,zLoc,icg,testInCell, &
781  ipatchout,ifgout)
782 
783  IMPLICIT NONE
784 
785 ! *****************************************************************************
786 ! Declarations and definitions
787 ! *****************************************************************************
788 
789 ! =============================================================================
790 ! Arguments
791 ! =============================================================================
792 
793  LOGICAL, INTENT(OUT) :: testincell
794  INTEGER, INTENT(IN) :: icg
795  INTEGER, INTENT(OUT) :: ipatchout,ifgout
796  REAL(RFREAL), INTENT(IN) :: xloc,yloc,zloc
797  TYPE(t_region), POINTER :: pregion
798 
799 ! =============================================================================
800 ! Locals
801 ! =============================================================================
802 
803  INTEGER :: cntr,icl,ict,ifg,ifl,ipatch,nfaces
804  REAL(RFREAL) :: dotp,toler
805  TYPE(t_global), POINTER :: global
806  TYPE(t_grid), POINTER :: pgrid
807 
808 ! *****************************************************************************
809 ! Start
810 ! *****************************************************************************
811 
812  global => pregion%global
813 
814  CALL registerfunction(global,'RFLU_ICT_TestInCellFancy',&
815  'RFLU_ModInCellTest.F90')
816 
817 ! =============================================================================
818 ! Set grid pointer and initialize
819 ! =============================================================================
820 
821  pgrid => pregion%grid
822 
823  testincell = .false.
824 
825  toler = -pregion%mixtInput%tolerICT
826 
827 ! *****************************************************************************
828 ! Check whether point is inside cell
829 ! *****************************************************************************
830 
831  ict = pgrid%cellGlob2Loc(1,icg) ! cell type
832  icl = pgrid%cellGlob2Loc(2,icg) ! local cell index
833 
834  cntr = 0
835 
836  SELECT CASE ( ict )
837  CASE ( cell_type_tet )
838  nfaces = 4
839 
840  DO ifl = 1,nfaces
841  ipatch = pgrid%tet2f(1,ifl,icl)
842  ifg = pgrid%tet2f(2,ifl,icl)
843 
844  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg,dotp)
845 
846  IF ( dotp > toler ) THEN
847  cntr = cntr + 1
848  ELSE
849  ipatchout = ipatch
850  ifgout = ifg
851 
852  CALL deregisterfunction(global)
853  RETURN
854  END IF ! dotp
855  END DO ! ifl
856  CASE ( cell_type_hex )
857  nfaces = 6
858 
859  DO ifl = 1,nfaces
860  ipatch = pgrid%hex2f(1,ifl,icl)
861  ifg = pgrid%hex2f(2,ifl,icl)
862 
863  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg,dotp)
864 
865  IF ( dotp > toler ) THEN
866  cntr = cntr + 1
867  ELSE
868  ipatchout = ipatch
869  ifgout = ifg
870 
871  CALL deregisterfunction(global)
872  RETURN
873  END IF ! dotp
874  END DO ! ifl
875  CASE ( cell_type_pri )
876  nfaces = 5
877 
878  DO ifl = 1,nfaces
879  ipatch = pgrid%pri2f(1,ifl,icl)
880  ifg = pgrid%pri2f(2,ifl,icl)
881 
882  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg,dotp)
883 
884  IF ( dotp > toler ) THEN
885  cntr = cntr + 1
886  ELSE
887  ipatchout = ipatch
888  ifgout = ifg
889 
890  CALL deregisterfunction(global)
891  RETURN
892  END IF ! dotp
893  END DO ! ifl
894  CASE ( cell_type_pyr )
895  nfaces = 5
896 
897  DO ifl = 1,nfaces
898  ipatch = pgrid%pyr2f(1,ifl,icl)
899  ifg = pgrid%pyr2f(2,ifl,icl)
900 
901  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg,dotp)
902 
903  IF ( dotp > toler ) THEN
904  cntr = cntr + 1
905  ELSE
906  ipatchout = ipatch
907  ifgout = ifg
908 
909  CALL deregisterfunction(global)
910  RETURN
911  END IF ! dotp
912  END DO ! ifl
913  CASE default
914  CALL errorstop(global,err_reached_default,__line__)
915  END SELECT
916 
917 ! =============================================================================
918 ! Set testInCell to TRUE if have nFaces positive dot products
919 ! =============================================================================
920 
921  IF ( cntr == nfaces ) THEN
922  testincell = .true.
923 
924  ipatchout = crazy_value_int
925  ifgout = crazy_value_int
926  END IF ! cntr
927 
928 ! *****************************************************************************
929 ! End
930 ! *****************************************************************************
931 
932  CALL deregisterfunction(global)
933 
934 END SUBROUTINE rflu_ict_testincellfancy
935 
936 
937 
938 
939 
940 
941 
942 ! ******************************************************************************
943 !
944 ! Purpose: Determine whether point is inside cell and return information about
945 ! which face failed the most, so to speak.
946 !
947 ! Description: None.
948 !
949 ! Input:
950 ! pRegion Pointer to region data
951 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
952 ! icg Global cell index
953 !
954 ! Output:
955 ! testInCell True if location in cell, false otherwise
956 ! ilocOut Location of face which failed test
957 ! ifgOut Global index of face which failed test
958 !
959 ! Notes:
960 ! 1. DO NOT return from this routine early if detect negative dot product.
961 ! 2. See R. Lohner and J. Ambrosiano, A Vectorized Particle Tracer for
962 ! Unstructured Grids, J. Comp. Phys., Vol. 91, pp. 22-31, 1990.
963 !
964 ! ******************************************************************************
965 
966 SUBROUTINE rflu_ict_testincelllohner(pRegion,xLoc,yLoc,zLoc,icg,testInCell, &
967  ipatchout,ifgout)
968 
969  IMPLICIT NONE
970 
971 ! ******************************************************************************
972 ! Declarations and definitions
973 ! ******************************************************************************
974 
975 ! ==============================================================================
976 ! Arguments
977 ! ==============================================================================
978 
979  LOGICAL, INTENT(OUT) :: testincell
980  INTEGER, INTENT(IN) :: icg
981  INTEGER, INTENT(OUT) :: ipatchout,ifgout
982  REAL(RFREAL), INTENT(IN) :: xloc,yloc,zloc
983  TYPE(t_region), POINTER :: pregion
984 
985 ! ==============================================================================
986 ! Locals
987 ! ==============================================================================
988 
989  INTEGER :: cntr,icl,ict,ifg,ifl,ipatch,nfaces
990  INTEGER, DIMENSION(1) :: idotpmin
991  INTEGER, DIMENSION(:,:), POINTER :: pc2f
992  REAL(RFREAL) :: toler
993  REAL(RFREAL), DIMENSION(6) :: dotp
994  TYPE(t_global), POINTER :: global
995  TYPE(t_grid), POINTER :: pgrid
996 
997 ! ******************************************************************************
998 ! Start
999 ! ******************************************************************************
1000 
1001  global => pregion%global
1002 
1003  CALL registerfunction(global,'RFLU_ICT_TestInCellLohner',&
1004  'RFLU_ModInCellTest.F90')
1005 
1006 ! ==============================================================================
1007 ! Set pointer and initialize
1008 ! ==============================================================================
1009 
1010  pgrid => pregion%grid
1011 
1012  testincell = .false.
1013 
1014  toler = -pregion%mixtInput%tolerICT
1015 
1016 ! ******************************************************************************
1017 ! Select cell type and set pointer to cell-to-face connectivity array
1018 ! ******************************************************************************
1019 
1020  ict = pgrid%cellGlob2Loc(1,icg) ! cell type
1021  icl = pgrid%cellGlob2Loc(2,icg) ! local cell index
1022 
1023  SELECT CASE ( ict )
1024  CASE ( cell_type_tet )
1025  pc2f => pgrid%tet2f(:,:,icl)
1026  CASE ( cell_type_hex )
1027  pc2f => pgrid%hex2f(:,:,icl)
1028  CASE ( cell_type_pri )
1029  pc2f => pgrid%pri2f(:,:,icl)
1030  CASE ( cell_type_pyr )
1031  pc2f => pgrid%pyr2f(:,:,icl)
1032  CASE default
1033  CALL errorstop(global,err_reached_default,__line__)
1034  END SELECT ! ict
1035 
1036  nfaces = SIZE(pc2f,2)
1037 
1038 ! ******************************************************************************
1039 ! Check whether point is inside cell
1040 ! ******************************************************************************
1041 
1042  cntr = 0
1043 
1044 ! ==============================================================================
1045 ! Loop over faces of cell. NOTE need to initialize dotp for non-existent faces.
1046 ! ==============================================================================
1047 
1048  DO ifl = 1,nfaces
1049  ipatch = pc2f(1,ifl)
1050  ifg = pc2f(2,ifl)
1051 
1052  CALL rflu_ict_testfaceplanar(pregion,xloc,yloc,zloc,icg,ipatch,ifg, &
1053  dotp(ifl))
1054 
1055  IF ( dotp(ifl) > toler ) THEN
1056  cntr = cntr + 1
1057  END IF ! dotp
1058  END DO ! ifl
1059 
1060  IF ( nfaces < 6 ) THEN
1061  DO ifl = nfaces+1,6
1062  dotp(ifl) = huge(1.0_rfreal)
1063  END DO ! ifl
1064  END IF ! nFaces
1065 
1066 ! ==============================================================================
1067 ! Set testInCell to TRUE if have nFaces positive dot products
1068 ! ==============================================================================
1069 
1070  IF ( cntr == nfaces ) THEN
1071  testincell = .true.
1072 
1073  ipatchout = crazy_value_int
1074  ifgout = crazy_value_int
1075  ELSE
1076  idotpmin = minloc(dotp(:))
1077 
1078  ipatchout = pc2f(1,idotpmin(1))
1079  ifgout = pc2f(2,idotpmin(1))
1080  END IF ! cntr
1081 
1082 ! ******************************************************************************
1083 ! End
1084 ! ******************************************************************************
1085 
1086  CALL deregisterfunction(global)
1087 
1088 END SUBROUTINE rflu_ict_testincelllohner
1089 
1090 
1091 
1092 
1093 
1094 ! ******************************************************************************
1095 ! End
1096 ! ******************************************************************************
1097 
1098 END MODULE rflu_modincelltest
1099 
1100 
1101 ! ******************************************************************************
1102 !
1103 ! RCS Revision history:
1104 !
1105 ! $Log: RFLU_ModInCellTest.F90,v $
1106 ! Revision 1.4 2008/12/06 08:44:22 mtcampbe
1107 ! Updated license.
1108 !
1109 ! Revision 1.3 2008/11/19 22:17:33 mtcampbe
1110 ! Added Illinois Open Source License/Copyright
1111 !
1112 ! Revision 1.2 2006/04/07 15:19:19 haselbac
1113 ! Removed tabs
1114 !
1115 ! Revision 1.1 2005/12/24 21:17:50 haselbac
1116 ! Initial revision
1117 !
1118 ! ******************************************************************************
1119 
1120 
1121 
1122 
1123 
1124 
1125 
1126 
1127 
1128 
1129 
1130 
1131 
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
subroutine, public rflu_blin_computenormal(global, ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz, u, v, nx, ny, nz)
subroutine, public rflu_ict_testfacequadbilinear(pRegion, xLoc, yLoc, zLoc, iPatch, ifg, dotp)
void int int REAL REAL * y
Definition: read.cpp:74
subroutine, public rflu_ict_testincellfancy(pRegion, xLoc, yLoc, zLoc, icg, testInCell, iPatchOut, ifgOut)
NT dx
subroutine, public rflu_ict_testincelllohner(pRegion, xLoc, yLoc, zLoc, icg, testInCell, iPatchOut, ifgOut)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
*********************************************************************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_ict_computetolerance(pRegion)
void int int int REAL REAL REAL * z
Definition: write.cpp:76
IndexType nfaces() const
Definition: Mesh.H:641
void int int REAL * x
Definition: read.cpp:74
LOGICAL function, public rflu_ict_testincell(pRegion, xLoc, yLoc, zLoc, icg)
subroutine, public rflu_blin_findclosestpoint(global, ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz, xq, yq, zq, u, v, x, y, z)
subroutine, public rflu_ict_testfaceplanar(pRegion, xLoc, yLoc, zLoc, icg, iPatch, ifg, dotp)
RT dz() const
Definition: Direction_3.h:133
NT dy
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469