Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_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: It detects NaN solution and/or negative pressure or density.
28 !
29 ! Input: region = Region data
30 !
31 ! Output: none.
32 !
33 ! Notes: none.
34 !
35 !******************************************************************************
36 !
37 ! $Id: RFLO_CheckValidity.F90,v 1.6 2008/12/06 08:44:06 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2003 by the University of Illinois
40 !
41 !******************************************************************************
42 
43 SUBROUTINE rflo_checkvalidity(region)
44 
45  USE moddatatypes
46  USE moderror
47  USE modglobal, ONLY: t_global
48  USE moddatastruct, ONLY: t_region
49  USE modbndpatch, ONLY: t_patch
50  USE modparameters
51  USE modmpi
52  USE modtools, ONLY: isnan
56 
57  IMPLICIT NONE
58 #include "Indexing.h"
59 
60 ! ... parameters
61  TYPE(t_region), TARGET :: region
62 
63 ! ... loop variables
64  INTEGER :: i, j, k, ipatch
65 
66 ! ... local variables
67  TYPE(t_global), POINTER :: global
68  TYPE(t_patch), POINTER :: patches(:)
69 
70  INTEGER, PARAMETER :: max_invalid_locs = 10
71  INTEGER :: ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend
72  INTEGER :: ilev, icoff, ijcoff, ijkc
73  INTEGER :: indcp,indmol,nlocs
74 #ifdef MPI
75  INTEGER :: mpierrcode
76 #endif
77  REAL(RFREAL) :: eo,gamma,p,rgas,rho,rrho,t,u,v,vm2,w,rmin,pmin
78  REAL(RFREAL), DIMENSION(:,:), POINTER :: cv,gv
79  LOGICAL :: foundnan
80 
81 !******************************************************************************
82 
83  global => region%global
84 
85  CALL registerfunction(global,'RFLO_CheckValidity',&
86  'RFLO_CheckValidity.F90')
87 
88  nlocs = 0
89 
90 ! get dimensions and pointers -------------------------------------------------
91 
92  ilev = region%currLevel
93 
94  CALL rflo_getdimensphys( region,ilev,ipcbeg,ipcend, &
95  jpcbeg,jpcend,kpcbeg,kpcend )
96  CALL rflo_getcelloffset( region,ilev,icoff,ijcoff )
97 
98  cv => region%levels(ilev)%mixt%cv
99  gv => region%levels(ilev)%mixt%gv
100  patches => region%levels(ilev)%patches
101 
102  indcp = region%levels(ilev)%mixt%indCp
103  indmol = region%levels(ilev)%mixt%indMol
104 
105 ! loop over cells and check for positivity ------------------------------------
106 
107  rmin = 1.e+13_rfreal
108  pmin = 1.e+13_rfreal
109  foundnan = .false.
110 
111  DO k=kpcbeg,kpcend
112  DO j=jpcbeg,jpcend
113  DO i=ipcbeg,ipcend
114  ijkc = indijk(i,j,k,icoff,ijcoff)
115 
116  rho = cv(cv_mixt_dens,ijkc)
117  rrho = 1.0_rfreal/rho
118  u = rrho*cv(cv_mixt_xmom,ijkc)
119  v = rrho*cv(cv_mixt_ymom,ijkc)
120  w = rrho*cv(cv_mixt_zmom,ijkc)
121  eo = rrho*cv(cv_mixt_ener,ijkc)
122 
123  rgas = mixtperf_r_m(gv(gv_mixt_mol,ijkc*indmol))
124  gamma = mixtperf_g_cpr(gv(gv_mixt_cp,ijkc*indcp),rgas)
125  vm2 = u*u + v*v + w*w
126 
127  p = mixtperf_p_deogvm2(rho,eo,gamma,vm2)
128 
129  rmin = min( rmin,rho )
130  pmin = min( pmin,p )
131 
132  foundnan = isnan(rho)
133  IF (foundnan) goto 888
134 
135  ENDDO ! i
136  ENDDO ! j
137  ENDDO ! k
138 
139 888 CONTINUE
140 
141  IF (foundnan .OR. rmin < 0._rfreal .OR. pmin < 0._rfreal) THEN
142 
143  DO k=kpcbeg,kpcend
144  DO j=jpcbeg,jpcend
145  DO i=ipcbeg,ipcend
146  ijkc = indijk(i,j,k,icoff,ijcoff)
147 
148  rho = cv(cv_mixt_dens,ijkc)
149  rrho = 1.0_rfreal/rho
150  u = rrho*cv(cv_mixt_xmom,ijkc)
151  v = rrho*cv(cv_mixt_ymom,ijkc)
152  w = rrho*cv(cv_mixt_zmom,ijkc)
153  eo = rrho*cv(cv_mixt_ener,ijkc)
154 
155  rgas = mixtperf_r_m(gv(gv_mixt_mol,ijkc*indmol))
156  gamma = mixtperf_g_cpr(gv(gv_mixt_cp,ijkc*indcp),rgas)
157  vm2 = u*u + v*v + w*w
158 
159  p = mixtperf_p_deogvm2(rho,eo,gamma,vm2)
160  t = mixtperf_t_dpr(rho,p,rgas)
161 
162  IF ( (isnan(rho) .EQV. .true.) .OR. &
163  (isnan(u) .EQV. .true.) .OR. &
164  (isnan(v) .EQV. .true.) .OR. &
165  (isnan(w) .EQV. .true.) .OR. &
166  (isnan(p) .EQV. .true.) .OR. &
167  (isnan(t) .EQV. .true.) .OR. &
168  ( rho < 0._rfreal) .OR. &
169  ( p < 0._rfreal) ) THEN
170  nlocs = nlocs + 1
171 
172  IF ( nlocs == 1 ) THEN
173  WRITE(stdout,'(A,1X,A,1X,I9)') solver_name, &
174  'Invalid variables detected!'
175 
176  IF ( global%flowType == flow_unsteady ) THEN
177  WRITE(stdout,'(A,3X,A,1X,1PE12.5)') solver_name, &
178  'Current time:', &
179  global%currentTime
180  ELSE
181  WRITE(stdout,'(A,3X,A,1X,I6)') solver_name, &
182  'Current iteration number:', &
183  global%currentIter
184  END IF ! global%flowType
185 
186  WRITE(stdout,1000) solver_name,'Region:',region%iRegionGlobal, &
187  ', bc-types:', (patches(ipatch)%bcType, &
188  ipatch = 1,region%nPatches)
189 
190  WRITE(stdout,'(A,6X,A,7(1X,A))') solver_name,'#', &
191  ' Density ', &
192  ' x-velocity ', &
193  ' y-velocity ', &
194  ' z-velocity ', &
195  ' Pressure ', &
196  ' Temperature ', &
197  ' i , j , k'
198  END IF ! nLocs
199 
200  IF ( nlocs <= max_invalid_locs ) THEN
201  WRITE(stdout,'(A,4X,I3,6(1X,E13.6),2X,3I7)') solver_name,nlocs, &
202  rho,u,v,w,p,t,i,j,k
203  END IF ! nLocs
204  END IF ! dv
205  ENDDO ! i
206  ENDDO ! j
207  ENDDO ! k
208 
209 #ifdef MPI
210  CALL mpi_abort( global%mpiComm,mpierrcode,global%mpierr )
211 #endif
212  stop
213  ENDIF ! foundNan...
214 
215 ! finalize --------------------------------------------------------------------
216 
217 1000 FORMAT( a,3x,a,i5,a,60i5 )
218 
219  CALL deregisterfunction( global )
220 
221 END SUBROUTINE rflo_checkvalidity
222 
223 !******************************************************************************
224 !
225 ! RCS Revision history:
226 !
227 ! $Log: RFLO_CheckValidity.F90,v $
228 ! Revision 1.6 2008/12/06 08:44:06 mtcampbe
229 ! Updated license.
230 !
231 ! Revision 1.5 2008/11/19 22:17:20 mtcampbe
232 ! Added Illinois Open Source License/Copyright
233 !
234 ! Revision 1.4 2005/05/12 21:31:14 wasistho
235 ! write i,j,k in the same line as previous vars
236 !
237 ! Revision 1.3 2005/05/12 20:53:51 wasistho
238 ! added bctypes in error msg
239 !
240 ! Revision 1.2 2005/01/11 00:26:15 wasistho
241 ! changed mpi_finalize to mpi_abort
242 !
243 ! Revision 1.1 2004/11/29 21:25:16 wasistho
244 ! lower to upper case
245 !
246 ! Revision 1.6 2004/08/24 01:02:23 wasistho
247 ! search nan per cell i.o. the sum value
248 !
249 ! Revision 1.5 2004/08/16 17:05:52 wasistho
250 ! moved MPI finalize within IF statement
251 !
252 ! Revision 1.4 2004/08/04 00:29:35 wasistho
253 ! speedup check validity
254 !
255 ! Revision 1.3 2004/07/26 20:03:13 wasistho
256 ! added i,j,k locations
257 !
258 ! Revision 1.2 2004/07/26 19:30:44 wasistho
259 ! changed POINTER to TARGET for region parameter
260 !
261 ! Revision 1.1 2004/07/26 19:10:06 wasistho
262 ! initial import RFLO_CheckValidity
263 !
264 !
265 !******************************************************************************
266 
267 
268 
269 
270 
271 
272 
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
j indices k indices k
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE kpcbeg
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE jpcbeg
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE ipcend
*********************************************************************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
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE ipcbeg
logical function isnan(x)
Definition: ModTools.F90:201
blockLoc i
Definition: read.cpp:79
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
void int int REAL * x
Definition: read.cpp:74
real(rfreal) function mixtperf_t_dpr(D, P, R)
Definition: MixtPerf_T.F90:85
subroutine rflo_checkvalidity(region)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
j indices j
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE jpcend
subroutine deregisterfunction(global)
Definition: ModError.F90:469
real(rfreal) function mixtperf_g_cpr(Cp, R)
Definition: MixtPerf_G.F90:39
subroutine rflo_getdimensphys(region, iLev, ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend)
RT a() const
Definition: Line_2.h:140