Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_PostProcessing.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: write out ROCPART solution for visualization.
26 !
27 ! Description: currently supported formats are:
28 ! - TECPLOT ASCII
29 !
30 ! Input: case name from the list of arguments
31 !
32 ! Output: to file.
33 !
34 ! Notes: the output is collected in one file, but the regions are processed
35 ! separately to save memory.
36 !
37 !******************************************************************************
38 !
39 ! $Id: PLAG_PostProcessing.F90,v 1.5 2008/12/06 08:45:07 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2003 by the University of Illinois
42 !
43 !******************************************************************************
44 
45 PROGRAM rocpart_post
46 
47  USE moddatatypes
48  USE moderror
49  USE moddatastruct, ONLY : t_region
50  USE modglobal, ONLY : t_global
51  USE modmixture, ONLY : t_mixt
52  USE modpartlag, ONLY : t_plag, t_plag_input
67 
68 #ifdef STATS
72 #endif
73 
74  USE modmpi
75  USE modparameters
77 
78  IMPLICIT NONE
79 
80 ! ... loop variables
81  INTEGER :: ireg
82 
83 ! ... local variables
84  CHARACTER(CHRLEN) :: rcsidentstring, stamp, outfmt, msg, &
85  verbosity, versionstring, headerstring
86 
87  INTEGER :: ilev, outputformat
88  INTEGER :: margin, versionwidth, errorflag
89  INTEGER :: npclssum
90  INTEGER :: iregbin
91  INTEGER, PARAMETER :: headerwidth = 53
92  INTEGER, PARAMETER :: nstats_tec_plag = 10
93 
94 #ifdef STATS
95  LOGICAL :: statsactive
96 #endif
97 
98  TYPE(t_global), POINTER :: global
99  TYPE(t_region), POINTER :: regions(:)
100  TYPE(t_plag) , POINTER :: pplag
101 
102 !******************************************************************************
103 
104  rcsidentstring = '$RCSfile: PLAG_PostProcessing.F90,v $ $Revision: 1.5 $'
105 
106  ALLOCATE( global )
107 
108  global%nFunTree = 0
109  CALL registerfunction( global,'ROCPART_Post', 'PLAG_PostProcessing.F90' )
110 
111 ! initialize global parameters ------------------------------------------------
112 
113  global%verbLevel = verbose_none
114 
115  global%flowType = flow_steady ! stationary flow
116  global%currentTime = -1._rfreal ! no physical time set
117  global%currentIter = -1 ! no iteration
118 
119  global%inDir = './' ! directory path
120  global%outDir = './'
121 
122  global%nProcAlloc = 1
123  global%myProcid = masterproc ! default process number (not an MPI code)
124  global%mpierr = err_none
125  global%error = err_none
126 
127  global%pi = 4._rfreal*atan(1._rfreal)
128  global%rad = global%pi/180._rfreal
129 
130  global%startLevel = 1
131 
132 ! print header ----------------------------------------------------------------
133 
134 #ifdef MPI
135  CALL mpi_init( global%mpierr )
136  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
137 #endif
138 
139  CALL buildversionstring( versionstring )
140 
141  headerstring = ' '
142  versionwidth = len_trim(versionstring)
143  margin = (headerwidth-versionwidth)/2
144  headerstring(margin+1:margin+versionwidth) = versionstring(1:versionwidth)
145  headerstring(1:1) = '*'
146  headerstring(headerwidth:headerwidth) = '*'
147 
148  WRITE(stdout,'(/,A)') solver_name//' *****************************************************'
149  WRITE(stdout, '(A)') solver_name//' * *'
150  WRITE(stdout, '(A)') solver_name//' * ROCPART: Solution Postprocessing *'
151  WRITE(stdout, '(A)') solver_name//' * ================================ *'
152  WRITE(stdout, '(A)') solver_name//' * *'
153  WRITE(stdout, '(A)') solver_name//' '//trim(headerstring)
154  WRITE(stdout, '(A)') solver_name//' * Copyright (c) by the University of Illinois *'
155  WRITE(stdout, '(A)') solver_name//' * *'
156  WRITE(stdout,'(A,/)') solver_name//' *****************************************************'
157 
158 ! read argument list ----------------------------------------------------------
159 
160  CALL getarg(1,global%casename)
161  CALL getarg(2,stamp)
162  CALL getarg(3,outfmt)
163  CALL getarg(4,verbosity)
164 
165  IF (len_trim(global%casename)==0 .OR. &
166  len_trim(stamp)==0 .OR. &
167  len_trim(verbosity)==0 .OR. &
168  len_trim(outfmt)==0) THEN
169  WRITE(stdout,'(/,A,/,A,/,9(A,/))') &
170  solver_name//' Usage: plagpost <casename> <time> <format> <verbosity>', &
171  solver_name, &
172  solver_name//' time = time ', &
173  solver_name//' ', &
174  solver_name//' format = 3 - Tecplot ASCII',&
175  solver_name//' ', &
176  solver_name//' verbosity = 0-2 '
177 #ifdef MPI
178  CALL mpi_finalize( global%mpierr )
179 #endif
180  stop
181  ENDIF
182 
183  READ(outfmt ,*) outputformat
184 
185  IF (outputformat <= 1) THEN
186  outputformat = plot_fmt_generic
187  ELSE IF (outputformat == 2) THEN
188  outputformat = plot_fmt_tecplot
189  ELSE
190  outputformat = plot_fmt_tecascii
191  ENDIF
192 
193 ! check for TECPLOT library
194 
195 #ifdef NO_TECPLOT
196  IF (outputformat == plot_fmt_tecplot) THEN
197  WRITE(stdout,'(/,A,/)') solver_name// &
198  ' Sorry, not linked to TECPLOT library.'
199 #ifdef MPI
200  CALL mpi_finalize( global%mpierr )
201 #endif
202  stop
203  ENDIF
204 #endif
205 
206  READ(verbosity,*) global%verbLevel
207 
208 ! read region topology --------------------------------------------------------
209 
210  WRITE(stdout,'(/,A)') solver_name//' Reading region topology ...'
211 
212  CALL rflo_readregiontopology( global,regions )
213 
214  DO ireg=1,global%nRegions
215  regions(ireg)%startLevel = global%startLevel
216  regions(ireg)%currLevel = global%startLevel
217  IF (regions(ireg)%nGridLevels < regions(ireg)%currLevel) THEN
218  WRITE(msg,1000) solver_name,ireg,global%startLevel
219  CALL errorstop( global,err_grid_level,__line__,msg )
220  ENDIF
221  ENDDO
222 
223 ! get user parameters ---------------------------------------------------------
224 
225  WRITE(stdout,'(/,A)') solver_name//' Reading user input ...'
226 
227  CALL rflo_initinputvalues( regions )
228  CALL readinputfile( regions )
229  CALL plag_userinput( regions )
230 
231  IF (global%flowType == flow_steady) THEN
232  WRITE(stdout,'(/,A,/)') solver_name// &
233  ' Sorry, unable to run Rocpart Post-processing ', &
234  ' tool for steady state case.'
235 #ifdef MPI
236  CALL mpi_finalize( global%mpierr )
237 #endif
238  stop
239  ELSE
240  READ(stamp,*) global%timeStamp
241  global%currentTime = global%timeStamp
242  ENDIF
243 
244  CALL rflo_derivedinputvalues( regions )
245 
246 #ifndef PLAG
247  WRITE(stdout,'(/,A,/)') solver_name// &
248  ' Sorry, unable to run Rocpart Post-processing ', &
249  ' tool since code was not compiled with PLAG.'
250 #ifdef MPI
251  CALL mpi_finalize( global%mpierr )
252 #endif
253  stop
254 #endif
255 
256 #ifdef STATS
257  statsactive = ( (global%plagUsed .EQV. .true.) .AND. &
258  (global%flowType == flow_unsteady) .AND. &
259  (global%doStat == active) )
260 #endif
261 
262 ! allocate memory -------------------------------------------------------------
263 
264  WRITE(stdout,'(A)') solver_name// &
265  ' Reading ROCPART solution and writing plot file ...'
266 
267  DO ireg=1,global%nRegions
268  CALL plag_allocatememorypost( regions(ireg), ireg )
269  ENDDO ! iReg
270 
271 ! read solution ---------------------------------------------------------------
272 
273  CALL plag_readsolutionfilepost( regions )
274 
275 ! initialize cumulative sum ---------------------------------------------------
276 
277  npclssum = 0
278 
279 ! write data ------------------------------------------------------------------
280 
281  DO ireg=1,global%nRegions
282 
283  WRITE(stdout,'(A,I5.5)') solver_name//' - region ',ireg
284 
285  ilev = regions(ireg)%currLevel
286 
287 ! - compute cumulative number of particles in all regions
288 
289  npclssum = npclssum + regions(ireg)%levels(ilev)%plag%nPcls
290 
291  IF ( ireg == global%nRegions ) &
292  WRITE(stdout,'(A,I8.8)') 'Total Number of Particles = ',npclssum
293 
294 ! - calculate derived variables
295 
296  CALL plag_calcderivedvariables( regions(ireg) )
297 
298 ! - write data
299 
300  SELECT CASE ( outputformat )
301 
302 ! -- write data to TECPLOT file (ASCII)
303 
304  CASE ( plot_fmt_tecascii )
305  CALL plag_writetecplotascii( ireg,ilev,regions(ireg) )
306 
307  CASE default
308  CALL errorstop(global,err_reached_default,__line__)
309  END SELECT ! outputFormat
310  ENDDO ! iReg
311 
312 ! write bined particle data at nozzle inlet (ASCII format)
313 
314  DO ireg=1,global%nRegions
315  IF ( ireg == 41 .OR. ireg == 52 ) THEN
316  iregbin = ireg
317  CALL plag_binsortnozzleinlet( ireg,ilev,regions(ireg), iregbin )
318  CALL plag_binsortspatialdist( ireg,ilev,regions(ireg), iregbin )
319  END IF ! iReg
320  ENDDO ! iReg
321 
322 ! process Eulerian grid-based data for PLAG -----------------------------------
323 
324  DO ireg=1,global%nRegions
325  CALL plag_processeulerfield( regions,ireg,npclssum )
326  ENDDO ! iReg
327 
328 ! deallocate memory -----------------------------------------------------------
329 
330  DO ireg=1,global%nRegions
331  CALL plag_deallocatememorypost( regions(ireg), ireg )
332  ENDDO ! iReg
333 
334 ! ******************************************************************************
335 ! Save currentTime as global value is clobbered by RFLO_ReadGridRegion
336 ! ******************************************************************************
337 
338  global%currentTime = global%timeStamp
339 
340 ! process Eulerian grid-based statistics data for PLAG ------------------------
341 
342 #ifdef STATS
343  IF ( statsactive .EQV. .true. ) THEN
344 
345 ! - trap error if expected number of statistics is less then set value -------
346 
347  IF ( global%plagNStat > 0 ) THEN
348  IF ( global%plagNStat < nstats_tec_plag ) &
349  CALL errorstop( global,err_stats_tecplot,__line__, &
350  'plagNStat < NSTATS_TEC_PLAG' )
351  ENDIF ! plagNStat > 0
352 
353 ! - write tecplot statistics file ---------------------------------------------
354 
355  DO ireg=1,global%nRegions
356 
357 ! -- allocate memory ----------------------------------------------------------
358 
359  IF ( ireg== 1 .AND. global%myProcid == masterproc .AND. &
360  global%verbLevel > verbose_none ) THEN
361  WRITE(stdout,'(A,3X,A)') solver_name,'Allocating memory for statistics...'
362  END IF ! global%verbLevel
363 
364  DO ilev=1,regions(ireg)%nGridLevels
365  pplag => regions(ireg)%levels(ilev)%plag
366  CALL plag_createstat( regions(ireg), pplag )
367  END DO ! iLev
368 
369  IF ( ireg == global%nRegions .AND. global%myProcid == masterproc .AND. &
370  global%verbLevel > verbose_none ) THEN
371  WRITE(stdout,'(A,3X,A)') solver_name,'Allocating memory for statistics done...'
372  END IF ! global%verbLevel
373 
374 ! -- read statistics file ------------------------------------------------------
375 
376  IF ( ireg== 1 .AND. global%myProcid == masterproc .AND. &
377  global%verbLevel > verbose_none ) THEN
378  WRITE(stdout,'(A,3X,A)') solver_name,'Reading statistics solution file for PLAG...'
379  END IF ! global%verbLevel
380 
381  CALL plag_readstatpost( regions,ireg )
382 
383  IF ( ireg == global%nRegions .AND. global%myProcid == masterproc .AND. &
384  global%verbLevel > verbose_none ) THEN
385  WRITE(stdout,'(A,3X,A)') solver_name,'Reading statistics solution file for PLAG done...'
386  END IF ! global%verbLevel
387 
388 ! -- write data to file --------------------------------------------------------
389 
390  WRITE(stdout,'(A,I5.5)') solver_name//' Statistics - region ',ireg
391 
392  SELECT CASE ( outputformat )
393 
394 ! --- TECPLOT file (ASCII) -----------------------------------------------------
395 
396  CASE ( plot_fmt_tecascii )
397  CALL plag_writestattecascii( regions,ireg )
398 
399  CASE default
400  CALL errorstop(global,err_reached_default,__line__)
401  END SELECT ! outputFormat
402 
403 ! -- deallocate memory ---------------------------------------------------------
404 
405  IF ( ireg== 1 .AND. global%myProcid == masterproc .AND. &
406  global%verbLevel > verbose_none ) THEN
407  WRITE(stdout,'(A,3X,A)') solver_name,'Deallocating memory for statistics...'
408  END IF ! global%verbLevel
409 
410  DO ilev=1,regions(ireg)%nGridLevels
411  pplag => regions(ireg)%levels(ilev)%plag
412  CALL plag_destroystat( regions(ireg), pplag )
413  END DO ! iLev
414 
415  IF ( ireg == global%nRegions .AND. global%myProcid == masterproc .AND. &
416  global%verbLevel > verbose_none ) THEN
417  WRITE(stdout,'(A,3X,A)') solver_name,'Deallocating memory for statistics done...'
418  END IF ! global%verbLevel
419 
420  ENDDO ! iReg
421 
422 
423  ENDIF ! statsActive
424 #endif
425 
426 ! finalize --------------------------------------------------------------------
427 
428  CALL deregisterfunction( global )
429 
430  WRITE(stdout,'(/,A)') solver_name//' Finished.'
431 
432 #ifdef MPI
433  CALL mpi_finalize( global%mpierr )
434 #endif
435 
436 1000 FORMAT(a,' Region ',i5,', grid level= ',i2,'.')
437 
438 END PROGRAM rocpart_post
439 
440 !******************************************************************************
441 !
442 ! RCS Revision history:
443 !
444 ! $Log: PLAG_PostProcessing.F90,v $
445 ! Revision 1.5 2008/12/06 08:45:07 mtcampbe
446 ! Updated license.
447 !
448 ! Revision 1.4 2008/11/19 22:18:18 mtcampbe
449 ! Added Illinois Open Source License/Copyright
450 !
451 ! Revision 1.3 2005/02/16 23:44:16 fnajjar
452 ! Moved statistics-specific routines inside ifdef construct
453 !
454 ! Revision 1.2 2005/02/16 14:49:23 fnajjar
455 ! Added infrastructure to write Tecplot-based statistics file
456 !
457 ! Revision 1.1 2004/12/01 22:00:46 fnajjar
458 ! Initial revision after changing case
459 !
460 ! Revision 1.8 2004/11/17 22:13:17 fnajjar
461 ! Cosmetic changes, removed support for enhanced Tecplot files and added call for eulerian data processing
462 !
463 ! Revision 1.7 2004/11/13 21:58:48 fnajjar
464 ! Added spatial binary sort and streamlined calls to binary sorts
465 !
466 ! Revision 1.6 2004/06/29 14:06:19 fnajjar
467 ! Removed call to interpolation of mixture properties since mixture data not allocated
468 !
469 ! Revision 1.5 2004/05/24 14:24:18 fnajjar
470 ! Included interpolation for mixture and binning routine
471 !
472 ! Revision 1.4 2004/03/20 23:47:52 fnajjar
473 ! Updated executable name in error trapping from rplagpost to plagpost
474 !
475 ! Revision 1.3 2003/07/30 23:21:53 fnajjar
476 ! Included cumulative sum of particles in IO
477 !
478 ! Revision 1.2 2003/05/28 13:57:36 fnajjar
479 ! Removed IndIJK as being an obsolete option
480 !
481 ! Revision 1.1.1.1 2003/05/06 16:14:38 fnajjar
482 ! Import of postprocessing tool for Rocpart
483 !
484 !******************************************************************************
485 
486 
487 
488 
489 
490 
491 
subroutine plag_deallocatememorypost(region, iReg)
subroutine, public plag_createstat(pRegion, pPlag)
subroutine plag_readsolutionfilepost(regions)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine plag_allocatememorypost(region, iReg)
subroutine plag_intrpmixtproperties(region)
subroutine buildversionstring(versionString)
subroutine plag_processeulerfield(regions, iReg, nPclsSum)
subroutine plag_writetecplotascii(iReg, iLev, region)
subroutine plag_binsortnozzleinlet(iReg, iLev, region, iRegBin)
subroutine plag_binsortspatialdist(iReg, iLev, region, iRegBin)
subroutine readinputfile(regions)
subroutine plag_writestattecascii(regions, iReg)
subroutine plag_calcderivedvariables(region)
subroutine rflo_derivedinputvalues(regions)
subroutine plag_readstatpost(regions, iReg)
subroutine rflo_readregiontopology(global, regions)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine, public plag_destroystat(pRegion, pPlag)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_initinputvalues(regions)
program rocpart_post
subroutine plag_userinput(regions)
RT a() const
Definition: Line_2.h:140