Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TO3D_Main.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: convert a 2-D grid into ROCFLO`s 3-D format.
26 !
27 ! Description: none.
28 !
29 ! Input: none.
30 !
31 ! Output: none.
32 !
33 ! Notes: none.
34 !
35 !******************************************************************************
36 !
37 ! $Id: TO3D_Main.F90,v 1.4 2008/12/06 08:44:52 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2001 by the University of Illinois
40 !
41 !******************************************************************************
42 
44 
45  USE moddatatypes
46  USE moddatastruct, ONLY : t_region
47  USE modglobal, ONLY : t_global
50  USE moderror
51  USE modmpi
52  USE modparameters
53  IMPLICIT NONE
54 
55 #include "Indexing.h"
56 
57 ! ... loop variables
58  INTEGER :: i, j, k, ijk, ijkm1
59 
60 ! ... local variables
61  CHARACTER(CHRLEN) :: versionstring, headerstring
62  CHARACTER(3*CHRLEN) :: fname2d
63 
64  INTEGER :: inoff, ijnoff, ijkbeg, ijkend
65  INTEGER :: idnbeg, jdnbeg, kdnbeg, idnend, jdnend, kdnend
66  INTEGER :: ipnbeg, jpnbeg, kpnbeg, ipnend, jpnend, kpnend
67  INTEGER :: margin, versionwidth, errorflag
68  INTEGER, PARAMETER :: headerwidth = 53
69 
70  REAL(RFREAL) :: depth, dz
71  REAL(RFREAL), POINTER :: xyz(:,:)
72 
73  TYPE(t_global), POINTER :: global
74  TYPE(t_region), POINTER :: regions(:)
75 
76 !******************************************************************************
77 
78  ALLOCATE( global )
79 
80  global%nFunTree = 0
81  CALL registerfunction( global,'ROCFLO_2Dto3D',&
82  'TO3D_Main.F90' )
83 
84 ! initialize ------------------------------------------------------------------
85 ! global parameters
86 
87  global%verbLevel = verbose_high
88 
89  global%flowType = flow_steady ! stationary flow
90  global%currentTime = 0._rfreal ! no physical time set
91  global%currentIter = 0 ! no iteration
92 
93  global%inDir = './' ! directory path
94  global%outDir = './'
95 
96  global%nProcAlloc = 1
97  global%myProcid = masterproc ! default process number (if not MPI)
98  global%mpierr = err_none
99  global%error = err_none
100 
101  global%pi = 4._rfreal*atan(1._rfreal)
102  global%rad = global%pi/180._rfreal
103 
104 ! print header ----------------------------------------------------------------
105 
106 #ifdef MPI
107  CALL mpi_init( global%mpierr )
108  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
109 #endif
110 
111  CALL buildversionstring( versionstring )
112 
113  headerstring = ' '
114  versionwidth = len_trim(versionstring)
115  margin = (headerwidth-versionwidth)/2
116  headerstring(margin+1:margin+versionwidth) = versionstring(1:versionwidth)
117  headerstring(1:1) = '*'
118  headerstring(headerwidth:headerwidth) = '*'
119 
120  WRITE(stdout,'(/,A)') solver_name//' *****************************************************'
121  WRITE(stdout, '(A)') solver_name//' * *'
122  WRITE(stdout, '(A)') solver_name//' * ROCFLO-MP: 2-D to 3-D Grid Convertor *'
123  WRITE(stdout, '(A)') solver_name//' * ==================================== *'
124  WRITE(stdout, '(A)') solver_name//' * *'
125  WRITE(stdout, '(A)') solver_name//' '//trim(headerstring)
126  WRITE(stdout, '(A)') solver_name//' * Copyright (c) by the University of Illinois *'
127  WRITE(stdout, '(A)') solver_name//' * *'
128  WRITE(stdout,'(A,/)') solver_name//' *****************************************************'
129 
130 ! region data
131 
132  global%nRegions = 1
133 
134  ALLOCATE( regions(global%nRegions),stat=errorflag )
135  global%error = errorflag
136  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
137 
138  regions(1)%global => global
139  regions(1)%active = active
140  regions(1)%procid = global%myProcid
141  regions(1)%nPatches = 1
142  regions(1)%nGridLevels = 1
143  regions(1)%nDumCells = 0
144  regions(1)%mixtInput%moveGrid = .false. ! fixed grid
145 
146  ALLOCATE( regions(1)%levels(regions(1)%nGridLevels),stat=errorflag )
147  global%error = errorflag
148  IF (global%error /=0 ) CALL errorstop( global,err_allocate,__line__ )
149 
150 ! read user input -------------------------------------------------------------
151 
152  WRITE(stdout,'(A)') solver_name//' Name of file with 2-D grid:'
153  READ(stdin,'(A)') fname2d
154 
155  WRITE(stdout,'(A)') solver_name//' Case name:'
156  READ(stdin,'(A)') global%casename
157 
158  WRITE(stdout,'(A)') solver_name//' Number of cells in the 3rd direction (>1):'
159  READ(stdin,*) regions(1)%levels(1)%grid%kpc
160  regions(1)%levels(1)%grid%kpc = max(2,regions(1)%levels(1)%grid%kpc)
161 
162  WRITE(stdout,'(A)') solver_name//' Depth of the 3-D grid (>0.):'
163  READ(stdin,*) depth
164 
165  WRITE(stdout,'(A)') solver_name//' Format of 3-D grid (0=ASCII, 1=binary):'
166  READ(stdin,*) global%gridFormat
167 
168 ! read the 2-D grid -----------------------------------------------------------
169 
170  WRITE(stdout,'(/,A)') solver_name//' Reading 2-D grid ...'
171 
172  OPEN(if_grid,file=fname2d,status='old',form='formatted',iostat=errorflag)
173  global%error = errorflag
174  IF (global%error /= 0) &
175  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname2d) )
176 
177 ! dimensions
178 
179  READ(if_grid,*) regions(1)%levels(1)%grid%ipc, &
180  regions(1)%levels(1)%grid%jpc
181 
182  WRITE(stdout,'(A,I4,A,I4)') solver_name//' dimensions= ', &
183  regions(1)%levels(1)%grid%ipc, &
184  ' x ',regions(1)%levels(1)%grid%jpc
185 
186  CALL rflo_getdimensdummynodes( regions(1),1,idnbeg,idnend, &
187  jdnbeg,jdnend,kdnbeg,kdnend )
188  CALL rflo_getdimensphysnodes( regions(1),1,ipnbeg,ipnend, &
189  jpnbeg,jpnend,kpnbeg,kpnend )
190  CALL rflo_getnodeoffset( regions(1),1,inoff,ijnoff )
191 
192  ijkbeg = indijk(idnbeg,jdnbeg,kdnbeg,inoff,ijnoff)
193  ijkend = indijk(idnend,jdnend,kdnend,inoff,ijnoff)
194 
195 ! allocate memory for coordinates
196 
197  ALLOCATE( regions(1)%levels(1)%grid%xyz(3,ijkbeg:ijkend),stat=errorflag )
198  global%error = errorflag
199  IF (global%error /=0 ) CALL errorstop( global,err_allocate,__line__ )
200 
201 ! coordinates (store as k=kpnbeg plane at z=depth)
202 
203  xyz => regions(1)%levels(1)%grid%xyz
204 
205  k = kpnbeg
206  DO j=jpnbeg,jpnend
207  DO i=ipnbeg,ipnend
208  ijk = indijk(i,j,k,inoff,ijnoff)
209  READ(if_grid,*) xyz(xcoord,ijk), &
210  xyz(ycoord,ijk)
211  xyz(zcoord,ijk) = 0._rfreal
212  ENDDO
213  ENDDO
214 
215 ! close file
216 
217  CLOSE(if_grid,iostat=errorflag)
218  global%error = errorflag
219  IF (global%error /= 0) &
220  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname2d) )
221 
222 ! translate the x-y-plane -----------------------------------------------------
223 
224  WRITE(stdout,'(A)') solver_name//' Generating 3-D grid ...'
225 
226  dz = depth/REAL(regions(1)%levels(1)%grid%kpc)
227 
228  DO k=kpnbeg+1,kpnend
229  DO j=jpnbeg,jpnend
230  DO i=ipnbeg,ipnend
231  ijk = indijk(i,j,k ,inoff,ijnoff)
232  ijkm1 = indijk(i,j,k-1,inoff,ijnoff)
233  xyz(xcoord,ijk) = xyz(xcoord,ijkm1)
234  xyz(ycoord,ijk) = xyz(ycoord,ijkm1)
235  xyz(zcoord,ijk) = xyz(zcoord,ijkm1) + dz
236  ENDDO
237  ENDDO
238  ENDDO
239 
240 ! store 3-D grid --------------------------------------------------------------
241 
242  WRITE(stdout,'(A)') solver_name//' Storing 3-D grid ...'
243 
244  CALL rflo_writegridregion( 1,regions )
245 
246 ! finalize --------------------------------------------------------------------
247 
248  CALL deregisterfunction( global )
249 
250  WRITE(stdout,'(/,A)') solver_name//' Finished.'
251 
252 #ifdef MPI
253  CALL mpi_finalize( global%mpierr )
254 #endif
255 
256 END PROGRAM rocflo_2dto3d
257 
258 !******************************************************************************
259 !
260 ! RCS Revision history:
261 !
262 ! $Log: TO3D_Main.F90,v $
263 ! Revision 1.4 2008/12/06 08:44:52 mtcampbe
264 ! Updated license.
265 !
266 ! Revision 1.3 2008/11/19 22:18:03 mtcampbe
267 ! Added Illinois Open Source License/Copyright
268 !
269 ! Revision 1.2 2004/12/03 03:37:55 wasistho
270 ! rflo_modinterfacesto3d to to3d_modinterfaces
271 !
272 ! Revision 1.1 2004/12/03 02:50:44 wasistho
273 ! added prefix
274 !
275 ! Revision 1.1 2004/12/03 00:52:40 wasistho
276 ! lower to upper case
277 !
278 ! Revision 1.15 2003/05/15 02:57:07 jblazek
279 ! Inlined index function.
280 !
281 ! Revision 1.14 2003/03/20 22:37:45 haselbac
282 ! Renamed ModInterfaces
283 !
284 ! Revision 1.13 2003/03/20 19:49:34 haselbac
285 ! Corrected mistake in phased check-in
286 !
287 ! Revision 1.12 2002/10/12 03:20:51 jblazek
288 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
289 !
290 ! Revision 1.11 2002/09/20 22:22:37 jblazek
291 ! Finalized integration into GenX.
292 !
293 ! Revision 1.10 2002/09/05 17:40:23 jblazek
294 ! Variable global moved into regions().
295 !
296 ! Revision 1.9 2002/07/16 21:34:37 jblazek
297 ! Prefixed screen output with SOLVER_NAME.
298 !
299 ! Revision 1.8 2002/06/14 17:48:36 jblazek
300 ! Added call to MPI_Finalize.
301 !
302 ! Revision 1.7 2002/06/14 17:46:51 jblazek
303 ! Added version string.
304 !
305 ! Revision 1.6 2002/06/07 16:40:37 jblazek
306 ! Grid & solution for all regions in one file.
307 !
308 ! Revision 1.5 2002/03/18 21:31:55 jblazek
309 ! Made codes compatible with MPI.
310 !
311 ! Revision 1.4 2002/02/21 23:25:07 jblazek
312 ! Blocks renamed as regions.
313 !
314 ! Revision 1.3 2002/01/11 17:20:19 jblazek
315 ! Added time stamp or iteration number to file names.
316 !
317 ! Revision 1.2 2002/01/08 22:09:17 jblazek
318 ! Added calculation of face vectors and volumes.
319 !
320 ! Revision 1.1 2001/12/21 23:56:52 jblazek
321 ! Added utility to convert 2D grids to 3D.
322 !
323 !******************************************************************************
324 
325 
326 
327 
328 
329 
330 
**********************************************************************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
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
program rocflo_2dto3d
Definition: TO3D_Main.F90:43
**********************************************************************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 jdnbeg
**********************************************************************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
**********************************************************************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 idnend
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
**********************************************************************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 jdnend
**********************************************************************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 idnbeg
subroutine buildversionstring(versionString)
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
RT dz() const
Definition: Direction_3.h:133
subroutine rflo_getdimensphysnodes(region, iLev, ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend)
j indices j
Definition: Indexing.h:6
subroutine rflo_getdimensdummynodes(region, iLev, idnbeg, idnend, jdnbeg, jdnend, kdnbeg, kdnend)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine grid(bp)
Definition: setup_py.f90:257
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
**********************************************************************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 kdnbeg