Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PLAG_ReadStatPost.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 time averaged statistics of the Lagrangian particles
26 ! on Eulerian grid.
27 !
28 ! Description: the following solution formats are supported:
29 ! - RocfloMP ASCII
30 ! - RocfloMP binary
31 !
32 ! Input: regions = dimensions of all regions
33 !
34 ! Output: region%levels%plag%tav = time avg Lagrangian particle variables
35 ! global%integrTime = integrated averaging time
36 !
37 ! Notes: time averaged solution is read in only for the current grid level;
38 ! it is also read in for all dummy cells
39 !
40 ! ******************************************************************************
41 !
42 ! $Id: PLAG_ReadStatPost.F90,v 1.3 2008/12/06 08:45:07 mtcampbe Exp $
43 !
44 ! Copyright: (c) 2005 by the University of Illinois
45 !
46 ! ******************************************************************************
47 
48 SUBROUTINE plag_readstatpost(regions,iReg)
49 
50  USE modparameters
51  USE moddatatypes
52  USE modglobal, ONLY: t_global
53  USE modpartlag, ONLY: t_buffer_plag
54  USE modbndpatch, ONLY: t_patch
55  USE modgrid, ONLY: t_grid
56  USE modpartlag, ONLY: t_plag
57  USE moddatastruct, ONLY: t_region
58  USE moderror
59  USE modmpi
61 
62 #include "Indexing.h"
63  USE modindexing, ONLY: indijkmap
64  USE modinterfaces, ONLY: rflo_getcelloffset, &
73 
74  IMPLICIT NONE
75 
76 ! ******************************************************************************
77 ! Declarations and definitions
78 ! ******************************************************************************
79 
80 ! ==============================================================================
81 ! Arguments
82 ! ==============================================================================
83 
84  TYPE(t_region), POINTER :: regions(:)
85  INTEGER, INTENT(IN) :: ireg
86 
87 ! ==============================================================================
88 ! Locals
89 ! ==============================================================================
90 
91  CHARACTER(2*CHRLEN+17) :: fname
92  CHARACTER(CHRLEN) :: msg
93 
94  INTEGER :: i, j, k, l, n, ind
95 
96 #ifdef MPI
97  INTEGER :: status(mpi_status_size)
98 #endif
99  INTEGER :: ilev,iregfile,ipc,jpc,kpc,ndumcells,ndim,ioff,ijoff,ijk
100  INTEGER :: idcbeg,jdcbeg,kdcbeg,idcend,jdcend,kdcend,ijkbeg,ijkend
101  INTEGER :: errorflag,ntav,ntavvar
102 
103  INTEGER, ALLOCATABLE, DIMENSION (:,:) :: ivar,jvar,plagvarid
104 
105  REAL(RFREAL), POINTER, DIMENSION(:,:) :: tav
106  REAL(RFREAL), ALLOCATABLE, DIMENSION(:,:) :: rvar, tavfile
107 
108  TYPE(t_global), POINTER :: global
109 
110 ! ******************************************************************************
111 ! Start, set pointers and variables
112 ! ******************************************************************************
113 
114  global => regions(ireg)%global
115 
116  CALL registerfunction( global,'PLAG_RFLO_ReadStatPost',&
117  'PLAG_ReadStatPost.F90' )
118 
119 ! ******************************************************************************
120 ! Allocate temporary data arrays
121 ! ******************************************************************************
122 
123  ALLOCATE( ivar(5,1),stat=errorflag )
124  global%error = errorflag
125  IF ( global%error /= err_none ) &
126  CALL errorstop( global,err_allocate,__line__,'ivar' )
127 
128  ALLOCATE( rvar(2,1),stat=errorflag )
129  global%error = errorflag
130  IF ( global%error /= err_none ) &
131  CALL errorstop( global,err_allocate,__line__,'rvar' )
132 
133  ALLOCATE( jvar(global%plagNStat+1,1),stat=errorflag )
134  global%error = errorflag
135  IF ( global%error /= err_none ) &
136  CALL errorstop( global,err_allocate,__line__,'jvar' )
137 
138  ALLOCATE( plagvarid(2,global%plagNStat+1),stat=errorflag )
139  global%error = errorflag
140  IF ( global%error /= err_none ) &
141  CALL errorstop( global,err_allocate,__line__,'plagVarId' )
142 
143 ! ******************************************************************************
144 ! Open statistics file (only if iReg=1.)
145 ! ******************************************************************************
146 
147  IF (ireg == 1) THEN
148 
149  SELECT CASE( global%solutFormat )
150  CASE ( format_ascii )
151  WRITE(fname,'(A,1PE11.5)') &
152  trim(global%inDir)//trim(global%casename)//'.plag_stata_', &
153  global%timeStamp
154  OPEN( if_plag_stats,file=fname,form='formatted',status='old', &
155  iostat=errorflag )
156 
157  CASE ( format_binary )
158  WRITE(fname,'(A,1PE11.5)') &
159  trim(global%inDir)//trim(global%casename)//'.plag_stat_', &
160  global%timeStamp
161  OPEN( if_plag_stats,file=fname,form='unformatted',status='old', &
162  iostat=errorflag )
163 
164  CASE default
165  CALL errorstop( global,err_reached_default,__line__ )
166 
167  END SELECT ! solutFormat
168 
169  global%error = errorflag
170  IF ( global%error /= err_none ) &
171  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
172 
173  ENDIF ! iReg
174 
175 ! ******************************************************************************
176 ! Read current and integrated time in file, and stats ID (only if iReg=1)
177 ! ******************************************************************************
178 
179  IF ( ireg == 1 ) THEN
180  CALL rflo_readdatafilereal( global,if_plag_stats,global%solutFormat,2,1,rvar )
181 
182  global%integrTime = rvar(2,1)
183 
184 ! ==============================================================================
185 ! Trap error for inconsistent variables in header
186 ! ==============================================================================
187 
188  IF ( global%flowType==flow_unsteady .AND. global%currentTime>0._rfreal ) THEN
189  IF (abs(global%currentTime-rvar(1,1))/global%currentTime > 1.0e-03_rfreal) THEN
190  WRITE(msg,1000) rvar(1,1),global%currentTime
191  CALL errorstop( global,err_time_solution,__line__,msg//' File: '//trim(fname) )
192  ENDIF ! currentTime
193  ENDIF ! global%flowType
194 
195  print*,' PLAG_ReadStatPost: integrTime, currentime = ',global%integrTime,global%currentTime,rvar(1,1)
196 
197  ENDIF ! iReg
198 
199 ! ******************************************************************************
200 ! Read plagNStat and plagStatId from file
201 ! ******************************************************************************
202 
203  IF ( ireg == 1 ) THEN
204  IF (global%plagNStat > 0) THEN
205  CALL rflo_readdatafileint( global,if_plag_stats,global%solutFormat, &
206  global%plagNStat+1,1,jvar )
207  ntavvar = jvar(1,1)
208  IF ( ntavvar /= global%plagNStat ) THEN
209  CALL errorstop( global,err_stats_restart,__line__ )
210  END IF ! nTavVar
211 
212  plagvarid(1,:) = jvar(2:global%plagNStat+1,1)
213  plagvarid(2,:) = mod(plagvarid(1,:),10)
214  plagvarid(1,:) = (plagvarid(1,:)-plagvarid(2,:))/10
215 
216  DO ind=1,2
217  DO l=1,global%plagNStat
218  IF ( plagvarid(ind,l) /= global%plagStatId(ind,l) ) &
219  CALL errorstop( global,err_stats_restart,__line__ )
220  END DO ! l
221  END DO ! ind
222  ENDIF ! plagNStat
223 
224  ENDIF ! iReg
225 
226 ! ******************************************************************************
227 ! Read statistics data from all regions
228 ! ******************************************************************************
229 
230 ! ==============================================================================
231 ! Get dimensions and pointers
232 ! ==============================================================================
233 
234  ilev = regions(ireg)%currLevel
235  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
236  jdcbeg,jdcend,kdcbeg,kdcend )
237  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
238  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
239  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
240  ndim = ijkend - ijkbeg + 1
241 
242  ntav = global%plagNStat
243 
244 ! ==============================================================================
245 ! Read region number and dimensions
246 ! ==============================================================================
247 
248  CALL rflo_readdatafileint( global,if_plag_stats,global%solutFormat,5,1,ivar )
249  iregfile = ivar(1,1)
250  ipc = ivar(2,1)
251  jpc = ivar(3,1)
252  kpc = ivar(4,1)
253  ndumcells = ivar(5,1)
254 
255  IF (iregfile /= ireg) &
256  CALL errorstop( global,err_region_number,__line__,'File: '//trim(fname) )
257 
258  IF ( (ipc /= regions(ireg)%levels(ilev)%grid%ipc) .OR. &
259  (jpc /= regions(ireg)%levels(ilev)%grid%jpc) .OR. &
260  (kpc /= regions(ireg)%levels(ilev)%grid%kpc) ) THEN
261  WRITE(msg,1005) ireg,ipc,jpc,kpc
262  CALL errorstop( global,err_grid_dimensions,__line__,msg )
263  ENDIF ! ipc
264 
265  IF ( ndumcells /= regions(ireg)%nDumCells ) THEN
266  WRITE(msg,1010) ireg,ndumcells,regions(ireg)%nDumCells
267  CALL errorstop( global,err_grid_dumcells,__line__,msg )
268  ENDIF ! nDumCells
269 
270 ! ==============================================================================
271 ! read data
272 ! ==============================================================================
273 
274  ALLOCATE( tavfile(ntav,ndim),stat=errorflag )
275  global%error = errorflag
276  IF ( global%error /= err_none ) &
277  CALL errorstop( global,err_allocate,__line__ )
278 
279  CALL rflo_readdatafilereal( global,if_plag_stats,global%solutFormat, &
280  ntav,ndim,tavfile )
281 
282 ! ==============================================================================
283 ! Copy statistics into data structure
284 ! ==============================================================================
285 
286  IF ( ntav > 0 ) tav => regions(ireg)%levels(ilev)%plag%tav
287 
288  n = 0
289  DO k=kdcbeg,kdcend
290  DO j=jdcbeg,jdcend
291  DO i=idcbeg,idcend
292  n = n + 1
293  ijk = indijk(i,j,k,ioff,ijoff)
294  DO l=1,ntav
295  tav(l,ijk) = tavfile(l,n)
296  ENDDO ! l
297  ENDDO ! i
298  ENDDO ! j
299  ENDDO ! k
300 
301 ! ==============================================================================
302 ! Deallocate local array
303 ! ==============================================================================
304 
305  IF ( ALLOCATED(tavfile) ) THEN
306  DEALLOCATE( tavfile,stat=errorflag )
307  global%error = errorflag
308  IF ( global%error /= err_none ) &
309  CALL errorstop( global,err_deallocate,__line__,'tavFile' )
310  ENDIF ! tavFile
311 
312 ! ******************************************************************************
313 ! Deallocate temporary data arrays
314 ! ******************************************************************************
315 
316  DEALLOCATE( ivar,stat=errorflag )
317  global%error = errorflag
318  IF ( global%error /= err_none ) &
319  CALL errorstop( global,err_deallocate,__line__,'ivar' )
320 
321  DEALLOCATE( rvar,stat=errorflag )
322  global%error = errorflag
323  IF ( global%error /= err_none ) &
324  CALL errorstop( global,err_deallocate,__line__,'rvar' )
325 
326  DEALLOCATE( jvar,stat=errorflag )
327  global%error = errorflag
328  IF ( global%error /= err_none ) &
329  CALL errorstop( global,err_deallocate,__line__,'jvar' )
330 
331  DEALLOCATE( plagvarid,stat=errorflag )
332  global%error = errorflag
333  IF ( global%error /= err_none ) &
334  CALL errorstop( global,err_deallocate,__line__,'plagVarId' )
335 
336 ! ******************************************************************************
337 ! Finalize
338 ! ******************************************************************************
339 
340  IF ( ireg == global%nRegions ) THEN
341  CLOSE(if_plag_stats,iostat=errorflag)
342  global%error = errorflag
343  IF ( global%error /= err_none ) &
344  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
345  ENDIF ! iReg
346 
347 ! ******************************************************************************
348 ! End
349 ! ******************************************************************************
350 
351  CALL deregisterfunction( global )
352 
353 ! ******************************************************************************
354 ! Formats
355 ! ******************************************************************************
356 
357 1000 FORMAT('Time in file is= ',1pe12.5,' but it should be= ',e12.5,'.')
358 1005 FORMAT('Region ',i5,', ipc= ',i6,', jpc= ',i6,', kpc= ',i6,'.')
359 1010 FORMAT('Region ',i5,', # dummy cells=',i2,' but should be= ',i1)
360 2000 FORMAT('Integration Time in file is= ',1pe12.5,' but it should be= ',e12.5,'.')
361 
362 END SUBROUTINE plag_readstatpost
363 
364 ! ******************************************************************************
365 !
366 ! RCS Revision history:
367 !
368 ! $Log: PLAG_ReadStatPost.F90,v $
369 ! Revision 1.3 2008/12/06 08:45:07 mtcampbe
370 ! Updated license.
371 !
372 ! Revision 1.2 2008/11/19 22:18:18 mtcampbe
373 ! Added Illinois Open Source License/Copyright
374 !
375 ! Revision 1.1 2005/02/16 14:52:40 fnajjar
376 ! Initial import
377 !
378 ! ******************************************************************************
379 
380 
381 
382 
383 
384 
385 
**********************************************************************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 idcend
subroutine rflo_getpatchdirection(patch, idir, jdir, kdir)
subroutine rflo_writedatafileint(global, fileId, form, nDim1, nDim2, ivar)
j indices k indices k
Definition: Indexing.h:6
INTEGER function indijkmap(i, j, k, mapMat, iOffset, ijOffset)
Definition: ModIndexing.F90:67
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine rflo_getpatchindices(region, patch, iLev, ibeg, iend, jbeg, jend, kbeg, kend)
subroutine rflo_readdatafileint(global, fileId, form, nDim1, nDim2, ivar)
subroutine rflo_getdimensdummy(region, iLev, idcbeg, idcend, jdcbeg, jdcend, kdcbeg, kdcend)
**********************************************************************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 kdcbeg
blockLoc i
Definition: read.cpp:79
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
**********************************************************************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 idcbeg
**********************************************************************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
**********************************************************************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 jdcend
j indices j
Definition: Indexing.h:6
subroutine plag_readstatpost(regions, iReg)
**********************************************************************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 jdcbeg
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine rflo_getpatchmapping(lb, lbs, l1SrcDir, l2SrcDir, align, idir, jdir, kdir, idirSrc, jdirSrc, kdirSrc, ibeg, iend, jbeg, jend, kbeg, kend, ibegSrc, iendSrc, jbegSrc, jendSrc, kbegSrc, kendSrc, mapMat)
subroutine rflo_writedatafilereal(global, fileId, form, nDim1, nDim2, var)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_readdatafilereal(global, fileId, form, nDim1, nDim2, var)