Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_ReadGridRegion.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 x-,y-,z-coordinates of grid nodes for one region.
26 !
27 ! Description: the following grid 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%grid%xyz = grid coordinates
35 ! global%currentTime = physical time
36 !
37 ! Notes: additionaly, physical time is read in, which is stored at
38 ! the beginning of the file (meaningful only in the case of unsteady
39 ! flow and dynamic grids). It is the finest grid, which is read in.
40 ! There is no transfer of data to other processors.
41 !
42 !******************************************************************************
43 !
44 ! $Id: RFLO_ReadGridRegion.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_readgridregion( iReg,regions )
51 
52  USE moddatatypes
53  USE moddatastruct, ONLY : t_region
54  USE modglobal, ONLY : t_global
57  USE moderror
58  USE modparameters
59  IMPLICIT NONE
60 
61 #include "Indexing.h"
62 
63 ! ... parameters
64  INTEGER :: ireg
65 
66  TYPE(t_region), POINTER :: regions(:)
67 
68 ! ... loop variables
69  INTEGER :: i, j, k, n
70 
71 ! ... local variables
72  CHARACTER(2*CHRLEN+17) :: fname
73  CHARACTER(CHRLEN) :: msg
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_ReadGridRegion',&
92  'RFLO_ReadGridRegion.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,__line__ )
100 
101 ! open grid file (only if iReg=1) ---------------------------------------------
102 
103  IF (ireg == 1) THEN
104 
105  movegrid = .false.
106  DO iregfile=1,global%nRegions
107  IF (regions(iregfile)%mixtInput%moveGrid) movegrid = .true.
108  ENDDO
109 
110 ! - unsteady flow
111 
112  IF (global%flowType==flow_unsteady .AND. &
113  movegrid .AND. global%timeStamp>0._rfreal) THEN
114  IF (global%gridFormat == format_ascii) THEN
115  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.grda_', &
116  global%timeStamp
117  OPEN(if_grid,file=fname,form='formatted',status='old',iostat=errorflag)
118  ELSE IF (global%gridFormat == format_binary) THEN
119  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.grdb_', &
120  global%timeStamp
121  OPEN(if_grid,file=fname,form='unformatted',status='old',iostat=errorflag)
122  ELSE
123  CALL errorstop( global,err_unknown_format,__line__ )
124  ENDIF
125 
126 ! - steady flow
127 
128  ELSE
129  IF (global%gridFormat == format_ascii) THEN
130  WRITE(fname,'(A)') trim(global%inDir)//trim(global%casename)//'.grda'
131  OPEN(if_grid,file=fname,form='formatted',status='old',iostat=errorflag)
132  ELSE IF (global%gridFormat == format_binary) THEN
133  WRITE(fname,'(A)') trim(global%inDir)//trim(global%casename)//'.grdb'
134  OPEN(if_grid,file=fname,form='unformatted',status='old',iostat=errorflag)
135  ELSE
136  CALL errorstop( global,err_unknown_format,__line__ )
137  ENDIF
138  ENDIF
139 
140  global%error = errorflag
141  IF (global%error /= 0) &
142  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
143 
144 ! - read time
145 
146  CALL rflo_readdatafilereal( global,if_grid,global%gridFormat,1,1,rvar )
147  global%currentTime = rvar(1,1)
148 
149  ENDIF ! 1st region
150 
151 ! read grid data --------------------------------------------------------------
152 ! read region number and dimensions
153 
154  CALL rflo_readdatafileint( global,if_grid,global%gridFormat,4,1,ivar )
155  iregfile = ivar(1,1)
156  ipc = ivar(2,1)
157  jpc = ivar(3,1)
158  kpc = ivar(4,1)
159 
160  IF (iregfile /= ireg) &
161  CALL errorstop( global,err_region_number,__line__,'File: '//trim(fname) )
162  IF ((ipc /= regions(ireg)%levels(1)%grid%ipc) .OR. &
163  (jpc /= regions(ireg)%levels(1)%grid%jpc) .OR. &
164  (kpc /= regions(ireg)%levels(1)%grid%kpc)) THEN
165  WRITE(msg,1000) ireg,ipc,jpc,kpc
166  CALL errorstop( global,err_grid_dimensions,__line__,msg )
167  ENDIF
168 
169 ! read data
170 
171  ndim = (ipc+1)*(jpc+1)*(kpc+1)
172  ALLOCATE( xyzfile(3,ndim),stat=errorflag )
173  global%error = errorflag
174  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
175 
176  CALL rflo_readdatafilereal( global,if_grid,global%gridFormat,3,ndim,xyzfile )
177 
178 ! copy grid into data structure
179 
180  CALL rflo_getdimensphysnodes( regions(ireg),1,ipnbeg,ipnend, &
181  jpnbeg,jpnend,kpnbeg,kpnend )
182  CALL rflo_getnodeoffset( regions(ireg),1,inoff,ijnoff )
183  xyz => regions(ireg)%levels(1)%grid%xyz
184 
185  n = 0
186  DO k=kpnbeg,kpnend
187  DO j=jpnbeg,jpnend
188  DO i=ipnbeg,ipnend
189  n = n + 1
190  ijkn = indijk(i,j,k,inoff,ijnoff)
191  xyz(xcoord,ijkn) = xyzfile(1,n)
192  xyz(ycoord,ijkn) = xyzfile(2,n)
193  xyz(zcoord,ijkn) = xyzfile(3,n)
194  ENDDO
195  ENDDO
196  ENDDO
197 
198  DEALLOCATE( xyzfile,stat=errorflag )
199  global%error = errorflag
200  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
201 
202 ! finalize --------------------------------------------------------------------
203 
204  IF (ireg == global%nRegions) THEN
205  CLOSE(if_grid,iostat=errorflag)
206  global%error = errorflag
207  IF (global%error /= 0) &
208  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
209  ENDIF
210 
211  CALL deregisterfunction( global )
212 
213 1000 FORMAT('Region ',i5,', ipc= ',i6,', jpc= ',i6,', kpc= ',i6,'.')
214 
215 END SUBROUTINE rflo_readgridregion
216 
217 !******************************************************************************
218 !
219 ! RCS Revision history:
220 !
221 ! $Log: RFLO_ReadGridRegion.F90,v $
222 ! Revision 1.3 2008/12/06 08:44:07 mtcampbe
223 ! Updated license.
224 !
225 ! Revision 1.2 2008/11/19 22:17:21 mtcampbe
226 ! Added Illinois Open Source License/Copyright
227 !
228 ! Revision 1.1 2004/11/29 21:25:16 wasistho
229 ! lower to upper case
230 !
231 ! Revision 1.10 2003/11/20 16:40:34 mdbrandy
232 ! Backing out RocfluidMP changes from 11-17-03
233 !
234 ! Revision 1.7 2003/05/15 02:57:01 jblazek
235 ! Inlined index function.
236 !
237 ! Revision 1.6 2002/10/23 18:43:24 jblazek
238 ! Changed temporary pointer arrays into allocatable arrays
239 ! in grid and solution I/O routines.
240 !
241 ! Revision 1.5 2002/10/12 03:20:50 jblazek
242 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
243 !
244 ! Revision 1.4 2002/09/20 22:22:35 jblazek
245 ! Finalized integration into GenX.
246 !
247 ! Revision 1.3 2002/09/05 17:40:19 jblazek
248 ! Variable global moved into regions().
249 !
250 ! Revision 1.2 2002/08/29 21:52:21 jblazek
251 ! Added I/O of grid speeds.
252 !
253 ! Revision 1.1 2002/06/07 16:40:36 jblazek
254 ! Grid & solution for all regions in one file.
255 !
256 !******************************************************************************
257 
258 
259 
260 
261 
262 
263 
**********************************************************************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
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_readdatafileint(global, fileId, form, nDim1, nDim2, ivar)
**********************************************************************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_readgridregion(iReg, regions)
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 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_readdatafilereal(global, fileId, form, nDim1, nDim2, var)