Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_CreateGrid.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: Create grid.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Region pointer
31 !
32 ! Output: None.
33 !
34 ! Notes:
35 ! 1. This routine creates the basic grid arrays only, i.e., those read in
36 ! by RFLU_ReadGrid{ASCII/Binary}.F90. Other grid-associated arrays
37 ! are created in other routines. One exception is the local boundary
38 ! face connectivity arrays required for GENX runs. These arrays are
39 ! created by the call to RFLU_CreateBFaceLocLists.
40 ! 2. The dimensions of the various arrays MUST have been previously read
41 ! by a call to RFLU_ReadDimensions.F90.
42 !
43 ! ******************************************************************************
44 !
45 ! $Id: RFLU_CreateGrid.F90,v 1.25 2008/12/06 08:44:12 mtcampbe Exp $
46 !
47 ! Copyright: (c) 2002-2006 by the University of Illinois
48 !
49 ! ******************************************************************************
50 
51 SUBROUTINE rflu_creategrid(pRegion)
52 
53  USE moddatatypes
54  USE moderror
55  USE modglobal, ONLY: t_global
56  USE modparameters
57  USE modbndpatch, ONLY: t_patch
58  USE modgrid, ONLY: t_grid
59  USE moddatastruct, ONLY: t_region
60  USE modmixture, ONLY: t_mixt_input
61  USE modmpi
62 
63  IMPLICIT NONE
64 
65 ! ******************************************************************************
66 ! Definitions and declarations
67 ! ******************************************************************************
68 
69 ! ==============================================================================
70 ! Arguments
71 ! ==============================================================================
72 
73  TYPE(t_region), POINTER :: pregion
74 
75 ! ==============================================================================
76 ! Locals
77 ! ==============================================================================
78 
79  CHARACTER(CHRLEN) :: rcsidentstring
80  INTEGER :: errorflag,ipatch
81  TYPE(t_grid), POINTER :: pgrid
82  TYPE(t_patch), POINTER :: ppatch
83  TYPE(t_global), POINTER :: global
84 
85 ! ******************************************************************************
86 ! Start
87 ! ******************************************************************************
88 
89  rcsidentstring = '$RCSfile: RFLU_CreateGrid.F90,v $ $Revision: 1.25 $'
90 
91  global => pregion%global
92 
93  CALL registerfunction(global,'RFLU_CreateGrid',&
94  'RFLU_CreateGrid.F90')
95 
96  IF ( global%myProcid == masterproc .AND. &
97  global%verbLevel >= verbose_high ) THEN
98  WRITE(stdout,'(A,1X,A)') solver_name,'Creating grid...'
99  END IF ! global%verbLevel
100 
101 ! ******************************************************************************
102 ! Set grid pointer
103 ! ******************************************************************************
104 
105  pgrid => pregion%grid
106 
107 ! ******************************************************************************
108 ! Coordinates and vertex flags
109 ! ******************************************************************************
110 
111  ALLOCATE(pgrid%xyz(3,pgrid%nVertMax),stat=errorflag)
112  global%error = errorflag
113  IF ( global%error /= err_none ) THEN
114  CALL errorstop(global,err_allocate,__line__,'region%grid%xyz')
115  END IF ! global%error
116 
117 ! ******************************************************************************
118 ! Connectivity
119 ! ******************************************************************************
120 
121 ! ==============================================================================
122 ! Tetrahedra
123 ! ==============================================================================
124 
125  IF ( pgrid%nTetsMax > 0 ) THEN
126  ALLOCATE(pgrid%tet2v(4,pgrid%nTetsMax),stat=errorflag)
127  global%error = errorflag
128  IF ( global%error /= err_none ) THEN
129  CALL errorstop(global,err_allocate,__line__,'region%grid%tet2v')
130  END IF ! global%error
131  ELSE
132  nullify(pgrid%tet2v)
133  END IF ! pGrid%nTetsMax
134 
135 ! ==============================================================================
136 ! Hexahedra
137 ! ==============================================================================
138 
139  IF ( pgrid%nHexsMax > 0 ) THEN
140  ALLOCATE(pgrid%hex2v(8,pgrid%nHexsMax),stat=errorflag)
141  global%error = errorflag
142  IF ( global%error /= err_none ) THEN
143  CALL errorstop(global,err_allocate,__line__,'region%grid%hex2v')
144  END IF ! global%error
145  ELSE
146  nullify(pgrid%hex2v)
147  END IF ! pGrid%nHexsTot
148 
149 ! ==============================================================================
150 ! Prisms
151 ! ==============================================================================
152 
153  IF ( pgrid%nPrisMax > 0 ) THEN
154  ALLOCATE(pgrid%pri2v(6,pgrid%nPrisMax),stat=errorflag)
155  global%error = errorflag
156  IF ( global%error /= err_none ) THEN
157  CALL errorstop(global,err_allocate,__line__,'region%grid%pri2v')
158  END IF ! global%error
159  ELSE
160  nullify(pgrid%pri2v)
161  END IF ! pGrid%nPrisTot
162 
163 ! ==============================================================================
164 ! Pyramids
165 ! ==============================================================================
166 
167  IF ( pgrid%nPyrsMax > 0 ) THEN
168  ALLOCATE(pgrid%pyr2v(5,pgrid%nPyrsMax),stat=errorflag)
169  global%error = errorflag
170  IF ( global%error /= err_none ) THEN
171  CALL errorstop(global,err_allocate,__line__,'region%grid%pyr2v')
172  END IF ! global%error
173  ELSE
174  nullify(pgrid%pyr2v)
175  END IF ! pGrid%nPyrsTot
176 
177 ! ==============================================================================
178 ! Initialize some dimensions
179 ! ==============================================================================
180 
181  pgrid%nCellsSpecial = 0
182  pgrid%nFacesSpecial = 0
183 
184  pgrid%nBFaces = 0
185  pgrid%nBFacesTot = 0
186 
187  pgrid%nCellsConstr = 0
188  pgrid%nFacesConstr = 0
189 
190 ! ******************************************************************************
191 ! Patches
192 ! ******************************************************************************
193 
194  IF ( pgrid%nPatches > 0 ) THEN
195  ALLOCATE(pregion%patches(pgrid%nPatches),stat=errorflag)
196  global%error = errorflag
197  IF ( global%error /= err_none ) THEN
198  CALL errorstop(global,err_allocate,__line__,'pRegion%patches')
199  END IF ! global%error
200  ELSE
201  nullify(pregion%patches)
202  END IF ! pGrid%nPatches
203 
204 ! ==============================================================================
205 ! Loop over patches
206 ! ==============================================================================
207 
208  DO ipatch = 1,pgrid%nPatches
209  ppatch => pregion%patches(ipatch)
210 
211 ! ------------------------------------------------------------------------------
212 ! Copy data read in from dimension file into patch type
213 ! ------------------------------------------------------------------------------
214 
215  ppatch%iPatchLocal = ipatch
216  ppatch%iPatchGlobal = pgrid%patchDimens(patch_dimens_ipglobal,ipatch)
217 
218  ppatch%nBTris = pgrid%patchDimens(patch_dimens_nbtris ,ipatch)
219  ppatch%nBTrisTot = pgrid%patchDimens(patch_dimens_nbtristot ,ipatch)
220  ppatch%nBTrisMax = pgrid%patchDimens(patch_dimens_nbtrismax ,ipatch)
221 
222  ppatch%nBQuads = pgrid%patchDimens(patch_dimens_nbquads ,ipatch)
223  ppatch%nBQuadsTot = pgrid%patchDimens(patch_dimens_nbquadstot ,ipatch)
224  ppatch%nBQuadsMax = pgrid%patchDimens(patch_dimens_nbquadsmax ,ipatch)
225 
226  ppatch%nBCellsVirt = pgrid%patchDimens(patch_dimens_nbcellsvirt,ipatch)
227 
228  ppatch%nBFaces = ppatch%nBTris + ppatch%nBQuads
229  ppatch%nBFacesTot = ppatch%nBTrisTot + ppatch%nBQuadsTot
230  ppatch%nBFacesMax = ppatch%nBTrisMax + ppatch%nBQuadsMax
231 
232  pgrid%nBFaces = pgrid%nBFaces + ppatch%nBFaces
233  pgrid%nBFacesTot = pgrid%nBFacesTot + ppatch%nBFacesTot
234 
235  ppatch%nBVert = 0
236  ppatch%nBVertTot = 0
237 
238 ! ------------------------------------------------------------------------------
239 ! Set variables
240 ! ------------------------------------------------------------------------------
241 
242  ppatch%plotFlag = .true.
243  ppatch%renumFlag = .false.
244  ppatch%flatFlag = .false.
245  ppatch%transformFlag = .false.
246 
247  ppatch%movePatchDir = 0
248 
249 ! ------------------------------------------------------------------------------
250 ! Allocate remaining arrays (see also note above)
251 ! ------------------------------------------------------------------------------
252 
253 ! - Face arrays ----------------------------------------------------------------
254 
255  IF ( ppatch%nBTrisMax > 0 ) THEN
256  ALLOCATE(ppatch%bTri2v(3,ppatch%nBTrisMax),stat=errorflag)
257  global%error = errorflag
258  IF ( global%error /= err_none ) THEN
259  CALL errorstop(global,err_allocate,__line__,'region%patches%bTri2v')
260  END IF ! global%error
261  ELSE
262  nullify(ppatch%bTri2v)
263  END IF ! pPatch%nBTrisTot
264 
265  IF ( ppatch%nBQuadsMax > 0 ) THEN
266  ALLOCATE(ppatch%bQuad2v(4,ppatch%nBQuadsMax),stat=errorflag)
267  global%error = errorflag
268  IF ( global%error /= err_none ) THEN
269  CALL errorstop(global,err_allocate,__line__,'region%patch%bQuad2v')
270  END IF ! global%error
271  ELSE
272  nullify(ppatch%bQuad2v)
273  END IF ! pPatch%nBQuadsTot
274 
275 ! - Virtual cell array ---------------------------------------------------------
276 
277  IF ( ppatch%nBCellsVirt > 0 ) THEN
278  ALLOCATE(ppatch%bvc(ppatch%nBCellsVirt),stat=errorflag)
279  global%error = errorflag
280  IF ( global%error /= err_none ) THEN
281  CALL errorstop(global,err_allocate,__line__,'pPatch%bvc')
282  END IF ! global%error
283  ELSE
284  nullify(ppatch%bvc)
285  END IF ! pPatch%nBCellsVirt
286 
287 ! ------------------------------------------------------------------------------
288 ! Initialize transformation matrix
289 ! ------------------------------------------------------------------------------
290 
291  ppatch%tm(xcoord,xcoord) = REAL(crazy_value_int,kind=rfreal)
292  ppatch%tm(xcoord,ycoord) = REAL(crazy_value_int,kind=rfreal)
293  ppatch%tm(xcoord,zcoord) = REAL(crazy_value_int,kind=rfreal)
294  ppatch%tm(xcoord,xyzmag) = REAL(crazy_value_int,kind=rfreal)
295  ppatch%tm(ycoord,xcoord) = REAL(crazy_value_int,kind=rfreal)
296  ppatch%tm(ycoord,ycoord) = REAL(crazy_value_int,kind=rfreal)
297  ppatch%tm(ycoord,zcoord) = REAL(crazy_value_int,kind=rfreal)
298  ppatch%tm(ycoord,xyzmag) = REAL(crazy_value_int,kind=rfreal)
299  ppatch%tm(zcoord,xcoord) = REAL(crazy_value_int,kind=rfreal)
300  ppatch%tm(zcoord,ycoord) = REAL(crazy_value_int,kind=rfreal)
301  ppatch%tm(zcoord,zcoord) = REAL(crazy_value_int,kind=rfreal)
302  ppatch%tm(zcoord,xyzmag) = REAL(crazy_value_int,kind=rfreal)
303  ppatch%tm(xyzmag,xcoord) = REAL(crazy_value_int,kind=rfreal)
304  ppatch%tm(xyzmag,ycoord) = REAL(crazy_value_int,kind=rfreal)
305  ppatch%tm(xyzmag,zcoord) = REAL(crazy_value_int,kind=rfreal)
306  ppatch%tm(xyzmag,xyzmag) = REAL(crazy_value_int,kind=rfreal)
307  END DO ! iPatch
308 
309 ! ******************************************************************************
310 ! End
311 ! ******************************************************************************
312 
313  IF ( global%myProcid == masterproc .AND. &
314  global%verbLevel >= verbose_high ) THEN
315  WRITE(stdout,'(A,1X,A)') solver_name,'Creating grid done.'
316  END IF ! global%verbLevel
317 
318  CALL deregisterfunction(global)
319 
320 END SUBROUTINE rflu_creategrid
321 
322 ! ******************************************************************************
323 !
324 ! RCS Revision history:
325 !
326 ! $Log: RFLU_CreateGrid.F90,v $
327 ! Revision 1.25 2008/12/06 08:44:12 mtcampbe
328 ! Updated license.
329 !
330 ! Revision 1.24 2008/11/19 22:17:25 mtcampbe
331 ! Added Illinois Open Source License/Copyright
332 !
333 ! Revision 1.23 2006/08/18 13:59:01 haselbac
334 ! Added init of transform flag and tm
335 !
336 ! Revision 1.22 2006/04/07 15:19:16 haselbac
337 ! Removed tabs
338 !
339 ! Revision 1.21 2006/04/07 14:42:00 haselbac
340 ! Added setting of pPatch%iPatchLocal
341 !
342 ! Revision 1.20 2006/03/25 21:41:48 haselbac
343 ! Changes made bcos of sype boundaries
344 !
345 ! Revision 1.19 2005/10/27 18:55:36 haselbac
346 ! Added init of nCellsConstr and nFacesConstr
347 !
348 ! Revision 1.18 2005/08/09 00:53:33 haselbac
349 ! Added init of plotFlag for patches
350 !
351 ! Revision 1.17 2005/06/13 22:42:40 haselbac
352 ! Removed setting of cnstrType
353 !
354 ! Revision 1.16 2005/06/10 19:44:12 haselbac
355 ! Bug fix: Wrong module
356 !
357 ! Revision 1.15 2005/06/10 18:04:38 haselbac
358 ! Bug fix for backward-compatibility in GENx with cnstr_type
359 !
360 ! Revision 1.14 2005/01/14 21:09:18 haselbac
361 ! Removed init of nBorders, otherwise cannot read comm maps in solver
362 !
363 ! Revision 1.13 2004/12/29 21:01:14 haselbac
364 ! Added setting of pGrid%nBFaces and pGrid%nBFacesTot
365 !
366 ! Revision 1.12 2004/12/04 03:21:37 haselbac
367 ! Added initialization of nBorders
368 !
369 ! Revision 1.11 2004/11/09 00:27:04 haselbac
370 ! Bug fix: Used nTetsTot instead of nTetsMax
371 !
372 ! Revision 1.10 2004/11/03 16:58:39 haselbac
373 ! Removed allocation of vertex and cell flags
374 !
375 ! Revision 1.9 2004/10/19 19:24:13 haselbac
376 ! Introduced Max dims, removed bf arrays and derived dims
377 !
378 ! Revision 1.8 2004/10/08 21:08:00 fnajjar
379 ! ACH: Bug fix: Added initialization of nFacesSpecial
380 !
381 ! Revision 1.7 2004/07/06 15:14:13 haselbac
382 ! Bug fix: patchDimens now under grid type, cosmetics
383 !
384 ! Revision 1.6 2003/11/03 03:48:53 haselbac
385 ! Cosmetic changes only
386 !
387 ! Revision 1.5 2003/06/04 22:01:16 haselbac
388 ! Added NULLIFY for patches
389 !
390 ! Revision 1.4 2003/04/01 19:37:14 haselbac
391 ! Added initialization of nCellsSpecial
392 !
393 ! Revision 1.3 2003/03/25 19:11:52 haselbac
394 ! Added setting of patch renumbering flag
395 !
396 ! Revision 1.2 2003/03/15 16:52:04 haselbac
397 ! Added vertex arrays, allocate based on *Tot
398 !
399 ! Revision 1.1 2003/01/28 15:53:31 haselbac
400 ! Initial revision
401 !
402 ! ******************************************************************************
403 
404 
405 
406 
407 
408 
409 
subroutine rflu_creategrid(pRegion)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469