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