Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UpdateTbcPiecewise.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: update values for Piecewise Constant or Piecewise Linear TBC
26 !
27 ! Description: none.
28 !
29 ! Input: pointer to TBC, substep time
30 !
31 ! Output: modifies TBC data
32 !
33 ! Notes:
34 !
35 ! * Example input section:
36 !
37 !-----
38 ! # TBC_PIECEWISE
39 ! INJECT MFRATE ! BC and variable to which TBC applies
40 ! BLOCK 0 0 ! applies to block ... (0 0 = to all)
41 ! PATCH 0 0 ! applies to patch ... (0 0 = to all patches from blocks)
42 ! ONTIME -1.e6 ! time to start using this TBC
43 ! OFFTIME 1.e6 ! time to stop using this TBC
44 ! ORDER 0 ! 0 = piecewise constant (default), 1 = piecewise linear
45 ! NJUMPS 4 ! number of points at which behavior changes
46 ! #
47 ! FRAC 0.0 ! fraction of input value of variable before first time
48 ! TIME 0.001 ! first time at which behavior changes
49 ! FRAC 0.1 ! next fraction attained (constant) or ramped to (linear)
50 ! TIME 0.002 ! second time at which behavior changes
51 ! FRAC 0.3
52 ! TIME 0.003
53 ! FRAC 0.6
54 ! TIME 0.004 ! final time at which behavior changes
55 ! FRAC 1.0 ! final value for constant case; *ignored* for linear case
56 ! #
57 !-----
58 !
59 ! * ONTIME and OFFTIME would not typically be used with this TBC.
60 !
61 ! * ORDER = 0 is specified above, which yields
62 !
63 ! frac = 0 for t < 0.001,
64 ! frac = 0.1 for 0.001 < t < 0.002,
65 ! frac = 0.3 for 0.002 < t < 0.003,
66 ! frac = 0.6 for 0.003 < t < 0.004,
67 ! frac = 1.0 for 0.004 < t.
68 !
69 ! * If ORDER = 1 were specified instead, the above would yield
70 !
71 ! frac = 0 for t < 0.001,
72 ! frac = 100.0*t-0.1 for 0.001 < t < 0.002,
73 ! frac = 200.0*t-0.3 for 0.002 < t < 0.003,
74 ! frac = 300.0*t-0.6 for 0.003 < t < 0.004,
75 ! frac = 0.6 for 0.004 < t.
76 !
77 ! Note that the final value (1.0) is ignored for this case.
78 !
79 ! * The value used in the boundary condition is the one input times the factor
80 ! "frac" given above, provided OFFTIME <= t <= ONTIME.
81 !
82 !******************************************************************************
83 !
84 ! $Id: UpdateTbcPiecewise.F90,v 1.3 2008/12/06 08:44:10 mtcampbe Exp $
85 !
86 ! Copyright: (c) 2003 by the University of Illinois
87 !
88 !******************************************************************************
89 
90 SUBROUTINE updatetbcpiecewise( global,tbc,t )
91 
92  USE moddatatypes
93  USE modbndpatch, ONLY : t_tbcvalues
94  USE modglobal, ONLY : t_global
95  USE modparameters
96  USE moderror
97  IMPLICIT NONE
98 
99 ! ... parameters
100  TYPE(t_global), POINTER :: global
101  TYPE(t_tbcvalues), INTENT(INOUT) :: tbc
102 
103  REAL(RFREAL), INTENT(IN) :: t
104 
105 ! ... loop variables
106  INTEGER :: i
107 
108 ! ... local variables
109  INTEGER :: order,njumps
110  LOGICAL :: usemaxtime
111  REAL(RFREAL) :: val,val0,val1,t0,t1
112 
113 !******************************************************************************
114 
115  CALL registerfunction( global,'UpdateTbcPiecewise',&
116  'UpdateTbcPiecewise.F90')
117 
118  order = tbc%switches(tbcswi_order)
119  njumps = tbc%switches(tbcswi_njumps)
120 
121  IF (t >= tbc%params(tbcdat_dat0 + 2*njumps)) THEN
122 
123  usemaxtime = .true.
124 
125  ELSE IF (t < tbc%params(tbcdat_dat0 + 2)) THEN
126 
127  usemaxtime = .false.
128  val = tbc%params(tbcdat_dat0 + 1) ! for both CONSTANT and LINEAR cases
129 
130  ELSE
131 
132  usemaxtime = .true.
133  DO i=2,njumps
134  IF (t < tbc%params(tbcdat_dat0 + 2*i)) THEN
135  SELECT CASE (order)
136  CASE (tbcopt_constant)
137  val = tbc%params(tbcdat_dat0 + 2*i-1) ! CONSTANT case
138  CASE (tbcopt_linear)
139  val0 = tbc%params(tbcdat_dat0 + 2*i-3)
140  t0 = tbc%params(tbcdat_dat0 + 2*i-2)
141  val1 = tbc%params(tbcdat_dat0 + 2*i-1)
142  t1 = tbc%params(tbcdat_dat0 + 2*i)
143  val = ((t-t0)*val1 + (t1-t)*val0) / (t1-t0) ! LINEAR case
144  END SELECT ! order
145  usemaxtime = .false.
146  EXIT
147  ENDIF ! t
148  ENDDO
149 
150  ENDIF ! tbc%params
151 
152  IF (usemaxtime) THEN
153 
154  SELECT CASE (order)
155  CASE (tbcopt_constant)
156  val = tbc%params(tbcdat_dat0 + 2*njumps+1) ! CONSTANT case
157  CASE (tbcopt_linear)
158  val = tbc%params(tbcdat_dat0 + 2*njumps-1) ! LINEAR case
159  END SELECT ! order
160 
161  ENDIF ! usemaxtime
162 
163  tbc%svals(tbcsto_val) = val
164 
165 ! finalize --------------------------------------------------------------------
166 
167  CALL deregisterfunction( global )
168 
169 END SUBROUTINE updatetbcpiecewise
170 
171 !******************************************************************************
172 !
173 ! RCS Revision history:
174 !
175 ! $Log: UpdateTbcPiecewise.F90,v $
176 ! Revision 1.3 2008/12/06 08:44:10 mtcampbe
177 ! Updated license.
178 !
179 ! Revision 1.2 2008/11/19 22:17:24 mtcampbe
180 ! Added Illinois Open Source License/Copyright
181 !
182 ! Revision 1.1 2004/12/01 16:52:07 haselbac
183 ! Initial revision after changing case
184 !
185 ! Revision 1.1 2003/06/10 22:54:42 jferry
186 ! Added Piecewise TBC
187 !
188 !******************************************************************************
189 
190 
191 
192 
193 
194 
195 
Size order() const
Degree of the element. 1 for linear and 2 for quadratic.
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
blockLoc i
Definition: read.cpp:79
subroutine updatetbcpiecewise(global, tbc, t)
subroutine deregisterfunction(global)
Definition: ModError.F90:469