Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_CheckGridSpeeds.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 grid speeds.
26 !
27 ! Description: Compute norms of difference of LHS and RHS of GCL.
28 !
29 ! Input:
30 ! pRegion Pointer to region
31 !
32 ! Output: None.
33 !
34 ! Notes: None.
35 !
36 !******************************************************************************
37 !
38 ! $Id: RFLU_CheckGridSpeeds.F90,v 1.6 2008/12/06 08:44:29 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2002 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 SUBROUTINE rflu_checkgridspeeds(pRegion)
45 
46  USE moddatatypes
47  USE modgrid, ONLY: t_grid
48  USE moddatastruct, ONLY: t_region
49  USE modbndpatch, ONLY: t_patch
50  USE modglobal, ONLY: t_global
51  USE moderror
52  USE modmpi
53  USE modparameters
54  USE modsortsearch
55 
56  USE rflu_modgrid
57 
58  IMPLICIT NONE
59 
60 ! *****************************************************************************
61 ! Declarations and definitions
62 ! *****************************************************************************
63 
64 ! =============================================================================
65 ! Arguments
66 ! =============================================================================
67 
68  TYPE(t_region), POINTER :: pregion
69 
70 ! =============================================================================
71 ! Locals
72 ! =============================================================================
73 
74  CHARACTER(CHRLEN) :: rcsidentstring
75  INTEGER :: c1,c2,errorflag,ic,ifc,indgs,ipatch
76  REAL(RFREAL) :: fs,nm,term
77  REAL(RFREAL), DIMENSION(:), ALLOCATABLE :: checksum,checksumsorted
78  REAL(RFREAL), DIMENSION(:,:), POINTER :: pxyz,pxyzold
79  TYPE(t_global), POINTER :: global
80  TYPE(t_grid), POINTER :: pgrid,pgridold
81  TYPE(t_patch), POINTER :: ppatch
82 
83 ! *****************************************************************************
84 ! Start
85 ! *****************************************************************************
86 
87  rcsidentstring = '$RCSfile: RFLU_CheckGridSpeeds.F90,v $ $Revision: 1.6 $'
88 
89  global => pregion%global
90 
91  CALL registerfunction(global,'RFLU_CheckGridSpeeds',&
92  'RFLU_CheckGridSpeeds.F90')
93 
94  IF ( global%myProcid == masterproc .AND. &
95  global%verbLevel > verbose_low ) THEN
96  WRITE(stdout,'(A,1X,A)') solver_name,'Checking grid speeds...'
97  END IF ! global%myProcid
98 
99 ! *****************************************************************************
100 ! Set pointers and variables
101 ! *****************************************************************************
102 
103  pgrid => pregion%grid
104  pgridold => pregion%gridOld
105 
106  indgs = pgrid%indGs
107 
108 ! *****************************************************************************
109 ! Allocate memory
110 ! *****************************************************************************
111 
112  ALLOCATE(checksum(pgrid%nCellsTot),stat=errorflag)
113  global%error = errorflag
114  IF ( global%error /= err_none ) THEN
115  CALL errorstop(global,err_allocate,__line__,'checkSum')
116  END IF ! global%error
117 
118  ALLOCATE(checksumsorted(pgrid%nCellsTot),stat=errorflag)
119  global%error = errorflag
120  IF ( global%error /= err_none ) THEN
121  CALL errorstop(global,err_allocate,__line__,'checkSumSorted')
122  END IF ! global%error
123 
124  DO ic = 1,pgrid%nCellsTot ! Explicit loop because of ASCI White problem
125  checksum(ic) = 0.0_rfreal
126  END DO ! ic
127 
128 ! *****************************************************************************
129 ! Interior faces
130 ! *****************************************************************************
131 
132  DO ifc = 1,pgrid%nFaces
133  c1 = pgrid%f2c(1,ifc)
134  c2 = pgrid%f2c(2,ifc)
135 
136  nm = pgrid%fn(xyzmag,ifc)
137  fs = pgrid%gs(indgs*ifc)
138 
139  checksum(c1) = checksum(c1) + fs*nm
140  checksum(c2) = checksum(c2) - fs*nm
141  END DO ! ifc
142 
143 ! *****************************************************************************
144 ! Boundary faces
145 ! *****************************************************************************
146 
147  DO ipatch = 1,pgrid%nPatches
148  ppatch => pregion%patches(ipatch)
149 
150  DO ifc = 1,ppatch%nBFaces
151  c1 = ppatch%bf2c(ifc)
152 
153  nm = ppatch%fn(xyzmag,ifc)
154  fs = ppatch%gs(indgs*ifc)
155 
156  checksum(c1) = checksum(c1) + fs*nm
157  END DO ! ifc
158  END DO ! iPatch
159 
160 ! *****************************************************************************
161 ! Check values and compute norms
162 ! *****************************************************************************
163 
164  DO ic = 1,pgrid%nCells
165  checksum(ic) = checksum(ic)*global%dtMin - (pgrid%vol(ic)-pgridold%vol(ic))
166  checksumsorted(ic) = checksum(ic)
167  END DO ! ic
168 
169  CALL quicksortrfreal(checksumsorted(1:pgrid%nCells),pgrid%nCells)
170 
171  term = 0.0_rfreal
172 
173  DO ic = 1,pgrid%nCells
174  term = term + checksumsorted(ic)*checksumsorted(ic)
175  END DO ! ic
176 
177  term = sqrt(term/REAL(pgrid%ncells,rfreal))
178 
179  IF ( global%myProcid == masterproc .AND. &
180  global%verbLevel > verbose_low ) THEN
181  WRITE(stdout,'(A,3X,A)') solver_name,'Error in GCL:'
182  WRITE(stdout,'(A,5X,A,1X,E15.8)') solver_name,'L2-norm:',term
183  WRITE(stdout,'(A,5X,A,1X,E15.8,1X,I6)') solver_name,'L8-norm:', &
184  maxval(checksum(1:pgrid%nCells)), &
185  maxloc(checksum(1:pgrid%nCells))
186  END IF ! global%myProcid
187 
188 ! *****************************************************************************
189 ! End
190 ! *****************************************************************************
191 
192  DEALLOCATE(checksum,stat=errorflag)
193  global%error = errorflag
194  IF ( global%error /= err_none ) THEN
195  CALL errorstop(global,err_deallocate,__line__,'checkSum')
196  END IF ! global%error
197 
198  DEALLOCATE(checksumsorted,stat=errorflag)
199  global%error = errorflag
200  IF ( global%error /= err_none ) THEN
201  CALL errorstop(global,err_deallocate,__line__,'checkSum')
202  END IF ! global%error
203 
204  IF ( global%myProcid == masterproc .AND. &
205  global%verbLevel > verbose_low ) THEN
206  WRITE(stdout,'(A,1X,A)') solver_name,'Checking grid speeds done.'
207  END IF ! global%myProcid
208 
209  CALL deregisterfunction(global)
210 
211 END SUBROUTINE rflu_checkgridspeeds
212 
213 !******************************************************************************
214 !
215 ! RCS Revision history:
216 !
217 ! $Log: RFLU_CheckGridSpeeds.F90,v $
218 ! Revision 1.6 2008/12/06 08:44:29 mtcampbe
219 ! Updated license.
220 !
221 ! Revision 1.5 2008/11/19 22:17:42 mtcampbe
222 ! Added Illinois Open Source License/Copyright
223 !
224 ! Revision 1.4 2003/03/27 14:32:18 haselbac
225 ! Fixed bug: Must not use MINLOC/MAXLOC on sorted list
226 !
227 ! Revision 1.3 2003/03/15 18:25:54 haselbac
228 ! Changed loop limit
229 !
230 ! Revision 1.2 2003/01/28 14:27:13 haselbac
231 ! Cosmetic changes only, use parameters in fn
232 !
233 ! Revision 1.1 2002/11/08 21:55:20 haselbac
234 ! Initial revision
235 !
236 ! Revision 1.1 2002/10/27 19:20:08 haselbac
237 ! Initial revision
238 !
239 !******************************************************************************
240 
241 
242 
243 
244 
245 
246 
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 ic
double sqrt(double d)
Definition: double.h:73
subroutine quicksortrfreal(a, n)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine rflu_checkgridspeeds(pRegion)
subroutine deregisterfunction(global)
Definition: ModError.F90:469