Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PREP_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 intitial guess for ROCFLO-MP.
26 !
27 ! Description: the initialization is done sepoarately for each region.
28 ! Flow conditions can vary between the regions.
29 !
30 ! Input: case name from the list of arguments
31 !
32 ! Output: none
33 !
34 ! Notes: none
35 !
36 !******************************************************************************
37 !
38 ! $Id: PREP_Main.F90,v 1.7 2008/12/06 08:44:50 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2001 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 PROGRAM rocflo_init
45 
46  USE moddatatypes
47  USE moderror
48  USE moddatastruct, ONLY : t_region
49  USE modglobal, ONLY : t_global
50 #ifdef GENX
52 #endif
58  USE modmpi
59  USE modparameters
60  IMPLICIT NONE
61 
62 #ifdef GENX
63  include 'roccomf90.h'
64 #endif
65 
66 ! ... loop variables
67  INTEGER :: ireg, ilev
68 
69 ! ... local variables
70  CHARACTER(CHRLEN) :: casename, verbosity, msg, versionstring, headerstring
71 #ifdef GENX
72  CHARACTER(CHRLEN) :: wins, winv
73 #endif
74 
75  INTEGER :: ipc, jpc, kpc, gridlevel
76  INTEGER :: margin, versionwidth, errorflag
77  INTEGER, PARAMETER :: headerwidth = 53
78 
79  TYPE(t_global), POINTER :: global
80  TYPE(t_region), POINTER :: regions(:)
81 
82 !******************************************************************************
83 
84  ALLOCATE( global )
85 
86  global%nFunTree = 0
87  CALL registerfunction( global,'ROCFLO_Init',&
88  'PREP_Main.F90' )
89 
90 ! initialize global parameters ------------------------------------------------
91 
92  global%verbLevel = verbose_none
93 
94  global%flowType = flow_steady ! stationary flow
95  global%currentTime = 0._rfreal ! no physical time set
96  global%currentIter = 0 ! no iteration yet
97  global%resInit = 1._rfreal
98 
99  global%inDir = './' ! directory path
100  global%outDir = './'
101 
102  global%nProcAlloc = 1
103  global%myProcid = masterproc ! default process number (if not MPI)
104  global%mpierr = err_none
105  global%error = err_none
106 
107  global%pi = 4._rfreal*atan(1._rfreal)
108  global%rad = global%pi/180._rfreal
109 
110 ! print header ----------------------------------------------------------------
111 
112 !#ifdef MPI
113 ! CALL MPI_Init( global%mpierr )
114 ! IF (global%mpierr /=0 ) CALL ErrorStop( global,ERR_MPI_TROUBLE,__LINE__ )
115 !#endif
116 
117  CALL buildversionstring( versionstring )
118 
119  headerstring = ' '
120  versionwidth = len_trim(versionstring)
121  margin = (headerwidth-versionwidth)/2
122  headerstring(margin+1:margin+versionwidth) = versionstring(1:versionwidth)
123  headerstring(1:1) = '*'
124  headerstring(headerwidth:headerwidth) = '*'
125 
126  WRITE(stdout,'(/,A)') solver_name//' *****************************************************'
127  WRITE(stdout, '(A)') solver_name//' * *'
128  WRITE(stdout, '(A)') solver_name//' * ROCFLO-MP: Solution Initialization *'
129  WRITE(stdout, '(A)') solver_name//' * ================================== *'
130  WRITE(stdout, '(A)') solver_name//' * *'
131  WRITE(stdout, '(A)') solver_name//' '//trim(headerstring)
132  WRITE(stdout, '(A)') solver_name//' * Copyright (c) by the University of Illinois *'
133  WRITE(stdout, '(A)') solver_name//' * *'
134  WRITE(stdout,'(A,/)') solver_name//' *****************************************************'
135 
136 ! print required input and read argument list ---------------------------------
137 
138  WRITE(stdout,'(/,A,/,A,/,8(A,/))') &
139  solver_name//' Required Rocflo-Prep input:', &
140  solver_name, &
141  solver_name//' <casename> => command line input', &
142  solver_name//' <verbosity> => command line input', &
143  solver_name//' grid level => .inp file: # MULTIGRID: START', &
144  solver_name//' input grd format => .inp file: # FORMATS: GRID', &
145  solver_name//' output sol format => .inp file: # FORMATS: SOLUTION', &
146  solver_name//' unsteadiness => .inp file: # TIMESTEP: FLOWTYPE', &
147  solver_name//' spec. heat ratio => .inp file: # REFERENCE: GAMMA', &
148  solver_name//' initial solution => .inp file: # INITFLOW: all'
149 
150  CALL getarg(1,casename)
151  CALL getarg(2,verbosity)
152 
153  IF (len_trim(casename)==0 .OR. &
154  len_trim(verbosity)==0) THEN
155  WRITE(stdout,'(/,A,/)') &
156  solver_name//' Usage: rfloprep <casename> <verbosity>'
157 !#ifdef MPI
158 ! CALL MPI_Finalize( global%mpierr )
159 !#endif
160  stop
161  ENDIF
162 
163  READ(casename ,*) global%casename
164  READ(verbosity,*) global%verbLevel
165 
166 ! initial process for Genx ----------------------------------------------------
167 
168 #ifdef GENX
169  CALL com_init
170 
171 ! load Rocout module
172  CALL com_set_verbose( 1 )
173  CALL rocout_load_module( 'OUT')
174 #endif
175 
176 ! read, check and print user input --------------------------------------------
177 
178  WRITE(stdout,'(/,A)') solver_name//' Reading region topology ...'
179 
180  CALL rflo_readregiontopology( global,regions )
181 
182  WRITE(stdout,'(A)') solver_name//' Reading user input file ...'
183 
184  CALL initinputvalues( regions )
185 
186  CALL readinputfile( regions )
187 
188  WRITE(stdout,'(A)') solver_name//' Checking BC consistency ...'
189 
190  CALL readbcinputfile( regions )
191 
192  CALL checkbcvalidity( regions )
193 
194  IF (global%verbLevel >= verbose_low) CALL printprepinput( regions )
195 
196 ! check grid level and obtain volume grid -------------------------------------
197 
198  WRITE(stdout,'(A)') solver_name//' Reading grid ...'
199 
200  gridlevel = global%startLevel
201 
202  DO ireg=1,global%nRegions
203  IF (regions(ireg)%nGridLevels < gridlevel) THEN
204  WRITE(msg,1000) solver_name,ireg,gridlevel
205  CALL errorstop( global,err_grid_level,__line__,msg )
206  ENDIF
207  DO ilev=2,regions(ireg)%nGridLevels
208  ipc = regions(ireg)%levels(ilev-1)%grid%ipc
209  jpc = regions(ireg)%levels(ilev-1)%grid%jpc
210  kpc = regions(ireg)%levels(ilev-1)%grid%kpc
211  regions(ireg)%levels(ilev)%grid%ipc = ipc/2
212  regions(ireg)%levels(ilev)%grid%jpc = jpc/2
213  regions(ireg)%levels(ilev)%grid%kpc = kpc/2
214  ENDDO
215 
216  CALL getgrid( gridlevel,ireg,regions )
217  ENDDO
218 
219 ! create bc distribution files if applicable ----------------------------------
220 
221  WRITE(stdout,'(A)') solver_name//' Write BC distribution to files ...'
222 
223  CALL bcdistributionfiles( regions )
224 
225 ! check for Genx format -------------------------------------------------------
226 
227  IF (global%solutFormat==2) THEN
228 #ifndef GENX
229  CALL errorstop( global,err_unknown_format,__line__, &
230  'compile with GENX=1 for format=2 (Genx HDF format)' )
231 #endif
232  ENDIF
233 
234 ! generate initial guess (regionwise) -----------------------------------------
235 
236  WRITE(stdout,'(A)') solver_name//' Generating and storing solution ...'
237 
238  DO ireg=1,global%nregions
239  WRITE(stdout,'(A,I5.5)') solver_name//' - region ',ireg
240 
241  IF (global%solutFormat==2) THEN
242 #ifdef GENX
243  CALL genxinitsolution( gridlevel,ireg,regions,wins,winv )
244  CALL genxwritesolution( gridlevel,ireg,regions(ireg),wins,winv )
245 #endif
246  ELSE
247  CALL initializeflowfield( gridlevel,regions(ireg) )
248  CALL rflo_writesolutionregion( ireg,regions )
249 
250  DEALLOCATE( regions(ireg)%levels(gridlevel)%mixt%cv,stat=errorflag )
251  global%error = errorflag
252  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
253  ENDIF ! solFormat
254  ENDDO ! iReg
255 
256 ! finalize --------------------------------------------------------------------
257 
258  CALL deregisterfunction( global )
259 
260  WRITE(stdout,'(/,A)') solver_name//' Finished.'
261 
262 !#ifdef MPI
263 ! CALL MPI_Finalize( global%mpierr )
264 !#endif
265 
266 1000 FORMAT(a,' Region ',i5,', grid level= ',i2,'.')
267 
268 END PROGRAM rocflo_init
269 
270 !******************************************************************************
271 !
272 ! RCS Revision history:
273 !
274 ! $Log: PREP_Main.F90,v $
275 ! Revision 1.7 2008/12/06 08:44:50 mtcampbe
276 ! Updated license.
277 !
278 ! Revision 1.6 2008/11/19 22:18:00 mtcampbe
279 ! Added Illinois Open Source License/Copyright
280 !
281 ! Revision 1.5 2005/05/03 03:20:01 wasistho
282 ! enabled modified cyl.Taylor inflow profile
283 !
284 ! Revision 1.4 2005/05/02 18:07:54 wasistho
285 ! added cylindrical Taylor inflow profile capability
286 !
287 ! Revision 1.3 2005/04/29 03:31:45 wasistho
288 ! added distribution bc file generator
289 !
290 ! Revision 1.2 2004/12/03 03:29:42 wasistho
291 ! rflo_modinterfacesprep to prep_modinterfaces
292 !
293 ! Revision 1.1 2004/12/03 02:20:08 wasistho
294 ! added prefix
295 !
296 ! Revision 1.1 2004/12/03 00:40:49 wasistho
297 ! lower to upper case
298 !
299 ! Revision 1.30 2004/11/16 07:16:32 jiao
300 ! Updated to call Rocout_load_module directly instead of calling through
301 ! COM_load_module, to allow static linking.
302 !
303 ! Revision 1.29 2004/11/14 17:23:09 jiao
304 ! Removed conditional compilation for CHARM.
305 !
306 ! Revision 1.28 2004/11/14 05:42:16 jiao
307 ! Changed to use TCHARM_GETARG when CHARM is defined.
308 !
309 ! Revision 1.27 2004/09/08 05:18:30 wasistho
310 ! commented ifdef MPI, as it is always one processor operation anyway
311 !
312 ! Revision 1.26 2004/07/28 01:47:04 wasistho
313 ! cosmetics and cleanup
314 !
315 ! Revision 1.25 2004/07/27 20:28:13 wasistho
316 ! added readBcInputFile and checkBcValidity
317 !
318 ! Revision 1.24 2004/07/27 03:34:47 wasistho
319 ! add printPrepInput
320 !
321 ! Revision 1.23 2004/07/23 04:32:18 wasistho
322 ! Genx: readin from Rocin, standalone: read .inp file i.o. command line input
323 !
324 ! Revision 1.22 2004/06/30 00:00:19 wasistho
325 ! migrated to Roccom-3
326 !
327 ! Revision 1.21 2003/05/25 18:11:30 jiao
328 ! Added support for Charm.
329 !
330 ! Revision 1.20 2003/05/15 02:57:07 jblazek
331 ! Inlined index function.
332 !
333 ! Revision 1.19 2003/04/10 03:44:38 jblazek
334 ! Merged .ini file into .inp file.
335 !
336 ! Revision 1.18 2003/03/20 23:31:50 jiao
337 ! ACH: Changed ModInterfaces to RFLO_ModInterfacesPrep.
338 !
339 ! Revision 1.17 2003/03/20 19:44:22 haselbac
340 ! Corrected mistake in phased check-in
341 !
342 ! Revision 1.16 2003/03/20 19:35:43 haselbac
343 ! Modified RegFun call to avoid probs with long 'PREP_Main.F90' names
344 !
345 ! Revision 1.15 2002/10/12 03:20:51 jblazek
346 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
347 !
348 ! Revision 1.14 2002/09/20 22:22:37 jblazek
349 ! Finalized integration into GenX.
350 !
351 ! Revision 1.13 2002/09/05 17:40:22 jblazek
352 ! Variable global moved into regions().
353 !
354 ! Revision 1.12 2002/07/16 21:34:37 jblazek
355 ! Prefixed screen output with SOLVER_NAME.
356 !
357 ! Revision 1.11 2002/07/12 21:50:07 jblazek
358 ! Added tool to split single grid into multiple regions.
359 !
360 ! Revision 1.10 2002/06/14 17:35:11 jblazek
361 ! Added version string.
362 !
363 ! Revision 1.9 2002/06/07 16:40:37 jblazek
364 ! Grid & solution for all regions in one file.
365 !
366 ! Revision 1.8 2002/03/18 21:31:55 jblazek
367 ! Made codes compatible with MPI.
368 !
369 ! Revision 1.7 2002/02/21 23:25:07 jblazek
370 ! Blocks renamed as regions.
371 !
372 ! Revision 1.6 2002/02/16 07:16:00 jblazek
373 ! Added implicit residual smoothing.
374 !
375 ! Revision 1.5 2002/01/11 17:20:19 jblazek
376 ! Added time stamp or iteration number to file names.
377 !
378 ! Revision 1.4 2002/01/10 18:21:30 jblazek
379 ! Added iteration number and initial residual to solution file.
380 !
381 ! Revision 1.3 2002/01/08 22:09:17 jblazek
382 ! Added calculation of face vectors and volumes.
383 !
384 ! Revision 1.2 2002/01/02 15:57:08 jblazek
385 ! Added flow initialization.
386 !
387 ! Revision 1.1.1.1 2001/12/03 21:44:05 jblazek
388 ! Import of RocfluidMP
389 !
390 !******************************************************************************
391 
392 
393 
394 
395 
396 
397 
398 
subroutine genxinitsolution(gridLevel, iReg, regions, wins, winv)
subroutine checkbcvalidity(regions)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine getgrid(gridLevel, iReg, regions)
subroutine initinputvalues(regions)
subroutine buildversionstring(versionString)
program rocflo_init
Definition: PREP_Main.F90:44
subroutine genxwritesolution(gridLevel, iReg, region, wins, winv)
subroutine readinputfile(regions)
subroutine readbcinputfile(regions)
subroutine printprepinput(regions)
subroutine rflo_readregiontopology(global, regions)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine, public bcdistributionfiles(regions)
subroutine rflo_writesolutionregion(iReg, regions)
subroutine initializeflowfield(iLev, region)
RT a() const
Definition: Line_2.h:140