Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PEUL_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 flow solution for one region (for Eulerian particles).
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: region%levels%peul%cv = conservative variables (current grid level)
35 ! global%currentTime = physical time
36 ! global%peulResInit = initial residual.
37 !
38 ! Notes: solution is read in only for the current grid level;
39 ! solution is also read in for all dummy cells.
40 ! There is no transfer of data to other processors.
41 !
42 !******************************************************************************
43 !
44 ! $Id: PEUL_ReadSolutionRegion.F90,v 1.3 2008/12/06 08:44:39 mtcampbe Exp $
45 !
46 ! Copyright: (c) 2003 by the University of Illinois
47 !
48 !******************************************************************************
49 
50 SUBROUTINE peul_readsolutionregion( iReg,regions ) ! PUBLIC
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, INTENT(IN) :: ireg
66  TYPE(t_region), POINTER :: regions(:)
67 
68 ! ... loop variables
69  INTEGER :: iptype, i, j, k, n
70 
71 ! ... local variables
72  CHARACTER(2*CHRLEN+22) :: fhead, fname
73  CHARACTER(CHRLEN) :: rcsidentstring, msg, timestring
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, ncv, errorflag
79  INTEGER, ALLOCATABLE :: ivar(:,:)
80 
81  LOGICAL :: fileexists
82 
83  REAL(RFREAL), POINTER :: cv(:,:), cvfile(:,:)
84  REAL(RFREAL), ALLOCATABLE :: rvar(:,:)
85 
86  TYPE(t_global), POINTER :: global
87 
88 !******************************************************************************
89 
90  rcsidentstring = '$RCSfile: PEUL_ReadSolutionRegion.F90,v $ $Revision: 1.3 $'
91 
92  global => regions(ireg)%global
93 
94  CALL registerfunction( global,'PEUL_ReadSolutionRegion',&
95  'PEUL_ReadSolutionRegion.F90' )
96 
97 ! begin -----------------------------------------------------------------------
98 
99 ! allocate fixed-size temporary data arrays -----------------------------------
100 
101  ALLOCATE( ivar(5,1),stat=errorflag )
102  ALLOCATE( rvar(2,1),stat=errorflag )
103  global%error = errorflag
104  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
105 
106 ! copy time to string ---------------------------------------------------------
107 
108  IF (global%flowType == flow_unsteady) THEN
109  WRITE(timestring,'(ES11.5)') global%timeStamp
110  ELSE
111  WRITE(timestring,'(ES11.5)') 0._rfreal
112  ENDIF
113 
114 ! open solution file (only if iReg=1) -----------------------------------------
115 
116  IF (ireg == 1) THEN
117 
118  fhead = trim(global%inDir)//trim(global%casename)
119 
120  SELECT CASE(global%solutFormat)
121  CASE (format_ascii)
122  fhead = trim(fhead)//'.peul_sola_'
123  CASE (format_binary)
124  fhead = trim(fhead)//'.peul_solb_'
125  CASE default
126  CALL errorstop( global,err_unknown_format,__line__ )
127  END SELECT
128 
129  IF (global%flowType == flow_unsteady) THEN
130  WRITE(fname,'(A,ES11.5)') trim(fhead), global%timeStamp
131  ELSE
132  WRITE(fname,'(A,I6.6)') trim(fhead), global%currentIter
133  ENDIF
134 
135  INQUIRE(file=fname,exist=fileexists)
136 
137  IF (fileexists) THEN
138 
139  SELECT CASE(global%solutFormat)
140  CASE (format_ascii)
141  OPEN(if_peul_solut,file=fname,form= 'formatted',status='old', &
142  iostat=errorflag)
143  CASE (format_binary)
144  OPEN(if_peul_solut,file=fname,form='unformatted',status='old', &
145  iostat=errorflag)
146  END SELECT
147  global%error = errorflag
148  IF (global%error /= 0) &
149  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
150 
151  ENDIF
152 
153 ! - read time and initial residual
154 
155  IF (fileexists) THEN
156  CALL rflo_readdatafilereal( global,if_peul_solut,global%solutFormat, &
157  2,1,rvar )
158  ELSE
159  rvar(1,1) = 0._rfreal
160  rvar(2,1) = 1._rfreal
161  ENDIF
162 
163  IF (global%flowType==flow_unsteady .AND. global%currentTime>0._rfreal) THEN
164  IF (global%currentTime /= rvar(1,1) .AND. &
165  .NOT.regions(1)%peulInput%constInit) THEN
166  WRITE(msg,1000) rvar(1,1),global%currentTime
167  CALL errorstop( global,err_time_solution,__line__,msg//' File: '// &
168  trim(fname) )
169  ENDIF
170  ENDIF
171  global%peulResInit = rvar(2,1)
172 
173  ENDIF ! 1st region
174 
175 ! read solution data ----------------------------------------------------------
176 ! get dimensions and pointers
177 
178  ilev = regions(ireg)%currLevel
179  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
180  jdcbeg,jdcend,kdcbeg,kdcend )
181  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
182  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
183  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
184  ndimc = ijkend - ijkbeg + 1
185 
186  CALL rflo_getdimensphysnodes( regions(ireg),ilev,ipnbeg,ipnend, &
187  jpnbeg,jpnend,kpnbeg,kpnend )
188  CALL rflo_getnodeoffset( regions(ireg),ilev,inoff,ijnoff )
189  ndimn = (regions(ireg)%levels(ilev)%grid%ipc+1)* &
190  (regions(ireg)%levels(ilev)%grid%jpc+1)* &
191  (regions(ireg)%levels(ilev)%grid%kpc+1)
192 
193  ncv = regions(ireg)%levels(ilev)%peul%nCv
194 
195 ! read region number and dimensions
196 
197  CALL rflo_readdatafileint( global,if_peul_solut,global%solutFormat, &
198  5,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 
205  IF (iregfile /= ireg) &
206  CALL errorstop( global,err_region_number,__line__,'File: '//trim(fname) )
207  IF ((ipc /= regions(ireg)%levels(ilev)%grid%ipc) .OR. &
208  (jpc /= regions(ireg)%levels(ilev)%grid%jpc) .OR. &
209  (kpc /= regions(ireg)%levels(ilev)%grid%kpc)) THEN
210  WRITE(msg,1005) ireg,ipc,jpc,kpc
211  CALL errorstop( global,err_grid_dimensions,__line__,msg )
212  ENDIF
213  IF (ndumcells /= regions(ireg)%nDumCells) THEN
214  WRITE(msg,1010) ireg,ndumcells,regions(ireg)%nDumCells
215  CALL errorstop( global,err_grid_dumcells,__line__,msg )
216  ENDIF
217 
218 ! read data
219 
220  ALLOCATE( cvfile(ncv,ndimc),stat=errorflag )
221  global%error = errorflag
222  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
223 
224  CALL rflo_readdatafilereal( global,if_peul_solut,global%solutFormat, &
225  ncv,ndimc,cvfile )
226 
227 ! copy solution into data structure
228 
229  cv => regions(ireg)%levels(ilev)%peul%cv
230 
231  n = 0
232  DO k=kdcbeg,kdcend
233  DO j=jdcbeg,jdcend
234  DO i=idcbeg,idcend
235  n = n + 1
236  ijk = indijk(i,j,k,ioff,ijoff)
237  cv(:,ijk) = cvfile(:,n)
238  ENDDO
239  ENDDO
240  ENDDO
241 
242  IF (ASSOCIATED(cvfile)) THEN
243  DEALLOCATE( cvfile,stat=errorflag )
244  global%error = errorflag
245  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
246  nullify( cvfile )
247  ENDIF
248 
249 ! finalize --------------------------------------------------------------------
250 
251  IF (ireg == global%nRegions) THEN
252  CLOSE(if_peul_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 1000 FORMAT('Time in file is= ',es12.5,' but it should be= ',e12.5,'.')
261 1005 FORMAT('Region ',i5,', ipc= ',i6,', jpc= ',i6,', kpc= ',i6,'.')
262 1010 FORMAT('Region ',i5,', # dummy cells=',i2,' but should be= ',i1)
263 
264 END SUBROUTINE peul_readsolutionregion
265 
266 !******************************************************************************
267 !
268 ! RCS Revision history:
269 !
270 ! $Log: PEUL_ReadSolutionRegion.F90,v $
271 ! Revision 1.3 2008/12/06 08:44:39 mtcampbe
272 ! Updated license.
273 !
274 ! Revision 1.2 2008/11/19 22:17:51 mtcampbe
275 ! Added Illinois Open Source License/Copyright
276 !
277 ! Revision 1.1 2004/12/01 21:09:49 haselbac
278 ! Initial revision after changing case
279 !
280 ! Revision 1.4 2004/04/15 16:04:03 jferry
281 ! minor formatting (removed trailing spaces)
282 !
283 ! Revision 1.3 2003/09/26 22:52:12 jferry
284 ! changed file number for read/write of rocsmoke solutions
285 !
286 ! Revision 1.2 2003/05/15 02:57:05 jblazek
287 ! Inlined index function.
288 !
289 ! Revision 1.1 2003/05/07 15:11:58 jferry
290 ! Added routine PEUL_ReadSolutionRegion
291 !
292 !******************************************************************************
293 
294 
295 
296 
297 
298 
299 
**********************************************************************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
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_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 peul_readsolutionregion(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
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 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)