Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_WriteGridRegion.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 x-,y-,z-coordinates of grid nodes to file for one region.
26 !
27 ! Description: the following grid formats are supported:
28 ! - RocfloMP ASCII
29 ! - RocfloMP binary
30 ! - HDF.
31 !
32 ! Input: region = dimensions and coordinates of all regions
33 ! iReg = region number
34 ! global%currentTime = physical time.
35 !
36 ! Output: to file.
37 !
38 ! Notes: additionaly, the physical time is stored at the beginning of the file
39 ! (set to zero in the case of steady flow and/or fixed grid). Only the
40 ! finest grid gets stored. All regions are written into one file.
41 ! There is no transfer of data from other processors.
42 !
43 !******************************************************************************
44 !
45 ! $Id: RFLO_WriteGridRegion.F90,v 1.3 2008/12/06 08:44:07 mtcampbe Exp $
46 !
47 ! Copyright: (c) 2001 by the University of Illinois
48 !
49 !******************************************************************************
50 
51 SUBROUTINE rflo_writegridregion( iReg,regions )
52 
53  USE moddatatypes
54  USE moddatastruct, ONLY : t_region
55  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 :: iregfile, ipc, jpc, kpc, ndim
76  INTEGER :: ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend
77  INTEGER :: inoff, ijnoff, ijkn, errorflag
78  INTEGER, ALLOCATABLE :: ivar(:,:)
79 
80  LOGICAL :: movegrid
81 
82  REAL(RFREAL), POINTER :: xyz(:,:)
83  REAL(RFREAL), ALLOCATABLE :: rvar(:,:), xyzfile(:,:)
84 
85  TYPE(t_global), POINTER :: global
86 
87 !******************************************************************************
88 
89  global => regions(ireg)%global
90 
91  CALL registerfunction( global,'RFLO_WriteGridRegion',&
92  'RFLO_WriteGridRegion.F90' )
93 
94 ! allocate fixed-size temporary data arrays -----------------------------------
95 
96  ALLOCATE( ivar(4,1),stat=errorflag )
97  ALLOCATE( rvar(1,1),stat=errorflag )
98  global%error = errorflag
99  IF (global%error /= 0) CALL errorstop( global,err_allocate,&
100  __line__ )
101 
102 ! open grid file (only if iReg=1) ---------------------------------------------
103 
104  IF (ireg == 1) THEN
105 
106  movegrid = .false.
107  DO iregfile=1,global%nRegions
108  IF (regions(iregfile)%mixtInput%moveGrid) movegrid = .true.
109  ENDDO
110 
111 ! - unsteady flow
112 
113  IF (global%flowType==flow_unsteady .AND. &
114  movegrid .AND. global%currentTime>0._rfreal) THEN
115  IF (global%gridFormat == format_ascii) THEN
116  WRITE(fname,'(A,1PE11.5)') trim(global%outDir)//trim(global%casename)//'.grda_', &
117  global%currentTime
118  OPEN(if_grid,file=fname,form='formatted',status='unknown', &
119  iostat=errorflag)
120  ELSE IF (global%gridFormat == format_binary) THEN
121  WRITE(fname,'(A,1PE11.5)') trim(global%outDir)//trim(global%casename)//'.grdb_', &
122  global%currentTime
123  OPEN(if_grid,file=fname,form='unformatted',status='unknown', &
124  iostat=errorflag)
125  ELSE
126  CALL errorstop( global,err_unknown_format,&
127  __line__ )
128  ENDIF
129  rvar(1,1) = global%currentTime
130 
131 ! - steady flow
132 
133  ELSE
134  IF (global%gridFormat == format_ascii) THEN
135  WRITE(fname,'(A)') trim(global%outDir)//trim(global%casename)//'.grda'
136  OPEN(if_grid,file=fname,form='formatted',status='unknown', &
137  iostat=errorflag)
138  ELSE IF (global%gridFormat == format_binary) THEN
139  WRITE(fname,'(A)') trim(global%outDir)//trim(global%casename)//'.grdb'
140  OPEN(if_grid,file=fname,form='unformatted',status='unknown', &
141  iostat=errorflag)
142  ELSE
143  CALL errorstop( global,err_unknown_format,&
144  __line__ )
145  ENDIF
146  rvar(1,1) = 0._rfreal
147  ENDIF
148 
149  global%error = errorflag
150  IF (global%error /= 0) &
151  CALL errorstop( global,err_file_open,&
152  __line__,'File: '//trim(fname) )
153 
154 ! - write time
155 
156  CALL rflo_writedatafilereal( global,if_grid,global%gridFormat,1,1,rvar )
157 
158  ENDIF ! 1st region
159 
160 ! write grid data -------------------------------------------------------------
161 
162  ndim = (regions(ireg)%levels(1)%grid%ipc+1)* &
163  (regions(ireg)%levels(1)%grid%jpc+1)* &
164  (regions(ireg)%levels(1)%grid%kpc+1)
165  ALLOCATE( xyzfile(3,ndim),stat=errorflag )
166  global%error = errorflag
167  IF (global%error /= 0) CALL errorstop( global,err_allocate,&
168  __line__ )
169 
170 ! copy grid into data structure
171 
172  CALL rflo_getdimensphysnodes( regions(ireg),1,ipnbeg,ipnend, &
173  jpnbeg,jpnend,kpnbeg,kpnend )
174  CALL rflo_getnodeoffset( regions(ireg),1,inoff,ijnoff )
175  xyz => regions(ireg)%levels(1)%grid%xyz
176 
177  n = 0
178  DO k=kpnbeg,kpnend
179  DO j=jpnbeg,jpnend
180  DO i=ipnbeg,ipnend
181  n = n + 1
182  ijkn = indijk(i,j,k,inoff,ijnoff)
183  xyzfile(1,n) = xyz(xcoord,ijkn)
184  xyzfile(2,n) = xyz(ycoord,ijkn)
185  xyzfile(3,n) = xyz(zcoord,ijkn)
186  ENDDO
187  ENDDO
188  ENDDO
189 
190 ! write region number and dimensions
191 
192  ivar(1,1) = ireg
193  ivar(2,1) = regions(ireg)%levels(1)%grid%ipc
194  ivar(3,1) = regions(ireg)%levels(1)%grid%jpc
195  ivar(4,1) = regions(ireg)%levels(1)%grid%kpc
196  CALL rflo_writedatafileint( global,if_grid,global%gridFormat,4,1,ivar )
197 
198 ! write data
199 
200  CALL rflo_writedatafilereal( global,if_grid,global%gridFormat,3,ndim,xyzfile )
201 
202  DEALLOCATE( xyzfile,stat=errorflag )
203  global%error = errorflag
204  IF (global%error /= 0) CALL errorstop( global,err_deallocate,&
205  __line__ )
206 
207 ! finalize --------------------------------------------------------------------
208 
209  IF (ireg == global%nRegions) THEN
210  CLOSE(if_grid,iostat=errorflag)
211  global%error = errorflag
212  IF (global%error /= 0) &
213  CALL errorstop( global,err_file_close,&
214  __line__,'File: '//trim(fname) )
215  ENDIF
216 
217  CALL deregisterfunction( global )
218 
219 END SUBROUTINE rflo_writegridregion
220 
221 !******************************************************************************
222 !
223 ! RCS Revision history:
224 !
225 ! $Log: RFLO_WriteGridRegion.F90,v $
226 ! Revision 1.3 2008/12/06 08:44:07 mtcampbe
227 ! Updated license.
228 !
229 ! Revision 1.2 2008/11/19 22:17:21 mtcampbe
230 ! Added Illinois Open Source License/Copyright
231 !
232 ! Revision 1.1 2004/11/29 21:25:17 wasistho
233 ! lower to upper case
234 !
235 ! Revision 1.9 2003/11/20 16:40:34 mdbrandy
236 ! Backing out RocfluidMP changes from 11-17-03
237 !
238 ! Revision 1.6 2003/05/15 02:57:01 jblazek
239 ! Inlined index function.
240 !
241 ! Revision 1.5 2002/10/23 18:43:24 jblazek
242 ! Changed temporary pointer arrays into allocatable arrays
243 ! in grid and solution I/O routines.
244 !
245 ! Revision 1.4 2002/10/12 03:20:50 jblazek
246 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
247 !
248 ! Revision 1.3 2002/09/20 22:22:35 jblazek
249 ! Finalized integration into GenX.
250 !
251 ! Revision 1.2 2002/09/05 17:40:19 jblazek
252 ! Variable global moved into regions().
253 !
254 ! Revision 1.1 2002/06/07 16:40:36 jblazek
255 ! Grid & solution for all regions in one file.
256 !
257 !******************************************************************************
258 
259 
260 
261 
262 
263 
264 
**********************************************************************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
subroutine rflo_writegridregion(iReg, regions)
**********************************************************************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)
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
**********************************************************************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
subroutine rflo_getdimensphysnodes(region, iLev, ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend)
j indices j
Definition: Indexing.h:6
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