Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModDimensionality.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 two dimensional computations.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModDimensionality.F90,v 1.9 2008/12/06 08:44:21 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2005 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE modglobal, ONLY: t_global
42  USE modparameters
43  USE moddatatypes
44  USE moderror
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_123d_checkgeometrywrapper, &
55 
56 ! ******************************************************************************
57 ! Declarations and definitions
58 ! ******************************************************************************
59 
60  CHARACTER(CHRLEN), PRIVATE :: &
61  RCSIdentString = '$RCSfile: RFLU_ModDimensionality.F90,v $ $Revision: 1.9 $'
62 
63 ! ******************************************************************************
64 ! Routines
65 ! ******************************************************************************
66 
67  CONTAINS
68 
69 
70 
71 
72 
73 
74 ! ******************************************************************************
75 !
76 ! Purpose: Check whether geometry is correct for 1d and 2d runs.
77 !
78 ! Description: None.
79 !
80 ! Input:
81 ! pRegion Pointer to region
82 !
83 ! Output: None.
84 !
85 ! Notes: None.
86 !
87 ! ******************************************************************************
88 
89  SUBROUTINE rflu_123d_checkgeometrywrapper(pRegion)
90 
91  IMPLICIT NONE
92 
93 ! ******************************************************************************
94 ! Declarations and definitions
95 ! ******************************************************************************
96 
97 ! ==============================================================================
98 ! Parameters
99 ! ==============================================================================
100 
101  TYPE(t_region), POINTER :: pregion
102 
103 ! ==============================================================================
104 ! Locals
105 ! ==============================================================================
106 
107  TYPE(t_global), POINTER :: global
108  TYPE(t_grid), POINTER :: pgrid
109 
110 ! ******************************************************************************
111 ! Start
112 ! ******************************************************************************
113 
114  global => pregion%global
115 
116  CALL registerfunction(global,'RFLU_123D_CheckGeometryWrapper',&
117  'RFLU_ModDimensionality.F90')
118 
119 ! ******************************************************************************
120 ! Set pointers and variables
121 ! ******************************************************************************
122 
123  pgrid => pregion%grid
124 
125 ! ******************************************************************************
126 ! Check geometry for 2d runs
127 ! ******************************************************************************
128 
129  SELECT CASE ( pregion%mixtInput%dimens )
130  CASE ( 1 )
131  CALL rflu_123d_checkgeometrykernel(pregion,ycoord)
132  CALL rflu_123d_checkgeometrykernel(pregion,zcoord)
133  CASE ( 2 )
134  CALL rflu_123d_checkgeometrykernel(pregion,zcoord)
135  CASE ( 3 ) ! Defensive coding
136  CASE default
137  CALL errorstop(global,err_reached_default,__line__)
138  END SELECT ! pRegion%mixtInput%dimens
139 
140 ! ******************************************************************************
141 ! End
142 ! ******************************************************************************
143 
144  CALL deregisterfunction(global)
145 
146  END SUBROUTINE rflu_123d_checkgeometrywrapper
147 
148 
149 
150 
151 
152 
153 
154 
155 ! ******************************************************************************
156 !
157 ! Purpose: Check whether geometry is correct for 1d and 2d runs.
158 !
159 ! Description: None.
160 !
161 ! Input:
162 ! pRegion Pointer to region
163 ! dir Coordinate direction
164 !
165 ! Output: None.
166 !
167 ! Notes:
168 ! 1. dir-component of normals MUST be close to machine precision for all
169 ! patches except virtual ones, for which they must be close to unity.
170 !
171 ! ******************************************************************************
172 
173  SUBROUTINE rflu_123d_checkgeometrykernel(pRegion,dir)
174 
175  USE modtools, ONLY: floatequal
176 
177  IMPLICIT NONE
178 
179 ! ******************************************************************************
180 ! Declarations and definitions
181 ! ******************************************************************************
182 
183 ! ==============================================================================
184 ! Parameters
185 ! ==============================================================================
186 
187  INTEGER, INTENT(IN) :: dir
188  TYPE(t_region), POINTER :: pregion
189 
190 ! ==============================================================================
191 ! Locals
192 ! ==============================================================================
193 
194  INTEGER :: ipatch
195  REAL(RFREAL) :: ndmax,nxmax,ndmin,nxmin,ntol
196  TYPE(t_grid), POINTER :: pgrid
197  TYPE(t_patch), POINTER :: ppatch
198  TYPE(t_global), POINTER :: global
199 
200 ! ******************************************************************************
201 ! Start
202 ! ******************************************************************************
203 
204  global => pregion%global
205 
206  CALL registerfunction(global,'RFLU_123D_CheckGeometryKernel',&
207  'RFLU_ModDimensionality.F90')
208 
209  IF ( global%myProcid == masterproc .AND. &
210  global%verbLevel >= verbose_high) THEN
211  WRITE(stdout,'(A,1X,A)') solver_name,'Checking geometry...'
212  WRITE(stdout,'(A,3X,A,1X,I2)') solver_name,'Component:',dir
213  END IF ! global%myProcid
214 
215  pgrid => pregion%grid
216 
217  ntol = 1.0e-14_rfreal
218 
219 ! ******************************************************************************
220 ! Interior faces: dir-component of normal must be close to zero
221 ! ******************************************************************************
222 
223  IF ( pgrid%nFacesTot > 0 ) THEN
224  ndmin = minval(pgrid%fn(dir,1:pgrid%nFacesTot))
225  ndmax = maxval(pgrid%fn(dir,1:pgrid%nFacesTot))
226 
227  IF ( global%myProcid == masterproc .AND. &
228  global%verbLevel >= verbose_high) THEN
229  WRITE(stdout,'(A,3X,A)') solver_name,'Extrema of face-normal vectors:'
230  WRITE(stdout,'(A,5X,A,1X,E23.16)') solver_name,'Tolerance:',ntol
231  WRITE(stdout,'(A,7X,A,1X,2(1X,E23.16))') solver_name,'Interior:', &
232  ndmin,ndmax
233  END IF ! global%myProcid
234 
235  IF ( (abs(ndmin) > ntol) .OR. (abs(ndmax) > ntol) ) THEN
236  CALL errorstop(global,err_face_normal_invalid,__line__)
237  END IF ! ABS(ndMin)
238 
239  IF ( (floatequal(abs(ndmin),0.0_rfreal,ntol) .EQV. .false.) .OR. &
240  (floatequal(abs(ndmax),0.0_rfreal,ntol) .EQV. .false.) ) THEN
241  CALL errorstop(global,err_face_normal_invalid,__line__)
242  END IF ! FloatEqual
243  END IF ! pGrid%nFacesTot
244 
245 ! ******************************************************************************
246 ! Boundary faces: dir-component of normal must be close to zero for faces on
247 ! non-virtual patches, otherwise must be close to unity.
248 ! ******************************************************************************
249 
250  DO ipatch = 1,pgrid%nPatches
251  ppatch => pregion%patches(ipatch)
252 
253  IF ( ppatch%nBFacesTot > 0 ) THEN
254  ndmin = minval(ppatch%fn(dir,1:ppatch%nBFacesTot))
255  ndmax = maxval(ppatch%fn(dir,1:ppatch%nBFacesTot))
256 
257  nxmin = minval(ppatch%fn(xcoord,1:ppatch%nBFacesTot))
258  nxmax = maxval(ppatch%fn(xcoord,1:ppatch%nBFacesTot))
259 
260  IF ( global%myProcid == masterproc .AND. &
261  global%verbLevel >= verbose_high) THEN
262  WRITE(stdout,'(A,7X,A,1X,I2,A,1X,2(1X,E23.16))') &
263  solver_name,'Patch',ipatch,':',ndmin,ndmax
264  END IF ! global%myProcid
265 
266 ! ==============================================================================
267 ! Non-virtual patches: dir-component of normal must be close to zero
268 ! ==============================================================================
269 
270  IF ( ppatch%bcType /= bc_virtual ) THEN
271  IF ( (floatequal(abs(ndmin),0.0_rfreal,ntol) .EQV. .false.) .OR. &
272  (floatequal(abs(ndmax),0.0_rfreal,ntol) .EQV. .false.) ) THEN
273  CALL errorstop(global,err_face_normal_invalid,__line__)
274  END IF ! FloatEqual
275 
276 ! ==============================================================================
277 ! Virtual patches: x-component of normal must be close to zero
278 ! ==============================================================================
279 
280  ELSE
281  IF ( (floatequal(abs(nxmin),0.0_rfreal,ntol) .EQV. .false.) .OR. &
282  (floatequal(abs(nxmax),0.0_rfreal,ntol) .EQV. .false.) ) THEN
283  CALL errorstop(global,err_face_normal_invalid,__line__)
284  END IF ! FloatEqual
285  END IF ! pPatch%bcType
286  END IF ! pPatch%nBFacesTot
287  END DO ! iPatch
288 
289 ! ******************************************************************************
290 ! End
291 ! ******************************************************************************
292 
293  IF ( global%myProcid == masterproc .AND. &
294  global%verbLevel >= verbose_high) THEN
295  WRITE(stdout,'(A,1X,A)') solver_name,'Checking geometry done.'
296  END IF ! global%verbLevel
297 
298  CALL deregisterfunction(global)
299 
300  END SUBROUTINE rflu_123d_checkgeometrykernel
301 
302 
303 
304 
305 
306 
307 ! ******************************************************************************
308 !
309 ! Purpose: Check whether topology is correct.
310 !
311 ! Description: None.
312 !
313 ! Input:
314 ! pRegion Pointer to region
315 !
316 ! Output: None.
317 !
318 ! Notes: None.
319 !
320 ! ******************************************************************************
321 
322  SUBROUTINE rflu_123d_checktopology(pRegion)
323 
324  IMPLICIT NONE
325 
326 ! ******************************************************************************
327 ! Declarations and definitions
328 ! ******************************************************************************
329 
330 ! ==============================================================================
331 ! Parameters
332 ! ==============================================================================
333 
334  TYPE(t_region), POINTER :: pregion
335 
336 ! ==============================================================================
337 ! Locals
338 ! ==============================================================================
339 
340  INTEGER :: icl,ifg,ifl,ifl2,ipatch,ipatchcntr
341  TYPE(t_grid), POINTER :: pgrid
342  TYPE(t_patch), POINTER :: ppatch
343  TYPE(t_global), POINTER :: global
344 
345 ! ******************************************************************************
346 ! Start
347 ! ******************************************************************************
348 
349  global => pregion%global
350 
351  CALL registerfunction(global,'RFLU_123D_CheckTopology',&
352  'RFLU_ModDimensionality.F90')
353 
354  IF ( global%myProcid == masterproc .AND. &
355  global%verbLevel >= verbose_high) THEN
356  WRITE(stdout,'(A,1X,A)') solver_name,'Checking topology...'
357  END IF ! global%verbLevel
358 
359 ! ******************************************************************************
360 ! Set pointers and variables
361 ! ******************************************************************************
362 
363  pgrid => pregion%grid
364 
365 ! ******************************************************************************
366 ! Check dimensionality
367 ! ******************************************************************************
368 
369 ! ==============================================================================
370 ! Check that have only appropriate cells
371 ! ==============================================================================
372 
373  SELECT CASE ( pregion%mixtInput%dimens )
374  CASE ( 1 )
375  IF ( pgrid%nTetsTot /= 0 .OR. &
376  pgrid%nPrisTot /= 0 .OR. &
377  pgrid%nPyrsTot /= 0 ) THEN
378  CALL errorstop(global,err_dimens_invalid,__line__)
379  END IF ! pGrid%nTetsTot
380  CASE ( 2 )
381  IF ( pgrid%nTetsTot /= 0 .OR. pgrid%nPyrsTot /= 0 ) THEN
382  CALL errorstop(global,err_dimens_invalid,__line__)
383  END IF ! pGrid%nTetsTot
384  CASE ( 3 )
385  CASE default ! Defensive coding
386  CALL errorstop(global,err_reached_default,__line__)
387  END SELECT ! pRegion%mixtInput%dimens
388 
389 ! ==============================================================================
390 ! Must have specified number of virtual patches
391 ! ==============================================================================
392 
393  ipatchcntr = 0
394 
395  DO ipatch = 1,pgrid%nPatches
396  ppatch => pregion%patches(ipatch)
397 
398  IF ( ppatch%bcType == bc_virtual ) THEN
399  ipatchcntr = ipatchcntr + 1
400  END IF ! pPatch%bcType
401  END DO ! iPatch
402 
403  SELECT CASE ( pregion%mixtInput%dimens )
404  CASE ( 1 )
405  IF ( ipatchcntr /= 4 ) THEN
406  CALL errorstop(global,err_num_bc_virtual,__line__)
407  END IF ! iPatchCntr
408  CASE ( 2 )
409  IF ( ipatchcntr /= 2 ) THEN
410  CALL errorstop(global,err_num_bc_virtual,__line__)
411  END IF ! iPatchCntr
412  CASE ( 3 )
413  IF ( ipatchcntr /= 0 ) THEN
414  CALL errorstop(global,err_num_bc_virtual,__line__)
415  END IF ! iPatchCntr
416  CASE default ! Defensive coding
417  CALL errorstop(global,err_reached_default,__line__)
418  END SELECT ! pRegion%mixtInput%dimens
419 
420 ! ==============================================================================
421 ! Each cell must have specified number of boundary faces. NOTE require
422 ! cell-to-face connectivity array. For prisms, boundary faces must be
423 ! triangular faces.
424 ! ==============================================================================
425 
426  SELECT CASE ( pregion%mixtInput%dimens )
427 
428 ! ------------------------------------------------------------------------------
429 ! One dimension
430 ! ------------------------------------------------------------------------------
431 
432  CASE ( 1 )
433 
434 ! ----- Hexahedra --------------------------------------------------------------
435 
436  DO icl = 1,pgrid%nHexsTot
437  ipatchcntr = 0
438 
439  DO ifl = 1,6
440  ipatch = pgrid%hex2f(1,ifl,icl)
441 
442  IF ( ipatch > 0 ) THEN
443  ppatch => pregion%patches(ipatch)
444 
445  IF ( ppatch%bcType == bc_virtual ) THEN
446  ipatchcntr = ipatchcntr + 1
447  END IF ! pPatch%bcType
448  END IF ! iPatch
449  END DO ! ifl
450 
451  IF ( ipatchcntr /= 4 ) THEN
452  CALL errorstop(global,err_dimens_invalid,__line__)
453  END IF ! iPatchCntr
454  END DO ! icl
455 
456 ! ------------------------------------------------------------------------------
457 ! Two dimensions
458 ! ------------------------------------------------------------------------------
459 
460  CASE ( 2 )
461 
462 ! ----- Hexahedra --------------------------------------------------------------
463 
464  DO icl = 1,pgrid%nHexsTot
465  ipatchcntr = 0
466 
467  DO ifl = 1,6
468  ipatch = pgrid%hex2f(1,ifl,icl)
469 
470  IF ( ipatch > 0 ) THEN
471  ppatch => pregion%patches(ipatch)
472 
473  IF ( ppatch%bcType == bc_virtual ) THEN
474  ipatchcntr = ipatchcntr + 1
475  END IF ! pPatch%bcType
476  END IF ! iPatch
477  END DO ! ifl
478 
479  IF ( ipatchcntr /= 2 ) THEN
480  CALL errorstop(global,err_dimens_invalid,__line__)
481  END IF ! iPatchCntr
482  END DO ! icl
483 
484 ! ----- Prisms -----------------------------------------------------------------
485 
486  DO icl = 1,pgrid%nPrisTot
487  ipatchcntr = 0
488 
489  DO ifl = 1,5
490  ipatch = pgrid%pri2f(1,ifl,icl)
491  ifl2 = pgrid%pri2f(2,ifl,icl)
492 
493  IF ( ipatch > 0 ) THEN
494  ppatch => pregion%patches(ipatch)
495 
496  IF ( ppatch%bcType == bc_virtual ) THEN
497  ipatchcntr = ipatchcntr + 1
498 
499  IF ( ppatch%bf2v(4,ifl2) /= vert_none ) THEN
500  CALL errorstop(global,err_dimens_invalid,__line__)
501  END IF ! pGrid%f2v
502  END IF ! pPatch%bcType
503  END IF ! iPatch
504  END DO ! ifl
505 
506  IF ( ipatchcntr /= 2 ) THEN
507  CALL errorstop(global,err_dimens_invalid,__line__)
508  END IF ! iPatchCntr
509  END DO ! icl
510 
511 ! ------------------------------------------------------------------------------
512 ! Three dimensions and default
513 ! ------------------------------------------------------------------------------
514 
515  CASE ( 3 )
516  CASE default ! Defensive coding
517  CALL errorstop(global,err_reached_default,__line__)
518  END SELECT ! pRegion%mixtInput%dimens
519 
520 ! ******************************************************************************
521 ! End
522 ! ******************************************************************************
523 
524  IF ( global%myProcid == masterproc .AND. &
525  global%verbLevel >= verbose_high) THEN
526  WRITE(stdout,'(A,1X,A)') solver_name,'Checking topology done.'
527  END IF ! global%verbLevel
528 
529  CALL deregisterfunction(global)
530 
531  END SUBROUTINE rflu_123d_checktopology
532 
533 
534 
535 
536 ! ******************************************************************************
537 ! End
538 ! ******************************************************************************
539 
540 END MODULE rflu_moddimensionality
541 
542 
543 ! ******************************************************************************
544 !
545 ! RCS Revision history:
546 !
547 ! $Log: RFLU_ModDimensionality.F90,v $
548 ! Revision 1.9 2008/12/06 08:44:21 mtcampbe
549 ! Updated license.
550 !
551 ! Revision 1.8 2008/11/19 22:17:32 mtcampbe
552 ! Added Illinois Open Source License/Copyright
553 !
554 ! Revision 1.7 2007/03/07 03:20:05 haselbac
555 ! Added IFs on nFacesTot to avoid problems with single-cell grid
556 !
557 ! Revision 1.6 2007/02/27 13:03:55 haselbac
558 ! Enabled 1d computations
559 !
560 ! Revision 1.5 2005/12/11 15:55:03 haselbac
561 ! Bug fix: Added missing IF on myProcid
562 !
563 ! Revision 1.4 2005/11/09 01:23:05 haselbac
564 ! Increased tolerance again, did not increase version number
565 !
566 ! Revision 1.3 2005/11/09 01:18:20 haselbac
567 ! Changed tolerance after finding problems with Manojs cylinder comp
568 !
569 ! Revision 1.2 2005/11/04 14:06:48 haselbac
570 ! Renamed existing routine, added new routine to check geom
571 !
572 ! ******************************************************************************
573 
574 
575 
576 
577 
578 
579 
580 
581 
582 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine, public rflu_123d_checkgeometrywrapper(pRegion)
subroutine, public rflu_123d_checktopology(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
vector3d dir(void) const
Definition: vector3d.h:144
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflu_123d_checkgeometrykernel(pRegion, dir)
LOGICAL function floatequal(a, b, tolIn)
Definition: ModTools.F90:99