Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UpdateTbc.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: find new values for TBCs and reset BCs accordingly.
26 !
27 ! Description: none.
28 !
29 ! Input: region index, substep time and timestep, and whether at final substep
30 !
31 ! Output: modifies TBC and BC data in regions
32 !
33 ! Notes: none.
34 !
35 ! ******************************************************************************
36 !
37 ! $Id: UpdateTbc.F90,v 1.8 2008/12/06 08:44:10 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2001-2005 by the University of Illinois
40 !
41 ! ******************************************************************************
42 
43 SUBROUTINE updatetbc(region,t,dt,final)
44 
45  USE moddatatypes
46  USE modbndpatch
47  USE moddatastruct, ONLY: t_region
48  USE modglobal, ONLY: t_global
49  USE moderror
50  USE modparameters
51 
52  USE modinterfaces, ONLY : updatetbcpiecewise, &
56 
57  IMPLICIT NONE
58 
59 ! ******************************************************************************
60 ! Definitions and declarations
61 ! ******************************************************************************
62 
63 ! ==============================================================================
64 ! Arguments
65 ! ==============================================================================
66 
67  LOGICAL, INTENT(IN) :: final
68  REAL(RFREAL), INTENT(IN) :: t, dt
69  TYPE(t_region), INTENT(INOUT) :: region
70 
71 ! ==============================================================================
72 ! Locals
73 ! ==============================================================================
74 
75  LOGICAL :: finitedt
76  INTEGER :: ipatch, n, ftype
77  REAL(RFREAL), POINTER :: vals(:,:)
78  TYPE(t_patch), POINTER :: patch
79  TYPE(t_tbcvalues), POINTER :: tbc, tbcs(:)
80  TYPE(t_bcvalues), POINTER :: bc
81  TYPE(t_global), POINTER :: global
82 
83 ! ******************************************************************************
84 ! Start
85 ! ******************************************************************************
86 
87  global => region%global
88 
89  CALL registerfunction(global,'UpdateTbc',&
90  'UpdateTbc.F90')
91 
92  finitedt = (dt > 1.e-10_rfreal*global%dtMin)
93 
94 ! ******************************************************************************
95 ! Loop over patches
96 ! ******************************************************************************
97 
98 #ifdef RFLO
99  DO ipatch=1,region%nPatches
100  patch => region%levels(region%currLevel)%patches(ipatch)
101 #endif
102 
103 #ifdef RFLU
104  DO ipatch=1,region%grid%nPatches
105  patch => region%patches(ipatch)
106 #endif
107 
108 ! ==============================================================================
109 ! Loop over modules
110 ! ==============================================================================
111 
112  DO ftype = 1,ftype_max
113  SELECT CASE ( ftype )
114  CASE ( ftype_mixt )
115  bc => patch%mixt
116 #ifdef TURB
117  CASE ( ftype_turb )
118  cycle
119 #endif
120 #ifdef PEUL
121  CASE ( ftype_peul )
122  bc => patch%peul
123 #endif
124 #ifdef SPEC
125  CASE ( ftype_spec )
126  IF ( global%specUsed .EQV. .false. ) THEN
127  cycle
128  END IF ! global%specUsed
129  bc => patch%spec
130 #endif
131 #ifdef RADI
132  CASE ( ftype_radi )
133  cycle
134 #endif
135  CASE default
136  cycle
137  END SELECT ! ftype
138 
139  IF ( ASSOCIATED(bc%vals) .NEQV. .true. ) THEN
140  cycle
141  ELSE
142  vals => bc%vals
143  END IF ! ASSOCIATED
144 
145 ! ------------------------------------------------------------------------------
146 ! Loop over variables
147 ! ------------------------------------------------------------------------------
148 
149  DO n = 1,bc%nData
150  tbc => bc%tbcs(n)
151 
152  IF ( tbc%tbcType /= tbc_none ) THEN
153 
154 ! ------- Check if TBC is on ---------------------------------------------------
155 
156  IF ( t <= tbc%params(tbcdat_ontime) ) THEN
157  vals(n,:) = tbc%mean
158  ELSE IF ( t >= tbc%params(tbcdat_offtime) ) THEN
159  tbc%tbcType = tbc_none
160  vals(n,:) = tbc%mean
161  ELSE
162 
163 ! --------- Update TBC data
164 
165  SELECT CASE ( tbc%tbcType )
166  CASE ( tbc_sinusoidal )
167  IF (finitedt) THEN
168  CALL updatetbcsinusoidal(global,tbc,t)
169  vals(n,:) = tbc%mean*(1.0_rfreal + tbc%svals(tbcsto_val))
170  END IF
171  CASE ( tbc_stochastic )
172  IF ( finitedt ) THEN
173  CALL updatetbcstochastic(region,tbc,dt)
174  vals(n,:) = tbc%mean*tbc%bvals(tbcsto_factor,:)
175  END IF
176  CASE ( tbc_whitenoise )
177  IF ( (tbc%switches(tbcswi_substep) == tbcopt_step .AND. final) .OR. &
178  (tbc%switches(tbcswi_substep) == tbcopt_substep .AND. finitedt) ) THEN
179  CALL updatetbcwhitenoise(region,tbc)
180  vals(n,:) = tbc%mean*(1.0_rfreal + tbc%bvals(tbcsto_val,:))
181  END IF
182  CASE ( tbc_piecewise )
183  CALL updatetbcpiecewise(global,tbc,t)
184  vals(n,:) = tbc%mean*tbc%svals(tbcsto_val)
185  CASE default
186  CALL errorstop(global,err_reached_default,__line__)
187  END SELECT ! tbc%tbctype
188  END IF ! t
189  END IF ! tbc%tbctype
190  END DO ! n
191  END DO ! ftype
192  END DO ! iPatch
193 
194 ! ******************************************************************************
195 ! Finalize
196 ! ******************************************************************************
197 
198  CALL deregisterfunction(global)
199 
200 END SUBROUTINE updatetbc
201 
202 ! ******************************************************************************
203 !
204 ! RCS Revision history:
205 !
206 ! $Log: UpdateTbc.F90,v $
207 ! Revision 1.8 2008/12/06 08:44:10 mtcampbe
208 ! Updated license.
209 !
210 ! Revision 1.7 2008/11/19 22:17:24 mtcampbe
211 ! Added Illinois Open Source License/Copyright
212 !
213 ! Revision 1.6 2006/08/19 15:38:36 mparmar
214 ! Renamed patch variables
215 !
216 ! Revision 1.5 2006/05/20 19:10:25 fnajjar
217 ! Fixed bug to include a CYCLE statement when specUsed is not active
218 !
219 ! Revision 1.4 2006/04/07 15:19:15 haselbac
220 ! Removed tabs
221 !
222 ! Revision 1.3 2006/01/07 04:49:36 wasistho
223 ! cycled turb and radi
224 !
225 ! Revision 1.2 2005/04/27 02:07:23 haselbac
226 ! Cosmetics only
227 !
228 ! Revision 1.1 2004/12/01 16:52:03 haselbac
229 ! Initial revision after changing case
230 !
231 ! Revision 1.14 2003/11/20 16:40:35 mdbrandy
232 ! Backing out RocfluidMP changes from 11-17-03
233 !
234 ! Revision 1.11 2003/06/21 20:39:36 haselbac
235 ! Added ifdefs as workaround for IBM problems, removd finiteDt if for pw linear
236 !
237 ! Revision 1.10 2003/06/10 22:54:42 jferry
238 ! Added Piecewise TBC
239 !
240 ! Revision 1.9 2003/05/15 02:57:02 jblazek
241 ! Inlined index function.
242 !
243 ! Revision 1.8 2003/02/17 19:31:12 jferry
244 ! Implemented portable random number generator ModRandom
245 !
246 ! Revision 1.7 2002/10/12 19:10:30 haselbac
247 ! Added check for association status of vals (does not work otherwise)
248 !
249 ! Revision 1.6 2002/09/27 00:57:09 jblazek
250 ! Changed makefiles - no makelinks needed.
251 !
252 ! Revision 1.5 2002/09/25 18:29:57 jferry
253 ! simplified TBC parameter lists
254 !
255 ! Revision 1.4 2002/09/20 22:22:35 jblazek
256 ! Finalized integration into GenX.
257 !
258 ! Revision 1.3 2002/09/18 21:50:49 jferry
259 ! Streamlined inelegant coding
260 !
261 ! Revision 1.2 2002/09/18 15:25:30 jferry
262 ! Fixed RFLU compilation bug
263 !
264 ! Revision 1.1 2002/09/17 13:42:59 jferry
265 ! Added Time-dependent boundary conditions
266 !
267 ! ******************************************************************************
268 
269 
270 
271 
272 
273 
274 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine updatetbcsinusoidal(global, tbc, t)
Definition: patch.h:74
subroutine updatetbcstochastic(region, tbc, dt)
subroutine updatetbc(region, t, dt, final)
Definition: UpdateTbc.F90:43
const NT & n
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine updatetbcpiecewise(global, tbc, t)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine updatetbcwhitenoise(region, tbc)