Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SPEC_RFLU_ReadBcInflowSection.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: Read in user input related to inflow boundary condition for species.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Region pointer
31 !
32 ! Output: None.
33 !
34 ! Notes:
35 ! 1. Define additional keyword, SPEC_, which can be used to set a default
36 ! for all species. Individual species can be overridden by specifying
37 ! the appropriate keyword SPECn.
38 !
39 !******************************************************************************
40 !
41 ! $Id: SPEC_RFLU_ReadBcInflowSection.F90,v 1.5 2008/12/06 08:44:40 mtcampbe Exp $
42 !
43 ! Copyright: (c) 2003 by the University of Illinois
44 !
45 !******************************************************************************
46 
47 SUBROUTINE spec_rflu_readbcinflowsection(pRegion)
48 
49  USE moddatatypes
50  USE modbndpatch, ONLY: t_patch
51  USE moddatastruct, ONLY: t_region
52  USE modglobal, ONLY: t_global
53  USE modgrid, ONLY: t_grid
54  USE moderror
55  USE modparameters
56 
58 
59  IMPLICIT NONE
60 
61 ! *****************************************************************************
62 ! Definitions and declarations
63 ! *****************************************************************************
64 
65 ! =============================================================================
66 ! Arguments
67 ! =============================================================================
68 
69  TYPE(t_region), POINTER :: pregion
70 
71 ! =============================================================================
72 ! Locals
73 ! =============================================================================
74 
75  CHARACTER(CHRLEN) :: bcname,rcsidentstring
76  CHARACTER(10), DIMENSION(:), ALLOCATABLE :: keys
77  CHARACTER(256) :: filename
78  LOGICAL, DIMENSION(:), ALLOCATABLE :: defined
79  INTEGER :: checksum,distrib,errorflag,ikey,ipatch,ipatchbeg,ipatchend, &
80  ireg,ival,nkeys
81  REAL(RFREAL), DIMENSION(:), ALLOCATABLE :: vals
82  TYPE(t_grid) :: grid
83  TYPE(t_patch), POINTER :: ppatch
84  TYPE(t_global), POINTER :: global
85 
86 ! *****************************************************************************
87 ! Start
88 ! *****************************************************************************
89 
90  rcsidentstring = '$RCSfile: SPEC_RFLU_ReadBcInflowSection.F90,v $ $Revision: 1.5 $'
91 
92  global => pregion%global
93 
94  CALL registerfunction(global,'SPEC_RFLU_ReadBcInflowSection',&
95  'SPEC_RFLU_ReadBcInflowSection.F90')
96 
97 ! *****************************************************************************
98 ! Allocate memory
99 ! *****************************************************************************
100 
101  nkeys = pregion%specInput%nSpecies + 1 ! Add one because of default key
102 
103  ALLOCATE(keys(nkeys),stat=errorflag)
104  global%error = errorflag
105  IF ( global%error /= err_none ) THEN
106  CALL errorstop(global,err_allocate,__line__,'keys')
107  END IF ! global%error
108 
109  ALLOCATE(vals(nkeys),stat=errorflag)
110  global%error = errorflag
111  IF ( global%error /= err_none ) THEN
112  CALL errorstop(global,err_allocate,__line__,'vals')
113  END IF ! global%error
114 
115  ALLOCATE(defined(nkeys),stat=errorflag)
116  global%error = errorflag
117  IF ( global%error /= err_none ) THEN
118  CALL errorstop(global,err_allocate,__line__,'defined')
119  END IF ! global%error
120 
121 ! *****************************************************************************
122 ! Generate keys. NOTE first key is default key.
123 ! *****************************************************************************
124 
125  keys(1) = 'SPEC_'
126 
127  CALL makenumberedkeys(keys,2,'SPEC',1,nkeys,1)
128 
129 ! *****************************************************************************
130 ! Read section
131 ! *****************************************************************************
132 
133  CALL readpatchsection(global,if_input,nkeys,keys,vals,ipatchbeg,ipatchend, &
134  distrib,filename,bcname,defined)
135 
136 ! *****************************************************************************
137 ! Check if specified number of patches exceeds available ones
138 ! *****************************************************************************
139 
140  IF ( ipatchend > global%nPatches ) THEN
141  CALL errorstop(global,err_patch_range,__line__)
142  END IF ! iPatchEnd
143 
144 ! *****************************************************************************
145 ! Set options and check if all necessary values defined
146 ! *****************************************************************************
147 
148  DO ipatch = 1,pregion%grid%nPatches
149  ppatch => pregion%patches(ipatch)
150 
151 ! =============================================================================
152 ! Check whether this global patch exists in this region
153 ! =============================================================================
154 
155  IF ( ppatch%iPatchGlobal >= ipatchbeg .AND. &
156  ppatch%iPatchGlobal <= ipatchend ) THEN
157 
158 ! -----------------------------------------------------------------------------
159 ! Set options
160 ! -----------------------------------------------------------------------------
161 
162  ppatch%spec%nData = pregion%specInput%nSpecies
163  ppatch%spec%nSwitches = 0
164  ppatch%spec%distrib = distrib
165 
166 ! -----------------------------------------------------------------------------
167 ! Check whether all values defined (if no default defined)
168 ! -----------------------------------------------------------------------------
169 
170  IF ( defined(1) .EQV. .false. ) THEN ! No default defined
171  checksum = 0
172 
173  DO ikey = 2,nkeys
174  IF ( defined(ikey) .EQV. .true. ) THEN
175  checksum = checksum + 1
176  END IF ! defined
177  END DO ! iKey
178 
179  IF ( checksum /= pregion%specInput%nSpecies ) THEN
180  CALL errorstop(global,err_bcval_missing,__line__)
181  END IF ! checkSum
182  END IF ! defined(1)
183 
184  END IF ! pPatch%iPatchGlobal
185  END DO ! iPatch
186 
187 ! *****************************************************************************
188 ! Copy values/distribution to variables
189 ! *****************************************************************************
190 
191  DO ipatch = 1,pregion%grid%nPatches
192  ppatch => pregion%patches(ipatch)
193 
194 ! =============================================================================
195 ! Check whether this global patch exists in this region
196 ! =============================================================================
197 
198  IF ( ppatch%iPatchGlobal >= ipatchbeg .AND. &
199  ppatch%iPatchGlobal <= ipatchend ) THEN
200 
201 ! -----------------------------------------------------------------------------
202 ! Distribution from file
203 ! -----------------------------------------------------------------------------
204 
205  IF ( ppatch%spec%distrib == bcdat_distrib ) THEN
206 
207 ! TO DO
208 ! Reading of data from file needs to be coded
209 ! END TO DO
210 
211 ! -----------------------------------------------------------------------------
212 ! Constant value
213 ! -----------------------------------------------------------------------------
214 
215  ELSE
216  ALLOCATE(ppatch%spec%vals(ppatch%spec%nData,0:1), &
217  stat=errorflag)
218  global%error = errorflag
219  IF ( global%error /= 0 ) THEN
220  CALL errorstop(global,err_allocate,__line__,'pPatch%spec%vals')
221  END IF ! global%error
222 
223  DO ival = 1,ppatch%spec%nData
224  IF ( defined(1+ival) .EQV. .true. ) THEN ! Set to input
225  ppatch%spec%vals(ival,0:1) = vals(1+ival)
226  ELSE ! Set to input
227  ppatch%spec%vals(ival,0:1) = vals(1)
228  END IF ! defined
229  END DO ! iVal
230  END IF ! pPatch%spec%distrib
231  END IF ! pPatch%iPatchGlobal
232  END DO ! iPatch
233 
234 ! *****************************************************************************
235 ! Deallocate memory
236 ! *****************************************************************************
237 
238  DEALLOCATE(keys,stat=errorflag)
239  global%error = errorflag
240  IF ( global%error /= err_none ) THEN
241  CALL errorstop(global,err_deallocate,__line__,'keys')
242  END IF ! global%error
243 
244  DEALLOCATE(vals,stat=errorflag)
245  global%error = errorflag
246  IF ( global%error /= err_none ) THEN
247  CALL errorstop(global,err_deallocate,__line__,'vals')
248  END IF ! global%error
249 
250  DEALLOCATE(defined,stat=errorflag)
251  global%error = errorflag
252  IF ( global%error /= err_none ) THEN
253  CALL errorstop(global,err_deallocate,__line__,'defined')
254  END IF ! global%error
255 
256 ! *****************************************************************************
257 ! End
258 ! *****************************************************************************
259 
260  CALL deregisterfunction(global)
261 
262 END SUBROUTINE spec_rflu_readbcinflowsection
263 
264 !******************************************************************************
265 !
266 ! RCS Revision history:
267 !
268 ! $Log: SPEC_RFLU_ReadBcInflowSection.F90,v $
269 ! Revision 1.5 2008/12/06 08:44:40 mtcampbe
270 ! Updated license.
271 !
272 ! Revision 1.4 2008/11/19 22:17:53 mtcampbe
273 ! Added Illinois Open Source License/Copyright
274 !
275 ! Revision 1.3 2006/08/19 15:40:31 mparmar
276 ! Renamed patch variables
277 !
278 ! Revision 1.2 2006/04/07 15:19:25 haselbac
279 ! Removed tabs
280 !
281 ! Revision 1.1 2003/11/25 21:08:37 haselbac
282 ! Initial revision
283 !
284 !******************************************************************************
285 
286 
287 
288 
289 
290 
291 
subroutine makenumberedkeys(keys, indBegin, string, numBegin, numEnd, numSkip)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine readpatchsection(global, fileID, nvals, keys, vals, brbeg, brend, prbeg, prend, distrib, profType, fname, defined)
subroutine spec_rflu_readbcinflowsection(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine grid(bp)
Definition: setup_py.f90:257
subroutine deregisterfunction(global)
Definition: ModError.F90:469