Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TURB_rFLO_ReadSolutionRegion.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 turbulence solution.
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:
35 ! globalClass LES : region%levels%mixt%tv = turbulent viscosity
36 ! globalClass RANS : no yet defined
37 ! global%currentTime = physical time
38 ! global%resInit = initial residual
39 !
40 ! Notes: solution is read in only for the current grid level;
41 ! solution is also read in for all dummy cells. There is no transfer
42 ! of data to other processors.
43 !
44 !******************************************************************************
45 !
46 ! $Id: TURB_rFLO_ReadSolutionRegion.F90,v 1.4 2008/12/06 08:44:45 mtcampbe Exp $
47 !
48 ! Copyright: (c) 2001 by the University of Illinois
49 !
50 !******************************************************************************
51 
52 SUBROUTINE turb_rflo_readsolutionregion( iReg,regions ) ! PUBLIC
53 
54  USE moddatatypes
55  USE moddatastruct, ONLY : t_region
56  USE modglobal, ONLY : t_global
59  USE moderror
60  USE modparameters
62  IMPLICIT NONE
63 
64 #include "Indexing.h"
65 
66 ! ... parameters
67  INTEGER :: ireg
68  TYPE(t_region), POINTER :: regions(:)
69 
70 ! ... loop variables
71  INTEGER :: i, j, k, n
72 
73 ! ... local variables
74  CHARACTER(2*CHRLEN+17) :: fname
75  CHARACTER(CHRLEN) :: msg, timestring
76 
77  INTEGER :: ilev, iregfile, ipc, jpc, kpc, ndumcells, nfield, ioff, ijoff, ijk
78  INTEGER :: idcbeg, jdcbeg, kdcbeg, idcend, jdcend, kdcend, ijkbeg, ijkend
79  INTEGER :: ndimc, nrvar, noutsol, globalclass, errorflag
80  INTEGER, ALLOCATABLE :: ivar(:,:)
81 
82  REAL(RFREAL), POINTER :: tv(:,:), tcv(:,:), vort(:,:), lens(:)
83  REAL(RFREAL), ALLOCATABLE :: rvar(:,:), solfile(:,:)
84 
85  TYPE(t_global), POINTER :: global
86 
87 !******************************************************************************
88 
89  global => regions(ireg)%global
90 
91  CALL registerfunction( global,'TURB_RFLO_ReadSolutionRegion',&
92  'TURB_rFLO_ReadSolutionRegion.F90' )
93 
94 ! allocate fixed-size temporary data arrays -----------------------------------
95 
96  nrvar = 4
97 
98  ALLOCATE( ivar(6,1),stat=errorflag )
99  ALLOCATE( rvar(nrvar,1),stat=errorflag )
100  global%error = errorflag
101  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
102 
103 ! copy time to string ---------------------------------------------------------
104 
105  IF (global%flowType == flow_unsteady) THEN
106  WRITE(timestring,'(1PE11.5)') global%timeStamp
107  ELSE
108  WRITE(timestring,'(1PE11.5)') 0._rfreal
109  ENDIF
110 
111 ! open solution file (only if iReg=1) -----------------------------------------
112 
113  IF (ireg == 1) THEN
114 
115 ! - unsteady flow
116 
117  IF (global%flowType == flow_unsteady) THEN
118  IF (global%solutFormat == format_ascii) THEN
119  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.turba_', &
120  global%timeStamp
121  OPEN(if_turb_solut,file=fname,form='formatted',status='old',iostat=errorflag)
122  ELSE IF (global%solutFormat == format_binary) THEN
123  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.turbb_', &
124  global%timeStamp
125  OPEN(if_turb_solut,file=fname,form='unformatted',status='old',iostat=errorflag)
126  ELSE
127  CALL errorstop( global,err_unknown_format,__line__ )
128  ENDIF
129 
130 ! - steady flow
131 
132  ELSE
133  IF (global%solutFormat == format_ascii) THEN
134  WRITE(fname,'(A,I6.6)') trim(global%inDir)//trim(global%casename)//'.turba_', &
135  global%currentIter
136  OPEN(if_turb_solut,file=fname,form='formatted',status='old',iostat=errorflag)
137  ELSE IF (global%solutFormat == format_binary) THEN
138  WRITE(fname,'(A,I6.6)') trim(global%inDir)//trim(global%casename)//'.turbb_', &
139  global%currentIter
140  OPEN(if_turb_solut,file=fname,form='unformatted',status='old',iostat=errorflag)
141  ELSE
142  CALL errorstop( global,err_unknown_format,__line__ )
143  ENDIF
144  ENDIF
145 
146  global%error = errorflag
147  IF (global%error /= 0) &
148  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
149 
150 ! - read time and initial residual
151 
152  CALL rflo_readdatafilereal( global,if_turb_solut,global%solutFormat,nrvar,1,rvar )
153 
154  IF (global%flowType==flow_unsteady .AND. global%currentTime>0._rfreal) THEN
155  IF (global%currentTime /= rvar(1,1)) THEN
156  WRITE(msg,1000) rvar(1,1),global%currentTime
157  CALL errorstop( global,err_time_solution,__line__,msg//' File: '//trim(fname) )
158  ENDIF
159  ELSE
160  global%currentTime = rvar(1,1)
161  ENDIF
162  global%resInit = rvar(2,1)
163  global%esg1Sum = rvar(3,1)
164  global%esg4Sum = rvar(4,1)
165 
166  ENDIF ! 1st region
167 
168 ! read solution data ----------------------------------------------------------
169 
170 ! first define no.of output solution by subsquent selection (order matters)
171 
172  IF (regions(ireg)%procid == global%myProcid) THEN
173  IF (regions(ireg)%turbInput%modelClass == model_les) THEN
174  globalclass = model_les
175  ENDIF
176  ENDIF
177 
178  IF (regions(ireg)%procid == global%myProcid) THEN
179  IF ((regions(ireg)%mixtInput%turbModel == turb_model_sa) .OR. &
180  (regions(ireg)%mixtInput%turbModel == turb_model_dessa) .OR. &
181  (regions(ireg)%mixtInput%turbModel == turb_model_hdessa)) THEN
182  globalclass = model_rans
183  ENDIF
184  ENDIF
185 
186 ! get dimensions and pointers
187 
188  ilev = regions(ireg)%currLevel
189  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
190  jdcbeg,jdcend,kdcbeg,kdcend )
191  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
192  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
193  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
194  ndimc = ijkend - ijkbeg + 1
195 
196 ! read region number and dimensions
197 
198  CALL rflo_readdatafileint( global,if_turb_solut,global%solutFormat,6,1,ivar )
199  iregfile = ivar(1,1)
200  ipc = ivar(2,1)
201  jpc = ivar(3,1)
202  kpc = ivar(4,1)
203  ndumcells = ivar(5,1)
204  nfield = ivar(6,1)
205 
206  IF (iregfile /= ireg) &
207  CALL errorstop( global,err_region_number,__line__,'File: '//trim(fname) )
208  IF ((ipc /= regions(ireg)%levels(ilev)%grid%ipc) .OR. &
209  (jpc /= regions(ireg)%levels(ilev)%grid%jpc) .OR. &
210  (kpc /= regions(ireg)%levels(ilev)%grid%kpc)) THEN
211  WRITE(msg,1005) ireg,ipc,jpc,kpc
212  CALL errorstop( global,err_grid_dimensions,__line__,msg )
213  ENDIF
214  IF (ndumcells /= regions(ireg)%nDumCells) THEN
215  WRITE(msg,1010) ireg,ndumcells,regions(ireg)%nDumCells
216  CALL errorstop( global,err_grid_dumcells,__line__,msg )
217  ENDIF
218 
219 ! read data
220 
221  noutsol = nfield
222  ALLOCATE( solfile(noutsol,ndimc),stat=errorflag )
223  global%error = errorflag
224  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
225 
226  CALL rflo_readdatafilereal( global,if_turb_solut,global%solutFormat, &
227  noutsol,ndimc,solfile )
228 
229 ! copy solution into data structure
230 
231  IF (regions(ireg)%turbInput%modelClass == model_les) THEN
232  tv => regions(ireg)%levels(ilev)%mixt%tv
233  n = 0
234  DO k=kdcbeg,kdcend
235  DO j=jdcbeg,jdcend
236  DO i=idcbeg,idcend
237  n = n + 1
238  ijk = indijk(i,j,k,ioff,ijoff)
239  tv(tv_mixt_muet,ijk) = solfile(1,n)
240  ENDDO
241  ENDDO
242  ENDDO
243  IF (noutsol == 2) THEN
244  vort => regions(ireg)%levels(ilev)%turb%vort
245  n = 0
246  DO k=kdcbeg,kdcend
247  DO j=jdcbeg,jdcend
248  DO i=idcbeg,idcend
249  n = n + 1
250  ijk = indijk(i,j,k,ioff,ijoff)
251  vort(xcoord,ijk) = solfile(2,n)
252  ENDDO
253  ENDDO
254  ENDDO
255  ENDIF ! nOutSol
256  ENDIF
257  IF ((regions(ireg)%mixtInput%turbModel == turb_model_sa) .OR. &
258  (regions(ireg)%mixtInput%turbModel == turb_model_dessa) .OR. &
259  (regions(ireg)%mixtInput%turbModel == turb_model_hdessa)) THEN
260  tcv => regions(ireg)%levels(ilev)%turb%cv
261  n = 0
262  DO k=kdcbeg,kdcend
263  DO j=jdcbeg,jdcend
264  DO i=idcbeg,idcend
265  n = n + 1
266  ijk = indijk(i,j,k,ioff,ijoff)
267  tcv(cv_sa_nutil,ijk) = solfile(1,n)
268  ENDDO
269  ENDDO
270  ENDDO
271  IF (noutsol == 2) THEN
272  vort => regions(ireg)%levels(ilev)%turb%vort
273  n = 0
274  DO k=kdcbeg,kdcend
275  DO j=jdcbeg,jdcend
276  DO i=idcbeg,idcend
277  n = n + 1
278  ijk = indijk(i,j,k,ioff,ijoff)
279  vort(xcoord,ijk) = solfile(2,n)
280  ENDDO
281  ENDDO
282  ENDDO
283  ENDIF ! nOutSol
284  IF (noutsol == 3) THEN
285  vort => regions(ireg)%levels(ilev)%turb%vort
286  lens => regions(ireg)%levels(ilev)%turb%lens
287  n = 0
288  DO k=kdcbeg,kdcend
289  DO j=jdcbeg,jdcend
290  DO i=idcbeg,idcend
291  n = n + 1
292  ijk = indijk(i,j,k,ioff,ijoff)
293  vort(xcoord,ijk) = solfile(2,n)
294  lens(ijk) = solfile(3,n)
295  ENDDO
296  ENDDO
297  ENDDO
298  ENDIF ! nOutSol
299  ENDIF ! turbModel/modelClass
300 
301  DEALLOCATE( ivar ,stat=errorflag )
302  DEALLOCATE( rvar ,stat=errorflag )
303  DEALLOCATE( solfile,stat=errorflag )
304  global%error = errorflag
305  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
306 
307 ! finalize --------------------------------------------------------------------
308 
309  IF (ireg == global%nRegions) THEN
310  CLOSE(if_turb_solut,iostat=errorflag)
311  global%error = errorflag
312  IF (global%error /= 0) &
313  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
314  ENDIF
315 
316  CALL deregisterfunction( global )
317 
318 1000 FORMAT('Time in file is= ',1pe12.5,' but it should be= ',e12.5,'.')
319 1005 FORMAT('Region ',i5,', ipc= ',i6,', jpc= ',i6,', kpc= ',i6,'.')
320 1010 FORMAT('Region ',i5,', # dummy cells=',i2,' but should be= ',i1)
321 
322 END SUBROUTINE turb_rflo_readsolutionregion
323 
324 !******************************************************************************
325 !
326 ! RCS Revision history:
327 !
328 ! $Log: TURB_rFLO_ReadSolutionRegion.F90,v $
329 ! Revision 1.4 2008/12/06 08:44:45 mtcampbe
330 ! Updated license.
331 !
332 ! Revision 1.3 2008/11/19 22:17:56 mtcampbe
333 ! Added Illinois Open Source License/Copyright
334 !
335 ! Revision 1.2 2005/03/09 06:37:40 wasistho
336 ! incorporated HDESSA
337 !
338 ! Revision 1.1 2004/03/11 03:26:34 wasistho
339 ! changed rocturb nomenclature
340 !
341 ! Revision 1.1 2004/03/08 23:35:46 wasistho
342 ! changed turb nomenclature
343 !
344 ! Revision 1.3 2004/02/26 21:28:14 wasistho
345 ! added esg1Sum and esg4Sum to Real heading for restart
346 !
347 ! Revision 1.2 2004/02/11 03:25:07 wasistho
348 ! added feature: variable number of turbulence output fields
349 !
350 ! Revision 1.1 2004/02/07 01:21:19 wasistho
351 ! added TURB_ReadSolutionRegion to be used in utilities/rocflo/post
352 !
353 !
354 !******************************************************************************
355 
356 
357 
358 
359 
360 
361 
362 
363 
**********************************************************************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 turb_rflo_readsolutionregion(iReg, regions)
j indices k indices k
Definition: Indexing.h:6
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_readdatafilereal(global, fileId, form, nDim1, nDim2, var)