Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_ReadStatRegion.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 mixture.
26 !
27 ! Description: the following solution formats are supported:
28 ! - RocfloMP ASCII
29 ! - RocfloMP binary
30 !
31 ! Input: regions = dimensions of all regions
32 ! iReg = region number.
33 !
34 ! Output: region%levels%mixt%tav = time avg mixture variables (current grid level)
35 ! region%levels%turb%tav = time avg TURB variables (current grid level)
36 ! global%integrTime = integrated averaging time
37 !
38 ! Notes: time averaged solution is read in only for the current grid level;
39 ! it is also read in for all dummy cells
40 !
41 !******************************************************************************
42 !
43 ! $Id: RFLO_ReadStatRegion.F90,v 1.3 2008/12/06 08:44:07 mtcampbe Exp $
44 !
45 ! Copyright: (c) 2001 by the University of Illinois
46 !
47 !******************************************************************************
48 
49 SUBROUTINE rflo_readstatregion( iReg,regions )
50 
51  USE moddatatypes
52  USE moddatastruct, ONLY : t_region
53  USE modglobal, ONLY : t_global
56  USE moderror
57  USE modmpi
58  USE modparameters
59  IMPLICIT NONE
60 
61 #include "Indexing.h"
62 
63 ! ... parameters
64  INTEGER :: ireg
65  TYPE(t_region), POINTER :: regions(:)
66 
67 ! ... loop variables
68  INTEGER :: i, j, k, l, n, ind
69 
70 ! ... local variables
71  CHARACTER(2*CHRLEN+17) :: fname
72  CHARACTER(CHRLEN) :: msg
73 
74 #ifdef MPI
75  INTEGER :: status(mpi_status_size)
76 #endif
77  INTEGER :: ilev, iregfile, ipc, jpc, kpc, ndumcells, ndim, ioff, ijoff, ijk
78  INTEGER :: idcbeg, jdcbeg, kdcbeg, idcend, jdcend, kdcend, ijkbeg, ijkend
79  INTEGER :: mixtvarid(2,regions(1)%global%mixtnstat)
80  INTEGER :: turbvarid(2,regions(1)%global%turbnstat)
81  INTEGER :: ntavgvar, maxnstat, allnstat, errorflag
82  INTEGER, ALLOCATABLE :: ivar(:,:), jvar(:,:)
83 
84  REAL(RFREAL), POINTER :: mixttav(:,:), turbtav(:,:)
85  REAL(RFREAL), ALLOCATABLE :: rvar(:,:), tavfile(:,:)
86 
87  TYPE(t_global), POINTER :: global
88 
89 !******************************************************************************
90 
91  global => regions(1)%global
92 
93  CALL registerfunction( global,'RFLO_ReadStatRegion',&
94  'RFLO_ReadStatRegion.F90' )
95 
96 ! allocate temporary data arrays --------------------------------------------
97 
98  ALLOCATE( ivar(5,1),stat=errorflag )
99  ALLOCATE( rvar(2,1),stat=errorflag )
100  maxnstat = global%mixtNStat
101 #ifdef TURB
102  IF (global%turbNStat>0) maxnstat = max( global%mixtNStat,global%turbNStat )
103 #endif
104  ALLOCATE( jvar(maxnstat+1,1),stat=errorflag )
105  global%error = errorflag
106  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
107 
108 ! open statistics file (only master proc.) ----------------------------------
109 
110  IF (ireg == 1) THEN
111 
112  IF (global%solutFormat == format_ascii) THEN
113  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.stata_', &
114  global%timeStamp
115  OPEN(if_stat,file=fname,form='formatted',status='old',iostat=errorflag)
116  ELSE IF (global%solutFormat == format_binary) THEN
117  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.statb_', &
118  global%timeStamp
119  OPEN(if_stat,file=fname,form='unformatted',status='old',iostat=errorflag)
120  ELSE
121  CALL errorstop( global,err_unknown_format,__line__ )
122  ENDIF
123 
124  global%error = errorflag
125  IF (global%error /= 0) &
126  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
127 
128 ! read & broadcast current and integrated time in file, and stats ID ---------------
129 
130  CALL rflo_readdatafilereal( global,if_stat,global%solutFormat,2,1,rvar )
131 
132  IF (global%currentTime>0._rfreal) THEN
133  IF (global%currentTime /= rvar(1,1)) THEN
134  WRITE(msg,1000) rvar(1,1),global%currentTime
135  CALL errorstop( global,err_time_solution,__line__,msg//' File: '//trim(fname) )
136  ENDIF
137  ELSE
138  global%currentTime = rvar(1,1)
139  ENDIF
140  global%integrTime = rvar(2,1)
141 
142 ! - mixture statistics NSTATS and ID
143 
144  IF (global%mixtNStat > 0) THEN
145  CALL rflo_readdatafileint( global,if_stat,global%solutFormat, &
146  global%mixtNStat+1,1,jvar )
147  ntavgvar = jvar(1,1)
148  IF (ntavgvar /= global%mixtNStat) THEN
149  CALL errorstop( global,err_stats_restart,__line__ )
150  ENDIF
151 
152  mixtvarid(1,:) = jvar(2:global%mixtNStat+1,1)
153  mixtvarid(2,:) = mod(mixtvarid(1,:),10)
154  mixtvarid(1,:) = (mixtvarid(1,:)-mixtvarid(2,:))/10
155 
156  DO ind=1,2
157  DO l=1,global%mixtNStat
158  IF (mixtvarid(ind,l) /= global%mixtStatId(ind,l)) &
159  CALL errorstop( global,err_stats_restart,__line__ )
160  ENDDO
161  ENDDO
162  ENDIF
163 
164 ! - turbulence statistics NSTATS and ID
165 
166 #ifdef TURB
167  IF (global%turbNStat > 0) THEN
168  CALL rflo_readdatafileint( global,if_stat,global%solutFormat, &
169  global%turbNStat+1,1,jvar )
170  ntavgvar = jvar(1,1)
171  IF (ntavgvar /= global%turbNStat) THEN
172  CALL errorstop( global,err_stats_restart,__line__ )
173  ENDIF
174 
175  turbvarid(1,:) = jvar(2:global%turbNStat+1,1)
176  turbvarid(2,:) = mod(turbvarid(1,:),10)
177  turbvarid(1,:) = (turbvarid(1,:)-turbvarid(2,:))/10
178 
179  DO ind=1,2
180  DO l=1,global%turbNStat
181  IF (turbvarid(ind,l) /= global%turbStatId(ind,l)) &
182  CALL errorstop( global,err_stats_restart,__line__ )
183  ENDDO
184  ENDDO
185  ENDIF
186 #endif
187  ENDIF ! 1st region
188 
189 ! read statistics data from all regions ------------------------------------------
190 
191  allnstat = global%mixtNStat+global%turbNStat
192 
193 ! get dimensions and pointers
194 
195  ilev = regions(ireg)%currLevel
196  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
197  jdcbeg,jdcend,kdcbeg,kdcend )
198  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
199  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
200  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
201  ndim = ijkend - ijkbeg + 1
202 
203 ! read region number and dimensions
204 
205  CALL rflo_readdatafileint( global,if_stat,global%solutFormat,5,1,ivar )
206  iregfile = ivar(1,1)
207  ipc = ivar(2,1)
208  jpc = ivar(3,1)
209  kpc = ivar(4,1)
210  ndumcells = ivar(5,1)
211 
212  IF (iregfile /= ireg) &
213  CALL errorstop( global,err_region_number,__line__,'File: '//trim(fname) )
214  IF ((ipc /= regions(ireg)%levels(ilev)%grid%ipc) .OR. &
215  (jpc /= regions(ireg)%levels(ilev)%grid%jpc) .OR. &
216  (kpc /= regions(ireg)%levels(ilev)%grid%kpc)) THEN
217  WRITE(msg,1005) ireg,ipc,jpc,kpc
218  CALL errorstop( global,err_grid_dimensions,__line__,msg )
219  ENDIF
220  IF (ndumcells /= regions(ireg)%nDumCells) THEN
221  WRITE(msg,1010) ireg,ndumcells,regions(ireg)%nDumCells
222  CALL errorstop( global,err_grid_dumcells,__line__,msg )
223  ENDIF
224 
225 ! read data
226 
227  ALLOCATE( tavfile(allnstat,ndim),stat=errorflag )
228  global%error = errorflag
229  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
230 
231  CALL rflo_readdatafilereal( global,if_stat,global%solutFormat, &
232  allnstat,ndim,tavfile )
233 
234 ! copy statistics into data structure
235 
236  IF (global%mixtNStat > 0) mixttav => regions(ireg)%levels(ilev)%mixt%tav
237  n = 0
238  DO k=kdcbeg,kdcend
239  DO j=jdcbeg,jdcend
240  DO i=idcbeg,idcend
241  n = n + 1
242  ijk = indijk(i,j,k,ioff,ijoff)
243  DO l=1,global%mixtNStat
244  mixttav(l,ijk) = tavfile(l,n)
245  ENDDO
246  ENDDO
247  ENDDO
248  ENDDO
249 
250 #ifdef TURB
251  IF (global%turbNStat > 0) THEN
252  IF ((regions(ireg)%mixtInput%flowModel == flow_navst) .AND. &
253  (regions(ireg)%mixtInput%turbModel /= turb_model_none)) THEN
254  turbtav => regions(ireg)%levels(ilev)%turb%tav
255  n = 0
256  DO k=kdcbeg,kdcend
257  DO j=jdcbeg,jdcend
258  DO i=idcbeg,idcend
259  n = n + 1
260  ijk = indijk(i,j,k,ioff,ijoff)
261  DO l=1,global%turbNStat
262  turbtav(l,ijk) = tavfile(l+global%mixtNStat,n)
263  ENDDO
264  ENDDO
265  ENDDO
266  ENDDO
267  ENDIF
268  ENDIF
269 #endif
270 
271  IF (ALLOCATED(tavfile)) THEN
272  DEALLOCATE( tavfile,stat=errorflag )
273  global%error = errorflag
274  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
275  ENDIF
276 
277 ! finalize -----------------------------------------------------------------
278 
279  IF (ireg == global%nRegions) THEN
280  CLOSE(if_stat,iostat=errorflag)
281  global%error = errorflag
282  IF (global%error /= 0) &
283  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
284  ENDIF
285 
286  CALL deregisterfunction( global )
287 
288 1000 FORMAT('Time in file is= ',1pe12.5,' but it should be= ',e12.5,'.')
289 1005 FORMAT('Region ',i5,', ipc= ',i6,', jpc= ',i6,', kpc= ',i6,'.')
290 1010 FORMAT('Region ',i5,', # dummy cells=',i2,' but should be= ',i1)
291 
292 END SUBROUTINE rflo_readstatregion
293 
294 !******************************************************************************
295 !
296 ! RCS Revision history:
297 !
298 ! $Log: RFLO_ReadStatRegion.F90,v $
299 ! Revision 1.3 2008/12/06 08:44:07 mtcampbe
300 ! Updated license.
301 !
302 ! Revision 1.2 2008/11/19 22:17:21 mtcampbe
303 ! Added Illinois Open Source License/Copyright
304 !
305 ! Revision 1.1 2004/11/29 21:25:17 wasistho
306 ! lower to upper case
307 !
308 ! Revision 1.1 2004/11/09 10:57:30 wasistho
309 ! initial import RFLO_readStatRegion
310 !
311 !
312 !******************************************************************************
313 
314 
315 
316 
317 
318 
319 
**********************************************************************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
j indices k indices k
Definition: Indexing.h:6
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
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)
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
**********************************************************************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
**********************************************************************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 deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_readstatregion(iReg, regions)
subroutine rflo_readdatafilereal(global, fileId, form, nDim1, nDim2, var)