Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_CheckValidity.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.F90,v 1.7 2008/12/06 08:44:11 mtcampbe Exp $
42 !
43 ! Copyright: (c) 2003-2006 by the University of Illinois
44 !
45 ! ******************************************************************************
46 
47 SUBROUTINE rflu_checkvalidity(pRegion)
48 
49  USE moddatatypes
50  USE moderror
51  USE modglobal, ONLY: t_global
52  USE moddatastruct, ONLY: t_region
53  USE modparameters
54  USE modmpi
55  USE modtools, ONLY: isnan
56 
57  USE modinterfaces, ONLY: mixtperf_g_cpr, &
59  mixtperf_r_m, &
62 
63  IMPLICIT NONE
64 
65 ! ******************************************************************************
66 ! Definitions and declarations
67 ! ******************************************************************************
68 
69 ! ==============================================================================
70 ! Arguments
71 ! ==============================================================================
72 
73  TYPE(t_region), POINTER :: pregion
74 
75 ! ==============================================================================
76 ! Locals
77 ! ==============================================================================
78 
79  CHARACTER(CHRLEN) :: rcsidentstring
80  INTEGER, PARAMETER :: max_invalid_locs = 10
81  INTEGER :: icg,indcp,indmol,nlocs
82  INTEGER :: loc(max_invalid_locs,min_val:max_val)
83  REAL(RFREAL) :: eo,gamma,p,rgas,rho,rrho,t,u,v,vm2,w
84  REAL(RFREAL), DIMENSION(:,:), POINTER :: cv,gv
85  TYPE(t_global), POINTER :: global
86 
87 ! ******************************************************************************
88 ! Start
89 ! ******************************************************************************
90 
91  rcsidentstring = '$RCSfile: RFLU_CheckValidity.F90,v $ $Revision: 1.7 $'
92 
93  global => pregion%global
94 
95  CALL registerfunction(global,'RFLU_CheckValidity',&
96  'RFLU_CheckValidity.F90')
97 
98  nlocs = 0
99 
100 #ifdef ROCPROF
101  CALL fprofiler_begins("RFLU::CheckValidity")
102 #endif
103 
104 ! ******************************************************************************
105 ! Loop over cells and check for positivity
106 ! ******************************************************************************
107 
108  cv => pregion%mixt%cv
109  gv => pregion%mixt%gv
110 
111  indcp = pregion%mixtInput%indCp
112  indmol = pregion%mixtInput%indMol
113 
114  DO icg = 1,pregion%grid%nCells
115  rho = cv(cv_mixt_dens,icg)
116  rrho = 1.0_rfreal/rho
117  u = rrho*cv(cv_mixt_xmom,icg)
118  v = rrho*cv(cv_mixt_ymom,icg)
119  w = rrho*cv(cv_mixt_zmom,icg)
120  eo = rrho*cv(cv_mixt_ener,icg)
121  rgas = mixtperf_r_m(gv(gv_mixt_mol,icg*indmol))
122  gamma= mixtperf_g_cpr(gv(gv_mixt_cp,icg*indcp),rgas)
123  vm2 = u*u + v*v + w*w
124  p = mixtperf_p_deogvm2(rho,eo,gamma,vm2)
125  t = mixtperf_t_dpr(rho,p,rgas)
126 
127  IF ( (isnan(rho) .EQV. .true.) .OR. &
128  (isnan(u) .EQV. .true.) .OR. &
129  (isnan(v) .EQV. .true.) .OR. &
130  (isnan(w) .EQV. .true.) .OR. &
131  (isnan(p) .EQV. .true.) .OR. &
132  (isnan(t) .EQV. .true.) ) THEN
133  nlocs = nlocs + 1
134 
135  IF ( nlocs == 1 ) THEN
136  WRITE(stdout,'(A,1X,A,1X,I9)') solver_name, &
137  'Invalid variables detected!'
138 
139  IF ( global%flowType == flow_unsteady ) THEN
140  WRITE(stdout,'(A,3X,A,1X,1PE12.5)') solver_name,'Current time:', &
141  global%currentTime
142  ELSE
143  WRITE(stdout,'(A,3X,A,1X,I6)') solver_name, &
144  'Current iteration number:', &
145  global%currentIter
146  END IF ! global%flowType
147 
148  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
149  pregion%iRegionGlobal
150  WRITE(stdout,'(A,6X,A,6(1X,A))') solver_name,'#', &
151  ' Density ', &
152  ' x-velocity ', &
153  ' y-velocity ', &
154  ' z-velocity ', &
155  ' Pressure ', &
156  ' Temperature '
157  END IF ! nLocs
158 
159  IF ( nlocs <= max_invalid_locs ) THEN
160  WRITE(stdout,'(A,4X,I3,6(1X,E13.6))') solver_name,nlocs, &
161  rho,u,v,w,p,t
162  loc(nlocs,min_val:max_val) = icg
163  END IF ! nLocs
164  END IF ! cv
165  END DO ! icg
166 
167 ! ******************************************************************************
168 ! Write out message and call error handling routine
169 ! ******************************************************************************
170 
171  IF ( nlocs > 0 ) THEN
172  IF ( nlocs > max_invalid_locs ) THEN
173  WRITE(stdout,'(A,3X,A,1X,I3,1X,A,1X,I9,1X,A)') solver_name, &
174  'Only wrote the first',max_invalid_locs,'of',nlocs, &
175  'cells with invalid variables.'
176  CALL rflu_printlocinfo(pregion,loc,max_invalid_locs, &
177  locinfo_mode_silent,output_mode_anybody)
178  ELSE
179  CALL rflu_printlocinfo(pregion,loc(1:nlocs,min_val:max_val),nlocs, &
180  locinfo_mode_silent,output_mode_anybody)
181  END IF ! nLocs
182 
183  CALL errorstop(global,err_invalid_value,__line__)
184  END IF ! nLocs
185 
186 ! ******************************************************************************
187 ! End
188 ! ******************************************************************************
189 
190 #ifdef ROCPROF
191  CALL fprofiler_ends("RFLU::CheckValidity")
192 #endif
193 
194  CALL deregisterfunction( global )
195 
196 END SUBROUTINE rflu_checkvalidity
197 
198 ! ******************************************************************************
199 !
200 ! RCS Revision history:
201 !
202 ! $Log: RFLU_CheckValidity.F90,v $
203 ! Revision 1.7 2008/12/06 08:44:11 mtcampbe
204 ! Updated license.
205 !
206 ! Revision 1.6 2008/11/19 22:17:25 mtcampbe
207 ! Added Illinois Open Source License/Copyright
208 !
209 ! Revision 1.5 2006/04/07 15:19:16 haselbac
210 ! Removed tabs
211 !
212 ! Revision 1.4 2006/03/26 20:21:30 haselbac
213 ! Removed dv declaration and definition
214 !
215 ! Revision 1.3 2005/07/07 22:44:00 haselbac
216 ! Added profiling calls, cosmetics
217 !
218 ! Revision 1.2 2004/01/11 02:06:38 jiao
219 ! Eliminated some redundant trailing spaces that made some lines too long.
220 ! This changed was needed to compile with NAG F90 compiler.
221 !
222 ! Revision 1.1 2003/12/04 03:23:33 haselbac
223 ! Initial revision
224 !
225 ! ******************************************************************************
226 
227 
228 
229 
230 
231 
232 
real(rfreal) function mixtperf_p_deogvm2(D, Eo, G, Vm2)
Definition: MixtPerf_P.F90:39
real(rfreal) function mixtperf_r_m(M)
Definition: MixtPerf_R.F90:54
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
*********************************************************************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
subroutine rflu_checkvalidity(pRegion)
logical function isnan(x)
Definition: ModTools.F90:201
real(rfreal) function mixtperf_t_dpr(D, P, R)
Definition: MixtPerf_T.F90:85
subroutine rflu_printlocinfo(pRegion, locUnsorted, nLocUnsorted, locInfoMode, outputMode)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
real(rfreal) function mixtperf_g_cpr(Cp, R)
Definition: MixtPerf_G.F90:39