Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ComputeExactFlowProbeError.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: Compute errors of computed solution relative to exact solution at
26 ! probe locations.
27 !
28 ! Description: None.
29 !
30 ! Input:
31 ! pRegion Pointer to region
32 !
33 ! Output: None.
34 !
35 ! Notes:
36 ! 1. This routine assumes a perfect gas.
37 !
38 ! ******************************************************************************
39 !
40 ! $Id: RFLU_ComputeExactFlowProbeError.F90,v 1.3 2008/12/06 08:45:05 mtcampbe Exp $
41 !
42 ! Copyright: (c) 2005 by the University of Illinois
43 !
44 ! ******************************************************************************
45 
47 
48  USE moddatatypes
49  USE moderror
50  USE moddatastruct, ONLY: t_region
51  USE modmixture, ONLY: t_mixt_input
52  USE modglobal, ONLY: t_global
53  USE modgrid, ONLY: t_grid
54  USE modparameters
55 
56  USE rflu_modbessel
59 
60  USE modinterfaces, ONLY: mixtperf_d_cgp, &
62 
63  IMPLICIT NONE
64 
65 ! ******************************************************************************
66 ! Declarations and definitions
67 ! ******************************************************************************
68 
69 ! ==============================================================================
70 ! Arguments
71 ! ==============================================================================
72 
73  TYPE(t_region), POINTER :: pregion
74 
75 ! ==============================================================================
76 ! Locals
77 ! ==============================================================================
78 
79  LOGICAL :: printerrornorms
80  CHARACTER(CHRLEN) :: ifilename,rcsidentstring
81  INTEGER :: errorflag,ibc,icg,im,in,iprobe,iq
82  REAL(RFREAL) :: atot,const,cpgas,dc,de,dinc,dtot,dummyreal,etaqm,ggas, &
83  idc,l,omega,pc,pe,probetime,ptot,rgas,ro,term,tc,ttot,uc, &
84  ue,vc,ve,wc,we,x,y,z
85  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv,pdv
86  TYPE(t_global), POINTER :: global
87  TYPE(t_grid), POINTER :: pgrid
88  TYPE(t_mixt_input), POINTER :: pmixtinput
89 
90 ! ******************************************************************************
91 ! Start
92 ! ******************************************************************************
93 
94  rcsidentstring = '$RCSfile: RFLU_ComputeExactFlowProbeError.F90,v $ $Revision: 1.3 $'
95 
96  global => pregion%global
97 
98  CALL registerfunction(global,'RFLU_ComputeExactFlowProbeError', &
99  'RFLU_ComputeExactFlowProbeError.F90')
100 
101  IF ( global%verbLevel > verbose_none ) THEN
102  WRITE(stdout,'(A,1X,A)') solver_name, &
103  'Computing errors in flow solution at probe locations...'
104 
105  IF ( global%verbLevel > verbose_low ) THEN
106  WRITE(stdout,'(A,3X,A,A)') solver_name,'Case: ',trim(global%casename)
107  END IF ! global%verbLevel
108  END IF ! global%verbLevel
109 
110 ! ==============================================================================
111 ! Set pointers
112 ! ==============================================================================
113 
114  pgrid => pregion%grid
115  pcv => pregion%mixt%cv
116  pdv => pregion%mixt%dv
117  pmixtinput => pregion%mixtInput
118 
119 ! ==============================================================================
120 ! Set constants and initialize variables
121 ! ==============================================================================
122 
123  cpgas = global%refCp
124  ggas = global%refGamma
125  rgas = mixtperf_r_cpg(cpgas,ggas)
126 
127 ! ******************************************************************************
128 ! Compute errors in probe quantities
129 ! ******************************************************************************
130 
131  SELECT CASE ( global%casename )
132 
133 ! ==============================================================================
134 ! Pipe acoustics. NOTE the pipe is assumed to have the x-coordinate
135 ! running down the axis.
136 ! ==============================================================================
137 
138  CASE ( "pipeacoust" )
139  CALL rflu_getparamshardcodepacoust(ptot,atot)
140  dtot = mixtperf_d_cgp(atot,ggas,ptot)
141 
142  l = maxval(pgrid%xyz(xcoord,1:pgrid%nVert))
143  ro = maxval(pgrid%xyz(ycoord,1:pgrid%nVert))
144 
145  im = max(pmixtinput%prepIntVal1,1)
146  in = max(pmixtinput%prepIntVal2,1)
147  iq = max(pmixtinput%prepIntVal3,1)
148  ibc = max(min(pmixtinput%prepIntVal4,1),0)
149 
150  const = max(pmixtinput%prepRealVal1,0.0_rfreal)
151 
152  CALL rflu_jyzom(im,iq,dummyreal,etaqm,dummyreal,dummyreal)
153 
154  omega = atot*sqrt((in*global%pi/l)**2 + (etaqm/ro)**2)
155 
156  IF ( global%verbLevel > verbose_low ) THEN
157  WRITE(stdout,'(A,5X,A,1X,I2)' ) solver_name, &
158  'Boundary condition:',ibc
159  WRITE(stdout,'(A,5X,A,3(1X,I2))') solver_name, &
160  'Mode:',im,in,iq
161  WRITE(stdout,'(A,5X,A,1X,E13.6)') solver_name, &
162  'Total density (kg/m^3): ',dtot
163  WRITE(stdout,'(A,5X,A,1X,E13.6)') solver_name, &
164  'Total pressure (N/m^2): ',ptot
165  WRITE(stdout,'(A,5X,A,1X,E13.6)') solver_name, &
166  'Angular frequency (rad/s):',omega
167  WRITE(stdout,'(A,5X,A,1X,E13.6)') solver_name, &
168  'Constant (-): ',const
169  END IF ! global%verbLevel
170 
171 ! ------------------------------------------------------------------------------
172 ! Loop over probes and compute error: NOTE need to rewind because opening
173 ! of probe file positions file at end.
174 ! ------------------------------------------------------------------------------
175 
176  DO iprobe = 1,global%nProbes
177  IF ( global%probePos(iprobe,probe_region) == &
178  pregion%iRegionGlobal ) THEN
179  icg = global%probePos(iprobe,probe_cell)
180 
181  rewind(if_probe+iprobe-1)
182 
183  WRITE(ifilename,'(A,I4.4)') trim(global%outDir)// &
184  trim(global%casename)//'.prbe_',iprobe
185  OPEN(if_extr_data1,file=trim(ifilename),form='FORMATTED', &
186  status='UNKNOWN',iostat=errorflag)
187  global%error = errorflag
188  IF (global%error /= err_none ) THEN
189  CALL errorstop(global,err_file_open,__line__, &
190  'File: '//trim(ifilename))
191  END IF ! global%error
192 
193  emptyloop: DO
194  READ(if_probe+iprobe-1,*,iostat=errorflag) probetime, &
195  dc,uc,vc,wc,pc,tc
196  IF ( errorflag /= err_none ) THEN
197  EXIT emptyloop
198  END IF ! errorFlag
199 
200  x = pgrid%cofg(xcoord,icg)
201  y = pgrid%cofg(ycoord,icg)
202  z = pgrid%cofg(zcoord,icg)
203 
204  CALL rflu_computeexactflowpacoust(global,z,y,x,probetime,l,ro, &
205  ibc,im,in,iq,etaqm,omega, &
206  dtot,ptot,atot,const,de,ue, &
207  ve,we,pe)
208 
209  WRITE(if_extr_data1,'(1PE14.7,3(1X,E13.6))') &
210  probetime,pe,pc,((pc-ptot)/(pe-ptot)-1.0_rfreal)
211  END DO emptyloop
212 
213  CLOSE(if_extr_data1,iostat=errorflag)
214  global%error = errorflag
215  IF (global%error /= err_none ) THEN
216  CALL errorstop(global,err_file_close,__line__, &
217  'File: '//trim(ifilename))
218  END IF ! global%error
219  END IF ! global%probePos
220  END DO ! iProbe
221 
222 ! ==============================================================================
223 ! Default - due to input error or missing CALL in this routine
224 ! ==============================================================================
225 
226  CASE default
227  global%warnCounter = global%warnCounter + 1
228 
229  IF ( global%verbLevel > verbose_none ) THEN
230  WRITE(stdout,'(A,3X,A,1X,A)') solver_name,'*** WARNING ***', &
231  'Exact solution not available. Returning to calling procedure.'
232  END IF ! global%verbLevel
233  END SELECT ! global%casename
234 
235 ! ******************************************************************************
236 ! End
237 ! ******************************************************************************
238 
239  IF ( global%verbLevel > verbose_none ) THEN
240  WRITE(stdout,'(A,1X,A)') solver_name, &
241  'Computing errors in flow solution at probe locations done.'
242  END IF ! global%verbLevel
243 
244  CALL deregisterfunction(global)
245 
246 END SUBROUTINE rflu_computeexactflowprobeerror
247 
248 ! ******************************************************************************
249 !
250 ! RCS Revision history:
251 !
252 ! $Log: RFLU_ComputeExactFlowProbeError.F90,v $
253 ! Revision 1.3 2008/12/06 08:45:05 mtcampbe
254 ! Updated license.
255 !
256 ! Revision 1.2 2008/11/19 22:18:16 mtcampbe
257 ! Added Illinois Open Source License/Copyright
258 !
259 ! Revision 1.1 2005/04/29 12:41:32 haselbac
260 ! Initial revision
261 !
262 ! ******************************************************************************
263 
264 
265 
266 
267 
268 
269 
void int int REAL REAL * y
Definition: read.cpp:74
subroutine, public rflu_computeexactflowpacoust(global, x, y, z, t, L, ro, iBc, im, in, iq, etaqm, omega, dTot, pTot, aTot, const, d, u, v, w, p)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
double sqrt(double d)
Definition: double.h:73
subroutine, public rflu_jyzom(N, M, RJ0M, RJ1M, RY0M, RY1M)
real(rfreal) function mixtperf_r_cpg(Cp, G)
Definition: MixtPerf_R.F90:39
void int int int REAL REAL REAL * z
Definition: write.cpp:76
subroutine rflu_computeexactflowprobeerror(pRegion)
void int int REAL * x
Definition: read.cpp:74
real(rfreal) function mixtperf_d_cgp(C, G, P)
Definition: MixtPerf_D.F90:40
**********************************************************************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 form
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine, public rflu_getparamshardcodepacoust(pTot, aTot)