Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_ReadSolutionFilePost.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 in PLAG solution pertaining to the main variable filed.
26 !
27 ! Description: the following solution formats are supported:
28 ! - RocfloMP ASCII
29 ! - RocfloMP binary.
30 !
31 ! Input: regions = dimensions of all regions.
32 !
33 ! Output: region%levels%plag%cv = conservative variables (current grid
34 ! level)
35 ! region%levels%plag%aiv = auxilliary integer variables
36 ! region%levels%plag%arv = auxilliary real variables
37 !
38 ! Notes: only unsteady solution file format is supported.
39 !
40 !******************************************************************************
41 !
42 ! $Id: PLAG_ReadSolutionFilePost.F90,v 1.4 2008/12/06 08:45:07 mtcampbe Exp $
43 !
44 ! Copyright: (c) 2003 by the University of Illinois
45 !
46 !******************************************************************************
47 
48 SUBROUTINE plag_readsolutionfilepost( regions )
49 
50  USE moddatatypes
51  USE modpartlag, ONLY : t_plag
52  USE modbndpatch, ONLY : t_patch
53  USE moddatastruct, ONLY : t_region, t_level
54  USE modglobal, ONLY : t_global
56  USE moderror
57  USE modmpi
58  USE modparameters
60  IMPLICIT NONE
61 
62 ! ... parameters
63  TYPE(t_region), POINTER :: regions(:)
64 
65 ! ... loop variables
66  INTEGER :: i, icont, ireg
67 
68 ! ... local variables
69  CHARACTER(CHRLEN+17) :: fname
70  CHARACTER(CHRLEN) :: rcsidentstring, msg, timestring
71 
72 #ifdef MPI
73  INTEGER :: status(mpi_status_size)
74 #endif
75  INTEGER, PARAMETER :: one = 1
76  INTEGER :: bctype, errorflag, ilev, iregfile, n, n1, n2, naiv, narv, &
77  ncont, ncv, ncvtile, ndimplag, ndimplagmax
78  INTEGER, ALLOCATABLE, DIMENSION(:,:) :: aivfile, ivar
79  INTEGER, POINTER, DIMENSION(:) :: pcvplagmass
80  INTEGER, POINTER, DIMENSION(:,:) :: paiv
81 
82  REAL(RFREAL), ALLOCATABLE, DIMENSION(:,:) :: arvfile, cvfile, dvfile, rvar
83  REAL(RFREAL), POINTER, DIMENSION(:,:) :: parv, pcv
84 
85  TYPE(t_patch), POINTER :: ppatch
86  TYPE(t_plag), POINTER :: pplag
87  TYPE(t_global), POINTER :: global
88 
89 !******************************************************************************
90 
91  rcsidentstring = '$RCSfile: PLAG_ReadSolutionFilePost.F90,v $ $Revision: 1.4 $'
92 
93  global => regions(1)%global
94 
95  CALL registerfunction( global,'PLAG_ReadSolutionFilePost',&
96  'PLAG_ReadSolutionFilePost.F90' )
97 
98  IF (.NOT. global%plagUsed) goto 999
99 
100  IF ( global%myProcid == masterproc .AND. &
101  global%verbLevel > verbose_none ) THEN
102  WRITE(stdout,'(A,3X,A)') solver_name,'Reading PLAG solution file...'
103  END IF ! global%verbLevel
104 
105 ! allocate fixed-size temporary data arrays -----------------------------------
106 
107  ALLOCATE( ivar(3,1),stat=errorflag )
108  global%error = errorflag
109  IF (global%error /= err_none) THEN
110  CALL errorstop( global,err_allocate,__line__,'ivar' )
111  END IF ! global%error
112 
113  ALLOCATE( rvar(1,1),stat=errorflag )
114  global%error = errorflag
115  IF (global%error /= err_none) THEN
116  CALL errorstop( global,err_allocate,__line__,'rvar' )
117  END IF ! global%error
118 
119 ! copy time to string ---------------------------------------------------------
120 
121  IF (global%flowType == flow_unsteady) THEN
122  WRITE(timestring,'(1PE11.5)') global%timeStamp
123  ELSE
124  WRITE(timestring,'(1PE11.5)') 0._rfreal
125  ENDIF
126 
127 ! open solution file (only master proc.) --------------------------------------
128 
129  IF (global%myProcid == masterproc) THEN
130 
131  IF (global%solutFormat == format_ascii) THEN
132  WRITE(fname,'(A,1PE11.5)') &
133  trim(global%inDir)//trim(global%casename)//'.plag_sola_',global%timeStamp
134  OPEN(if_solut,file=fname,form='formatted',status='old',iostat=errorflag)
135  ELSE IF (global%solutFormat == format_binary) THEN
136  WRITE(fname,'(A,1PE11.5)') &
137  trim(global%inDir)//trim(global%casename)//'.plag_solb_', global%timeStamp
138  OPEN(if_solut,file=fname,form='unformatted',status='old',iostat=errorflag)
139  ENDIF ! global%solutFormat
140 
141  global%error = errorflag
142  IF (global%error /= err_none) THEN
143  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
144  END IF ! global%error
145 
146  ENDIF ! MASTERPROC
147 
148 ! read & check time stamp in file ----------------------------------------------
149 
150  IF (global%myProcid == masterproc) THEN
151  CALL rflo_readdatafilereal( global,if_solut,global%solutFormat,1,1,rvar )
152  ENDIF
153 
154 #ifdef MPI
155  IF ( global%nProcAlloc > 1 ) THEN
156  CALL mpi_bcast( rvar,1,mpi_rfreal,masterproc,global%mpiComm,global%mpierr )
157  IF (global%mpierr /= err_none) THEN
158  CALL errorstop( global,err_mpi_trouble,__line__ )
159  END IF ! global%mpierr
160  ENDIF ! nProcAlloc
161 #endif
162 
163  IF (global%currentTime>0._rfreal) THEN
164 ! IF (global%currentTime /= rvar(1,1)) THEN
165  IF (abs(global%currentTime-rvar(1,1))/global%currentTime > 1.0e-03_rfreal) THEN
166  WRITE(msg,1000) rvar(1,1),global%currentTime
167  CALL errorstop( global,err_time_solution, __line__,msg//' File: '//trim(fname) )
168  ENDIF
169  ENDIF
170 
171 ! read solution data ----------------------------------------------------------
172 
173  DO ireg=1,global%nRegions
174 
175 ! - get dimensions and pointers for PLAG datastructure
176 
177  ilev = regions(ireg)%currLevel
178 
179  ncont = regions(ireg)%plagInput%nCont
180  naiv = aiv_plag_last
181  narv = arv_plag_last
182  ncv = cv_plag_last+ncont
183 
184 ! - read region number and dimensions (only master)
185 
186  IF (global%myProcid == masterproc) THEN
187  CALL rflo_readdatafileint( global,if_solut,global%solutFormat,2,1,ivar )
188  iregfile = ivar(1,1)
189  ndimplag = ivar(2,1)
190 
191  IF (iregfile /= ireg) &
192  CALL errorstop( global,err_region_number,__line__,'File: '//trim(fname) )
193  ENDIF ! global%myProcid
194 
195 ! - broadcast current value of nDimPlag to other processors
196 
197 #ifdef MPI
198  IF ( global%nProcAlloc > 1 ) THEN
199  CALL mpi_bcast( ndimplag,1,mpi_integer,masterproc,global%mpiComm,global%mpierr )
200  IF (global%mpierr /= err_none) THEN
201  CALL errorstop( global,err_mpi_trouble,__line__ )
202  END IF ! global%mpierr
203  ENDIF ! nProcAlloca
204 #endif
205 
206  regions(ireg)%levels(ilev)%plag%nPcls = ndimplag
207 
208  ndimplagmax = regions(ireg)%plagInput%nPclsMax
209 
210  print*,'PLAG_readSolutionFilePost: iReg, nPcls,nPclsMax = ',ireg,ndimplag,ndimplagmax
211 
212  IF( ndimplag > ndimplagmax) THEN
213  WRITE(*,*)'Increase Array size to fit Solution File'
214  stop
215  ENDIF ! nDimPlag
216 
217 ! - activate for number of particles greater than zero
218 
219  SELECT CASE (ndimplag)
220  CASE (one:)
221 
222 ! -- master reads Aiv & sends data, others receive them
223 
224  IF (global%myProcid == masterproc) THEN
225 
226  ALLOCATE( aivfile(naiv,ndimplag),stat=errorflag )
227  global%error = errorflag
228  IF (global%error /= err_none) THEN
229  CALL errorstop( global,err_allocate,__line__,'aivFile' )
230  END IF ! global%error
231 
232  CALL rflo_readdatafileint( global,if_solut,global%solutFormat, &
233  naiv,ndimplag,aivfile )
234 
235 #ifdef MPI
236  IF (regions(ireg)%procid /= masterproc) THEN
237  CALL mpi_send( aivfile,naiv*ndimplag,mpi_integer, &
238  regions(ireg)%procid,ireg, &
239  global%mpiComm,global%mpierr )
240  IF (global%mpierr /= err_none ) THEN
241  CALL errorstop( global,err_mpi_trouble,__line__ )
242  END IF ! global%mpierr
243 
244  ENDIF ! regions(iReg)%procid
245 #endif
246 
247  ELSE ! not the master
248 
249  IF (regions(ireg)%procid == global%myProcid) THEN
250  ALLOCATE( aivfile(naiv,ndimplag),stat=errorflag )
251  global%error = errorflag
252  IF (global%error /= err_none) THEN
253  CALL errorstop( global,err_allocate,__line__,'aivFile' )
254  ENDIF !global%error
255 
256 #ifdef MPI
257  CALL mpi_recv( aivfile,naiv*ndimplag,mpi_integer,masterproc,ireg, &
258  global%mpiComm,status,global%mpierr )
259  IF (global%mpierr /= err_none) THEN
260  CALL errorstop( global,err_mpi_trouble,__line__ )
261  END IF ! global%mpierr
262 #endif
263  END IF !regions(iReg)%procid
264 
265  END IF !global%myProcid
266 
267 ! -- copy solution into data structure
268 
269  IF (regions(ireg)%procid == global%myProcid) THEN
270  pplag => regions(ireg)%levels(ilev)%plag
271  paiv => pplag%aiv
272 
273 ! -- copy nDimPlag to nPcls
274  pplag%nPcls = ndimplag
275 
276  n=0
277  DO i=1, ndimplag
278  n = n+1
279  paiv(aiv_plag_pidini,i) = aivfile(1,n)
280  paiv(aiv_plag_regini,i) = aivfile(2,n)
281  paiv(aiv_plag_regcrt,i) = aivfile(3,n)
282  paiv(aiv_plag_icells,i) = aivfile(4,n)
283  paiv(aiv_plag_indexi,i) = aivfile(5,n)
284  paiv(aiv_plag_indexj,i) = aivfile(6,n)
285  paiv(aiv_plag_indexk,i) = aivfile(7,n)
286  paiv(aiv_plag_burnstat,i) = aivfile(8,n)
287  ENDDO ! i
288  END IF !regions(iReg)%procid
289 
290  IF (ALLOCATED(aivfile)) THEN
291  DEALLOCATE( aivfile,stat=errorflag )
292  global%error = errorflag
293  IF (global%error /= err_none) THEN
294  CALL errorstop( global,err_deallocate,__line__,'aivFile' )
295  ENDIF ! global%error
296  ENDIF ! aivFile
297 
298 ! -- master reads Arv & sends data, others receive them
299 
300  IF (global%myProcid == masterproc) THEN
301  ALLOCATE( arvfile(narv,ndimplag),stat=errorflag )
302  global%error = errorflag
303  IF (global%error /= err_none) THEN
304  CALL errorstop( global,err_allocate,__line__,'aivFile' )
305  END IF ! global%error
306  CALL rflo_readdatafilereal( global,if_solut,global%solutFormat, &
307  narv,ndimplag,arvfile )
308 
309 #ifdef MPI
310  IF (regions(ireg)%procid /= masterproc) THEN
311  CALL mpi_send( arvfile,narv*ndimplag,mpi_rfreal, &
312  regions(ireg)%procid,ireg, &
313  global%mpiComm,global%mpierr )
314  IF (global%mpierr /= err_none ) THEN
315  CALL errorstop( global,err_mpi_trouble,__line__ )
316  END IF ! global%mpierr
317 
318  ENDIF ! regions(iReg)%procid
319 #endif
320 
321  ELSE ! not the master
322 
323  IF (regions(ireg)%procid == global%myProcid) THEN
324  ALLOCATE( arvfile(narv,ndimplag),stat=errorflag )
325  global%error = errorflag
326  IF (global%error /= err_none) THEN
327  CALL errorstop( global,err_allocate,__line__,'arvFile' )
328  ENDIF !global%error
329 
330 #ifdef MPI
331  CALL mpi_recv( arvfile,narv*ndimplag,mpi_rfreal,masterproc,ireg, &
332  global%mpiComm,status,global%mpierr )
333  IF (global%mpierr /= err_none) THEN
334  CALL errorstop( global,err_mpi_trouble,__line__ )
335  END IF ! global%mpierr
336 #endif
337  END IF !regions(iReg)%procid
338 
339  END IF !global%myProcid
340 
341 ! -- copy solution into data structure
342 
343  IF (regions(ireg)%procid == global%myProcid) THEN
344  pplag => regions(ireg)%levels(ilev)%plag
345  parv => pplag%arv
346  n=0
347  DO i=1, ndimplag
348  n = n+1
349  parv(arv_plag_spload,i) = arvfile(1,n)
350  ENDDO ! i
351  END IF !regions(iReg)%procid
352 
353  IF (ALLOCATED(arvfile)) THEN
354  DEALLOCATE( arvfile,stat=errorflag )
355  global%error = errorflag
356  IF (global%error /= err_none) THEN
357  CALL errorstop( global,err_deallocate,__line__,'arvFile' )
358  ENDIF ! global%error
359  ENDIF ! arvFile
360 
361 ! -- master reads Cv & sends data, others receive them
362 
363  IF (global%myProcid == masterproc) THEN
364  ALLOCATE( cvfile(ncv,ndimplag),stat=errorflag )
365  global%error = errorflag
366  IF (global%error /= err_none) THEN
367  CALL errorstop( global,err_allocate,__line__,'cvFile' )
368  END IF ! global%error
369 
370  CALL rflo_readdatafilereal( global,if_solut,global%solutFormat, &
371  ncv,ndimplag,cvfile )
372 
373 #ifdef MPI
374  IF (regions(ireg)%procid /= masterproc) THEN
375  CALL mpi_send( cvfile,ncv*ndimplag,mpi_rfreal, &
376  regions(ireg)%procid,ireg, &
377  global%mpiComm,global%mpierr )
378  IF (global%mpierr /= err_none ) THEN
379  CALL errorstop( global,err_mpi_trouble,__line__ )
380  END IF ! global%mpierr
381 
382  ENDIF ! regions(iReg)%procid
383 #endif
384 
385  ELSE ! not the master
386 
387  IF (regions(ireg)%procid == global%myProcid) THEN
388  ALLOCATE( cvfile(ncv,ndimplag),stat=errorflag )
389  global%error = errorflag
390  IF (global%error /= err_none) THEN
391  CALL errorstop( global,err_allocate,__line__,'cvFile' )
392  ENDIF !global%error
393 
394 #ifdef MPI
395  CALL mpi_recv( cvfile,ncv*ndimplag,mpi_rfreal,masterproc,ireg, &
396  global%mpiComm,status,global%mpierr )
397  IF (global%mpierr /= err_none) THEN
398  CALL errorstop( global,err_mpi_trouble,__line__ )
399  END IF ! global%mpierr
400 #endif
401  END IF !regions(iReg)%procid
402 
403  END IF !global%myProcid
404 
405 ! -- copy solution into data structure
406 
407  IF (regions(ireg)%procid == global%myProcid) THEN
408  pplag => regions(ireg)%levels(ilev)%plag
409  pcv => pplag%cv
410  pcvplagmass => pplag%cvPlagMass
411  ncont = regions(ireg)%plagInput%nCont
412  n=0
413  DO i=1, ndimplag
414  n = n+1
415  pcv(cv_plag_xmom,i) = cvfile(1,n)
416  pcv(cv_plag_ymom,i) = cvfile(2,n)
417  pcv(cv_plag_zmom,i) = cvfile(3,n)
418  pcv(cv_plag_ener,i) = cvfile(4,n)
419  pcv(cv_plag_xpos,i) = cvfile(5,n)
420  pcv(cv_plag_ypos,i) = cvfile(6,n)
421  pcv(cv_plag_zpos,i) = cvfile(7,n)
422  pcv(cv_plag_enervapor,i) = cvfile(8,n)
423  DO icont = 1, ncont
424  pcv(pcvplagmass(icont),i) = cvfile(cv_plag_last+icont,n)
425  ENDDO ! iCont
426  ENDDO ! i
427  END IF !regions(iReg)%procid
428 
429  IF (ALLOCATED(cvfile)) THEN
430  DEALLOCATE( cvfile,stat=errorflag )
431  global%error = errorflag
432  IF (global%error /= err_none) THEN
433  CALL errorstop( global,err_deallocate,__line__,'cvFile' )
434  ENDIF ! global%error
435  ENDIF ! cvFile
436 
437  END SELECT ! nDimPlag
438  ENDDO ! iReg
439 
440 ! deallocate fixed-size temporary data arrays ---------------------------------
441 
442  DEALLOCATE( ivar,stat=errorflag )
443  global%error = errorflag
444  IF (global%error /= err_none) THEN
445  CALL errorstop( global,err_deallocate,__line__,'ivar' )
446  END IF ! global%error
447 
448  DEALLOCATE( rvar,stat=errorflag )
449  global%error = errorflag
450  IF (global%error /= err_none) THEN
451  CALL errorstop( global,err_deallocate,__line__,'rvar' )
452  END IF ! global%error
453 
454 ! finalize --------------------------------------------------------------------
455 
456  IF (global%myProcid == masterproc) THEN
457  CLOSE(if_solut,iostat=errorflag)
458  global%error = errorflag
459  IF (global%error /= err_none) &
460  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
461  ENDIF
462 
463 999 CONTINUE
464  CALL deregisterfunction( global )
465 
466 1000 FORMAT('Time in file is= ',1pe12.5,' but it should be= ',e12.5,'.')
467 
468 END SUBROUTINE plag_readsolutionfilepost
469 
470 !******************************************************************************
471 !
472 ! RCS Revision history:
473 !
474 ! $Log: PLAG_ReadSolutionFilePost.F90,v $
475 ! Revision 1.4 2008/12/06 08:45:07 mtcampbe
476 ! Updated license.
477 !
478 ! Revision 1.3 2008/11/19 22:18:18 mtcampbe
479 ! Added Illinois Open Source License/Copyright
480 !
481 ! Revision 1.2 2007/03/06 23:27:44 fnajjar
482 ! Renamed nPclsTot to nPclsMax
483 !
484 ! Revision 1.1 2004/12/01 22:00:46 fnajjar
485 ! Initial revision after changing case
486 !
487 ! Revision 1.3 2004/03/05 22:09:05 jferry
488 ! created global variables for peul, plag, and inrt use
489 !
490 ! Revision 1.2 2004/03/02 21:51:15 jferry
491 ! Added output of vapor energy to rplagpost output file
492 !
493 ! Revision 1.1.1.1 2003/05/06 16:14:38 fnajjar
494 ! Import of postprocessing tool for Rocpart
495 !
496 !******************************************************************************
497 
498 
499 
500 
501 
502 
503 
subroutine plag_readsolutionfilepost(regions)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine rflo_readdatafileint(global, fileId, form, nDim1, nDim2, ivar)
blockLoc i
Definition: read.cpp:79
**********************************************************************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
const NT & n
virtual std::ostream & print(std::ostream &os) const
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_readdatafilereal(global, fileId, form, nDim1, nDim2, var)