Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TURB_rFLO_WriteSolution.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: write turbulence instantaneous solution to file
26 !
27 ! Description: the following solution formats are supported:
28 ! - RocfloMP ASCII
29 ! - RocfloMP binary.
30 !
31 ! Input: regions = dimensions and turb. variables of all regions
32 ! global%currentTime = physical time
33 ! global%resInit = initial residual.
34 !
35 ! Output: to file.
36 !
37 ! Notes: solution is stored only for the current grid level; it is also
38 ! stored for all dummy cells. All regions are written into one file.
39 !
40 !******************************************************************************
41 !
42 ! $Id: TURB_rFLO_WriteSolution.F90,v 1.5 2009/08/26 12:28:53 mtcampbe Exp $
43 !
44 ! Copyright: (c) 2001 by the University of Illinois
45 !
46 !******************************************************************************
47 
48 SUBROUTINE turb_rflo_writesolution( regions ) ! PUBLIC
49 
50  USE moddatatypes
51  USE moddatastruct, ONLY : t_region
52  USE modglobal, ONLY : t_global
55  USE moderror
56  USE modmpi
57  USE modparameters
59  IMPLICIT NONE
60 
61 #include "Indexing.h"
62 
63 ! ... parameters
64  TYPE(t_region), POINTER :: regions(:)
65 
66 ! ... loop variables
67  INTEGER :: ireg, i, j, k, n
68 
69 ! ... local variables
70  TYPE(t_global), POINTER :: global
71 
72  CHARACTER(2*CHRLEN+17) :: fname
73 
74 #ifdef MPI
75  INTEGER :: status(mpi_status_size)
76 #endif
77  INTEGER :: ilev, iregfile, ipc, jpc, kpc, ndumcells, 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 !******************************************************************************
86 
87  global => regions(1)%global
88 
89  CALL registerfunction( global,'TURB_RFLO_WriteSolution',&
90  'TURB_rFLO_WriteSolution.F90' )
91 
92 ! allocate fixed-size temporary data arrays -----------------------------------
93 
94  nrvar = 4
95 
96  ALLOCATE( ivar(6,1),stat=errorflag )
97  ALLOCATE( rvar(nrvar,1),stat=errorflag )
98  global%error = errorflag
99  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
100 
101 ! open solution file (only master proc.) --------------------------------------
102 
103  IF (global%myProcid == masterproc) THEN
104 
105 ! - unsteady flow
106 
107  IF (global%flowType == flow_unsteady) THEN
108  IF (global%solutFormat == format_ascii) THEN
109  WRITE(fname,'(A,1PE11.5)') trim(global%outDir)//trim(global%casename)//'.turba_', &
110  global%currentTime
111  OPEN(if_solut,file=fname,form='formatted',status='unknown', &
112  iostat=errorflag)
113  ELSE IF (global%solutFormat == format_binary) THEN
114  WRITE(fname,'(A,1PE11.5)') trim(global%outDir)//trim(global%casename)//'.turbb_', &
115  global%currentTime
116  OPEN(if_solut,file=fname,form='unformatted',status='unknown', &
117  iostat=errorflag)
118  ELSE
119  CALL errorstop( global,err_unknown_format,__line__ )
120  ENDIF
121  rvar(1,1) = global%currentTime
122  rvar(2,1) = 1._rfreal
123 
124 ! - steady flow
125 
126  ELSE
127  IF (global%solutFormat == format_ascii) THEN
128  WRITE(fname,'(A,I6.6)') trim(global%outDir)//trim(global%casename)//'.turba_', &
129  global%currentIter
130  OPEN(if_solut,file=fname,form='formatted',status='unknown', &
131  iostat=errorflag)
132  ELSE IF (global%solutFormat == format_binary) THEN
133  WRITE(fname,'(A,I6.6)') trim(global%outDir)//trim(global%casename)//'.turbb_', &
134  global%currentIter
135  OPEN(if_solut,file=fname,form='unformatted',status='unknown', &
136  iostat=errorflag)
137  ELSE
138  CALL errorstop( global,err_unknown_format,__line__ )
139  ENDIF
140  rvar(1,1) = 0._rfreal
141  rvar(2,1) = global%resInit
142  ENDIF
143  rvar(3,1) = global%esg1Sum
144  rvar(4,1) = global%esg4Sum
145 
146  global%error = errorflag
147  IF (global%error /= 0) &
148  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
149 
150  ENDIF ! MASTERPROC
151 
152 ! write time and initial residual to file --------------------------------------
153 
154  IF (global%myProcid == masterproc) THEN
155  CALL rflo_writedatafilereal( global,if_solut,global%solutFormat,nrvar,1,rvar )
156  ENDIF
157 
158 ! write solution data ----------------------------------------------------------
159 
160 ! first define no.of output solution by subsquent selection (order matters)
161 
162  DO ireg=1,global%nRegions
163  IF (regions(ireg)%procid == global%myProcid) THEN
164  IF (regions(ireg)%turbInput%modelClass == model_les) THEN
165  globalclass = model_les
166  ENDIF
167  ENDIF
168  ENDDO
169 
170  DO ireg=1,global%nRegions
171  IF (regions(ireg)%procid == global%myProcid) THEN
172  IF ((regions(ireg)%mixtInput%turbModel == turb_model_sa) .OR. &
173  (regions(ireg)%mixtInput%turbModel == turb_model_dessa) .OR. &
174  (regions(ireg)%mixtInput%turbModel == turb_model_hdessa)) THEN
175  globalclass = model_rans
176  ENDIF
177  ENDIF
178  ENDDO
179 
180  DO ireg=1,global%nRegions
181 
182 ! - get dimensions and pointers
183 
184  ilev = regions(ireg)%currLevel
185  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
186  jdcbeg,jdcend,kdcbeg,kdcend )
187  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
188  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
189  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
190  ndimc = ijkend - ijkbeg + 1
191 
192 ! - allocate memory for data field and initiate it to zero
193 
194  IF (regions(ireg)%procid==global%myProcid .OR. &
195  global%myProcid==masterproc) THEN
196  noutsol = regions(ireg)%turbInput%nOutField
197  ALLOCATE( solfile(noutsol,ndimc),stat=errorflag )
198  global%error = errorflag
199  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
200  solfile = 0._rfreal
201  ENDIF
202 
203 ! - copy solution(s), depending on model selected, into data structure
204 
205  IF (regions(ireg)%procid == global%myProcid) THEN
206  IF (regions(ireg)%turbInput%modelClass == model_les) THEN
207  tv => regions(ireg)%levels(ilev)%mixt%tv
208  n = 0
209  DO k=kdcbeg,kdcend
210  DO j=jdcbeg,jdcend
211  DO i=idcbeg,idcend
212  n = n + 1
213  ijk = indijk(i,j,k,ioff,ijoff)
214  solfile(1,n) = tv(tv_mixt_muet,ijk)
215  ENDDO
216  ENDDO
217  ENDDO
218  IF (noutsol == 2) THEN
219  vort => regions(ireg)%levels(ilev)%turb%vort
220  n = 0
221  DO k=kdcbeg,kdcend
222  DO j=jdcbeg,jdcend
223  DO i=idcbeg,idcend
224  n = n + 1
225  ijk = indijk(i,j,k,ioff,ijoff)
226  solfile(2,n) = sqrt( vort(xcoord,ijk)*vort(xcoord,ijk) + &
227  vort(ycoord,ijk)*vort(ycoord,ijk) + &
228  vort(zcoord,ijk)*vort(zcoord,ijk) )
229  ENDDO
230  ENDDO
231  ENDDO
232  ENDIF ! nOutSol
233  ENDIF
234  IF ((regions(ireg)%mixtInput%turbModel == turb_model_sa) .OR. &
235  (regions(ireg)%mixtInput%turbModel == turb_model_dessa) .OR. &
236  (regions(ireg)%mixtInput%turbModel == turb_model_hdessa)) THEN
237  tcv => regions(ireg)%levels(ilev)%turb%cv
238  n = 0
239  DO k=kdcbeg,kdcend
240  DO j=jdcbeg,jdcend
241  DO i=idcbeg,idcend
242  n = n + 1
243  ijk = indijk(i,j,k,ioff,ijoff)
244  solfile(1,n) = tcv(cv_sa_nutil,ijk)
245  ENDDO
246  ENDDO
247  ENDDO
248  IF (noutsol == 2) THEN
249  vort => regions(ireg)%levels(ilev)%turb%vort
250  n = 0
251  DO k=kdcbeg,kdcend
252  DO j=jdcbeg,jdcend
253  DO i=idcbeg,idcend
254  n = n + 1
255  ijk = indijk(i,j,k,ioff,ijoff)
256  solfile(2,n) = sqrt( vort(xcoord,ijk)*vort(xcoord,ijk) + &
257  vort(ycoord,ijk)*vort(ycoord,ijk) + &
258  vort(zcoord,ijk)*vort(zcoord,ijk) )
259  ENDDO
260  ENDDO
261  ENDDO
262  ENDIF ! nOutSol
263  IF (noutsol == 3) THEN
264  vort => regions(ireg)%levels(ilev)%turb%vort
265  lens => regions(ireg)%levels(ilev)%turb%lens
266  n = 0
267  DO k=kdcbeg,kdcend
268  DO j=jdcbeg,jdcend
269  DO i=idcbeg,idcend
270  n = n + 1
271  ijk = indijk(i,j,k,ioff,ijoff)
272  solfile(2,n) = sqrt( vort(xcoord,ijk)*vort(xcoord,ijk) + &
273  vort(ycoord,ijk)*vort(ycoord,ijk) + &
274  vort(zcoord,ijk)*vort(zcoord,ijk) )
275  solfile(3,n) = lens(ijk)
276  ENDDO
277  ENDDO
278  ENDDO
279  ENDIF ! nOutSol
280  ENDIF ! turbModel/modelClass
281  ENDIF ! global%myProcid
282 
283 ! - write region number and dimensions (only master)
284 
285  IF (global%myProcid == masterproc) THEN
286  ivar(1,1) = ireg
287  ivar(2,1) = regions(ireg)%levels(ilev)%grid%ipc
288  ivar(3,1) = regions(ireg)%levels(ilev)%grid%jpc
289  ivar(4,1) = regions(ireg)%levels(ilev)%grid%kpc
290  ivar(5,1) = regions(ireg)%nDumCells
291  ivar(6,1) = noutsol
292  CALL rflo_writedatafileint( global,if_solut,global%solutFormat,6,1,ivar )
293  ENDIF
294 
295 ! - master receives and writes data, others send them
296 
297  IF (global%myProcid == masterproc) THEN
298 #ifdef MPI
299  IF (regions(ireg)%procid /= masterproc) THEN
300  CALL mpi_recv( solfile,noutsol*ndimc,mpi_rfreal, &
301  regions(ireg)%procid,ireg, &
302  global%mpiComm,status,global%mpierr )
303  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
304  ENDIF
305 #endif
306  CALL rflo_writedatafilereal( global,if_solut,global%solutFormat,noutsol, &
307  ndimc,solfile )
308  ELSE ! not the master
309 #ifdef MPI
310  IF (regions(ireg)%procid == global%myProcid) THEN
311  CALL mpi_send( solfile,noutsol*ndimc,mpi_rfreal, &
312  masterproc,ireg,global%mpiComm,global%mpierr )
313  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
314  ENDIF
315 #endif
316  ENDIF
317 
318  IF (ALLOCATED(solfile) .eqv. .true.) THEN
319  DEALLOCATE( solfile,stat=errorflag )
320  global%error = errorflag
321  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
322  ENDIF
323 
324  ENDDO ! iReg
325 
326 ! finalize --------------------------------------------------------------------
327 
328  IF (global%myProcid == masterproc) THEN
329  CLOSE(if_solut,iostat=errorflag)
330  global%error = errorflag
331  IF (global%error /= 0) &
332  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
333  ENDIF
334 
335  CALL deregisterfunction( global )
336 
337 END SUBROUTINE turb_rflo_writesolution
338 
339 !******************************************************************************
340 !
341 ! RCS Revision history:
342 !
343 ! $Log: TURB_rFLO_WriteSolution.F90,v $
344 ! Revision 1.5 2009/08/26 12:28:53 mtcampbe
345 ! Ported to Hera. Fixed logical expression syntax errors. Replaced all
346 ! IF (logical_variable) with IF (logical_variable .eqv. .true.) as
347 ! consistent with the specification. Also changed: IF( ASSOCIATED(expr) )
348 ! to IF ( ASSOCIATED(expr) .eqv. .true. ). Intel compilers produce code
349 ! which silently fails for some mal-formed expressions, so these changes
350 ! are a net which should ensure that they are evaluated as intended.
351 !
352 ! Revision 1.4 2008/12/06 08:44:45 mtcampbe
353 ! Updated license.
354 !
355 ! Revision 1.3 2008/11/19 22:17:56 mtcampbe
356 ! Added Illinois Open Source License/Copyright
357 !
358 ! Revision 1.2 2005/03/09 06:37:50 wasistho
359 ! incorporated HDESSA
360 !
361 ! Revision 1.1 2004/03/11 03:26:34 wasistho
362 ! changed rocturb nomenclature
363 !
364 ! Revision 1.1 2004/03/08 23:35:46 wasistho
365 ! changed turb nomenclature
366 !
367 ! Revision 1.5 2004/02/26 21:27:30 wasistho
368 ! added esg1Sum and esg4Sum to Real heading for restart
369 !
370 ! Revision 1.4 2004/02/11 03:24:50 wasistho
371 ! added feature: variable number of turbulence output fields
372 !
373 ! Revision 1.3 2004/02/07 01:13:26 wasistho
374 ! modified TURB_WriteSolution
375 !
376 ! Revision 1.2 2003/10/07 02:08:12 wasistho
377 ! initial installation of RaNS-SA and DES
378 !
379 ! Revision 1.1 2003/07/22 03:01:12 wasistho
380 ! prepare more accurate rocturb restart
381 !
382 !
383 !******************************************************************************
384 
385 
386 
387 
388 
389 
390 
391 
392 
**********************************************************************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_writedatafileint(global, fileId, form, nDim1, nDim2, ivar)
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
double sqrt(double d)
Definition: double.h:73
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
subroutine turb_rflo_writesolution(regions)
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 rflo_writedatafilereal(global, fileId, form, nDim1, nDim2, var)
subroutine deregisterfunction(global)
Definition: ModError.F90:469