Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModGeometryTools.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 geometry tools.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModGeometryTools.F90,v 1.5 2008/12/06 08:44:22 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2005-2007 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 modbndpatch, ONLY: t_patch
46  USE moddatastruct, ONLY: t_region
47  USE modgrid, ONLY: t_grid
48  USE modmpi
49 
50  IMPLICIT NONE
51 
52  PRIVATE
53  PUBLIC :: rflu_computelinecellxsectfast, &
57 
58 ! ******************************************************************************
59 ! Declarations and definitions
60 ! ******************************************************************************
61 
62  CHARACTER(CHRLEN), PRIVATE :: &
63  RCSIdentString = '$RCSfile: RFLU_ModGeometryTools.F90,v $ $Revision: 1.5 $'
64 
65 ! ******************************************************************************
66 ! Routines
67 ! ******************************************************************************
68 
69  CONTAINS
70 
71 
72 
73 
74 
75 ! ******************************************************************************
76 !
77 ! Purpose: Compute intersection of given line vector and faces of given cell
78 ! and distance between given location and intersection using fast algorithm.
79 !
80 ! Description: None.
81 !
82 ! Input:
83 ! pRegion Pointer to region data
84 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
85 ! ex,ey,ez x-, y-, and z-components of unit line vector
86 ! icg Global cell index
87 !
88 ! Output:
89 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of intersection
90 ! distOut Distance from location to intersection
91 ! iPatchOut Face location
92 ! ifgOut Face index
93 !
94 ! Notes:
95 ! 1. The line vector MUST be a unit line vector. If that is not correct, the
96 ! distance between the given point and the intersection of the line with
97 ! the faces of the given cell will not be computed correctly.
98 ! 2. Distance might be zero if vertices lie on path, so need to include this
99 ! case in IF statement on dist after calls to routine which computes the
100 ! distance.
101 ! 3. This is called a fast algorithm because it CANNOT detect and correct
102 ! inconsistent input data, which makes it faster than the safe version.
103 !
104 ! ******************************************************************************
105 
106 SUBROUTINE rflu_computelinecellxsectfast(pRegion,xLoc,yLoc,zLoc,ex,ey,ez,icg, &
107  distout,ipatchout,ifgout)
108 
110 
111  IMPLICIT NONE
112 
113 ! ******************************************************************************
114 ! Declarations and definitions
115 ! ******************************************************************************
116 
117 ! ==============================================================================
118 ! Arguments
119 ! ==============================================================================
120 
121  INTEGER, INTENT(IN) :: icg
122  INTEGER, INTENT(OUT) :: ifgout,ipatchout
123  REAL(RFREAL), INTENT(IN) :: ex,ey,ez
124  REAL(RFREAL), INTENT(INOUT) :: xloc,yloc,zloc
125  REAL(RFREAL), INTENT(OUT) :: distout
126  TYPE(t_region), POINTER :: pregion
127 
128 ! ==============================================================================
129 ! Locals
130 ! ==============================================================================
131 
132  INTEGER :: c1,c2,icl,ict,ifl,iflout,ifg,ipatch,nfaces,nxsect
133  INTEGER, DIMENSION(:,:), POINTER :: pc2f
134  REAL(RFREAL) :: denom,dist,fnx,fny,fnz,numer,toler,xcofg,ycofg,zcofg
135  REAL(RFREAL), DIMENSION(2) :: xsd
136  TYPE(t_global), POINTER :: global
137  TYPE(t_grid), POINTER :: pgrid
138  TYPE(t_patch), POINTER :: ppatch
139 
140 ! ******************************************************************************
141 ! Start
142 ! ******************************************************************************
143 
144  global => pregion%global
145 
146  CALL registerfunction(global,'RFLU_ComputeLineCellXSectFast',&
147  'RFLU_ModGeometryTools.F90')
148 
149 ! ==============================================================================
150 ! Set grid pointer and initialize variables
151 ! ==============================================================================
152 
153  pgrid => pregion%grid
154 
155  toler = -pregion%mixtInput%tolerICT ! Must be consistent with ICT tolerance
156 
157  distout = huge(1.0_rfreal)
158  iflout = crazy_value_int
159 
160 ! ******************************************************************************
161 ! Select cell type and set pointer to cell-to-face connectivity array
162 ! ******************************************************************************
163 
164  ict = pgrid%cellGlob2Loc(1,icg) ! cell type
165  icl = pgrid%cellGlob2Loc(2,icg) ! local cell index
166 
167  SELECT CASE ( ict )
168  CASE ( cell_type_tet )
169  pc2f => pgrid%tet2f(:,:,icl)
170  CASE ( cell_type_hex )
171  pc2f => pgrid%hex2f(:,:,icl)
172  CASE ( cell_type_pri )
173  pc2f => pgrid%pri2f(:,:,icl)
174  CASE ( cell_type_pyr )
175  pc2f => pgrid%pyr2f(:,:,icl)
176  CASE default
177  CALL errorstop(global,err_reached_default,__line__)
178  END SELECT ! ict
179 
180  nfaces = SIZE(pc2f,2)
181 
182 ! ******************************************************************************
183 ! Loop over faces of cell
184 ! ******************************************************************************
185 
186  DO ifl = 1,nfaces
187  ipatch = pc2f(1,ifl)
188  ifg = pc2f(2,ifl)
189 
190 ! ==============================================================================
191 ! Interior face
192 ! ==============================================================================
193 
194  IF ( ipatch == 0 ) THEN
195 
196 ! ------------------------------------------------------------------------------
197 ! Triangular face
198 ! ------------------------------------------------------------------------------
199 
200 ! TEMPORARY
201 ! IF ( pGrid%f2v(4,ifg) == VERT_NONE ) THEN
202 ! END TEMPORARY
203  c1 = pgrid%f2c(1,ifg)
204  c2 = pgrid%f2c(2,ifg)
205 
206  IF ( c1 == icg ) THEN
207  fnx = pgrid%fn(xcoord,ifg)
208  fny = pgrid%fn(ycoord,ifg)
209  fnz = pgrid%fn(zcoord,ifg)
210  ELSE IF ( c2 == icg ) THEN
211  fnx = -pgrid%fn(xcoord,ifg)
212  fny = -pgrid%fn(ycoord,ifg)
213  fnz = -pgrid%fn(zcoord,ifg)
214  ELSE ! defensive programming
215  CALL errorstop(global,err_reached_default,__line__)
216  END IF ! c1
217 
218  denom = ex*fnx + ey*fny + ez*fnz
219 
220  IF ( denom > 0.0_rfreal ) THEN
221  xcofg = pgrid%fc(xcoord,ifg)
222  ycofg = pgrid%fc(ycoord,ifg)
223  zcofg = pgrid%fc(zcoord,ifg)
224 
225  numer = (xcofg-xloc)*fnx + (ycofg-yloc)*fny + (zcofg-zloc)*fnz
226  numer = max(numer,0.0_rfreal)
227 
228  dist = numer/denom
229 
230  IF ( dist < distout ) THEN
231  distout = dist
232  iflout = ifl
233  END IF ! dist
234  END IF ! denom
235 
236 ! ------------------------------------------------------------------------------
237 ! Quadrilateral face
238 ! ------------------------------------------------------------------------------
239 
240 ! TEMPORARY
241 ! ELSE
242 ! CALL RFLU_BLIN_ComputeXSectLine(pRegion,xLoc,yLoc,zLoc,ex,ey,ez,icg, &
243 ! iPatch,ifg,nXSect,xsd)
244 !
245 ! IF ( nXSect > 0 ) THEN
246 ! dist = xsd(1)
247 !
248 ! IF ( dist < distOut ) THEN
249 ! distOut = dist
250 ! iflOut = ifl
251 ! END IF ! dist
252 ! END IF ! nXSect
253 ! END IF ! pGrid%f2v
254 ! END TEMPORARY
255 
256 ! ==============================================================================
257 ! Boundary face
258 ! ==============================================================================
259 
260  ELSE IF ( ipatch > 0 ) THEN
261  ppatch => pregion%patches(ipatch)
262 
263 ! ------------------------------------------------------------------------------
264 ! Triangular face
265 ! ------------------------------------------------------------------------------
266 
267 ! TEMPORARY
268 ! IF ( pPatch%bf2v(4,ifg) == VERT_NONE ) THEN
269 ! END TEMPORARY
270  fnx = ppatch%fn(xcoord,ifg)
271  fny = ppatch%fn(ycoord,ifg)
272  fnz = ppatch%fn(zcoord,ifg)
273 
274  denom = ex*fnx + ey*fny + ez*fnz
275 
276  IF ( denom > 0.0_rfreal ) THEN
277  xcofg = ppatch%fc(xcoord,ifg)
278  ycofg = ppatch%fc(ycoord,ifg)
279  zcofg = ppatch%fc(zcoord,ifg)
280 
281  numer = (xcofg-xloc)*fnx + (ycofg-yloc)*fny + (zcofg-zloc)*fnz
282  numer = max(numer,0.0_rfreal)
283 
284  dist = numer/denom
285 
286  IF ( dist < distout ) THEN
287  distout = dist
288  iflout = ifl
289  END IF ! dist
290  END IF ! denom
291 
292 ! ------------------------------------------------------------------------------
293 ! Quadrilateral face
294 ! ------------------------------------------------------------------------------
295 
296 ! TEMPORARY
297 ! ELSE
298 ! CALL RFLU_BLIN_ComputeXSectLine(pRegion,xLoc,yLoc,zLoc,ex,ey,ez,icg, &
299 ! iPatch,ifg,nXSect,xsd)
300 !
301 ! IF ( nXSect > 0 ) THEN
302 ! dist = xsd(1)
303 !
304 ! IF ( dist < distOut ) THEN
305 ! distOut = dist
306 ! iflOut = ifl
307 ! END IF ! dist
308 ! END IF ! nXSect
309 ! END IF ! pPatch%bf2v
310 ! END TEMPORARY
311 
312 ! ==============================================================================
313 ! Default
314 ! ==============================================================================
315 
316  ELSE ! Defensive programming
317  CALL errorstop(global,err_reached_default,__line__)
318  END IF ! iPatch
319  END DO ! ifl
320 
321 ! ******************************************************************************
322 ! Set output
323 ! ******************************************************************************
324 
325  ipatchout = pc2f(1,iflout)
326  ifgout = pc2f(2,iflout)
327 
328  xloc = xloc + distout*ex
329  yloc = yloc + distout*ey
330  zloc = zloc + distout*ez
331 
332 ! ******************************************************************************
333 ! End
334 ! ******************************************************************************
335 
336  CALL deregisterfunction(global)
337 
338 END SUBROUTINE rflu_computelinecellxsectfast
339 
340 
341 
342 
343 
344 
345 
346 
347 ! ******************************************************************************
348 !
349 ! Purpose: Compute intersection of given line vector and faces of given cell
350 ! and distance between given location and intersection using safe algorithm.
351 !
352 ! Description: None.
353 !
354 ! Input:
355 ! pRegion Pointer to region data
356 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
357 ! ex,ey,ez x-, y-, and z-components of unit line vector
358 ! icg Global cell index
359 !
360 ! Output:
361 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of intersection
362 ! distOut Distance from location to intersection
363 ! iPatchOut Face location
364 ! ifgOut Face index
365 !
366 ! Notes:
367 ! 1. The line vector MUST be a unit line vector. If that is not correct, the
368 ! distance between the given point and the intersection of the line with
369 ! the faces of the given cell will not be computed correctly.
370 ! 2. Distance might be zero if vertices lie on path, so need to include this
371 ! case in IF statement on dist after calls to routine which computes the
372 ! distance.
373 ! 3. This is called a safe algorithm because it can detect and correct
374 ! inconsistent input data.
375 !
376 ! ******************************************************************************
377 
378 SUBROUTINE rflu_computelinecellxsectsafe(pRegion,xLoc,yLoc,zLoc,ex,ey,ez,icg, &
379  distout,ipatchout,ifgout)
380 
382 
383  IMPLICIT NONE
384 
385 ! ******************************************************************************
386 ! Declarations and definitions
387 ! ******************************************************************************
388 
389 ! ==============================================================================
390 ! Arguments
391 ! ==============================================================================
392 
393  INTEGER, INTENT(IN) :: icg
394  INTEGER, INTENT(OUT) :: ifgout,ipatchout
395  REAL(RFREAL), INTENT(IN) :: ex,ey,ez
396  REAL(RFREAL), INTENT(INOUT) :: xloc,yloc,zloc
397  REAL(RFREAL), INTENT(OUT) :: distout
398  TYPE(t_region), POINTER :: pregion
399 
400 ! ==============================================================================
401 ! Locals
402 ! ==============================================================================
403 
404  INTEGER :: c1,c2,errorflag,icl,ict,ifl,iflout,iflout1,iflout2,ifg,ipatch, &
405  nfaces,nxsect
406  INTEGER, DIMENSION(:,:), POINTER :: pc2f
407  REAL(RFREAL) :: distout1,distout2,fnx,fny,fnz,toler,xcofg,ycofg,zcofg
408  REAL(RFREAL), DIMENSION(2) :: xsd
409  REAL(RFREAL), DIMENSION(6) :: denom,numer
410  TYPE(t_global), POINTER :: global
411  TYPE(t_grid), POINTER :: pgrid
412  TYPE(t_patch), POINTER :: ppatch
413 
414 ! ******************************************************************************
415 ! Start
416 ! ******************************************************************************
417 
418  global => pregion%global
419 
420  CALL registerfunction(global,'RFLU_ComputeLineCellXSectSafe',&
421  'RFLU_ModGeometryTools.F90')
422 
423 ! ==============================================================================
424 ! Set grid pointer and initialize variables
425 ! ==============================================================================
426 
427  pgrid => pregion%grid
428 
429  toler = -pregion%mixtInput%tolerICT ! Must be consistent with ICT tolerance
430 
431 ! ******************************************************************************
432 ! Select cell type and set pointer to cell-to-face connectivity array
433 ! ******************************************************************************
434 
435  ict = pgrid%cellGlob2Loc(1,icg) ! cell type
436  icl = pgrid%cellGlob2Loc(2,icg) ! local cell index
437 
438  SELECT CASE ( ict )
439  CASE ( cell_type_tet )
440  pc2f => pgrid%tet2f(:,:,icl)
441  CASE ( cell_type_hex )
442  pc2f => pgrid%hex2f(:,:,icl)
443  CASE ( cell_type_pri )
444  pc2f => pgrid%pri2f(:,:,icl)
445  CASE ( cell_type_pyr )
446  pc2f => pgrid%pyr2f(:,:,icl)
447  CASE default
448  CALL errorstop(global,err_reached_default,__line__)
449  END SELECT ! ict
450 
451  nfaces = SIZE(pc2f,2)
452 
453 ! DEBUG
454 ! WRITE(0,*) '@@@100',pRegion%iRegionGlobal,'xsect with cell:',icg,ict,icl
455 ! END DEBUG
456 
457 ! ******************************************************************************
458 ! Loop over faces of cell
459 ! ******************************************************************************
460 
461  DO ifl = 1,nfaces
462  ipatch = pc2f(1,ifl)
463  ifg = pc2f(2,ifl)
464 
465 ! DEBUG
466 ! WRITE(0,*) '@@@200',pRegion%iRegionGlobal,'Comp xsect with face:',iPatch,ifg
467 ! IF ( iPatch == 0 ) THEN
468 ! WRITE(0,*) '@@@210',pRegion%iRegionGlobal,pGrid%fn(1:3,ifg)
469 ! ELSE
470 ! pPatch => pRegion%patches(iPatch)
471 ! WRITE(0,*) '@@@211',pPatch%fn(1:3,ifg)
472 ! END IF ! iPatch
473 ! END DEBUG
474 
475 ! ==============================================================================
476 ! Interior face
477 ! ==============================================================================
478 
479  IF ( ipatch == 0 ) THEN
480 
481 ! ------------------------------------------------------------------------------
482 ! Triangular face
483 ! ------------------------------------------------------------------------------
484 
485 ! TEMPORARY
486 ! IF ( pGrid%f2v(4,ifg) == VERT_NONE ) THEN
487 ! END TEMPORARY
488  c1 = pgrid%f2c(1,ifg)
489  c2 = pgrid%f2c(2,ifg)
490 
491  IF ( c1 == icg ) THEN
492  fnx = pgrid%fn(xcoord,ifg)
493  fny = pgrid%fn(ycoord,ifg)
494  fnz = pgrid%fn(zcoord,ifg)
495  ELSE IF ( c2 == icg ) THEN
496  fnx = -pgrid%fn(xcoord,ifg)
497  fny = -pgrid%fn(ycoord,ifg)
498  fnz = -pgrid%fn(zcoord,ifg)
499  ELSE ! defensive programming
500  CALL errorstop(global,err_reached_default,__line__)
501  END IF ! c1
502 
503  xcofg = pgrid%fc(xcoord,ifg)
504  ycofg = pgrid%fc(ycoord,ifg)
505  zcofg = pgrid%fc(zcoord,ifg)
506 
507  numer(ifl) = (xcofg-xloc)*fnx + (ycofg-yloc)*fny + (zcofg-zloc)*fnz
508  denom(ifl) = ex*fnx + ey*fny + ez*fnz
509 
510 ! ------------------------------------------------------------------------------
511 ! Quadrilateral face
512 ! ------------------------------------------------------------------------------
513 
514 ! TEMPORARY
515 ! ELSE
516 ! CALL RFLU_BLIN_ComputeXSectLine(pRegion,xLoc,yLoc,zLoc,ex,ey,ez,icg, &
517 ! iPatch,ifg,nXSect,xsd)
518 !
519 !! DEBUG
520 ! WRITE(0,*) '@@@300',pRegion%iRegionGlobal,'xsect dist:',nXSect,xsd
521 !! END DEBUG
522 !
523 ! IF ( nXSect > 0 ) THEN
524 ! numer(ifl) = xsd(1)
525 ! denom(ifl) = 1.0_RFREAL
526 ! ELSE
527 ! numer(ifl) = HUGE(1.0_RFREAL)
528 ! denom(ifl) = 1.0_RFREAL
529 ! END IF ! nXSect
530 ! END IF ! pGrid%f2v
531 ! END TEMPORARY
532 
533 ! ==============================================================================
534 ! Boundary face
535 ! ==============================================================================
536 
537  ELSE IF ( ipatch > 0 ) THEN
538  ppatch => pregion%patches(ipatch)
539 
540 ! ------------------------------------------------------------------------------
541 ! Triangular face
542 ! ------------------------------------------------------------------------------
543 
544 ! IF ( pPatch%bf2v(4,ifg) == VERT_NONE ) THEN
545  fnx = ppatch%fn(xcoord,ifg)
546  fny = ppatch%fn(ycoord,ifg)
547  fnz = ppatch%fn(zcoord,ifg)
548 
549  xcofg = ppatch%fc(xcoord,ifg)
550  ycofg = ppatch%fc(ycoord,ifg)
551  zcofg = ppatch%fc(zcoord,ifg)
552 
553  numer(ifl) = (xcofg-xloc)*fnx + (ycofg-yloc)*fny + (zcofg-zloc)*fnz
554  denom(ifl) = ex*fnx + ey*fny + ez*fnz
555 
556 ! ------------------------------------------------------------------------------
557 ! Quadrilateral face
558 ! ------------------------------------------------------------------------------
559 
560 ! TEMPORARY
561 ! ELSE
562 ! CALL RFLU_BLIN_ComputeXSectLine(pRegion,xLoc,yLoc,zLoc,ex,ey,ez,icg, &
563 ! iPatch,ifg,nXSect,xsd)
564 !
565 ! IF ( nXSect > 0 ) THEN
566 ! numer(ifl) = xsd(1)
567 ! denom(ifl) = 1.0_RFREAL
568 ! ELSE
569 ! numer(ifl) = HUGE(1.0_RFREAL)
570 ! denom(ifl) = 1.0_RFREAL
571 ! END IF ! nXSect
572 ! END IF ! pPatch%bf2v
573 ! END TEMPORARY
574  ELSE ! Defensive programming
575  CALL errorstop(global,err_reached_default,__line__)
576  END IF ! iPatch
577  END DO ! ifl
578 
579 ! ******************************************************************************
580 ! Set output
581 ! ******************************************************************************
582 
583  errorflag = err_none
584 
585  distout1 = huge(1.0_rfreal)
586  distout2 = huge(1.0_rfreal)
587 
588  iflout1 = crazy_value_int
589  iflout2 = crazy_value_int
590 
591  faceloop: DO ifl = 1,nfaces
592  IF ( numer(ifl) > toler ) THEN ! Inside cell icl
593  IF ( denom(ifl) > 0.0 ) THEN
594  distout = max(numer(ifl),0.0_rfreal)/denom(ifl)
595 
596  IF ( distout < distout1 ) THEN
597  distout2 = distout1
598  iflout2 = iflout1
599 
600  distout1 = distout
601  iflout1 = ifl
602  ELSE IF ( distout < distout2 ) THEN
603  distout2 = distout
604  iflout2 = ifl
605  END IF ! dist
606  END IF ! denom
607  ELSE ! Outside cell icl
608  errorflag = 1
609  distout = 0.0_rfreal
610  iflout = ifl
611 
612  EXIT faceloop
613  END IF ! numer
614  END DO faceloop
615 
616  IF ( errorflag == err_none ) THEN
617  distout = distout1 ! Temporary
618  iflout = iflout1
619  END IF ! errorFlag
620 
621 ! DEBUG
622 ! WRITE(0,*) '@@@400',pRegion%iRegionGlobal,iflOut,distOut
623 ! END DEBUG
624 
625  ipatchout = pc2f(1,iflout)
626  ifgout = pc2f(2,iflout)
627 
628  xloc = xloc + distout*ex
629  yloc = yloc + distout*ey
630  zloc = zloc + distout*ez
631 
632 ! ******************************************************************************
633 ! End
634 ! ******************************************************************************
635 
636  CALL deregisterfunction(global)
637 
638 END SUBROUTINE rflu_computelinecellxsectsafe
639 
640 
641 
642 
643 
644 
645 ! ******************************************************************************
646 !
647 ! Purpose: Determine whether point is inside bounding box.
648 !
649 ! Description:
650 !
651 ! Input:
652 ! global Pointer to global data
653 ! xLoc,yLoc,zLoc x-, y-, and z-coordinates of location in question
654 ! xMin,yMin,zMin Minimum x-, y-, and z-coordinates
655 ! xMax,yMax,zMax Maximum x-, y-, and z-coordinates
656 !
657 ! Output:
658 ! RFLU_TestInBoundingBox = .TRUE. if point inside bounding box
659 ! RFLU_TestInBoundingBox = .FALSE. if point outside bounding box
660 !
661 ! Notes: None.
662 !
663 ! ******************************************************************************
664 
665 LOGICAL FUNCTION rflu_testinboundbox(global,xLoc,yLoc,zLoc,xMin,xMax, &
666  ymin,ymax,zmin,zmax)
667 
668  IMPLICIT NONE
669 
670 ! ******************************************************************************
671 ! Declarations and definitions
672 ! ******************************************************************************
673 
674 ! ==============================================================================
675 ! Arguments
676 ! ==============================================================================
677 
678  REAL(RFREAL), INTENT(IN) :: xloc,xmax,xmin,yloc,ymax,ymin,zloc,zmax,zmin
679  TYPE(t_global), POINTER :: global
680 
681 ! ******************************************************************************
682 ! Start
683 ! ******************************************************************************
684 
685  CALL registerfunction(global,'RFLU_TestInBoundBox',&
686  'RFLU_ModGeometryTools.F90')
687 
688 ! ******************************************************************************
689 ! Determine whether point is in bounding box
690 ! ******************************************************************************
691 
692  rflu_testinboundbox = .true.
693 
694  IF ( (xloc < xmin) .OR. (xloc > xmax) ) THEN
695  rflu_testinboundbox = .false.
696  CALL deregisterfunction(global)
697  RETURN
698  END IF ! xLoc
699 
700  IF ( (yloc < ymin) .OR. (yloc > ymax) ) THEN
701  rflu_testinboundbox = .false.
702  CALL deregisterfunction(global)
703  RETURN
704  END IF ! yLoc
705 
706  IF ( (zloc < zmin) .OR. (zloc > zmax) ) THEN
707  rflu_testinboundbox = .false.
708  CALL deregisterfunction(global)
709  RETURN
710  END IF ! zLoc
711 
712 ! ******************************************************************************
713 ! End
714 ! ******************************************************************************
715 
716  CALL deregisterfunction(global)
717 
718 END FUNCTION rflu_testinboundbox
719 
720 
721 
722 
723 
724 ! ******************************************************************************
725 !
726 ! Purpose: Determine whether vector is aligned with Cartesian coordinate
727 ! direction.
728 !
729 ! Description:
730 !
731 ! Input:
732 ! global Pointer to global data
733 ! dr Vector
734 ! dir Cartesian direction index
735 !
736 ! Output:
737 ! RFLU_TestVectorCartAxisAligned = .TRUE. if dr aligned with Cartesian
738 ! coordinate direction
739 ! RFLU_TestVectorCartAxisAligned = .FALSE. if dr not aligned with Cartesian
740 ! coordinate direction
741 !
742 ! Notes: None.
743 !
744 ! ******************************************************************************
745 
746 LOGICAL FUNCTION rflu_testvectorcartaxisaligned(global,dr,dir)
747 
748  IMPLICIT NONE
749 
750 ! ******************************************************************************
751 ! Declarations and definitions
752 ! ******************************************************************************
753 
754 ! ==============================================================================
755 ! Arguments
756 ! ==============================================================================
757 
758  INTEGER, INTENT(IN) :: dir
759  REAL(RFREAL), INTENT(INOUT) :: dr(xcoord:zcoord)
760  TYPE(t_global), POINTER :: global
761 
762 ! ==============================================================================
763 ! Locals
764 ! ==============================================================================
765 
766  REAL(RFREAL) :: drsum,drtol
767 
768 ! ******************************************************************************
769 ! Start
770 ! ******************************************************************************
771 
772  CALL registerfunction(global,'RFLU_TestVectorCartAxisAligned',&
773  'RFLU_ModGeometryTools.F90')
774 
775 ! ******************************************************************************
776 ! Set tolerance
777 ! ******************************************************************************
778 
779  drtol = 1.0e-12_rfreal
780 
781 ! ******************************************************************************
782 ! Test whether vector aligned
783 ! ******************************************************************************
784 
786 
787  dr(dir) = 0.0_rfreal
788 
789  drsum = abs(dr(xcoord)) + abs(dr(ycoord)) + abs(dr(zcoord))
790 
791  IF ( drsum <= drtol ) THEN
793  END IF ! drSum
794 
795 ! ******************************************************************************
796 ! End
797 ! ******************************************************************************
798 
799  CALL deregisterfunction(global)
800 
802 
803 
804 
805 
806 
807 ! ******************************************************************************
808 ! End
809 ! ******************************************************************************
810 
811 END MODULE rflu_modgeometrytools
812 
813 
814 ! ******************************************************************************
815 !
816 ! RCS Revision history:
817 !
818 ! $Log: RFLU_ModGeometryTools.F90,v $
819 ! Revision 1.5 2008/12/06 08:44:22 mtcampbe
820 ! Updated license.
821 !
822 ! Revision 1.4 2008/11/19 22:17:33 mtcampbe
823 ! Added Illinois Open Source License/Copyright
824 !
825 ! Revision 1.3 2007/03/06 18:06:42 haselbac
826 ! Added function to test for alignment ofvector with Cartesian direction
827 !
828 ! Revision 1.2 2006/04/07 15:19:19 haselbac
829 ! Removed tabs
830 !
831 ! Revision 1.1 2005/12/24 21:17:50 haselbac
832 ! Initial revision
833 !
834 ! ******************************************************************************
835 
836 
837 
838 
839 
840 
841 
842 
843 
844 
845 
subroutine, public rflu_computelinecellxsectsafe(pRegion, xLoc, yLoc, zLoc, ex, ey, ez, icg, distOut, iPatchOut, ifgOut)
double ymin() const
double xmax() const
LOGICAL function, public rflu_testinboundbox(global, xLoc, yLoc, zLoc, xMin, xMax, yMin, yMax, zMin, zMax)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
double xmin() const
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
double zmin() const
subroutine, public rflu_blin_computexsectline(pRegion, xLoc, yLoc, zLoc, ex, ey, ez, icg, iPatch, ifg, nt, t)
LOGICAL function, public rflu_testvectorcartaxisaligned(global, dr, dir)
IndexType nfaces() const
Definition: Mesh.H:641
double zmax() const
double ymax() const
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
vector3d dir(void) const
Definition: vector3d.h:144
long double dist(long double *coord1, long double *coord2, int size)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
CGAL_BEGIN_NAMESPACE void const NT NT NT NT & denom
subroutine, public rflu_computelinecellxsectfast(pRegion, xLoc, yLoc, zLoc, ex, ey, ez, icg, distOut, iPatchOut, ifgOut)