Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SURF_Main.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: provide grid coordinates for all surfaces which interact
26 ! with GenX.
27 !
28 ! Description: none.
29 !
30 ! Input: case name from the list of arguments
31 !
32 ! Output: none
33 !
34 ! Notes: none
35 !
36 !******************************************************************************
37 !
38 ! $Id: SURF_Main.F90,v 1.4 2008/12/06 08:44:52 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2002 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 #ifdef CHARM
45 SUBROUTINE mpi_main
46 #else
47 PROGRAM rocflo_surf
48 #endif
49 
50  USE moddatatypes
51  USE moderror
52  USE moddatastruct, ONLY : t_region
53  USE modglobal, ONLY : t_global
59  USE modmpi
60  USE modparameters
61  IMPLICIT NONE
62 
63 #include "Indexing.h"
64 
65 ! ... loop variables
66  INTEGER :: ireg, ilev
67 
68 ! ... local variables
69  CHARACTER(CHRLEN) :: level, gridformat, msg, versionstring, headerstring
70 
71  INTEGER :: ipc, jpc, kpc, ibn, ien, ninteract
72  INTEGER :: idnbeg, idnend, jdnbeg, jdnend, kdnbeg, kdnend, inoff, ijnoff
73  INTEGER :: margin, versionwidth, errorflag
74  INTEGER, PARAMETER :: headerwidth = 53
75 
76  TYPE(t_global), POINTER :: global
77  TYPE(t_region), POINTER :: regions(:)
78 
79 !******************************************************************************
80 
81  ALLOCATE( global )
82 
83  global%nFunTree = 0
84  CALL registerfunction( global,'ROCFLO_Surf',&
85  'SURF_Main.F90' )
86 
87 ! initialize global parameters ------------------------------------------------
88 
89  global%verbLevel = verbose_none
90 
91  global%flowType = flow_steady ! stationary flow
92  global%currentTime = 0._rfreal ! no physical time set
93  global%timeStamp = 0._rfreal
94  global%currentIter = 0 ! no iteration yet
95  global%resInit = 1._rfreal
96 
97  global%inDir = './' ! directory path
98  global%outDir = './'
99 
100  global%nProcAlloc = 1
101  global%myProcid = masterproc ! default process number (if not MPI)
102  global%mpierr = err_none
103  global%error = err_none
104 
105  global%pi = 4._rfreal*atan(1._rfreal)
106  global%rad = global%pi/180._rfreal
107 
108 ! print header ----------------------------------------------------------------
109 
110 #ifdef MPI
111  CALL mpi_init( global%mpierr )
112  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
113 #endif
114 
115  CALL buildversionstring( versionstring )
116 
117  headerstring = ' '
118  versionwidth = len_trim(versionstring)
119  margin = (headerwidth-versionwidth)/2
120  headerstring(margin+1:margin+versionwidth) = versionstring(1:versionwidth)
121  headerstring(1:1) = '*'
122  headerstring(headerwidth:headerwidth) = '*'
123 
124  WRITE(stdout,'(/,A)') solver_name//' *****************************************************'
125  WRITE(stdout, '(A)') solver_name//' * *'
126  WRITE(stdout, '(A)') solver_name//' * ROCFLO-MP: Surface Grid for GenX *'
127  WRITE(stdout, '(A)') solver_name//' * ================================ *'
128  WRITE(stdout, '(A)') solver_name//' * *'
129  WRITE(stdout, '(A)') solver_name//' '//trim(headerstring)
130  WRITE(stdout, '(A)') solver_name//' * Copyright (c) by the University of Illinois *'
131  WRITE(stdout, '(A)') solver_name//' * *'
132  WRITE(stdout,'(A,/)') solver_name//' *****************************************************'
133 
134 ! read argument list ----------------------------------------------------------
135 
136  CALL getarg(1,global%casename)
137  CALL getarg(2,level)
138  CALL getarg(3,gridformat)
139 
140  IF (len_trim(global%casename)==0 .OR. &
141  len_trim(level)==0 .OR. &
142  len_trim(gridformat)==0) THEN
143  WRITE(stdout,'(/,A,/,5(A,/))') &
144  solver_name//' Usage: rflosurf <casename> <level> <grid>', &
145  solver_name, &
146  solver_name//' level = grid level (>0)', &
147  solver_name, &
148  solver_name//' grid = 0 - ASCII format', &
149  solver_name//' = 1 - binary format'
150 #ifdef MPI
151  CALL mpi_finalize( global%mpierr )
152 #endif
153  stop
154  ENDIF
155 
156  READ(level ,*) global%startLevel
157  READ(gridformat,*) global%gridFormat
158 
159 ! read region topology --------------------------------------------------------
160 
161  WRITE(stdout,'(/,A)') solver_name//' Reading region topology ...'
162 
163  CALL rflo_readregiontopology( global,regions )
164 
165  DO ireg=1,global%nRegions
166  regions(ireg)%startLevel = global%startLevel
167  regions(ireg)%currLevel = global%startLevel
168  IF (regions(ireg)%nGridLevels < regions(ireg)%currLevel) THEN
169  WRITE(msg,1000) solver_name,ireg,global%startLevel
170  CALL errorstop( global,err_grid_level,__line__,msg )
171  ENDIF
172  DO ilev=2,regions(ireg)%nGridLevels
173  ipc = regions(ireg)%levels(ilev-1)%grid%ipc
174  jpc = regions(ireg)%levels(ilev-1)%grid%jpc
175  kpc = regions(ireg)%levels(ilev-1)%grid%kpc
176  regions(ireg)%levels(ilev)%grid%ipc = ipc/2
177  regions(ireg)%levels(ilev)%grid%jpc = jpc/2
178  regions(ireg)%levels(ilev)%grid%kpc = kpc/2
179  ENDDO
180  ENDDO
181 
182 ! read boundary conditions
183 
184  CALL rflo_readbcinputfile( regions )
185 
186 ! copy topology and BCs to all grid levels
187 
188  CALL rflo_copytopologylevels( regions )
189 
190 ! count number of interacting patches
191 
192  CALL countinteractingpatches( regions,ninteract )
193 
194 ! output surface grid (regionwise) --------------------------------------------
195 
196  WRITE(stdout,'(A)') solver_name//' Generating and storing surface grid ...'
197 
198 ! open file
199 
200  OPEN(if_plot,file=trim(global%casename)//'.im',form='formatted', &
201  status='unknown',iostat=errorflag)
202  global%error = errorflag
203  IF (global%error /= 0) CALL errorstop( global,err_file_open,__line__ )
204 
205  WRITE(if_plot,*) ninteract,' 2'
206 
207 ! loop over all regions
208 
209  DO ireg=1,global%nregions
210  WRITE(stdout,'(A,I5.5)') solver_name//' - region ',ireg
211 
212  regions(ireg)%currLevel = global%startLevel
213 
214 ! - allocate memory for grid
215 
216  DO ilev=1,regions(ireg)%nGridLevels
217  CALL rflo_getdimensdummynodes( regions(ireg),ilev,idnbeg,idnend, &
218  jdnbeg,jdnend,kdnbeg,kdnend )
219  CALL rflo_getnodeoffset( regions(ireg),ilev,inoff,ijnoff )
220  ibn = indijk(idnbeg,jdnbeg,kdnbeg,inoff,ijnoff)
221  ien = indijk(idnend,jdnend,kdnend,inoff,ijnoff)
222  ALLOCATE( regions(ireg)%levels(ilev)%grid%xyz(3,ibn:ien),stat=errorflag )
223  global%error = errorflag
224  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
225  ENDDO
226 
227 ! - read grid
228 
229  CALL rflo_readgridregion( ireg,regions )
230  CALL rflo_generatecoarsegrids( regions(ireg) )
231  CALL rflo_copygeometrydummy( regions(ireg) )
232 
233 ! - write out surface grid
234 
235  ilev = global%startLevel
236 
237  CALL writesurfacegrid( ireg,regions(ireg) )
238 
239 ! - deallocate memory
240 
241  DO ilev=1,regions(ireg)%nGridLevels
242  DEALLOCATE( regions(ireg)%levels(ilev)%grid%xyz,stat=errorflag )
243  global%error = errorflag
244  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
245  ENDDO
246  ENDDO ! iReg
247 
248 ! finalize --------------------------------------------------------------------
249 
250  CLOSE(if_plot,iostat=errorflag)
251  global%error = errorflag
252  IF (global%error /= 0) CALL errorstop( global,err_file_close,__line__ )
253 
254  CALL deregisterfunction( global )
255 
256  WRITE(stdout,'(/,A)') solver_name//' Finished.'
257 
258 #ifdef MPI
259  CALL mpi_finalize( global%mpierr )
260 #endif
261 
262 1000 FORMAT(a,' Region ',i5,', grid level= ',i2,'.')
263 
264 #ifdef CHARM
265 END SUBROUTINE mpi_main
266 #else
267 END PROGRAM rocflo_surf
268 #endif
269 
270 !******************************************************************************
271 !
272 ! RCS Revision history:
273 !
274 ! $Log: SURF_Main.F90,v $
275 ! Revision 1.4 2008/12/06 08:44:52 mtcampbe
276 ! Updated license.
277 !
278 ! Revision 1.3 2008/11/19 22:18:02 mtcampbe
279 ! Added Illinois Open Source License/Copyright
280 !
281 ! Revision 1.2 2004/12/03 03:35:43 wasistho
282 ! rflo_modinterfacessurf to surf_modinterfaces
283 !
284 ! Revision 1.1 2004/12/03 02:47:00 wasistho
285 ! added prefix
286 !
287 ! Revision 1.1 2004/12/03 00:49:09 wasistho
288 ! lower to upper case
289 !
290 ! Revision 1.5 2003/05/25 18:11:30 jiao
291 ! Added support for Charm.
292 !
293 ! Revision 1.4 2003/05/15 02:57:07 jblazek
294 ! Inlined index function.
295 !
296 ! Revision 1.3 2003/03/20 22:35:02 haselbac
297 ! Renamed ModInterfaces
298 !
299 ! Revision 1.2 2003/03/20 19:48:09 haselbac
300 ! Corrected mistake in phased check-in
301 !
302 ! Revision 1.1 2002/10/19 00:40:31 jblazek
303 ! Added utility (rflosurf) to write out surface grids for GenX.
304 !
305 !******************************************************************************
306 
307 
308 
309 
310 
311 
312 
subroutine rflo_copygeometrydummy(region)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine rflo_readbcinputfile(regions)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE jdnbeg
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE idnend
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE jdnend
subroutine rflo_readgridregion(iReg, regions)
subroutine rflo_copytopologylevels(regions)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE idnbeg
subroutine buildversionstring(versionString)
subroutine rflo_generatecoarsegrids(region)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE form
subroutine writesurfacegrid(iReg, region)
subroutine countinteractingpatches(regions, nInteract)
subroutine rflo_getdimensdummynodes(region, iLev, idnbeg, idnend, jdnbeg, jdnend, kdnbeg, kdnend)
subroutine rflo_readregiontopology(global, regions)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE kdnbeg
program rocflo_surf
Definition: SURF_Main.F90:47
RT a() const
Definition: Line_2.h:140