Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_DestroyGrid.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: Destroy grid.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Region pointer
31 !
32 ! Output: None.
33 !
34 ! Notes:
35 ! 1. Patch array deallocated at end of routine.
36 !
37 ! ******************************************************************************
38 !
39 ! $Id: RFLU_DestroyGrid.F90,v 1.10 2008/12/06 08:44:12 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2003-2006 by the University of Illinois
42 !
43 ! ******************************************************************************
44 
45 SUBROUTINE rflu_destroygrid(pRegion)
46 
47  USE moddatatypes
48  USE moderror
49  USE modglobal, ONLY: t_global
50  USE modparameters
51  USE modbndpatch, ONLY: t_patch
52  USE modgrid, ONLY: t_grid
53  USE moddatastruct, ONLY: t_region
54  USE modmixture, ONLY: t_mixt_input
55  USE modmpi
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(CHRLEN) :: rcsidentstring
74  INTEGER :: errorflag,ipatch
75  TYPE(t_grid), POINTER :: pgrid
76  TYPE(t_patch), POINTER :: ppatch
77  TYPE(t_global), POINTER :: global
78 
79 ! ******************************************************************************
80 ! Start
81 ! ******************************************************************************
82 
83  rcsidentstring = '$RCSfile: RFLU_DestroyGrid.F90,v $ $Revision: 1.10 $'
84 
85  global => pregion%global
86 
87  CALL registerfunction(global,'RFLU_DestroyGrid',&
88  'RFLU_DestroyGrid.F90')
89 
90  IF ( global%myProcid == masterproc .AND. &
91  global%verbLevel >= verbose_high ) THEN
92  WRITE(stdout,'(A,1X,A)') solver_name,'Destroying grid...'
93  END IF ! global%verbLevel
94 
95 ! ******************************************************************************
96 ! Set grid pointer
97 ! ******************************************************************************
98 
99  pgrid => pregion%grid
100 
101 ! ******************************************************************************
102 ! Coordinates and vertex flags
103 ! ******************************************************************************
104 
105  DEALLOCATE(pgrid%xyz,stat=errorflag)
106  global%error = errorflag
107  IF ( global%error /= err_none ) THEN
108  CALL errorstop(global,err_deallocate,__line__,'region%grid%xyz')
109  END IF ! global%error
110 
111  nullify(pgrid%xyz)
112 
113 ! ******************************************************************************
114 ! Connectivity
115 ! ******************************************************************************
116 
117 ! ==============================================================================
118 ! Tetrahedra
119 ! ==============================================================================
120 
121  IF ( pgrid%nTetsTot > 0 ) THEN
122  DEALLOCATE(pgrid%tet2v,stat=errorflag)
123  global%error = errorflag
124  IF ( global%error /= err_none ) THEN
125  CALL errorstop(global,err_deallocate,__line__,'region%grid%tet2v')
126  END IF ! global%error
127 
128  nullify(pgrid%tet2v)
129  END IF ! pGrid%nTetsTot
130 
131 ! ==============================================================================
132 ! Hexahedra
133 ! ==============================================================================
134 
135  IF ( pgrid%nHexsTot > 0 ) THEN
136  DEALLOCATE(pgrid%hex2v,stat=errorflag)
137  global%error = errorflag
138  IF ( global%error /= err_none ) THEN
139  CALL errorstop(global,err_deallocate,__line__,'region%grid%hex2v')
140  END IF ! global%error
141 
142  nullify(pgrid%hex2v)
143  END IF ! pGrid%nHexsTot
144 
145 ! ==============================================================================
146 ! Prisms
147 ! ==============================================================================
148 
149  IF ( pgrid%nPrisTot > 0 ) THEN
150  DEALLOCATE(pgrid%pri2v,stat=errorflag)
151  global%error = errorflag
152  IF ( global%error /= err_none ) THEN
153  CALL errorstop(global,err_deallocate,__line__,'region%grid%pri2v')
154  END IF ! global%error
155 
156  nullify(pgrid%pri2v)
157  END IF ! pGrid%nPrisTot
158 
159 ! ==============================================================================
160 ! Pyramids
161 ! ==============================================================================
162 
163  IF ( pgrid%nPyrsTot > 0 ) THEN
164  DEALLOCATE(pgrid%pyr2v,stat=errorflag)
165  global%error = errorflag
166  IF ( global%error /= err_none ) THEN
167  CALL errorstop(global,err_deallocate,__line__,'region%grid%pyr2v')
168  END IF ! global%error
169 
170  nullify(pgrid%pyr2v)
171  END IF ! pGrid%nPyrsTot
172 
173 ! ******************************************************************************
174 ! Patches
175 ! ******************************************************************************
176 
177 ! ==============================================================================
178 ! Loop over patches
179 ! ==============================================================================
180 
181  DO ipatch = 1,pgrid%nPatches
182  ppatch => pregion%patches(ipatch)
183 
184  IF ( ppatch%nBTrisTot > 0 ) THEN
185  DEALLOCATE(ppatch%bTri2v,stat=errorflag)
186  global%error = errorflag
187  IF ( global%error /= err_none ) THEN
188  CALL errorstop(global,err_deallocate,__line__,'region%patches%bTri2v')
189  END IF ! global%error
190  nullify(ppatch%bTri2v)
191  END IF ! pPatch%nBTrisTot
192 
193  IF ( ppatch%nBQuadsTot > 0 ) THEN
194  DEALLOCATE(ppatch%bQuad2v,stat=errorflag)
195  global%error = errorflag
196  IF ( global%error /= err_none ) THEN
197  CALL errorstop(global,err_deallocate,__line__,'region%patch%bQuad2v')
198  END IF ! global%error
199  nullify(ppatch%bQuad2v)
200  END IF ! pPatch%nBQuadsTot
201 
202  IF ( ppatch%nBCellsVirt > 0 ) THEN
203  DEALLOCATE(ppatch%bvc,stat=errorflag)
204  global%error = errorflag
205  IF ( global%error /= err_none ) THEN
206  CALL errorstop(global,err_allocate,__line__,'pPatch%bvc')
207  END IF ! global%error
208  nullify(ppatch%bvc)
209  END IF ! pPatch%bcType
210  END DO ! iPatch
211 
212 ! ******************************************************************************
213 ! Deallocate actual patch array
214 ! ******************************************************************************
215 
216  IF ( pgrid%nPatches > 0 ) THEN
217  DEALLOCATE(pregion%patches,stat=errorflag)
218  global%error = errorflag
219  IF ( global%error /= err_none ) THEN
220  CALL errorstop(global,err_deallocate,__line__,'region%patches')
221  END IF ! global%error
222  nullify(pregion%patches)
223  END IF ! pGrid%nPatches
224 
225 ! ******************************************************************************
226 ! End
227 ! ******************************************************************************
228 
229  IF ( global%myProcid == masterproc .AND. &
230  global%verbLevel >= verbose_high ) THEN
231  WRITE(stdout,'(A,1X,A)') solver_name,'Destroying grid done.'
232  END IF ! global%verbLevel
233 
234  CALL deregisterfunction(global)
235 
236 END SUBROUTINE rflu_destroygrid
237 
238 ! ******************************************************************************
239 !
240 ! RCS Revision history:
241 !
242 ! $Log: RFLU_DestroyGrid.F90,v $
243 ! Revision 1.10 2008/12/06 08:44:12 mtcampbe
244 ! Updated license.
245 !
246 ! Revision 1.9 2008/11/19 22:17:25 mtcampbe
247 ! Added Illinois Open Source License/Copyright
248 !
249 ! Revision 1.8 2006/04/07 15:19:16 haselbac
250 ! Removed tabs
251 !
252 ! Revision 1.7 2006/03/25 21:42:18 haselbac
253 ! Changes made bcos of sype boundaries
254 !
255 ! Revision 1.6 2004/11/03 16:58:55 haselbac
256 ! Removed deallocation of vertex and cell flags
257 !
258 ! Revision 1.5 2004/10/19 19:24:15 haselbac
259 ! Made consistent with changes in RFLU_CreateGrid.F90, cosmetics
260 !
261 ! Revision 1.4 2003/12/10 03:58:02 haselbac
262 ! Major bug fix: Fixed dealloc of patches if nPatches = 0
263 !
264 ! Revision 1.3 2003/12/04 03:23:51 haselbac
265 ! Clean-up
266 !
267 ! Revision 1.2 2003/03/15 16:53:34 haselbac
268 ! Clean up, bug fixes
269 !
270 ! Revision 1.1 2003/01/28 15:53:32 haselbac
271 ! Initial revision
272 !
273 ! ******************************************************************************
274 
275 
276 
277 
278 
279 
280 
subroutine rflu_destroygrid(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