Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
INRT_CheckUserInput.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: check interaction information provided by the user
26 !
27 ! Description: none.
28 !
29 ! Input: region = data of current region.
30 !
31 ! Output: none.
32 !
33 ! Notes: none.
34 !
35 !******************************************************************************
36 !
37 ! $Id: INRT_CheckUserInput.F90,v 1.5 2008/12/06 08:44:31 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2003 by the University of Illinois
40 !
41 !******************************************************************************
42 
43 SUBROUTINE inrt_checkuserinput( region )
44 
45  USE moddatatypes
46  USE moddatastruct, ONLY : t_region
47  USE modglobal, ONLY : t_global
48  USE modinteract
49  USE moderror
50  USE modtools, ONLY : floatequal
51  USE modparameters
52  USE modmpi
54 
55  IMPLICIT NONE
56 
57 ! ... parameters
58  TYPE (t_region), INTENT(INOUT) :: region
59 
60 ! ... loop variables
61  INTEGER :: iinrt,iedge,inod,iplag,ipeul,ipeuloutedge
62 
63 ! ... local variables
64  CHARACTER(CHRLEN) :: rcsidentstring
65 
66  LOGICAL :: errorflag,maxconedgesfound,maxdisedgesfound
67 
68  INTEGER :: nplag,npeul,nnodes,nusednodes,npeuloutedges,npeuloxedges
69  INTEGER :: ind,indmixt,indplag0,indpeul0,indintl,indplagjoint,indpeulox
70  INTEGER :: indplagvapor,loclactdiff,maxconedges,maxdisedges,globactdiff
71  INTEGER :: iwrite
72 
73  REAL(RFREAL) :: outmass,coef
74 
75  TYPE(t_inrt_input), POINTER :: input
76  TYPE(t_inrt_interact), POINTER :: inrt
77  TYPE(t_inrt_edge), POINTER :: edge
78  TYPE(t_global), POINTER :: global
79 
80 !******************************************************************************
81 
82  rcsidentstring = '$RCSfile: INRT_CheckUserInput.F90,v $ $Revision: 1.5 $'
83 
84  global => region%global
85 
86  CALL registerfunction( global,'INRT_CheckUserInput',&
87  'INRT_CheckUserInput.F90' )
88 
89 ! begin -----------------------------------------------------------------------
90 
91  IF (inrt_perm_pmass - inrt_perm_block /= 1 .OR. &
92  inrt_perm_pmome - inrt_perm_pmass /= 1 .OR. &
93  inrt_perm_pall - inrt_perm_pmome /= 1) &
94  CALL errorstop( global,err_inrt_parameter,__line__ )
95 
96  input => region%inrtInput
97 
98  IF (.NOT. input%defaultRead) &
99  CALL errorstop( global,err_inrt_defunread,__line__ )
100 
101  nplag = input%nPlag
102  npeul = input%nPeul
103  nnodes = input%nNodes
104 
105  indmixt = input%indMixt
106  indplag0 = input%indPlag0
107  indpeul0 = input%indPeul0
108  indintl = input%indIntl
109 
110  indplagjoint = input%indPlagJoint
111  indplagvapor = input%indPlagVapor
112 
113  maxconedges = input%maxConEdges
114  maxdisedges = input%maxDisEdges
115  maxconedgesfound = .false.
116  maxdisedgesfound = .false.
117 
118  iwrite = 1 ! option to write (1) or not (0) warnings
119 
120 ! Check that arrays are allocated an have the correct size
121 
122  errorflag = .false.
123 
124  IF (ASSOCIATED(input%globActiveness)) THEN
125  IF (ubound(input%globActiveness,1) /= nnodes) errorflag = .true.
126  ELSE
127  IF (nnodes /= 0) errorflag = .true.
128  END IF ! input%globActiveness
129 
130  IF (ASSOCIATED(input%globPermission)) THEN
131  IF (ubound(input%globPermission,1) /= nnodes) errorflag = .true.
132  ELSE
133  IF (nnodes /= 0) errorflag = .true.
134  END IF ! input%globPermission
135 
136  IF (ASSOCIATED(input%inrts)) THEN
137  IF (ubound(input%inrts,1) /= inrt_type_total) errorflag = .true.
138  ELSE
139  IF (inrt_type_total /= 0) errorflag = .true.
140  END IF ! input%inrts
141 
142  IF (errorflag) CALL errorstop( global,err_inrt_allocrange,__line__ )
143 
144 ! Active smoke not implemented for Rocflo
145 #ifdef RFLO
146  DO ind = indpeul0+1,indpeul0+npeul
147  IF (input%globActiveness(ind) == inrt_act_active) THEN
148  CALL errorstop( global,err_inrt_badactv,__line__, &
149  'Active smoke not implemented for Rocflo' )
150  END IF
151  END DO ! ind
152 #endif
153 
154 ! Active species not implemented for Rocflu (but soon?)
155 #ifdef RFLU
156  DO ind = indpeul0+1,indpeul0+npeul
157  IF (input%globActiveness(ind) == inrt_act_active) THEN
158  CALL errorstop( global,err_inrt_badactv,__line__, &
159  'Active species not implemented for Rocflu' )
160  END IF
161  END DO ! ind
162 #endif
163 
164 ! Check that indPlagJoint refers to a particle index
165 
166  IF (nplag > 0) THEN
167 
168  IF (indplagjoint < indplag0+1 .OR. indplagjoint > indplag0+nplag) &
169  CALL errorstop( global,err_inrt_indexrange,__line__ )
170 
171  END IF ! nPlag
172 
173 ! Check that indPlagVapor is assigned correctly
174 
175  IF (indplagvapor /= indplag0+nplag+1) &
176  CALL errorstop( global,err_inrt_indexrange,__line__ )
177 
178  DO iinrt = 1,inrt_type_total
179 
180  inrt => input%inrts(iinrt)
181 
182  IF (ASSOCIATED(inrt%switches)) THEN
183  IF (ubound(inrt%switches,1) /= inrt%nSwitches) errorflag = .true.
184  ELSE
185  IF (inrt%nSwitches /= 0) errorflag = .true.
186  END IF ! switches
187 
188  IF (ASSOCIATED(inrt%data)) THEN
189  IF (ubound(inrt%data,1) /= inrt%nData) errorflag = .true.
190  ELSE
191  IF (inrt%nData /= 0) errorflag = .true.
192  END IF ! data
193 
194  IF (ASSOCIATED(inrt%activeness)) THEN
195  IF (ubound(inrt%activeness,1) /= nnodes) errorflag = .true.
196  ELSE
197  IF (nnodes /= 0) errorflag = .true.
198  END IF ! inrt%activeness
199 
200  IF (ASSOCIATED(inrt%permission)) THEN
201  IF (ubound(inrt%permission,1) /= nnodes) errorflag = .true.
202  ELSE
203  IF (nnodes /= 0) errorflag = .true.
204  END IF ! inrt%permission
205 
206  IF (ASSOCIATED(inrt%edges)) THEN
207  IF (ubound(inrt%edges,1) /= inrt%nEdges) errorflag = .true.
208  ELSE
209  IF (inrt%nEdges /= 0) errorflag = .true.
210  END IF ! edges
211 
212  IF (errorflag) CALL errorstop( global,err_inrt_allocrange,__line__ )
213 
214  IF (.NOT. inrt%used) cycle ! do not worry about undefined interactions
215 
216 ! - Check that number of Edges is within proper range
217 
218  IF (inrt%pclsUsed) THEN
219  IF (inrt%nEdges > maxdisedges) THEN
220  CALL errorstop( global,err_illegal_value,__line__, &
221  'Number of Edges more than maximal number of Edges')
222  ELSE IF (inrt%nEdges == maxdisedges) THEN
223  maxdisedgesfound = .true.
224  END IF
225  ELSE
226  IF (inrt%nEdges > maxconedges) THEN
227  CALL errorstop( global,err_illegal_value,__line__, &
228  'Number of Edges more than maximal number of Edges')
229  ELSE IF (inrt%nEdges == maxconedges) THEN
230  maxconedgesfound = .true.
231  END IF
232  END IF
233 
234 ! - Check that number of internal Nodes is valid
235 
236  IF (inrt%nIntl < 0 .OR. inrt%nIntl > 1) &
237  CALL errorstop( global,err_inrt_nintl,__line__ )
238 
239 ! - Check various things if there is an Internal Node
240 
241  IF (inrt%nIntl == 1) THEN
242 
243 ! --- Check that Permission level is 3 (Permit All)
244 
245  IF (inrt%permission(indintl) /= inrt_perm_pall) &
246  CALL errorstop( global,err_inrt_permlevintl,__line__ )
247 
248 ! --- Check that there is at least one input and one output Edge
249 
250  IF (inrt%nInputEdges <= 0 .OR. inrt%nInputEdges >= inrt%nEdges) &
251  CALL errorstop( global,err_inrt_ninputedges,__line__ )
252 
253  DO iedge = 1,inrt%nInputEdges
254 
255  edge => inrt%edges(iedge)
256 
257 ! ----- Check that input Edge is correctly connected to Internal Node
258 
259  IF (edge%iNode(1) == indintl .OR. edge%iNode(2) /= indintl) &
260  CALL errorstop( global,err_inrt_connectintl,__line__ )
261 
262 ! ----- Check that input Edge has correct permission Token at Internal Node
263 
264  IF (edge%tEdge == inrt_edge_mome_dum .OR. &
265  edge%tEdge == inrt_edge_mass_gho) THEN
266 
267  IF (edge%token(2) /= inrt_perm_block) &
268  CALL errorstop( global,err_inrt_permintl,__line__ )
269 
270  ELSE
271 
272  IF (edge%token(2) /= inrt_perm_pall) &
273  CALL errorstop( global,err_inrt_permintl,__line__ )
274 
275  END IF ! edge%tEdge
276 
277  END DO ! iEdge
278 
279  DO iedge = inrt%nInputEdges+1,inrt%nEdges
280 
281  edge => inrt%edges(iedge)
282 
283 ! ----- Check that output Edge is correctly connected to Internal Node
284 
285  IF (edge%iNode(1) /= indintl .OR. edge%iNode(2) == indintl) &
286  CALL errorstop( global,err_inrt_connectintl,__line__ )
287 
288 ! ----- Check that output Edge has correct permission Token at Internal Node
289 
290  IF (edge%token(1) /= inrt_perm_block) &
291  CALL errorstop( global,err_inrt_permintl,__line__ )
292 
293  END DO ! iEdge
294 
295  END IF ! inrt%nIntl
296 
297  nusednodes = nnodes - 1 + inrt%nIntl
298 
299  DO inod = 1,nusednodes
300 
301 ! --- Check that Activeness of Node has valid value
302 
303  IF (inrt%activeness(inod) > inrt_act_active) &
304  CALL errorstop( global,err_inrt_badactv,__line__ )
305 
306 ! --- Warn if Node has been changed from active to passive, or vice-versa
307 ! --- (unless Node is Internal or not the first Lagranigan particle type)
308 
309  IF ( inod /= indintl .AND. &
310  (inod <= indplag0+1 .OR. inod > indplag0+nplag+1) ) THEN
311 
312  IF (inrt%activeness(inod) == inrt_act_active .NEQV. &
313  input%globActiveness(inod) == inrt_act_active) THEN
314 
315  IF (input%globActiveness(inod) == inrt_act_active) THEN
316  IF (global%myProcid==masterproc .AND. iwrite==1) &
317  WRITE(stdout,1030) solver_name//'### INRT_WARNING: Node has '// &
318  'been changed from active to passive for '//trim(inrt%name)
319  ELSE
320  IF (global%myProcid==masterproc .AND. iwrite==1) &
321  WRITE(stdout,1030) solver_name//'### INRT_WARNING: Node has '// &
322  'been changed from passive to active for '//trim(inrt%name)
323  END IF ! input%globActiveness(iNod)
324 
325  IF (global%myProcid==masterproc .AND. iwrite==1) &
326  WRITE(stdout,1040) solver_name//'### INRT_WARNING: '// &
327  'Node number',inod
328 
329  IF (input%consistent) THEN
330  IF (global%myProcid==masterproc .AND. iwrite==1) &
331  WRITE(stdout,1030) &
332  solver_name//'### INRT_WARNING: *** Consistency ruined! ***'
333  ENDIF
334  input%consistent = .false.
335 
336 
337  END IF ! inrt%activeness(iNod)
338 
339  END IF ! iNod
340 
341 ! --- Check that Permission level of Node has valid value
342 
343  IF (inrt%permission(inod) < inrt_perm_block .OR. &
344  inrt%permission(inod) > inrt_perm_pall) &
345  CALL errorstop( global,err_inrt_badperm,__line__ )
346 
347 ! --- Warn if Permission level less than 3 (Permit All) is on active Node
348 
349  IF (inrt%activeness(inod) == inrt_act_active .AND. &
350  inrt%permission(inod) /= inrt_perm_pall) THEN
351 
352  IF (global%myProcid==masterproc .AND. iwrite==1 ) &
353  WRITE(stdout,1030) solver_name//'### INRT_WARNING: Permission '// &
354  'restricted for '//trim(inrt%name)
355  IF (global%myProcid==masterproc .AND. iwrite==1 ) &
356  WRITE(stdout,1040) solver_name//'### INRT_WARNING: on (active) '// &
357  'Node number',inod
358 
359  IF (input%consistent) THEN
360  IF (global%myProcid==masterproc .AND. iwrite==1 ) &
361  WRITE(stdout,1030) &
362  solver_name//'### INRT_WARNING: *** Consistency ruined! ***'
363  ENDIF
364  input%consistent = .false.
365 
366  END IF ! inrt%activeness(iNod)
367 
368  END DO ! iNod
369 
370 ! - Check that all Lagrangian particle constituents have the same Activeness
371 ! - (Do not require Vapor Energy to have same Activeness as others, however)
372 
373  DO iplag=1,nplag
374 
375  IF (inrt%activeness(indplag0+iplag) /= inrt%activeness(indplag0+1)) &
376  CALL errorstop( global,err_inrt_actvplag,__line__ )
377 
378  END DO ! iPlag
379 
380 ! - Interaction-specific checks
381 
382  SELECT CASE (iinrt)
383 
384  CASE (inrt_type_burning)
385 
386  npeuloxedges = 0
387  IF (inrt%switches(inrt_swi_burning_oxused) /= 0) THEN
388 
389  npeuloxedges = 1
390 
391 ! ----- Extract index of oxidizer smoke type
392 
393  indpeulox = inrt%edges(inrt_burning_s_mass_x0 + npeuloxedges)%iNode(1)
394 
395 ! ----- Check that index is in the smoke range
396 
397  IF (indpeulox < indpeul0 + 1 .OR. indpeulox > indpeul0 + npeul) &
398  CALL errorstop( global,err_inrt_indexrange,__line__ )
399 
400 ! ----- Check that if oxidizer is used, it is less active than gas
401 
402  IF (input%globActiveness(indpeulox) >= input%globActiveness(indmixt)) &
403  CALL errorstop( global,err_inrt_ox_actv,__line__ )
404 
405  END IF ! INRT_SWI_BURNING_OXUSED
406 
407  IF (inrt%activeness(indintl) == inrt_act_active) THEN
408 
409 ! ----- Check that Gas and Lagrangian particles are active
410 
411  IF (inrt%activeness(indmixt) /= inrt_act_active .OR. &
412  inrt%activeness(indplag0+1) /= inrt_act_active) &
413  CALL errorstop( global,err_inrt_burning1,__line__ )
414 
415 ! ----- Warn if active smoke output has incorrect mass (within a tolerance)
416 
417  outmass = 0._rfreal
418  npeuloutedges = inrt%nEdges - npeuloxedges - inrt_burning_nedges0
419 
420  DO ipeuloutedge = 1,npeuloutedges ! loop over edges that output smoke
421 
422  iedge = inrt_burning_x_mass_s0 + npeuloxedges + ipeuloutedge
423 
424  ipeul = inrt%edges(iedge)%iNode(2) - indpeul0
425 
426  IF (ipeul < 1 .OR. ipeul > npeul) &
427  CALL errorstop( global,err_inrt_indexrange,__line__ )
428 
429  IF (inrt%activeness(indpeul0+ipeul) == inrt_act_active) THEN
430 
431  ind = inrt_dat_burning_mfrc_peul0 + ipeuloutedge
432 
433  outmass = outmass + inrt%data(ind)
434 
435  END IF ! inrt%activeness
436 
437  END DO ! iPeulOutEdge
438 
439  coef = inrt%data(inrt_dat_burning_mfrc_plag)
440  outmass = coef + (1._rfreal - coef)*outmass
441 
442  IF (.NOT.floatequal(outmass,1._rfreal)) THEN
443 
444  IF (global%myProcid==masterproc .AND. iwrite==1) &
445  WRITE(stdout,1030) solver_name//'### INRT_WARNING: active output '// &
446  'mass for '//trim(inrt%name)
447  IF (global%myProcid==masterproc .AND. iwrite==1) &
448  WRITE(stdout,1050) solver_name//'### INRT_WARNING: sums not '// &
449  'to 1, but to',outmass
450 
451  IF (input%consistent) THEN
452  IF (global%myProcid==masterproc .AND. iwrite==1) &
453  WRITE(stdout,1030) &
454  solver_name//'### INRT_WARNING: *** Consistency ruined! ***'
455  ENDIF
456  input%consistent = .false.
457 
458  END IF ! outmass
459 
460  END IF ! inrt%activeness(indIntl)
461 
462  END SELECT ! iInrt
463 
464  END DO ! iInrt
465 
466 ! Check that maximal number of Edges is correct
467 
468  IF (maxconedges > 0 .AND. .NOT.maxconedgesfound) THEN
469  CALL errorstop( global,err_illegal_value,__line__, &
470  'Inconsistency in maximal number of Edges')
471  ENDIF
472 
473  IF (maxdisedges > 0 .AND. .NOT.maxdisedgesfound) THEN
474  CALL errorstop( global,err_illegal_value,__line__, &
475  'Inconsistency in maximal number of Edges')
476  ENDIF
477 
478 ! finalize --------------------------------------------------------------------
479 
480  CALL deregisterfunction( global )
481 
482 1030 FORMAT(a)
483 1040 FORMAT(a,i3)
484 1050 FORMAT(a,es14.6)
485 
486 END SUBROUTINE inrt_checkuserinput
487 
488 !******************************************************************************
489 !
490 ! RCS Revision history:
491 !
492 ! $Log: INRT_CheckUserInput.F90,v $
493 ! Revision 1.5 2008/12/06 08:44:31 mtcampbe
494 ! Updated license.
495 !
496 ! Revision 1.4 2008/11/19 22:17:44 mtcampbe
497 ! Added Illinois Open Source License/Copyright
498 !
499 ! Revision 1.3 2005/03/06 18:13:44 wasistho
500 ! added parameter iwrite to control printing warnings to stdout
501 !
502 ! Revision 1.2 2005/03/06 00:18:38 wasistho
503 ! refrain from writing WARNING from each processor
504 !
505 ! Revision 1.1 2004/12/01 21:56:18 fnajjar
506 ! Initial revision after changing case
507 !
508 ! Revision 1.9 2004/07/28 15:42:12 jferry
509 ! deleted defunct constructs: useDetangle, useSmokeDrag, useSmokeHeatTransfer
510 !
511 ! Revision 1.8 2004/07/27 21:30:00 jferry
512 ! integrated maxConEdges and maxDisEdges variables more fully
513 !
514 ! Revision 1.7 2004/03/03 23:55:40 jferry
515 ! Allowed particles to be run with Euler case
516 !
517 ! Revision 1.6 2004/03/02 21:47:29 jferry
518 ! Added After Update interactions
519 !
520 ! Revision 1.5 2003/09/25 15:48:43 jferry
521 ! implemented Boiling Regulation interaction
522 !
523 ! Revision 1.4 2003/09/19 20:35:26 jferry
524 ! Implemented oxidizer species for burning interaction
525 !
526 ! Revision 1.3 2003/04/03 21:10:18 jferry
527 ! implemented additional safety checks for rocinteract
528 !
529 ! Revision 1.2 2003/04/02 22:32:03 jferry
530 ! codified Activeness and Permission structures for rocinteract
531 !
532 ! Revision 1.1 2003/03/11 15:55:02 jferry
533 ! Implemented routine to check user input for Rocinteract
534 !
535 !******************************************************************************
536 
537 
538 
539 
540 
541 
542 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine input(X, NNODE, NDC, NCELL, NFCE, NBPTS, NBFACE, ITYP, NPROP, XBNDY, XFAR, YFAR, ZFAR)
subroutine inrt_checkuserinput(region)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
LOGICAL function floatequal(a, b, tolIn)
Definition: ModTools.F90:99
RT a() const
Definition: Line_2.h:140