Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_RFLU_ReadSolutionASCII.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: Read flow file for particles in ASCII ROCFLU format.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to region
31 !
32 ! Output: None.
33 !
34 ! Notes: None.
35 !
36 ! ******************************************************************************
37 !
38 ! $Id: PLAG_RFLU_ReadSolutionASCII.F90,v 1.10 2008/12/06 08:44:35 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2004 by the University of Illinois
41 !
42 ! ******************************************************************************
43 
44 SUBROUTINE plag_rflu_readsolutionascii(pRegion)
45 
46  USE modglobal, ONLY: t_global
47  USE moddatatypes
48  USE modparameters
49  USE moderror
50  USE modgrid, ONLY: t_grid
51  USE modbndpatch, ONLY: t_patch
52  USE moddatastruct, ONLY: t_region
53  USE modpartlag, ONLY: t_plag,t_tile_plag
54  USE modmpi
55 
57 
59 
60  IMPLICIT NONE
61 
62 ! ******************************************************************************
63 ! Declarations and definitions
64 ! ******************************************************************************
65 
66 ! ==============================================================================
67 ! Local variables
68 ! ==============================================================================
69 
70  CHARACTER(CHRLEN) :: errorstring,ifilename,sectionstring,rcsidentstring, &
71  timestring1,timestring2
72  INTEGER :: errorflag,icont,ifile,ifl,imass,ipatch,ivars,j,loopcounter,ncont, &
73  npcls,npclsexpected,nvars,nvarsexpected,precactual,precexpected, &
74  rangeactual,rangeexpected
75  INTEGER, DIMENSION(:,:), POINTER :: paiv
76  REAL(RFREAL) :: currenttime
77  REAL(RFREAL), DIMENSION(:,:), POINTER :: parv,pcv
78  TYPE(t_grid), POINTER :: pgrid
79  TYPE(t_global), POINTER :: global
80  TYPE(t_patch), POINTER :: ppatch
81  TYPE(t_plag), POINTER :: pplag
82  TYPE(t_tile_plag), POINTER :: ptileplag
83 
84 ! ==============================================================================
85 ! Arguments
86 ! ==============================================================================
87 
88  TYPE(t_region), POINTER :: pregion
89 
90 ! ******************************************************************************
91 ! Start, open file
92 ! ******************************************************************************
93 
94  rcsidentstring = '$RCSfile: PLAG_RFLU_ReadSolutionASCII.F90,v $ $Revision: 1.10 $'
95 
96  global => pregion%global
97 
98  CALL registerfunction(global,'PLAG_RFLU_ReadSolutionASCII',&
99  'PLAG_RFLU_ReadSolutionASCII.F90')
100 
101  IF ( global%myProcid == masterproc .AND. &
102  global%verbLevel > verbose_none ) THEN
103  WRITE(stdout,'(A,1X,A)') solver_name,'Reading ASCII particle file...'
104  END IF ! global%verbLevel
105 
106  CALL buildfilenameunsteady(global,filedest_outdir,'.plag_sola', &
107  pregion%iRegionGlobal,global%currentTime, &
108  ifilename)
109 
110  ifile = if_solut
111  OPEN(ifile,file=ifilename,form="FORMATTED",status="OLD",iostat=errorflag)
112  global%error = errorflag
113  IF ( global%error /= err_none ) THEN
114  CALL errorstop(global,err_file_open,__line__,ifilename)
115  END IF ! global%error
116 
117 ! ==============================================================================
118 ! Header and general information
119 ! ==============================================================================
120 
121  IF ( global%myProcid == masterproc .AND. &
122  global%verbLevel > verbose_low ) THEN
123  WRITE(stdout,'(A,3X,A)') solver_name,'Header information...'
124  END IF ! global%verbLevel
125 
126  READ(ifile,'(A)') sectionstring
127  IF ( trim(sectionstring) /= '# ROCFLU particle file' ) THEN
128  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
129  END IF ! TRIM
130 
131 ! -----------------------------------------------------------------------------
132 ! Precision and range
133 ! -----------------------------------------------------------------------------
134 
135  READ(ifile,'(A)') sectionstring
136  IF ( trim(sectionstring) /= '# Precision and range' ) THEN
137  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
138  END IF ! TRIM
139 
140  precexpected = precision(1.0_rfreal)
141  rangeexpected = range(1.0_rfreal)
142 
143  READ(ifile,'(2(I8))') precactual,rangeactual
144  IF ( precactual < precexpected .OR. rangeactual < rangeexpected ) THEN
145  CALL errorstop(global,err_prec_range,__line__)
146  END IF ! precActual
147 
148 ! -----------------------------------------------------------------------------
149 ! Initial residual and physical time
150 ! -----------------------------------------------------------------------------
151 
152  READ(ifile,'(A)') sectionstring
153  IF ( trim(sectionstring) /= '# Physical time' ) THEN
154  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
155  END IF ! TRIM
156 
157  READ(ifile,'(E23.16)') currenttime
158 
159 #ifndef GENX
160  IF ( global%flowType == flow_unsteady ) THEN
161  IF ( global%currentTime < 0.0_rfreal ) THEN
162  global%currentTime = currenttime
163  ELSE
164  WRITE(timestring1,'(1PE11.5)') global%currentTime
165  WRITE(timestring2,'(1PE11.5)') currenttime
166  IF ( trim(timestring1) /= trim(timestring2) ) THEN
167  CALL errorstop(global,err_time_solution,__line__,trim(ifilename))
168  END IF ! global%currentTime
169  END IF ! global%currentTime
170  END IF ! global%flowType
171 #endif
172 
173 ! ==============================================================================
174 ! Dimensions
175 ! ==============================================================================
176 
177  pgrid => pregion%grid
178  pplag => pregion%plag
179 
180  ncont = pregion%plagInput%nCont
181 
182  nvarsexpected = 13 ! Hard-coded for now
183  npclsexpected = pplag%nPcls
184 
185  READ(ifile,'(A)') sectionstring
186  IF ( trim(sectionstring) /= '# Dimensions' ) THEN
187  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
188  END IF ! TRIM
189 
190  READ(ifile,'(2(I8))') npcls,nvars
191 
192  IF ( npcls /= npclsexpected ) THEN
193  WRITE(errorstring,'(A,1X,I6,1X,A,1X,I6)') 'Specified:',npcls, &
194  'but expected:',npclsexpected
195  CALL errorstop(global,err_plag_invalid_npcls,__line__,errorstring)
196  END IF ! nCellsExpected
197 
198  IF ( nvars /= nvarsexpected ) THEN
199  WRITE(errorstring,'(A,1X,I6,1X,A,1X,I6)') 'Specified:',nvars, &
200  'but expected:',nvarsexpected
201  CALL errorstop(global,err_invalid_nvars,__line__)
202  END IF ! nVarsExpected
203 
204 ! ==============================================================================
205 ! Rest of file
206 ! ==============================================================================
207 
208  icont = 0
209  ivars = 0
210  loopcounter = 0
211 
212  DO ! set up infinite loop
213  loopcounter = loopcounter + 1
214 
215  READ(ifile,'(A)') sectionstring
216 
217  SELECT CASE ( trim(sectionstring) )
218 
219 ! ------------------------------------------------------------------------------
220 ! Particle x-momentum
221 ! ------------------------------------------------------------------------------
222 
223  CASE ( '# Particle x-momentum' )
224  IF ( global%myProcid == masterproc .AND. &
225  global%verbLevel > verbose_low ) THEN
226  WRITE(stdout,'(A,3X,A)') solver_name,'Particle x-momentum...'
227  END IF ! global%verbLevel
228 
229  pcv => pregion%plag%cv
230 
231  ivars = ivars + 1
232  READ(ifile,'(5(E23.16))') (pcv(cv_plag_xmom,j),j=1,pplag%nPcls)
233 
234 ! ------------------------------------------------------------------------------
235 ! Particle y-momentum
236 ! ------------------------------------------------------------------------------
237 
238  CASE ( '# Particle y-momentum' )
239  IF ( global%myProcid == masterproc .AND. &
240  global%verbLevel > verbose_low ) THEN
241  WRITE(stdout,'(A,3X,A)') solver_name,'Particle y-momentum...'
242  END IF ! global%verbLevel
243 
244  pcv => pregion%plag%cv
245 
246  ivars = ivars + 1
247  READ(ifile,'(5(E23.16))') (pcv(cv_plag_ymom,j),j=1,pplag%nPcls)
248 
249 ! ------------------------------------------------------------------------------
250 ! Particle z-momentum
251 ! ------------------------------------------------------------------------------
252 
253  CASE ( '# Particle z-momentum' )
254  IF ( global%myProcid == masterproc .AND. &
255  global%verbLevel > verbose_low ) THEN
256  WRITE(stdout,'(A,3X,A)') solver_name,'Particle z-momentum...'
257  END IF ! global%verbLevel
258 
259  pcv => pregion%plag%cv
260 
261  ivars = ivars + 1
262  READ(ifile,'(5(E23.16))') (pcv(cv_plag_zmom,j),j=1,pplag%nPcls)
263 
264 ! ------------------------------------------------------------------------------
265 ! Particle energy
266 ! ------------------------------------------------------------------------------
267 
268  CASE ( '# Particle energy' )
269  IF ( global%myProcid == masterproc .AND. &
270  global%verbLevel > verbose_low ) THEN
271  WRITE(stdout,'(A,3X,A)') solver_name,'Particle energy...'
272  END IF ! global%verbLevel
273 
274  pcv => pregion%plag%cv
275 
276  ivars = ivars + 1
277  READ(ifile,'(5(E23.16))') (pcv(cv_plag_ener,j),j=1,pplag%nPcls)
278 
279 ! ------------------------------------------------------------------------------
280 ! Particle x-location
281 ! ------------------------------------------------------------------------------
282 
283  CASE ( '# Particle x-location' )
284  IF ( global%myProcid == masterproc .AND. &
285  global%verbLevel > verbose_low ) THEN
286  WRITE(stdout,'(A,3X,A)') solver_name,'Particle x-location...'
287  END IF ! global%verbLevel
288 
289  pcv => pregion%plag%cv
290 
291  ivars = ivars + 1
292  READ(ifile,'(5(E23.16))') (pcv(cv_plag_xpos,j),j=1,pplag%nPcls)
293 
294 ! ------------------------------------------------------------------------------
295 ! Particle y-location
296 ! ------------------------------------------------------------------------------
297 
298  CASE ( '# Particle y-location' )
299  IF ( global%myProcid == masterproc .AND. &
300  global%verbLevel > verbose_low ) THEN
301  WRITE(stdout,'(A,3X,A)') solver_name,'Particle y-location...'
302  END IF ! global%verbLevel
303 
304  pcv => pregion%plag%cv
305 
306  ivars = ivars + 1
307  READ(ifile,'(5(E23.16))') (pcv(cv_plag_ypos,j),j=1,pplag%nPcls)
308 
309 ! ------------------------------------------------------------------------------
310 ! Particle z-location
311 ! ------------------------------------------------------------------------------
312 
313  CASE ( '# Particle z-location' )
314  IF ( global%myProcid == masterproc .AND. &
315  global%verbLevel > verbose_low ) THEN
316  WRITE(stdout,'(A,3X,A)') solver_name,'Particle z-location...'
317  END IF ! global%verbLevel
318 
319  pcv => pregion%plag%cv
320 
321  ivars = ivars + 1
322  READ(ifile,'(5(E23.16))') (pcv(cv_plag_zpos,j),j=1,pplag%nPcls)
323 
324 ! ------------------------------------------------------------------------------
325 ! Particle vapor energy
326 ! ------------------------------------------------------------------------------
327 
328  CASE ( '# Particle vapor energy' )
329  IF ( global%myProcid == masterproc .AND. &
330  global%verbLevel > verbose_low ) THEN
331  WRITE(stdout,'(A,3X,A)') solver_name,'Particle vapor energy...'
332  END IF ! global%verbLevel
333 
334  pcv => pregion%plag%cv
335 
336  ivars = ivars + 1
337  READ(ifile,'(5(E23.16))') (pcv(cv_plag_enervapor,j),j=1,pplag%nPcls)
338 
339 ! ------------------------------------------------------------------------------
340 ! Particle mass
341 ! ------------------------------------------------------------------------------
342 
343  CASE ( '# Particle mass' )
344  IF ( global%myProcid == masterproc .AND. &
345  global%verbLevel > verbose_low ) THEN
346  WRITE(stdout,'(A,3X,A)') solver_name,'Particle mass...'
347  END IF ! global%verbLevel
348 
349  pcv => pregion%plag%cv
350 
351  IF ( icont == 0 ) THEN
352  ivars = ivars + 1
353  END IF ! iCont
354 
355  icont = icont + 1
356  imass = pplag%cvPlagMass(icont)
357 
358  READ(ifile,'(5(E23.16))') (pcv(imass,j),j=1,pplag%nPcls)
359 
360 ! ------------------------------------------------------------------------------
361 ! Particle superloading
362 ! ------------------------------------------------------------------------------
363 
364  CASE ( '# Particle superloading' )
365  IF ( global%myProcid == masterproc .AND. &
366  global%verbLevel > verbose_low ) THEN
367  WRITE(stdout,'(A,3X,A)') solver_name,'Particle superloading...'
368  END IF ! global%verbLevel
369 
370  parv => pregion%plag%arv
371 
372  ivars = ivars + 1
373  READ(ifile,'(5(E23.16))') (parv(arv_plag_spload,j),j=1,pplag%nPcls)
374 
375 ! ------------------------------------------------------------------------------
376 ! Particle initial identifier
377 ! ------------------------------------------------------------------------------
378 
379  CASE ( '# Particle initial identifier' )
380  IF ( global%myProcid == masterproc .AND. &
381  global%verbLevel > verbose_low ) THEN
382  WRITE(stdout,'(A,3X,A)') solver_name,'Particle initial identifier...'
383  END IF ! global%verbLevel
384 
385  paiv => pregion%plag%aiv
386 
387  ivars = ivars + 1
388  READ(ifile,'(5(I8))') (paiv(aiv_plag_pidini,j),j=1,pplag%nPcls)
389 
390 ! ------------------------------------------------------------------------------
391 ! Particle initial region
392 ! ------------------------------------------------------------------------------
393 
394  CASE ( '# Particle initial region' )
395  IF ( global%myProcid == masterproc .AND. &
396  global%verbLevel > verbose_low ) THEN
397  WRITE(stdout,'(A,3X,A)') solver_name,'Particle initial region...'
398  END IF ! global%verbLevel
399 
400  paiv => pregion%plag%aiv
401 
402  ivars = ivars + 1
403  READ(ifile,'(5(I8))') (paiv(aiv_plag_regini,j),j=1,pplag%nPcls)
404 
405 ! ------------------------------------------------------------------------------
406 ! Particle cell
407 ! ------------------------------------------------------------------------------
408 
409  CASE ( '# Particle cell' )
410  IF ( global%myProcid == masterproc .AND. &
411  global%verbLevel > verbose_low ) THEN
412  WRITE(stdout,'(A,3X,A)') solver_name,'Particle cell...'
413  END IF ! global%verbLevel
414 
415  paiv => pregion%plag%aiv
416 
417  ivars = ivars + 1
418  READ(ifile,'(5(I8))') (paiv(aiv_plag_icells,j),j=1,pplag%nPcls)
419 
420 ! ------------------------------------------------------------------------------
421 ! Patch data
422 ! ------------------------------------------------------------------------------
423 
424  CASE ( '# Patch data' )
425  IF ( global%myProcid == masterproc .AND. &
426  global%verbLevel > verbose_low ) THEN
427  WRITE(stdout,'(A,3X,A)') solver_name,'Patch data...'
428  END IF ! global%verbLevel
429 
430  DO ipatch = 1,pgrid%nPatches
431  ppatch => pregion%patches(ipatch)
432 
433  IF ( (ppatch%bcType >= bc_injection .AND. ppatch%bcType <= bc_injection + bc_range) .OR. &
434  (ppatch%bcType >= bc_inflow .AND. ppatch%bcType <= bc_inflow + bc_range) ) THEN
435  ptileplag => ppatch%tilePlag
436 
437  DO ifl = 1,ppatch%nBFaces
438  READ(ifile,'(2(E23.16))') ptileplag%cv(cv_tile_momnrm,ifl), &
439  ptileplag%cv(cv_tile_ener ,ifl)
440  END DO ! ifl
441 
442  DO icont = 1,ncont
443  imass = ptileplag%cvTileMass(icont)
444  READ(ifile,'(5(E23.16))') (ptileplag%cv(imass,ifl), &
445  ifl=1,ppatch%nBFaces)
446  END DO ! iCont
447 
448  DO ifl = 1,ppatch%nBFaces
449  READ(ifile,'(3(E23.16))') ptileplag%dv(dv_tile_countdown,ifl), &
450  ptileplag%dv(dv_tile_diam ,ifl), &
451  ptileplag%dv(dv_tile_spload ,ifl)
452  END DO ! ifl
453  END IF ! pPatch%bcType
454  END DO ! iPatch
455 
456 ! ------------------------------------------------------------------------------
457 ! End marker
458 ! ------------------------------------------------------------------------------
459 
460  CASE ( '# End' )
461  IF ( global%myProcid == masterproc .AND. &
462  global%verbLevel > verbose_low ) THEN
463  WRITE(stdout,'(A,3X,A)') solver_name,'End marker...'
464  END IF ! global%verbLevel
465 
466  EXIT
467 
468 ! ------------------------------------------------------------------------------
469 ! Invalid section string
470 ! ------------------------------------------------------------------------------
471 
472  CASE default
473  IF ( global%verbLevel > verbose_low ) THEN
474  WRITE(stdout,'(A,3X,A)') solver_name,sectionstring
475  END IF ! verbosityLevel
476 
477  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
478 
479  END SELECT ! TRIM
480 
481 ! ------------------------------------------------------------------------------
482 ! Guard against infinite loop - might be unnecessary because of read errors?
483 ! ------------------------------------------------------------------------------
484 
485  IF ( loopcounter >= limit_infinite_loop ) THEN
486  CALL errorstop(global,err_infinite_loop,__line__)
487  END IF ! loopCounter
488 
489  END DO ! <empty>
490 
491 ! ==============================================================================
492 ! Check and information about number of variables read
493 ! ==============================================================================
494 
495  IF ( ivars /= nvars ) THEN
496  CALL errorstop(global,err_invalid_nvars,__line__)
497  END IF ! iVar
498 
499 ! ==============================================================================
500 ! Close file
501 ! ==============================================================================
502 
503  CLOSE(ifile,iostat=errorflag)
504  global%error = errorflag
505  IF ( global%error /= err_none ) THEN
506  CALL errorstop(global,err_file_close,__line__,ifilename)
507  END IF ! global%error
508 
509  IF ( global%myProcid == masterproc .AND. &
510  global%verbLevel > verbose_none ) THEN
511  WRITE(stdout,'(A,1X,A)') solver_name,'Reading ASCII particle file done.'
512  END IF ! global%verbLevel
513 
514  CALL deregisterfunction(global)
515 
516 ! ******************************************************************************
517 ! End
518 ! ******************************************************************************
519 
520 END SUBROUTINE plag_rflu_readsolutionascii
521 
522 
523 ! ******************************************************************************
524 !
525 ! RCS Revision history:
526 !
527 ! $Log: PLAG_RFLU_ReadSolutionASCII.F90,v $
528 ! Revision 1.10 2008/12/06 08:44:35 mtcampbe
529 ! Updated license.
530 !
531 ! Revision 1.9 2008/11/19 22:17:48 mtcampbe
532 ! Added Illinois Open Source License/Copyright
533 !
534 ! Revision 1.8 2007/03/31 23:56:17 haselbac
535 ! Removed superfluous close parentheses
536 !
537 ! Revision 1.7 2006/09/18 20:37:02 fnajjar
538 ! Activated tile datastructure for inflow bc
539 !
540 ! Revision 1.6 2005/01/21 17:23:10 fnajjar
541 ! Included vapor energy in IO capability
542 !
543 ! Revision 1.5 2004/06/16 23:03:09 fnajjar
544 ! Renamed DV_TILE_TIMEFCTR to DV_TILE_COUNTDOWN for CRE kernel
545 !
546 ! Revision 1.4 2004/06/16 20:01:19 haselbac
547 ! Added use of ModBuildFileNames, cosmetics
548 !
549 ! Revision 1.3 2004/05/17 15:05:16 haselbac
550 ! Bug fix: Only update iVars for first constituent
551 !
552 ! Revision 1.2 2004/03/05 23:19:16 haselbac
553 ! Added reading of additional patch data and modified reading of constituents
554 !
555 ! Revision 1.1 2004/02/26 21:00:50 haselbac
556 ! Initial revision
557 !
558 ! ******************************************************************************
559 
560 
561 
562 
563 
564 
565 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
**********************************************************************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
j indices j
Definition: Indexing.h:6
subroutine plag_rflu_readsolutionascii(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine buildfilenameunsteady(global, dest, ext, id, tm, fileName)