Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_FlowSolver.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: solve the discretized governing equations.
26 !
27 ! Description: none.
28 !
29 ! Input: dTimeSystem = time step to run the solver
30 ! dIterSystem = no. of iterations to run the solver
31 ! regions = dimension, BC`s and flow variables of all regions.
32 !
33 ! Output: accurate solution.
34 !
35 ! Notes: none.
36 !
37 !******************************************************************************
38 !
39 ! $Id: RFLO_FlowSolver.F90,v 1.5 2008/12/06 08:44:27 mtcampbe Exp $
40 !
41 ! Copyright: (c) 2001 by the University of Illinois
42 !
43 !******************************************************************************
44 
45 #ifdef GENX
46 SUBROUTINE rflo_flowsolver( globalGenx,timeSystem,dTimeSystem,genxHandleBc, &
47  genxhandlegm )
48 #else
49 SUBROUTINE rflo_flowsolver( dTimeSystem,dIterSystem,regions )
50 #endif
51 
52  USE moddatatypes
53 #ifdef GENX
54  USE modrocstar, ONLY : t_globalgenx
55 #endif
56  USE moddatastruct, ONLY : t_region
57  USE modglobal, ONLY : t_global
64  USE moderror
65  USE modmpi
66  USE modparameters
67  IMPLICIT NONE
68 #ifdef GENX
69  include 'roccomf90.h'
70 #endif
71 
72 ! ... parameters
73 #ifdef GENX
74  INTEGER, INTENT(in) :: genxhandlebc, genxhandlegm
75 
76  DOUBLE PRECISION, INTENT(in) :: timesystem, dtimesystem
77 
78  TYPE(t_globalgenx), POINTER :: globalgenx
79 #else
80  REAL(RFREAL) :: dtimesystem
81 #endif
82 
83  INTEGER :: ditersystem
84 
85  TYPE (t_region), POINTER :: regions(:)
86 
87 ! ... loop variables
88  INTEGER :: ireg
89 
90 ! ... local variables
91  CHARACTER(CHRLEN) :: msg
92 
93  REAL(RFREAL) :: timerbeg, timerend, timerloc, timerglob
94 
95  TYPE(t_global), POINTER :: global
96 
97 !******************************************************************************
98 ! initialize some global variables
99 
100 #ifdef GENX
101  global => globalgenx%global
102  regions => globalgenx%regions
103 
104  global%genxHandleBc = genxhandlebc
105  global%genxHandleGm = genxhandlegm
106  ditersystem = 0
107  IF ((global%currentTime-timesystem) > 1.e-9_rfreal) THEN
108  global%predCorrIter = .true.
109  ELSE
110  global%predCorrIter = .false.
111  ENDIF
112  global%currentTime = timesystem
113  global%timeStamp = timesystem
114 #else
115  global => regions(1)%global
116 #endif
117 
118  global%dTimeSystem = dtimesystem
119 
120  CALL registerfunction( global,'RFLO_FlowSolver',&
121  'RFLO_FlowSolver.F90' )
122 
123 #ifdef GENX
124 ! restore geometry if predictor-corrector iteration
125 
126  IF (global%predCorrIter) THEN
127  IF (global%myProcid == masterproc) WRITE(stdout,'(A)') &
128  solver_name//' Restoring geometry (PC iteration) ...'
129  DO ireg=1,global%nRegions
130  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
131  regions(ireg)%active==active) THEN ! on my processor
132  CALL rflo_generatecoarsegrids( regions(ireg) ) ! coarsen finest grid
133  CALL rflo_copygeometrydummy( regions(ireg) ) ! copy to dummy nodes
134  CALL rflo_extrapolategeometry( regions(ireg) ) ! extrapolate
135  ENDIF ! region on this processor and active
136  ENDDO ! iReg
137  CALL rflo_exchangegeometry( regions ) ! exchange geometry
138  CALL rflo_calcgridmetrics( regions )
139  ENDIF ! predCorrIter==true
140 
141 ! get BC data from GenX at time=0
142 
143  CALL com_call_function( genxhandlebc,2,0._rfreal,1 )
144  DO ireg=1,global%nRegions
145  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
146  regions(ireg)%active==active) THEN ! on my processor
147  CALL rflo_sendboundaryvalues( regions(ireg),.false. )
148  ENDIF ! region on this processor and active
149  ENDDO ! iReg
150  CALL com_call_function( genxhandlebc,2,0._rfreal,2 )
151 
152  DO ireg=1,global%nRegions
153  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
154  regions(ireg)%active==active .AND. & ! on my processor
155  regions(ireg)%mixtInput%externalBc) THEN ! external BC
156  CALL rflo_getboundaryvalues( regions(ireg) )
157  ENDIF
158  ENDDO
159 #endif
160 
161 ! start time stepping
162 
163  IF (global%flowType == flow_unsteady) THEN
164  IF (dtimesystem <= 0._rfreal) THEN
165  WRITE(msg,1000) global%currentTime,global%maxTime
166  CALL errorstop( global,err_dtime_negative,__line__,msg )
167  ENDIF
168  ELSE
169  IF (ditersystem <= 0) THEN
170  WRITE(msg,1005) global%currentIter,global%maxIter
171  CALL errorstop( global,err_diter_negative,__line__,msg )
172  ENDIF
173  ENDIF
174 
175 ! call time-stepping routines
176 
177 #ifndef GENX
178 #ifdef MPI
179  CALL mpi_barrier( global%mpiComm,global%mpierr )
180  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
181  timerbeg = mpi_wtime()
182 #endif
183 #endif
184 
185  IF (global%flowType == flow_unsteady) THEN
186  IF (global%solverType == solv_explicit) THEN
187  CALL rflo_timestepping( dtimesystem,ditersystem,regions )
188  ELSE
189  IF (global%cycleType == mgcycle_no) THEN
190  CALL rflo_dualtimestepping( dtimesystem,regions )
191  ELSE
192  CALL rflo_dualmultigrid( dtimesystem,regions )
193  ENDIF
194  ENDIF
195  ELSE
196  IF (global%cycleType == mgcycle_no) THEN
197  CALL rflo_timestepping( dtimesystem,ditersystem,regions )
198  ELSE
199  CALL rflo_multigrid( ditersystem,regions )
200  ENDIF
201  ENDIF
202 
203 #ifndef GENX
204 #ifdef MPI
205  timerend = mpi_wtime()
206  timerloc = timerend - timerbeg
207  CALL mpi_reduce( timerloc,timerglob,1,mpi_rfreal,mpi_sum,masterproc, &
208  global%mpiComm,global%mpierr )
209  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
210 
211  IF (global%myProcid == masterproc) &
212  WRITE(stdout,1020) solver_name,timerglob/REAL(global%nProcAlloc), &
213  global%nprocalloc
214 #endif
215 #endif
216 
217 ! finalize
218 
219  CALL deregisterfunction( global )
220 
221 ! formats
222 
223 1000 FORMAT('Current time is= ',1pe12.5,' but max. time is= ',e12.5)
224 1005 FORMAT('Current iteration is= ',i6,' but max. iteration is= ',i6)
225 1020 FORMAT(/,a,' Elapsed time for this run: ',1pe12.5,' sec. (average over ', &
226  i5,' processors)')
227 
228 END SUBROUTINE rflo_flowsolver
229 
230 !******************************************************************************
231 !
232 ! RCS Revision history:
233 !
234 ! $Log: RFLO_FlowSolver.F90,v $
235 ! Revision 1.5 2008/12/06 08:44:27 mtcampbe
236 ! Updated license.
237 !
238 ! Revision 1.4 2008/11/19 22:17:38 mtcampbe
239 ! Added Illinois Open Source License/Copyright
240 !
241 ! Revision 1.3 2006/03/04 04:29:14 wasistho
242 ! moved calcGridMetrics to a rocflo module
243 !
244 ! Revision 1.2 2005/06/03 13:10:09 rfiedler
245 ! Reduce "Restoring geometry" messages. Use MASTERPROC.
246 !
247 ! Revision 1.1 2004/11/29 20:51:39 wasistho
248 ! lower to upper case
249 !
250 ! Revision 1.47 2003/11/20 16:40:39 mdbrandy
251 ! Backing out RocfluidMP changes from 11-17-03
252 !
253 ! Revision 1.43 2003/07/03 21:48:45 jblazek
254 ! Implemented dual-time stepping.
255 !
256 ! Revision 1.42 2003/05/15 02:57:04 jblazek
257 ! Inlined index function.
258 !
259 ! Revision 1.41 2003/05/09 17:01:03 jiao
260 ! Renamed the COM_call_function_handlers to COM_call_function.
261 !
262 ! Revision 1.40 2003/04/04 21:05:00 jblazek
263 ! Corrected bug in dumping out the solution.
264 !
265 ! Revision 1.39 2003/03/06 18:29:24 jiao
266 ! Jiri: Another silly change for GenX.
267 !
268 ! Revision 1.38 2003/03/04 21:56:47 jblazek
269 ! Corrected bug for predictor-corrector iterations.
270 !
271 ! Revision 1.37 2003/02/21 22:43:00 jblazek
272 ! Corrected timeStamp for GenX.
273 !
274 ! Revision 1.36 2003/02/07 00:07:03 jblazek
275 ! Slight change of the predictor-corrector check.
276 !
277 ! Revision 1.35 2003/02/06 23:55:22 jblazek
278 ! Added check for predictor-corrector iterations in GenX.
279 !
280 ! Revision 1.34 2002/10/25 18:36:47 jblazek
281 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
282 !
283 ! Revision 1.33 2002/10/19 00:40:30 jblazek
284 ! Added utility (rflosurf) to write out surface grids for GenX.
285 !
286 ! Revision 1.32 2002/10/18 16:49:20 jblazek
287 ! Changed parameter lists to some GenX routines.
288 !
289 ! Revision 1.31 2002/10/17 06:48:37 jiao
290 ! Added call to Rocman at time 0..
291 !
292 ! Revision 1.30 2002/10/16 18:56:14 jblazek
293 ! Within GenX, BC data at t>0 are obtained in GetFlowSolution.
294 !
295 ! Revision 1.29 2002/10/16 18:30:38 jblazek
296 ! Within GenX, BC data at t=0 are updated in FlowSolver before calling
297 ! the time-stepping routine.
298 !
299 ! Revision 1.28 2002/09/20 22:22:36 jblazek
300 ! Finalized integration into GenX.
301 !
302 ! Revision 1.27 2002/09/05 17:40:21 jblazek
303 ! Variable global moved into regions().
304 !
305 ! Revision 1.26 2002/07/16 21:34:37 jblazek
306 ! Prefixed screen output with SOLVER_NAME.
307 !
308 ! Revision 1.25 2002/04/17 22:45:20 jblazek
309 ! Pressure forces calculated also for injection boundaries.
310 !
311 ! Revision 1.24 2002/04/12 17:36:23 jblazek
312 ! Added timer.
313 !
314 ! Revision 1.23 2002/04/04 19:41:09 jblazek
315 ! Moved dTime and dIter test from main to flowSolver.
316 !
317 ! Revision 1.22 2002/02/25 22:36:52 jblazek
318 ! Simplified solver initialization routine.
319 !
320 ! Revision 1.21 2002/02/21 23:25:06 jblazek
321 ! Blocks renamed as regions.
322 !
323 ! Revision 1.20 2002/02/16 07:16:00 jblazek
324 ! Added implicit residual smoothing.
325 !
326 ! Revision 1.19 2002/02/09 01:47:01 jblazek
327 ! Added multi-probe option, residual smoothing, physical time step.
328 !
329 ! Revision 1.18 2002/02/04 15:30:25 jblazek
330 ! Added injection boundary condition.
331 !
332 ! Revision 1.17 2002/02/01 22:17:38 jblazek
333 ! Change addressing of face vectors at block boundaries.
334 !
335 ! Revision 1.16 2002/02/01 00:00:24 jblazek
336 ! Edge and corner cells defined for each level.
337 !
338 ! Revision 1.15 2002/01/31 20:56:30 jblazek
339 ! Added basic boundary conditions.
340 !
341 ! Revision 1.14 2002/01/28 23:55:22 jblazek
342 ! Added flux computation (central scheme).
343 !
344 ! Revision 1.13 2002/01/23 03:51:25 jblazek
345 ! Added low-level time-stepping routines.
346 !
347 ! Revision 1.12 2002/01/16 22:03:35 jblazek
348 ! Added time-stepping routines.
349 !
350 ! Revision 1.11 2002/01/12 00:02:49 jblazek
351 ! Added postprocessor.
352 !
353 ! Revision 1.10 2002/01/11 17:20:19 jblazek
354 ! Added time stamp or iteration number to file names.
355 !
356 ! Revision 1.9 2002/01/10 18:21:29 jblazek
357 ! Added iteration number and initial residual to solution file.
358 !
359 ! Revision 1.8 2002/01/10 00:02:07 jblazek
360 ! Added calculation of mixture properties.
361 !
362 ! Revision 1.7 2002/01/08 22:09:17 jblazek
363 ! Added calculation of face vectors and volumes.
364 !
365 ! Revision 1.6 2002/01/02 16:04:20 jblazek
366 ! Added routines to generate geometry for dummy cells.
367 !
368 ! Revision 1.5 2001/12/22 00:09:39 jblazek
369 ! Added routines to store grid and solution.
370 !
371 ! Revision 1.4 2001/12/19 23:09:22 jblazek
372 ! Added routines to read grid and solution.
373 !
374 ! Revision 1.3 2001/12/11 21:59:29 jblazek
375 ! memory allocation added.
376 !
377 ! Revision 1.2 2001/12/08 00:18:42 jblazek
378 ! Added routines to read BC input file.
379 !
380 ! Revision 1.1.1.1 2001/12/03 21:44:04 jblazek
381 ! Import of RocfluidMP
382 !
383 !******************************************************************************
384 
385 
386 
387 
388 
389 
390 
subroutine rflo_copygeometrydummy(region)
subroutine rflo_dualmultigrid(dTimeSystem, regions)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine rflo_extrapolategeometry(region)
subroutine rflo_flowsolver(dTimeSystem, dIterSystem, regions)
subroutine rflo_timestepping(dTimeSystem, dIterSystem, regions)
subroutine rflo_exchangegeometry(regions)
subroutine rflo_generatecoarsegrids(region)
subroutine rflo_sendboundaryvalues(region, initialize)
subroutine rflo_multigrid(dIterSystem, regions)
subroutine rflo_getboundaryvalues(region)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine, public rflo_calcgridmetrics(regions)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_dualtimestepping(dTimeSystem, regions)
RT a() const
Definition: Line_2.h:140