Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RkUpdateGeneric.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: Updates solution with classical 4-stage Runge-Kutta method.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! region Region data
31 ! varType Variable type to be updated
32 ! iStage Runge-Kutta stage
33 ! icBeg Beginning index for cell update
34 ! icEnd Ending index for cell update
35 ! ivBeg Beginning index for variable update
36 ! ivEnd Ending index for variable update
37 ! cv Conserved variables
38 ! cvOld Old conserved variables
39 ! rhs Residual
40 ! rhsSum Residual sum
41 !
42 ! Output:
43 ! cv Conserved variables
44 ! rhsSum Residual sum
45 !
46 ! Notes: None.
47 !
48 !******************************************************************************
49 !
50 ! $Id: RkUpdateGeneric.F90,v 1.4 2008/12/06 08:44:10 mtcampbe Exp $
51 !
52 ! Copyright: (c) 2003 by the University of Illinois
53 !
54 !******************************************************************************
55 
56 SUBROUTINE rkupdategeneric(region,varType,iStage,icBeg,icEnd,ivBeg,ivEnd, &
57  cv,cvold,rhs,rhssum)
58 
59  USE moddatatypes
60  USE moddatastruct, ONLY: t_region
61  USE modglobal, ONLY: t_global
62  USE moderror
63  USE modparameters
64 
65  IMPLICIT NONE
66 
67 ! *****************************************************************************
68 ! Definitions and declarations
69 ! *****************************************************************************
70 
71 ! =============================================================================
72 ! Arguments
73 ! =============================================================================
74 
75  TYPE(t_region) :: region
76  INTEGER, INTENT(IN) :: icbeg,icend,istage,ivbeg,ivend,vartype
77  REAL(RFREAL), DIMENSION(:,:), POINTER :: cv,cvold,rhs,rhssum
78 
79 ! =============================================================================
80 ! Locals
81 ! =============================================================================
82 
83  LOGICAL :: movegrid
84  CHARACTER(CHRLEN) :: rcsidentstring
85  INTEGER :: ic,iv
86 #ifdef RFLO
87  INTEGER :: ilev
88 #endif
89  REAL(RFREAL) :: adtv,fac,volrat
90  REAL(RFREAL) :: ark(5),grk(5)
91  REAL(RFREAL), DIMENSION(:), POINTER :: vol,volold
92  TYPE(t_global), POINTER :: global
93 
94 ! *****************************************************************************
95 ! Start
96 ! *****************************************************************************
97 
98  rcsidentstring = '$RCSfile: RkUpdateGeneric.F90,v $ $Revision: 1.4 $'
99 
100  global => region%global
101 
102  CALL registerfunction(global,'RkUpdateGeneric',&
103  'RkUpdateGeneric.F90')
104 
105 ! *****************************************************************************
106 ! Set pointers and variables
107 ! *****************************************************************************
108 
109  ark(:) = region%mixtInput%ark(:)
110  grk(:) = region%mixtInput%grk(:)
111 
112 ! =============================================================================
113 ! Set volume(s) when updating cell-based variables
114 ! =============================================================================
115 
116  IF ( vartype == var_type_cell ) THEN
117  movegrid = region%mixtInput%moveGrid
118 
119 #ifdef RFLO
120  ilev = region%currLevel
121 
122  vol => region%levels(ilev)%grid%vol
123 
124  IF ( movegrid .EQV. .true. ) THEN
125  volold => region%levels(ilev)%gridOld%vol
126  END IF ! moveGrid
127 #endif
128 
129 #ifdef RFLU
130  vol => region%grid%vol
131 
132  IF ( movegrid .EQV. .true. ) THEN
133  volold => region%gridOld%vol
134  END IF ! moveGrid
135 #endif
136  END IF ! varType
137 
138 ! *****************************************************************************
139 ! Update
140 ! *****************************************************************************
141 
142  fac = ark(istage)*global%dtMin
143 
144  SELECT CASE ( vartype )
145 
146 ! =============================================================================
147 ! Update cell-based variables, for which we need the volume (and volume
148 ! ratio for moving grid computations).
149 ! =============================================================================
150 
151  CASE ( var_type_cell )
152 
153 ! -----------------------------------------------------------------------------
154 ! Update for moving grid
155 ! -----------------------------------------------------------------------------
156 
157  IF ( movegrid .EQV. .true. ) THEN
158  SELECT CASE ( global%rkScheme )
159  CASE ( rk_scheme_4_classical )
160  IF ( istage == 1 ) THEN
161  DO ic = icbeg,icend
162  adtv = fac/vol(ic)
163  volrat = volold(ic)/vol(ic)
164 
165  DO iv = ivbeg,ivend
166  cv(iv,ic) = volrat*cvold(iv,ic) - adtv*rhs(iv,ic)
167  rhssum(iv,ic) = rhs(iv,ic)
168  END DO ! iv
169  END DO ! ic
170  ELSE IF ( istage == global%nrkSteps ) THEN
171  DO ic = icbeg,icend
172  adtv = fac/vol(ic)
173  volrat = volold(ic)/vol(ic)
174 
175  DO iv = ivbeg,ivend
176  cv(iv,ic) = volrat*cvold(iv,ic) &
177  - adtv*(rhs(iv,ic)+rhssum(iv,ic))
178  END DO ! iv
179  END DO ! ic
180  ELSE
181  DO ic = icbeg,icend
182  adtv = fac/vol(ic)
183  volrat = volold(ic)/vol(ic)
184 
185  DO iv = ivbeg,ivend
186  cv(iv,ic) = volrat*cvold(iv,ic) - adtv*rhs(iv,ic)
187  rhssum(iv,ic) = rhssum(iv,ic) + grk(istage)*rhs(iv,ic)
188  END DO ! iv
189  END DO ! ic
190  END IF ! iStage
191  CASE ( rk_scheme_3_wray )
192  IF ( istage == 1 ) THEN
193  DO ic = icbeg,icend
194  adtv = fac/vol(ic)
195  volrat = volold(ic)/vol(ic)
196 
197  DO iv = ivbeg,ivend
198  cv(iv,ic) = volrat*cvold(iv,ic) - adtv*rhs(iv,ic)
199  rhssum(iv,ic) = rhs(iv,ic)
200  END DO ! iv
201  END DO ! ic
202  ELSE IF ( istage == 2 ) THEN
203  DO ic = icbeg,icend
204  adtv = fac/vol(ic)
205  volrat = volold(ic)/vol(ic)
206 
207  DO iv = ivbeg,ivend
208  cv(iv,ic) = volrat*cvold(iv,ic) &
209  - adtv*(rhs(iv,ic) - grk(istage)*rhssum(iv,ic))
210  rhssum(iv,ic) = rhs(iv,ic)
211  END DO ! iv
212  END DO ! ic
213  ELSE
214  DO ic = icbeg,icend
215  adtv = fac/vol(ic)
216  volrat = volold(ic)/vol(ic)
217 
218  DO iv = ivbeg,ivend
219  cv(iv,ic) = volrat*cvold(iv,ic) &
220  - adtv*(rhs(iv,ic) - grk(istage)*rhssum(iv,ic))
221  END DO ! iv
222  END DO ! ic
223  END IF ! iStage
224  CASE default
225  CALL errorstop(global,err_reached_default,__line__)
226  END SELECT ! global%rkScheme
227 
228 ! =============================================================================
229 ! Update for non-moving grid
230 ! =============================================================================
231 
232  ELSE
233  SELECT CASE ( global%rkScheme )
234  CASE ( rk_scheme_4_classical )
235  IF ( istage == 1 ) THEN
236  DO ic = icbeg,icend
237  adtv = fac/vol(ic)
238 
239  DO iv = ivbeg,ivend
240  cv(iv,ic) = cvold(iv,ic) - adtv*rhs(iv,ic)
241  rhssum(iv,ic) = rhs(iv,ic)
242  END DO ! iv
243  END DO ! ic
244  ELSE IF ( istage == global%nrkSteps ) THEN
245  DO ic = icbeg,icend
246  adtv = fac/vol(ic)
247 
248  DO iv = ivbeg,ivend
249  cv(iv,ic) = cvold(iv,ic) - adtv*(rhs(iv,ic) + rhssum(iv,ic))
250  END DO ! iv
251  END DO !ic
252  ELSE
253  DO ic = icbeg,icend
254  adtv = fac/vol(ic)
255 
256  DO iv = ivbeg,ivend
257  cv(iv,ic) = cvold(iv,ic) - adtv*rhs(iv,ic)
258  rhssum(iv,ic) = rhssum(iv,ic) + grk(istage)*rhs(iv,ic)
259  END DO ! iv
260  END DO !ic
261  END IF ! iStage
262  CASE ( rk_scheme_3_wray )
263  IF ( istage == 1 ) THEN
264  DO ic = icbeg,icend
265  adtv = fac/vol(ic)
266 
267  DO iv = ivbeg,ivend
268  cv(iv,ic) = cvold(iv,ic) - adtv*rhs(iv,ic)
269  rhssum(iv,ic) = rhs(iv,ic)
270  END DO ! iv
271  END DO ! ic
272  ELSE IF ( istage == 2 ) THEN
273  DO ic = icbeg,icend
274  adtv = fac/vol(ic)
275 
276  DO iv = ivbeg,ivend
277  cv(iv,ic) = cvold(iv,ic) &
278  - adtv*(rhs(iv,ic) - grk(istage)*rhssum(iv,ic))
279  rhssum(iv,ic) = rhs(iv,ic)
280  END DO ! iv
281  END DO !ic
282  ELSE
283  DO ic = icbeg,icend
284  adtv = fac/vol(ic)
285 
286  DO iv = ivbeg,ivend
287  cv(iv,ic) = cvold(iv,ic) &
288  - adtv*(rhs(iv,ic) - grk(istage)*rhssum(iv,ic))
289  END DO ! iv
290  END DO !ic
291  END IF ! iStage
292  CASE default
293  CALL errorstop(global,err_reached_default,__line__)
294  END SELECT ! global%rkScheme
295  END IF ! moveGrid
296 
297 ! =============================================================================
298 ! Update point-based variables, for which we DO NOT need the volume (and
299 ! volume ratio for moving grid computations).
300 ! =============================================================================
301 
302  CASE ( var_type_point )
303  adtv = fac
304 
305  SELECT CASE ( global%rkScheme )
306  CASE ( rk_scheme_4_classical )
307  IF ( istage == 1 ) THEN
308  DO ic = icbeg,icend
309  DO iv = ivbeg,ivend
310  cv(iv,ic) = cvold(iv,ic) - adtv*rhs(iv,ic)
311  rhssum(iv,ic) = rhs(iv,ic)
312  END DO ! iv
313  END DO ! ic
314  ELSE IF ( istage == global%nrkSteps ) THEN
315  DO ic = icbeg,icend
316  DO iv = ivbeg,ivend
317  cv(iv,ic) = cvold(iv,ic) - adtv*(rhs(iv,ic) + rhssum(iv,ic))
318  END DO ! iv
319  END DO !ic
320  ELSE
321  DO ic = icbeg,icend
322  DO iv = ivbeg,ivend
323  cv(iv,ic) = cvold(iv,ic) - adtv*rhs(iv,ic)
324  rhssum(iv,ic) = rhssum(iv,ic) + grk(istage)*rhs(iv,ic)
325  END DO ! iv
326  END DO !ic
327  END IF ! iStage
328  CASE ( rk_scheme_3_wray )
329  IF ( istage == 1 ) THEN
330  DO ic = icbeg,icend
331  DO iv = ivbeg,ivend
332  cv(iv,ic) = cvold(iv,ic) - adtv*rhs(iv,ic)
333  rhssum(iv,ic) = rhs(iv,ic)
334  END DO ! iv
335  END DO ! ic
336  ELSE IF ( istage == 2 ) THEN
337  DO ic = icbeg,icend
338  DO iv = ivbeg,ivend
339  cv(iv,ic) = cvold(iv,ic) &
340  - adtv*(rhs(iv,ic) - grk(istage)*rhssum(iv,ic))
341  rhssum(iv,ic) = rhs(iv,ic)
342  END DO ! iv
343  END DO !ic
344  ELSE
345  DO ic = icbeg,icend
346  DO iv = ivbeg,ivend
347  cv(iv,ic) = cvold(iv,ic) &
348  - adtv*(rhs(iv,ic) - grk(istage)*rhssum(iv,ic))
349  END DO ! iv
350  END DO !ic
351  END IF ! iStage
352  CASE default
353  CALL errorstop(global,err_reached_default,__line__)
354  END SELECT ! global%rkScheme
355  CASE default
356  CALL errorstop(global,err_reached_default,__line__)
357  END SELECT ! varType
358 
359 ! *****************************************************************************
360 ! End
361 ! *****************************************************************************
362 
363  CALL deregisterfunction(global)
364 
365 END SUBROUTINE rkupdategeneric
366 
367 !******************************************************************************
368 !
369 ! RCS Revision history:
370 !
371 ! $Log: RkUpdateGeneric.F90,v $
372 ! Revision 1.4 2008/12/06 08:44:10 mtcampbe
373 ! Updated license.
374 !
375 ! Revision 1.3 2008/11/19 22:17:23 mtcampbe
376 ! Added Illinois Open Source License/Copyright
377 !
378 ! Revision 1.2 2006/04/07 15:19:15 haselbac
379 ! Removed tabs
380 !
381 ! Revision 1.1 2004/12/01 16:51:08 haselbac
382 ! Initial revision after changing case
383 !
384 ! Revision 1.2 2004/11/17 16:24:30 haselbac
385 ! Added varType and RK3
386 !
387 ! Revision 1.1 2003/11/25 21:01:50 haselbac
388 ! Initial revision
389 !
390 !******************************************************************************
391 
392 
393 
394 
395 
396 
397 
NT rhs
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
**********************************************************************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 ic
subroutine rkupdategeneric(region, varType, iStage, icBeg, icEnd, ivBeg, ivEnd, cv, cvOld, rhs, rhsSum)
**********************************************************************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 icbeg
**********************************************************************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 icend
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469