Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_CheckValidity_GL.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 validity of variables
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Region data
31 !
32 ! Output: None.
33 !
34 ! Notes:
35 ! 1. Compute and check pressure here because, it being computed later
36 ! through a call to MixtureProperties, an invalid value would not be
37 ! detected.
38 !
39 ! ******************************************************************************
40 !
41 ! $Id: RFLU_CheckValidity_GL.F90,v 1.4 2008/12/06 08:44:11 mtcampbe Exp $
42 !
43 ! Copyright: (c) 2006 by the University of Illinois
44 !
45 ! ******************************************************************************
46 
47 SUBROUTINE rflu_checkvalidity_gl(pRegion)
48 
49  USE moddatatypes
50  USE moderror
51  USE modglobal, ONLY: t_global
52  USE moddatastruct, ONLY: t_region
53  USE modgrid, ONLY: t_grid
54  USE modparameters
55  USE modmpi
56  USE modtools, ONLY: isnan
57 
58  USE modinterfaces, ONLY: mixtgasliq_p, &
59  mixtliq_c2_bp, &
62  mixtperf_r_m, &
65 
66  IMPLICIT NONE
67 
68 ! ******************************************************************************
69 ! Definitions and declarations
70 ! ******************************************************************************
71 
72 ! ==============================================================================
73 ! Arguments
74 ! ==============================================================================
75 
76  TYPE(t_region), POINTER :: pregion
77 
78 ! ==============================================================================
79 ! Locals
80 ! ==============================================================================
81 
82  CHARACTER(CHRLEN) :: rcsidentstring
83  INTEGER, PARAMETER :: max_invalid_locs = 10
84  INTEGER :: icg,indcp,indmol,nlocs
85  INTEGER :: loc(max_invalid_locs,min_val:max_val)
86  REAL(RFREAL) :: bp,bt,cg2,cl2,cpgas,cpvap,cv2,cvg,cvl,cvm,cvv,eo,p,po, &
87  rgas,rho,rhoyg,rhoyl,rhoyv,ro,rrho,rvap,t,to,u,v,vm2,w
88  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pcvspec,pdv,pgv
89  TYPE(t_global), POINTER :: global
90  TYPE(t_grid), POINTER :: pgrid
91 
92 ! ******************************************************************************
93 ! Start
94 ! ******************************************************************************
95 
96  rcsidentstring = '$RCSfile: RFLU_CheckValidity_GL.F90,v $'
97 
98  global => pregion%global
99 
100  CALL registerfunction(global,'RFLU_CheckValidity_GL',&
101  'RFLU_CheckValidity_GL.F90')
102 
103 ! ******************************************************************************
104 ! Set pointers and variables
105 ! ******************************************************************************
106 
107  pgrid => pregion%grid
108 
109  pcv => pregion%mixt%cv
110  pdv => pregion%mixt%dv
111  pgv => pregion%mixt%gv
112 
113 #ifdef SPEC
114  pcvspec => pregion%spec%cv
115 #endif
116 
117  nlocs = 0
118 
119  indcp = pregion%mixtInput%indCp
120  indmol = pregion%mixtInput%indMol
121 
122  ro = global%refDensityLiq
123  po = global%refPressLiq
124  to = global%refTempLiq
125  bp = global%refBetaPLiq
126  bt = global%refBetaTLiq
127  cvl = global%refCvLiq
128 
129  rgas = mixtperf_r_m(pregion%specInput%specType(1)%pMaterial%molw)
130  cvg = mixtperf_cv_cpr(pregion%specInput%specType(1)%pMaterial%spht,rgas)
131 
132  rvap = mixtperf_r_m(pregion%specInput%specType(2)%pMaterial%molw)
133  cvv = mixtperf_cv_cpr(pregion%specInput%specType(2)%pMaterial%spht,rvap)
134 
135 ! *****************************************************************************
136 ! Loop over cells and check for positivity
137 ! *****************************************************************************
138 
139  DO icg = 1,pgrid%nCells
140  rho = pcv(cv_mixt_dens,icg)
141  rrho = 1.0_rfreal/rho
142  rhoyg = pcvspec(1,icg)
143  rhoyv = pcvspec(2,icg)
144  rhoyl = rho - rhoyg - rhoyv
145 
146  u = rrho*pcv(cv_mixt_xmom,icg)
147  v = rrho*pcv(cv_mixt_ymom,icg)
148  w = rrho*pcv(cv_mixt_zmom,icg)
149  eo = rrho*pcv(cv_mixt_ener,icg)
150 
151  vm2 = u*u + v*v + w*w
152  cvm = (rhoyl*cvl + rhoyv*cvv + rhoyg*cvg)/rho
153  t = mixtperf_t_cveovm2(cvm,eo,vm2)
154 
155  cl2 = mixtliq_c2_bp(bp)
156  cv2 = mixtperf_c2_grt(1.0_rfreal,rgas,t)
157  cg2 = mixtperf_c2_grt(1.0_rfreal,rvap,t)
158 
159  p = mixtgasliq_p(rhoyl,rhoyv,rhoyg,cl2,cv2,cg2,rho,ro,po,to,bp,bt,t)
160 
161  IF ( (isnan(rho) .EQV. .true.) .OR. &
162  (isnan(u) .EQV. .true.) .OR. &
163  (isnan(v) .EQV. .true.) .OR. &
164  (isnan(w) .EQV. .true.) .OR. &
165  (isnan(p) .EQV. .true.) .OR. &
166  (isnan(t) .EQV. .true.) ) THEN
167  nlocs = nlocs + 1
168 
169  IF ( nlocs == 1 ) THEN
170  WRITE(stdout,'(A,1X,A,1X,I9)') solver_name, &
171  'Invalid variables detected!'
172 
173  IF ( global%flowType == flow_unsteady ) THEN
174  WRITE(stdout,'(A,3X,A,1X,1PE12.5)') solver_name,'Current time:', &
175  global%currentTime
176  ELSE
177  WRITE(stdout,'(A,3X,A,1X,I6)') solver_name, &
178  'Current iteration number:', &
179  global%currentIter
180  END IF ! global%flowType
181 
182  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
183  pregion%iRegionGlobal
184  WRITE(stdout,'(A,6X,A,6(1X,A))') solver_name,'#', &
185  ' Density ', &
186  ' x-velocity ', &
187  ' y-velocity ', &
188  ' z-velocity ', &
189  ' Pressure ', &
190  ' Temperature '
191  END IF ! nLocs
192 
193  IF ( nlocs <= max_invalid_locs ) THEN
194  WRITE(stdout,'(A,4X,I3,6(1X,E13.6))') solver_name,nlocs, &
195  rho,u,v,w,p,t
196  loc(nlocs,min_val:max_val) = icg
197  END IF ! nLocs
198  END IF ! cv
199  END DO ! icg
200 
201 ! *****************************************************************************
202 ! Write out message and call error handling routine
203 ! *****************************************************************************
204 
205  IF ( nlocs > 0 ) THEN
206  IF ( nlocs > max_invalid_locs ) THEN
207  WRITE(stdout,'(A,3X,A,1X,I3,1X,A,1X,I9,1X,A)') solver_name, &
208  'Only wrote the first',max_invalid_locs,'of',nlocs, &
209  'cells with invalid variables.'
210  CALL rflu_printlocinfo(pregion,loc,max_invalid_locs, &
211  locinfo_mode_silent,output_mode_anybody)
212  ELSE
213  CALL rflu_printlocinfo(pregion,loc(1:nlocs,min_val:max_val),nlocs, &
214  locinfo_mode_silent,output_mode_anybody)
215  END IF ! nLocs
216 
217  CALL errorstop(global,err_invalid_value,__line__)
218  END IF ! nLocs
219 
220 ! *****************************************************************************
221 ! End
222 ! *****************************************************************************
223 
224  CALL deregisterfunction(global)
225 
226 END SUBROUTINE rflu_checkvalidity_gl
227 
228 ! *****************************************************************************
229 !
230 ! RCS Revision history:
231 !
232 ! $Log: RFLU_CheckValidity_GL.F90,v $
233 ! Revision 1.4 2008/12/06 08:44:11 mtcampbe
234 ! Updated license.
235 !
236 ! Revision 1.3 2008/11/19 22:17:25 mtcampbe
237 ! Added Illinois Open Source License/Copyright
238 !
239 ! Revision 1.2 2006/04/07 15:19:16 haselbac
240 ! Removed tabs
241 !
242 ! Revision 1.1 2006/03/26 20:21:00 haselbac
243 ! Initial revision
244 !
245 ! *****************************************************************************
246 
247 
248 
249 
250 
251 
252 
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
real(rfreal) function mixtgasliq_p(DYl, DYv, DYg, Cl2, Cv2, Cg2, D, Dz, Po, To, Bp, Bt, T)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS 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 v
Definition: roccomf90.h:20
real(rfreal) function mixtperf_c2_grt(G, R, T)
Definition: MixtPerf_C.F90:101
logical function isnan(x)
Definition: ModTools.F90:201
real(rfreal) function mixtliq_c2_bp(Bp)
Definition: MixtLiq_C.F90:54
subroutine rflu_printlocinfo(pRegion, locUnsorted, nLocUnsorted, locInfoMode, outputMode)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
real(rfreal) function mixtperf_t_cveovm2(Cv, Eo, Vm2)
Definition: MixtPerf_T.F90:70
subroutine deregisterfunction(global)
Definition: ModError.F90:469
real(rfreal) function mixtperf_cv_cpr(Cp, R)
Definition: MixtPerf_Cv.F90:39
subroutine rflu_checkvalidity_gl(pRegion)