Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_CheckPositivity_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 for posivity 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, a negative value would not be
37 ! detected and could cause negative pressure and temperature.
38 !
39 ! ******************************************************************************
40 !
41 ! $Id: RFLU_CheckPositivity_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_checkpositivity_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 
57  USE modinterfaces, ONLY: mixtgasliq_p, &
58  mixtliq_c2_bp, &
61  mixtperf_r_m, &
64 
65  IMPLICIT NONE
66 
67 ! ******************************************************************************
68 ! Definitions and declarations
69 ! ******************************************************************************
70 
71 ! ==============================================================================
72 ! Arguments
73 ! ==============================================================================
74 
75  TYPE(t_region), POINTER :: pregion
76 
77 ! ==============================================================================
78 ! Locals
79 ! ==============================================================================
80 
81  CHARACTER(CHRLEN) :: rcsidentstring
82  INTEGER, PARAMETER :: max_negative_locs = 10
83  INTEGER :: icg,indcp,indmol,nlocs
84  INTEGER :: loc(max_negative_locs,min_val:max_val)
85  REAL(RFREAL) :: bp,bt,cg2,cpgas,cpvap,cl2,cv2,cvg,cvl,cvm,cvv,eo,p,po, &
86  rgas,rho,rhoyg,rhoyl,rhoyv,ro,rrho,rvap,t,to,u,v,vm2,w
87  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pcvspec,pdv,pgv
88  TYPE(t_global), POINTER :: global
89  TYPE(t_grid), POINTER :: pgrid
90 
91 ! ******************************************************************************
92 ! Start
93 ! ******************************************************************************
94 
95  rcsidentstring = '$RCSfile: RFLU_CheckPositivity_GL.F90,v $'
96 
97  global => pregion%global
98 
99  CALL registerfunction(global,'RFLU_CheckPositivity_GL',&
100  'RFLU_CheckPositivity_GL.F90')
101 
102 ! ******************************************************************************
103 ! Set pointers and variables
104 ! ******************************************************************************
105 
106  pgrid => pregion%grid
107 
108  pcv => pregion%mixt%cv
109  pdv => pregion%mixt%dv
110  pgv => pregion%mixt%gv
111 
112 #ifdef SPEC
113  pcvspec => pregion%spec%cv
114 #endif
115 
116  nlocs = 0
117 
118  indcp = pregion%mixtInput%indCp
119  indmol = pregion%mixtInput%indMol
120 
121  ro = global%refDensityLiq
122  po = global%refPressLiq
123  to = global%refTempLiq
124  bp = global%refBetaPLiq
125  bt = global%refBetaTLiq
126  cvl = global%refCvLiq
127 
128  rgas = mixtperf_r_m(pregion%specInput%specType(1)%pMaterial%molw)
129  cvg = mixtperf_cv_cpr(pregion%specInput%specType(1)%pMaterial%spht,rgas)
130 
131  rvap = mixtperf_r_m(pregion%specInput%specType(2)%pMaterial%molw)
132  cvv = mixtperf_cv_cpr(pregion%specInput%specType(2)%pMaterial%spht,rvap)
133 
134 ! ******************************************************************************
135 ! Loop over cells and check for positivity
136 ! ******************************************************************************
137 
138  DO icg = 1,pgrid%nCells
139  rho = pcv(cv_mixt_dens,icg)
140  rrho = 1.0_rfreal/rho
141  rhoyg = pcvspec(1,icg)
142  rhoyv = pcvspec(2,icg)
143  rhoyl = rho - rhoyg - rhoyv
144 
145  u = rrho*pcv(cv_mixt_xmom,icg)
146  v = rrho*pcv(cv_mixt_ymom,icg)
147  w = rrho*pcv(cv_mixt_zmom,icg)
148  eo = rrho*pcv(cv_mixt_ener,icg)
149 
150  vm2 = u*u + v*v + w*w
151  cvm = (rhoyl*cvl + rhoyv*cvv + rhoyg*cvg)/rho
152  t = mixtperf_t_cveovm2(cvm,eo,vm2)
153 
154  cl2 = mixtliq_c2_bp(bp)
155  cv2 = mixtperf_c2_grt(1.0_rfreal,rgas,t)
156  cg2 = mixtperf_c2_grt(1.0_rfreal,rvap,t)
157 
158  p = mixtgasliq_p(rhoyl,rhoyv,rhoyg,cl2,cv2,cg2,rho,ro,po,to,bp,bt,t)
159 
160  IF ( (rho <= 0.0_rfreal) .OR. (p <= 0.0_rfreal) ) THEN
161  nlocs = nlocs + 1
162 
163  IF ( nlocs == 1 ) THEN
164  WRITE(stdout,'(A,1X,A)') solver_name, &
165  'Negative positive-definite variables detected!'
166  WRITE(stdout,'(A,3X,A)') solver_name,'Module: Mixture.'
167 
168  IF ( global%flowType == flow_unsteady ) THEN
169  WRITE(stdout,'(A,3X,A,1X,1PE12.5)') solver_name,'Current time:', &
170  global%currentTime
171  ELSE
172  WRITE(stdout,'(A,3X,A,1X,I6)') solver_name, &
173  'Current iteration number:', &
174  global%currentIter
175  END IF ! global%flowType
176 
177  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
178  pregion%iRegionGlobal
179  WRITE(stdout,'(A,6X,A,6(1X,A))') solver_name,'#', &
180  ' Density ', &
181  ' x-velocity ', &
182  ' y-velocity ', &
183  ' z-velocity ', &
184  ' Pressure ', &
185  ' Temperature '
186  END IF ! nLocs
187 
188  IF ( nlocs <= max_negative_locs ) THEN
189  WRITE(stdout,'(A,4X,I3,6(1X,E13.6))') solver_name,nlocs, &
190  rho,u,v,w,p,t
191  loc(nlocs,min_val:max_val) = icg
192  END IF ! nLocs
193  END IF ! pCv
194  END DO ! icg
195 
196 ! ******************************************************************************
197 ! Write out message and call error handling routine
198 ! ******************************************************************************
199 
200  IF ( nlocs > 0 ) THEN
201  IF ( nlocs > max_negative_locs ) THEN
202  WRITE(stdout,'(A,3X,A,1X,I3,1X,A,1X,I9,1X,A)') solver_name, &
203  'Only wrote the first',max_negative_locs,'of',nlocs, &
204  'cells with negative positive-definite variables.'
205  CALL rflu_printlocinfo(pregion,loc,max_negative_locs, &
206  locinfo_mode_silent,output_mode_anybody)
207  ELSE
208  CALL rflu_printlocinfo(pregion,loc(1:nlocs,min_val:max_val),nlocs, &
209  locinfo_mode_silent,output_mode_anybody)
210  END IF ! nLocs
211 
212  CALL errorstop(global,err_negative_posdef,__line__)
213  END IF ! nLocs
214 
215 ! ******************************************************************************
216 ! End
217 ! ******************************************************************************
218 
219  CALL deregisterfunction(global)
220 
221 END SUBROUTINE rflu_checkpositivity_gl
222 
223 ! ******************************************************************************
224 !
225 ! RCS Revision history:
226 !
227 ! $Log: RFLU_CheckPositivity_GL.F90,v $
228 ! Revision 1.4 2008/12/06 08:44:11 mtcampbe
229 ! Updated license.
230 !
231 ! Revision 1.3 2008/11/19 22:17:25 mtcampbe
232 ! Added Illinois Open Source License/Copyright
233 !
234 ! Revision 1.2 2006/04/07 15:19:16 haselbac
235 ! Removed tabs
236 !
237 ! Revision 1.1 2006/03/26 20:20:56 haselbac
238 ! Initial revision
239 !
240 ! ******************************************************************************
241 
242 
243 
244 
245 
246 
247 
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
real(rfreal) function mixtliq_c2_bp(Bp)
Definition: MixtLiq_C.F90:54
subroutine rflu_printlocinfo(pRegion, locUnsorted, nLocUnsorted, locInfoMode, outputMode)
subroutine rflu_checkpositivity_gl(pRegion)
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