Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_GetSpecialCells.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: Get special cells.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to region data
31 !
32 ! Output: None.
33 !
34 ! Notes: None.
35 !
36 !*******************************************************************************
37 !
38 ! $Id: RFLU_GetSpecialCells.F90,v 1.3 2008/12/06 08:44:54 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2003 by the University of Illinois
41 !
42 !*******************************************************************************
43 
44 SUBROUTINE rflu_getspecialcells(pRegion)
45 
46  USE modglobal, ONLY: t_global
47  USE moddatatypes
48  USE modparameters
49  USE moderror
50  USE modbndpatch, ONLY: t_patch
51  USE modgrid, ONLY: t_grid
52  USE moddatastruct, ONLY: t_region
53  USE modsortsearch
54 
55  USE rflu_modgrid
56 
57  IMPLICIT NONE
58 
59 ! ******************************************************************************
60 ! Declarations and definitions
61 ! ******************************************************************************
62 
63 ! ==============================================================================
64 ! Arguments
65 ! ==============================================================================
66 
67  TYPE(t_region), POINTER :: pregion
68 
69 ! ==============================================================================
70 ! Locals
71 ! ==============================================================================
72 
73  CHARACTER :: infotype
74  CHARACTER(CHRLEN) :: rcsidentstring
75  INTEGER :: cellindx,errorflag,faceindx,icellsspecial,icl,iloc, &
76  nvertpercell,patchindx,vertindx
77  INTEGER :: v(8)
78  TYPE(t_global), POINTER :: global
79  TYPE(t_grid), POINTER :: pgrid
80  TYPE(t_patch), POINTER :: ppatch
81 
82 ! ******************************************************************************
83 ! Start
84 ! ******************************************************************************
85 
86  rcsidentstring = '$RCSfile: RFLU_GetSpecialCells.F90,v $'
87 
88  global => pregion%global
89 
90  CALL registerfunction(global,'RFLU_GetSpecialCells', &
91  'RFLU_GetSpecialCells.F90')
92 
93  IF ( global%verbLevel > verbose_none ) THEN
94  WRITE(stdout,'(A,1X,A)') solver_name,'Getting special cells...'
95  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
96  pregion%iRegionGlobal
97  END IF ! global%verbLevel
98 
99 ! ******************************************************************************
100 ! Set pointers and initialize
101 ! ******************************************************************************
102 
103  pgrid => pregion%grid
104 
105  icellsspecial = 0
106  pgrid%cellsSpecial(1:ncells_special_max) = 0
107 
108 ! ******************************************************************************
109 ! Get information from user
110 ! ******************************************************************************
111 
112  WRITE(stdout,'(A,5X,A)') solver_name,'Enter information on special cells:'
113  WRITE(stdout,'(A,7X,A)') solver_name,'b - cell adjacent to boundary face'
114  WRITE(stdout,'(A,7X,A)') solver_name,'c - single cell'
115  WRITE(stdout,'(A,7X,A)') solver_name,'f - cells adjacent to interior face'
116  WRITE(stdout,'(A,7X,A)') solver_name,'v - cells meeting at vertex'
117  WRITE(stdout,'(A,7X,A)') solver_name,'q - quit'
118 
119 ! ==============================================================================
120 ! Set up infinite loop
121 ! ==============================================================================
122 
123  DO
124 
125 ! ------------------------------------------------------------------------------
126 ! Enter information type
127 ! ------------------------------------------------------------------------------
128 
129  WRITE(stdout,'(A,3X,A)') solver_name,'Enter information type:'
130  READ(stdin,'(A)') infotype
131 
132  SELECT CASE ( infotype )
133 
134 ! --- cell adjacent to boundary face -------------------------------------------
135 
136  CASE ( 'b' )
137  WRITE(stdout,'(A,5X,A)') solver_name,'Enter patch index:'
138  READ(stdin,*,iostat=errorflag) patchindx
139 
140  IF ( errorflag /= err_none ) THEN
141  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
142  cycle
143  END IF ! errorFlag
144 
145  IF ( patchindx > 0 .AND. patchindx <= pgrid%nPatches ) THEN
146  ppatch => pregion%patches(patchindx)
147 
148  WRITE(stdout,'(A,5X,A)') solver_name,'Enter face index:'
149  READ(stdin,*,iostat=errorflag) faceindx
150 
151  IF ( errorflag /= err_none ) THEN
152  WRITE(stdout,'(A,5X,A)') solver_name, &
153  '*** WARNING *** Invalid input.'
154  cycle
155  END IF ! errorFlag
156 
157  IF ( faceindx > 0 .AND. faceindx <= ppatch%nBFacesTot ) THEN
158  IF ( icellsspecial == ncells_special_max ) THEN
159  CALL errorstop(global,err_ncells_special_max,__line__)
160  END IF ! iCellsSpecial
161 
162  icellsspecial = icellsspecial + 1
163  pgrid%cellsSpecial(icellsspecial) = ppatch%bf2c(faceindx)
164 
165  WRITE(stdout,'(A,5X,A,1X,I8)') solver_name,'Added cell:', &
166  ppatch%bf2c(faceindx)
167  ELSE
168  WRITE(stdout,'(A,5X,A)') solver_name, &
169  '*** WARNING *** Invalid input.'
170  cycle
171  END IF ! faceIndx
172  ELSE
173  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
174  cycle
175  END IF ! patchIndx
176 
177 ! --- single cell --------------------------------------------------------------
178 
179  CASE ( 'c' )
180  WRITE(stdout,'(A,5X,A)') solver_name,'Enter cell index:'
181  READ(stdin,*,iostat=errorflag) cellindx
182 
183  IF ( errorflag /= err_none ) THEN
184  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
185  cycle
186  END IF ! errorFlag
187 
188  IF ( cellindx > 0 .AND. cellindx <= pgrid%nCellsTot ) THEN
189  IF ( icellsspecial == ncells_special_max ) THEN
190  CALL errorstop(global,err_ncells_special_max,__line__)
191  END IF ! iCellsSpecial
192 
193  icellsspecial = icellsspecial + 1
194  pgrid%cellsSpecial(icellsspecial) = cellindx
195  ELSE
196  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
197  cycle
198  END IF ! cellIndx
199 
200 ! --- cells adjacent to interior face ------------------------------------------
201 
202  CASE ( 'f' )
203  WRITE(stdout,'(A,5X,A)') solver_name,'Enter interior face index:'
204  READ(stdin,*,iostat=errorflag) faceindx
205 
206  IF ( errorflag /= err_none ) THEN
207  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
208  cycle
209  END IF ! errorFlag
210 
211  IF ( faceindx > 0 .AND. faceindx <= pgrid%nFacesTot ) THEN
212  IF ( icellsspecial == ncells_special_max-1 ) THEN
213  CALL errorstop(global,err_ncells_special_max,__line__)
214  END IF ! iCellsSpecial
215 
216  icellsspecial = icellsspecial + 1
217  pgrid%cellsSpecial(icellsspecial) = pgrid%f2c(1,faceindx)
218 
219  icellsspecial = icellsspecial + 1
220  pgrid%cellsSpecial(icellsspecial) = pgrid%f2c(2,faceindx)
221 
222  WRITE(stdout,'(A,5X,A,1X,I8,1X,A,1X,I8)') solver_name, &
223  'Added cells:',pgrid%f2c(1,faceindx),'and', &
224  pgrid%f2c(2,faceindx)
225  ELSE
226  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
227  cycle
228  END IF ! faceIndx
229 
230 ! --- cells meeting at vertex --------------------------------------------------
231 
232  CASE ( 'v' )
233  WRITE(stdout,'(A,5X,A)') solver_name,'Enter vertex index:'
234  READ(stdin,*,iostat=errorflag) vertindx
235 
236  IF ( errorflag /= err_none ) THEN
237  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
238  cycle
239  END IF ! errorFlag
240 
241  IF ( vertindx > 0 .AND. vertindx <= pgrid%nVertTot ) THEN
242 
243 ! ------- Tetrahedra
244 
245  IF ( pgrid%nTetsTot > 0 ) THEN
246  WRITE(stdout,'(A,5X,A)') solver_name,'Tetrahedra...'
247 
248  nvertpercell = 4
249 
250  DO icl = 1,pgrid%nTetsTot
251  v(1:nvertpercell) = pgrid%tet2v(1:nvertpercell,icl)
252 
253  CALL quicksortinteger(v,nvertpercell)
254  CALL binarysearchinteger(v,nvertpercell,vertindx,iloc)
255 
256  IF ( iloc /= element_not_found ) THEN
257  IF ( icellsspecial == ncells_special_max ) THEN
258  CALL errorstop(global,err_ncells_special_max,__line__)
259  END IF ! iCellsSpecial
260 
261  icellsspecial = icellsspecial + 1
262  pgrid%cellsSpecial(icellsspecial) = pgrid%tet2CellGlob(icl)
263 
264  WRITE(stdout,'(A,7X,A,1X,I8)') solver_name,'Added cell:', &
265  pgrid%tet2CellGlob(icl)
266  END IF ! iloc
267  END DO ! icl
268  END IF ! pGrid%nTetsTot
269 
270 ! ------- Hexahedra
271 
272  IF ( pgrid%nHexsTot > 0 ) THEN
273  WRITE(stdout,'(A,5X,A)') solver_name,'Hexahedra...'
274 
275  nvertpercell = 8
276 
277  DO icl = 1,pgrid%nHexsTot
278  v(1:nvertpercell) = pgrid%hex2v(1:nvertpercell,icl)
279 
280  CALL quicksortinteger(v,nvertpercell)
281  CALL binarysearchinteger(v,nvertpercell,vertindx,iloc)
282 
283  IF ( iloc /= element_not_found ) THEN
284  IF ( icellsspecial == ncells_special_max ) THEN
285  CALL errorstop(global,err_ncells_special_max,__line__)
286  END IF ! iCellsSpecial
287 
288  icellsspecial = icellsspecial + 1
289  pgrid%cellsSpecial(icellsspecial) = pgrid%hex2CellGlob(icl)
290 
291  WRITE(stdout,'(A,7X,A,1X,I8)') solver_name,'Added cell:', &
292  pgrid%hex2CellGlob(icl)
293  END IF ! iloc
294  END DO ! icl
295  END IF ! pGrid%nPyrsTot
296 
297 ! ------- Prisms
298 
299  IF ( pgrid%nPrisTot > 0 ) THEN
300  WRITE(stdout,'(A,5X,A)') solver_name,'Prisms...'
301 
302  nvertpercell = 6
303 
304  DO icl = 1,pgrid%nPrisTot
305  v(1:nvertpercell) = pgrid%pri2v(1:nvertpercell,icl)
306 
307  CALL quicksortinteger(v,nvertpercell)
308  CALL binarysearchinteger(v,nvertpercell,vertindx,iloc)
309 
310  IF ( iloc /= element_not_found ) THEN
311  IF ( icellsspecial == ncells_special_max ) THEN
312  CALL errorstop(global,err_ncells_special_max,__line__)
313  END IF ! iCellsSpecial
314 
315  icellsspecial = icellsspecial + 1
316  pgrid%cellsSpecial(icellsspecial) = pgrid%pri2CellGlob(icl)
317 
318  WRITE(stdout,'(A,7X,A,1X,I8)') solver_name,'Added cell:', &
319  pgrid%pri2CellGlob(icl)
320  END IF ! iloc
321  END DO ! icl
322  END IF ! pGrid%nPyrsTot
323 
324 ! ------- Pyramids
325 
326  IF ( pgrid%nPyrsTot > 0 ) THEN
327  WRITE(stdout,'(A,5X,A)') solver_name,'Pyramids...'
328 
329  nvertpercell = 5
330 
331  DO icl = 1,pgrid%nPyrsTot
332  v(1:nvertpercell) = pgrid%pyr2v(1:nvertpercell,icl)
333 
334  CALL quicksortinteger(v,nvertpercell)
335  CALL binarysearchinteger(v,nvertpercell,vertindx,iloc)
336 
337  IF ( iloc /= element_not_found ) THEN
338  IF ( icellsspecial == ncells_special_max ) THEN
339  CALL errorstop(global,err_ncells_special_max,__line__)
340  END IF ! iCellsSpecial
341 
342  icellsspecial = icellsspecial + 1
343  pgrid%cellsSpecial(icellsspecial) = pgrid%pyr2CellGlob(icl)
344 
345  WRITE(stdout,'(A,7X,A,1X,I8)') solver_name,'Added cell:', &
346  pgrid%pyr2CellGlob(icl)
347  END IF ! iloc
348  END DO ! icl
349  END IF ! pGrid%nPyrsTot
350 
351  ELSE
352  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
353  cycle
354  END IF ! vertIndx
355 
356 ! --- quit ---------------------------------------------------------------------
357 
358  CASE ( 'q' )
359  EXIT
360 
361 ! --- default ------------------------------------------------------------------
362 
363  CASE default
364  WRITE(stdout,'(A,5X,A)') solver_name,'*** WARNING *** Invalid input.'
365  cycle
366  END SELECT
367  END DO ! <empty>
368 
369 ! ==============================================================================
370 ! Set number of special cells
371 ! ==============================================================================
372 
373  pgrid%nCellsSpecial = icellsspecial
374 
375 ! ******************************************************************************
376 ! End
377 ! ******************************************************************************
378 
379  IF ( global%verbLevel > verbose_none ) THEN
380  WRITE(stdout,'(A,1X,A)') solver_name,'Getting special cells done.'
381  END IF ! global%verbLevel
382 
383  CALL deregisterfunction(global)
384 
385 END SUBROUTINE rflu_getspecialcells
386 
387 !******************************************************************************
388 !
389 ! RCS Revision history:
390 !
391 ! $Log: RFLU_GetSpecialCells.F90,v $
392 ! Revision 1.3 2008/12/06 08:44:54 mtcampbe
393 ! Updated license.
394 !
395 ! Revision 1.2 2008/11/19 22:18:04 mtcampbe
396 ! Added Illinois Open Source License/Copyright
397 !
398 ! Revision 1.1 2003/04/01 17:02:46 haselbac
399 ! Initial revision
400 !
401 ! Revision 1.2 2003/03/20 20:07:19 haselbac
402 ! Modified RegFun call to avoid probs with
403 ! long 'RFLU_GetSpecialCells.F90' names
404 !
405 ! Revision 1.1 2003/03/15 19:16:54 haselbac
406 ! Initial revision
407 !
408 !******************************************************************************
409 
410 
411 
412 
413 
414 
415 
416 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine quicksortinteger(a, n)
subroutine rflu_getspecialcells(pRegion)
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 errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469