Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_WriteSolutionRegion.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 flow solution to file for one region (only mixture for now).
26 !
27 ! Description: the following solution formats are supported:
28 ! - RocfloMP ASCII
29 ! - RocfloMP binary.
30 !
31 ! Input: regions = dimensions and cons. variables of all regions
32 ! iReg = region number
33 ! global%currentTime = physical time
34 ! global%resInit = initial residual.
35 !
36 ! Output: to file.
37 !
38 ! Notes: solution is stored only for the current grid level; it is also
39 ! stored for all dummy cells. All regions are written into one file.
40 ! There is no transfer of data from other processors.
41 !
42 !******************************************************************************
43 !
44 ! $Id: RFLO_WriteSolutionRegion.F90,v 1.3 2008/12/06 08:44:07 mtcampbe Exp $
45 !
46 ! Copyright: (c) 2001 by the University of Illinois
47 !
48 !******************************************************************************
49 
50 SUBROUTINE rflo_writesolutionregion( iReg,regions )
51 
52  USE moddatatypes
53  USE moddatastruct, ONLY : t_region
54  USE modglobal, ONLY : t_global
58  USE moderror
59  USE modparameters
60  IMPLICIT NONE
61 
62 #include "Indexing.h"
63 
64 ! ... parameters
65  INTEGER :: ireg
66 
67  TYPE(t_region), POINTER :: regions(:)
68 
69 ! ... loop variables
70  INTEGER :: i, j, k, n
71 
72 ! ... local variables
73  CHARACTER(2*CHRLEN+17) :: fname
74 
75  INTEGER :: ilev, iregfile, ipc, jpc, kpc, ndumcells, ioff, ijoff, ijk
76  INTEGER :: idcbeg, jdcbeg, kdcbeg, idcend, jdcend, kdcend, ijkbeg, ijkend
77  INTEGER :: ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend, inoff, ijnoff
78  INTEGER :: ndimc, ndimn, errorflag
79  INTEGER, ALLOCATABLE :: ivar(:,:)
80 
81  REAL(RFREAL), POINTER :: cv(:,:), sivel(:), sjvel(:), skvel(:)
82  REAL(RFREAL), ALLOCATABLE :: rvar(:,:), cvfile(:,:), svelfile(:,:)
83 
84  TYPE(t_global), POINTER :: global
85 
86 !******************************************************************************
87 
88  global => regions(ireg)%global
89 
90  CALL registerfunction( global,'RFLO_WriteSolutionRegion',&
91  'RFLO_WriteSolutionRegion.F90' )
92 
93 ! allocate fixed-size temporary data arrays -----------------------------------
94 
95  ALLOCATE( ivar(5,1),stat=errorflag )
96  ALLOCATE( rvar(2,1),stat=errorflag )
97  global%error = errorflag
98  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
99 
100 ! open solution file (only if iReg=1) -----------------------------------------
101 
102  IF (ireg == 1) THEN
103 
104 ! - unsteady flow
105 
106  IF (global%flowType == flow_unsteady) THEN
107  IF (global%solutFormat == format_ascii) THEN
108  WRITE(fname,'(A,1PE11.5)') trim(global%outDir)//trim(global%casename)//'.sola_', &
109  global%currentTime
110  OPEN(if_solut,file=fname,form='formatted',status='unknown', &
111  iostat=errorflag)
112  ELSE IF (global%solutFormat == format_binary) THEN
113  WRITE(fname,'(A,1PE11.5)') trim(global%outDir)//trim(global%casename)//'.solb_', &
114  global%currentTime
115  OPEN(if_solut,file=fname,form='unformatted',status='unknown', &
116  iostat=errorflag)
117  ELSE
118  CALL errorstop( global,err_unknown_format,__line__ )
119  ENDIF
120  rvar(1,1) = global%currentTime
121  rvar(2,1) = 1._rfreal
122 
123 ! - steady flow
124 
125  ELSE
126  IF (global%solutFormat == format_ascii) THEN
127  WRITE(fname,'(A,I6.6)') trim(global%outDir)//trim(global%casename)//'.sola_', &
128  global%currentIter
129  OPEN(if_solut,file=fname,form='formatted',status='unknown', &
130  iostat=errorflag)
131  ELSE IF (global%solutFormat == format_binary) THEN
132  WRITE(fname,'(A,I6.6)') trim(global%outDir)//trim(global%casename)//'.solb_', &
133  global%currentIter
134  OPEN(if_solut,file=fname,form='unformatted',status='unknown', &
135  iostat=errorflag)
136  ELSE
137  CALL errorstop( global,err_unknown_format,__line__ )
138  ENDIF
139  rvar(1,1) = 0._rfreal
140  rvar(2,1) = global%resInit
141  ENDIF
142 
143  global%error = errorflag
144  IF (global%error /= 0) &
145  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
146 
147 ! - write time and initial residual to file
148 
149  CALL rflo_writedatafilereal( global,if_solut,global%solutFormat,2,1,rvar )
150 
151  ENDIF ! 1st region
152 
153 ! write solution data ---------------------------------------------------------
154 ! get dimensions and pointers
155 
156  ilev = regions(ireg)%currLevel
157  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
158  jdcbeg,jdcend,kdcbeg,kdcend )
159  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
160  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
161  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
162  ndimc = ijkend - ijkbeg + 1
163 
164  CALL rflo_getdimensphysnodes( regions(ireg),ilev,ipnbeg,ipnend, &
165  jpnbeg,jpnend,kpnbeg,kpnend )
166  CALL rflo_getnodeoffset( regions(ireg),ilev,inoff,ijnoff )
167  ndimn = (regions(ireg)%levels(ilev)%grid%ipc+1)* &
168  (regions(ireg)%levels(ilev)%grid%jpc+1)* &
169  (regions(ireg)%levels(ilev)%grid%kpc+1)
170 
171 ! allocate memory for data field
172 
173  ALLOCATE( cvfile(cv_mixt_neqs,ndimc),stat=errorflag )
174  global%error = errorflag
175  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
176 
177  IF (regions(ireg)%mixtInput%moveGrid) THEN
178  ALLOCATE( svelfile(3,ndimn),stat=errorflag )
179  global%error = errorflag
180  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
181  ENDIF
182 
183 ! copy solution into data structure
184 
185  cv => regions(ireg)%levels(ilev)%mixt%cv
186 
187  n = 0
188  DO k=kdcbeg,kdcend
189  DO j=jdcbeg,jdcend
190  DO i=idcbeg,idcend
191  n = n + 1
192  ijk = indijk(i,j,k,ioff,ijoff)
193  cvfile(1,n) = cv(cv_mixt_dens,ijk)
194  cvfile(2,n) = cv(cv_mixt_xmom,ijk)
195  cvfile(3,n) = cv(cv_mixt_ymom,ijk)
196  cvfile(4,n) = cv(cv_mixt_zmom,ijk)
197  cvfile(5,n) = cv(cv_mixt_ener,ijk)
198  ENDDO
199  ENDDO
200  ENDDO
201 
202  IF (regions(ireg)%mixtInput%moveGrid) THEN
203  sivel => regions(ireg)%levels(ilev)%grid%siVel
204  sjvel => regions(ireg)%levels(ilev)%grid%sjVel
205  skvel => regions(ireg)%levels(ilev)%grid%skVel
206  n = 0
207  DO k=kpnbeg,kpnend
208  DO j=jpnbeg,jpnend
209  DO i=ipnbeg,ipnend
210  n = n + 1
211  ijk = indijk(i,j,k,inoff,ijnoff)
212  svelfile(1,n) = sivel(ijk)
213  svelfile(2,n) = sjvel(ijk)
214  svelfile(3,n) = skvel(ijk)
215  ENDDO
216  ENDDO
217  ENDDO
218  ENDIF
219 
220 ! write region number and dimensions
221 
222  ivar(1,1) = ireg
223  ivar(2,1) = regions(ireg)%levels(ilev)%grid%ipc
224  ivar(3,1) = regions(ireg)%levels(ilev)%grid%jpc
225  ivar(4,1) = regions(ireg)%levels(ilev)%grid%kpc
226  ivar(5,1) = regions(ireg)%nDumCells
227  CALL rflo_writedatafileint( global,if_solut,global%solutFormat,5,1,ivar )
228 
229 ! write data
230 
231  CALL rflo_writedatafilereal( global,if_solut,global%solutFormat, &
232  cv_mixt_neqs,ndimc,cvfile )
233 
234  IF (regions(ireg)%mixtInput%moveGrid) THEN
235  CALL rflo_writedatafilereal( global,if_solut,global%solutFormat, &
236  3,ndimn,svelfile )
237  ENDIF
238 
239  DEALLOCATE( cvfile,stat=errorflag )
240  global%error = errorflag
241  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
242 
243  IF (regions(ireg)%mixtInput%moveGrid) THEN
244  DEALLOCATE( svelfile,stat=errorflag )
245  global%error = errorflag
246  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
247  ENDIF
248 
249 ! finalize --------------------------------------------------------------------
250 
251  IF (ireg == global%nRegions) THEN
252  CLOSE(if_solut,iostat=errorflag)
253  global%error = errorflag
254  IF (global%error /= 0) &
255  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
256  ENDIF
257 
258  CALL deregisterfunction( global )
259 
260 END SUBROUTINE rflo_writesolutionregion
261 
262 !******************************************************************************
263 !
264 ! RCS Revision history:
265 !
266 ! $Log: RFLO_WriteSolutionRegion.F90,v $
267 ! Revision 1.3 2008/12/06 08:44:07 mtcampbe
268 ! Updated license.
269 !
270 ! Revision 1.2 2008/11/19 22:17:21 mtcampbe
271 ! Added Illinois Open Source License/Copyright
272 !
273 ! Revision 1.1 2004/11/29 21:25:17 wasistho
274 ! lower to upper case
275 !
276 ! Revision 1.10 2003/11/20 16:40:35 mdbrandy
277 ! Backing out RocfluidMP changes from 11-17-03
278 !
279 ! Revision 1.7 2003/05/15 02:57:01 jblazek
280 ! Inlined index function.
281 !
282 ! Revision 1.6 2002/10/23 18:43:24 jblazek
283 ! Changed temporary pointer arrays into allocatable arrays
284 ! in grid and solution I/O routines.
285 !
286 ! Revision 1.5 2002/10/12 03:20:50 jblazek
287 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
288 !
289 ! Revision 1.4 2002/09/20 22:22:35 jblazek
290 ! Finalized integration into GenX.
291 !
292 ! Revision 1.3 2002/09/05 17:40:19 jblazek
293 ! Variable global moved into regions().
294 !
295 ! Revision 1.2 2002/08/29 21:52:21 jblazek
296 ! Added I/O of grid speeds.
297 !
298 ! Revision 1.1 2002/06/07 16:40:36 jblazek
299 ! Grid & solution for all regions in one file.
300 !
301 !******************************************************************************
302 
303 
304 
305 
306 
307 
308 
**********************************************************************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
**********************************************************************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 jpnbeg
subroutine rflo_writedatafileint(global, fileId, form, nDim1, nDim2, ivar)
j indices k indices k
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 kpnbeg
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
**********************************************************************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 jpnend
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
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
**********************************************************************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 ipnbeg
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
subroutine rflo_getdimensphysnodes(region, iLev, ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend)
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
**********************************************************************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 ipnend
subroutine rflo_writesolutionregion(iReg, regions)