Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SPLT_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: split up single region into multiple grids and generate
26 ! corresponding topology file.
27 !
28 ! Description: region can be splitted either in i-, j-, or in k-direction.
29 !
30 ! Input: file names, split direction, number of grids.
31 !
32 ! Output: to file.
33 !
34 ! Notes: none.
35 !
36 !******************************************************************************
37 !
38 ! $Id: SPLT_Main.F90,v 1.4 2008/12/06 08:44:51 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2002 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 PROGRAM rocflo_split
45 
46  USE moddatatypes
47  USE moderror
48  USE moddatastruct, ONLY : t_region
49  USE modglobal, ONLY : t_global
54  USE modmpi
55  USE modparameters
56  IMPLICIT NONE
57 
58 #include "Indexing.h"
59 
60 ! ... loop variables
61  INTEGER :: ireg
62 
63 ! ... local variables
64  CHARACTER(CHRLEN) :: casenameold, casenamenew, versionstring, headerstring
65 
66  INTEGER :: gridformat, splitdirection, nsplits
67  INTEGER :: strlen, ibn, ien, inoff, ijnoff
68  INTEGER :: idnbeg, idnend, jdnbeg, jdnend, kdnbeg, kdnend
69  INTEGER :: margin, versionwidth, errorflag
70  INTEGER, PARAMETER :: headerwidth = 53
71 
72  TYPE(t_global), POINTER :: globalold, globalnew
73  TYPE(t_region), POINTER :: regionsold(:), regionsnew(:)
74 
75 !******************************************************************************
76 
77  ALLOCATE( globalold )
78  ALLOCATE( globalnew )
79 
80  globalold%nFunTree = 0
81  CALL registerfunction( globalold,'ROCFLO_Split',&
82  'SPLT_Main.F90' )
83 
84 ! initialize global parameters ------------------------------------------------
85 
86  globalold%verbLevel = verbose_none
87 
88  globalold%flowType = flow_steady ! stationary flow
89  globalold%currentTime = -1._rfreal ! no physical time set
90  globalold%currentIter = -1 ! no iteration
91 
92  globalold%inDir = './' ! directory path
93  globalold%outDir = './'
94 
95  globalold%nProcAlloc = 1
96  globalold%myProcid = masterproc ! default process number (not an MPI code)
97  globalold%mpierr = err_none
98  globalold%error = err_none
99 
100  globalold%pi = 4._rfreal*atan(1._rfreal)
101  globalold%rad = globalold%pi/180._rfreal
102 
103 ! print header ----------------------------------------------------------------
104 
105 #ifdef MPI
106  CALL mpi_init( globalold%mpierr )
107  IF (globalold%mpierr /=0 ) &
108  CALL errorstop( globalold,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: Grid Split Up *'
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 ! read user input -------------------------------------------------------------
131 
132  WRITE(stdout,'(A)') solver_name//' Case name of old grid:'
133  READ(stdin,'(A)') casenameold
134 
135  WRITE(stdout,'(A)') solver_name//' Case name of new grid:'
136  READ(stdin,'(A)') casenamenew
137 
138  WRITE(stdout,'(A)') solver_name//' Grid format (ASCII=1, binary=2):'
139  READ(stdin,*) gridformat
140 
141  WRITE(stdout,'(A)') solver_name//' Split direction (i=1, j=2, k=3):'
142  READ(stdin,*) splitdirection
143 
144  WRITE(stdout,'(A)') solver_name//' Number of new regions:'
145  READ(stdin,*) nsplits
146 
147 ! figure out grid format
148 
149  IF (gridformat <= 1) THEN
150  globalold%gridFormat = format_ascii
151  ELSE
152  globalold%gridFormat = format_binary
153  ENDIF
154 
155 ! read old topology -----------------------------------------------------------
156 
157  WRITE(stdout,'(/,A)') solver_name//' Reading old topology ...'
158 
159  globalold%casename = casenameold
160 
161  CALL rflo_readregiontopology( globalold,regionsold )
162 
163  IF (globalold%nRegions > 1) THEN
164  WRITE(stdout,'(/,A)') solver_name//' Tool works only for SINGLE region.'
165 #ifdef MPI
166  CALL mpi_finalize( globalold%mpierr )
167 #endif
168  stop
169  ENDIF
170 
171 ! read old grid ---------------------------------------------------------------
172 
173  WRITE(stdout,'(A)') solver_name//' Reading old grid ...'
174 
175 ! allocate memory
176 
177  regionsold(1)%nDumCells = 0
178  CALL rflo_getdimensdummynodes( regionsold(1),1,idnbeg,idnend, &
179  jdnbeg,jdnend,kdnbeg,kdnend )
180  CALL rflo_getnodeoffset( regionsold(1),1,inoff,ijnoff )
181  ibn = indijk(idnbeg,jdnbeg,kdnbeg,inoff,ijnoff)
182  ien = indijk(idnend,jdnend,kdnend,inoff,ijnoff)
183 
184  ALLOCATE( regionsold(1)%levels(1)%grid%xyz(3,ibn:ien),stat=errorflag )
185  globalold%error = errorflag
186  IF (globalold%error /= 0) CALL errorstop( globalold,err_allocate,__line__ )
187 
188 ! read grid
189 
190  CALL rflo_readgridregion( 1,regionsold )
191 
192 ! split the grid --------------------------------------------------------------
193 
194  WRITE(stdout,'(A)') solver_name//' Splitting the grid ...'
195 
196  globalnew = globalold
197 
198  globalnew%casename = casenamenew
199  globalnew%nRegions = nsplits
200 
201  ALLOCATE( regionsnew(globalnew%nRegions),stat=errorflag )
202  globalold%error = errorflag
203  IF (globalold%error /= 0) CALL errorstop( globalold,err_allocate,__line__ )
204 
205 ! set global within regionsNew = globalNew
206 
207  DO ireg=1,globalnew%nRegions
208  regionsnew(ireg)%global => globalnew
209  ENDDO
210 
211 ! do the splitting
212 
213  CALL splitgrid( splitdirection,regionsold,regionsnew )
214 
215  CALL splittopology( splitdirection,regionsold,regionsnew )
216 
217 ! write new grid and topology
218 
219  WRITE(stdout,'(A)') solver_name//' Writing data ...'
220 
221  DO ireg=1,globalnew%nRegions
222  CALL rflo_writegridregion( ireg,regionsnew )
223  ENDDO
224 
225  CALL rflo_writeregiontopology( regionsnew )
226 
227 ! finalize --------------------------------------------------------------------
228 
229  CALL deregisterfunction( globalold )
230 
231  WRITE(stdout,'(/,A,/)') solver_name//' Finished.'
232 
233 #ifdef MPI
234  CALL mpi_finalize( globalold%mpierr )
235 #endif
236 
237 END PROGRAM rocflo_split
238 
239 !******************************************************************************
240 !
241 ! RCS Revision history:
242 !
243 ! $Log: SPLT_Main.F90,v $
244 ! Revision 1.4 2008/12/06 08:44:51 mtcampbe
245 ! Updated license.
246 !
247 ! Revision 1.3 2008/11/19 22:18:01 mtcampbe
248 ! Added Illinois Open Source License/Copyright
249 !
250 ! Revision 1.2 2004/12/03 03:33:15 wasistho
251 ! rflo_modinterfacessplit to splt_modinterfaces
252 !
253 ! Revision 1.1 2004/12/03 02:41:15 wasistho
254 ! added prefix
255 !
256 ! Revision 1.1 2004/12/03 00:45:30 wasistho
257 ! lower to upper case
258 !
259 ! Revision 1.7 2003/05/15 02:57:07 jblazek
260 ! Inlined index function.
261 !
262 ! Revision 1.6 2003/03/20 22:32:37 haselbac
263 ! Renamed ModInterfaces
264 !
265 ! Revision 1.5 2003/03/20 19:45:54 haselbac
266 ! Corrected mistake in phased check-in
267 !
268 ! Revision 1.4 2002/10/12 03:20:51 jblazek
269 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
270 !
271 ! Revision 1.3 2002/09/20 22:22:37 jblazek
272 ! Finalized integration into GenX.
273 !
274 ! Revision 1.2 2002/09/05 17:40:22 jblazek
275 ! Variable global moved into regions().
276 !
277 ! Revision 1.1 2002/07/12 21:50:08 jblazek
278 ! Added tool to split single grid into multiple regions.
279 !
280 !******************************************************************************
281 
282 
283 
284 
285 
286 
287 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
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 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
subroutine rflo_readgridregion(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 idnbeg
subroutine buildversionstring(versionString)
subroutine splittopology(splitDirection, regionsOld, regionsNew)
subroutine rflo_writeregiontopology(regions)
program rocflo_split
Definition: SPLT_Main.F90:44
subroutine rflo_getdimensdummynodes(region, iLev, idnbeg, idnend, jdnbeg, jdnend, kdnbeg, kdnend)
subroutine splitgrid(splitDirection, regionsOld, regionsNew)
subroutine rflo_readregiontopology(global, regions)
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 kdnbeg