Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModExtractFlowDataUtils.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: Collect utility routines for extraction of data from flow solution.
26 !
27 ! Description: None.
28 !
29 ! Input: None.
30 !
31 ! Output: None.
32 !
33 ! Notes: None.
34 !
35 ! ******************************************************************************
36 !
37 ! $Id: RFLU_ModExtractFlowDataUtils.F90,v 1.4 2008/12/06 08:45:06 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2007 by the University of Illinois
40 !
41 ! ******************************************************************************
42 
44 
45  USE moddatatypes
46  USE modparameters
47  USE moderror
48  USE modglobal, ONLY: t_global
49  USE modgrid, ONLY: t_grid
50  USE modbndpatch, ONLY: t_patch
51  USE moddatastruct, ONLY: t_region
52 
53 #ifdef PLAG
55 #endif
56 
57  IMPLICIT NONE
58 
59 ! ******************************************************************************
60 ! Definitions and declarations
61 ! ******************************************************************************
62 
63 ! ==============================================================================
64 ! Private data
65 ! ==============================================================================
66 
67  CHARACTER(CHRLEN), PARAMETER, PRIVATE :: &
68  RCSIdentString = '$RCSfile: RFLU_ModExtractFlowDataUtils.F90,v $ $Revision: 1.4 $'
69 
70 ! ==============================================================================
71 ! Public functions
72 ! ==============================================================================
73 
75 
76 ! ==============================================================================
77 ! Private functions
78 ! ==============================================================================
79 
80 
81 
82 ! ******************************************************************************
83 ! Subroutines and functions
84 ! ******************************************************************************
85 
86  CONTAINS
87 
88 
89 
90 
91 ! ******************************************************************************
92 !
93 ! Purpose: Extract shock location for 1D cases.
94 !
95 ! Description: Look for location of largest density gradient and then,
96 ! starting from this position, determine position of zero second derivative,
97 ! which is then taken to be shock location.
98 !
99 ! Input:
100 ! pRegion Pointer to region
101 ! icgBeg Beginning cell index
102 ! icgEnd Ending cell index
103 ! nCellsX Number of cells in x-direction
104 !
105 ! Output:
106 ! xs Shock location
107 !
108 ! Notes:
109 ! 1. This routine can be used for 2d cases, but then the array numbering must
110 ! be such that the indices follow the longest direction.
111 !
112 ! ******************************************************************************
113 
114 SUBROUTINE rflu_extractshocklocation1d(pRegion,icgBeg,icgEnd,nCellsX,xs)
115 
116  IMPLICIT NONE
117 
118 ! ******************************************************************************
119 ! Declarations and definitions
120 ! ******************************************************************************
121 
122 ! ==============================================================================
123 ! Arguments
124 ! ==============================================================================
125 
126  INTEGER, INTENT(IN) :: icgbeg,icgend,ncellsx
127  REAL(RFREAL), INTENT(OUT) :: xs
128  TYPE(t_region), POINTER :: pregion
129 
130 ! ==============================================================================
131 ! Locals
132 ! ==============================================================================
133 
134  INTEGER :: errorflag,icg,icl,icloffs,iclshock
135  INTEGER :: dummy(1)
136  REAL(RFREAL) :: idx,r,rm1,rp1,rxx,rxxp1,x,xp1
137  REAL(RFREAL), DIMENSION(:), ALLOCATABLE :: gradx,gradxx
138  REAL(RFREAL), DIMENSION(:,:), POINTER :: pcv
139  TYPE(t_global), POINTER :: global
140  TYPE(t_grid), POINTER :: pgrid
141 
142 ! ******************************************************************************
143 ! Start
144 ! ******************************************************************************
145 
146  global => pregion%global
147 
148  CALL registerfunction(global,'RFLU_ExtractShockLocation1D', &
149  'RFLU_ModExtractFlowDataUtils.F90')
150 
151 ! ******************************************************************************
152 ! Set
153 ! ******************************************************************************
154 
155  pgrid => pregion%grid
156  pcv => pregion%mixt%cv
157 
158  icloffs = 4
159 
160 ! ******************************************************************************
161 ! Allocate temporary memory
162 ! ******************************************************************************
163 
164  ALLOCATE(gradx(ncellsx-2),stat=errorflag)
165  global%error = errorflag
166  IF ( global%error /= err_none ) THEN
167  CALL errorstop(global,err_allocate,__line__,'gradx')
168  END IF ! global%error
169 
170  ALLOCATE(gradxx(ncellsx-2),stat=errorflag)
171  global%error = errorflag
172  IF ( global%error /= err_none ) THEN
173  CALL errorstop(global,err_allocate,__line__,'gradxx')
174  END IF ! global%error
175 
176 ! ******************************************************************************
177 ! Compute first and second density derivatives and find location of maximum
178 ! (absolute) value of first derivative
179 ! ******************************************************************************
180 
181  DO icl = 1,ncellsx-2
182  icg = icgbeg + icl
183 
184  rp1 = pcv(cv_mixt_dens,icg+1)
185  r = pcv(cv_mixt_dens,icg )
186  rm1 = pcv(cv_mixt_dens,icg-1)
187 
188  gradx(icl) = 0.5_rfreal*(rp1-rm1)
189  gradxx(icl) = rp1-2.0_rfreal*r+rm1
190  END DO ! icl
191 
192  dummy = maxloc(abs(gradx(1:ncellsx-2)))
193  iclshock = dummy(1)
194 
195 ! ******************************************************************************
196 ! Starting from this location, search for zero crossing of second derivative
197 ! and then use linear approximation to compute location of zero crossing. NOTE
198 ! this search is carried out for iclOffs points on either side of location of
199 ! maximum (absolute) value of first derivative, so need to make sure do not step
200 ! out of bounds. If that is the case, simply pick shock location to be that cell
201 ! with maximum (absolute) value of first derivative.
202 ! ******************************************************************************
203 
204  IF ( (iclshock <= (ncellsx-icloffs-2)) .AND. &
205  (iclshock >= (icloffs+1)) ) THEN
206  DO icl = iclshock-icloffs,iclshock+icloffs-1
207  icg = icgbeg + icl
208 
209  IF ( sign(1.0_rfreal,gradxx(icl)) /= sign(1.0_rfreal,gradxx(icl+1)) ) THEN
210  rxxp1 = gradxx(icl+1)
211  rxx = gradxx(icl)
212 
213  xp1 = pgrid%cofg(xcoord,icg+1)
214  x = pgrid%cofg(xcoord,icg)
215 
216  xs = (x*rxxp1-xp1*rxx)/(rxxp1-rxx)
217  END IF ! SIGN
218  END DO ! icl
219  ELSE
220  xs = pgrid%cofg(xcoord,icgbeg+iclshock)
221  END IF ! icl
222 
223 ! ******************************************************************************
224 ! Deallocate temporary memory
225 ! ******************************************************************************
226 
227  DEALLOCATE(gradx,stat=errorflag)
228  global%error = errorflag
229  IF ( global%error /= err_none ) THEN
230  CALL errorstop(global,err_deallocate,__line__,'gradx')
231  END IF ! global%error
232 
233  DEALLOCATE(gradxx,stat=errorflag)
234  global%error = errorflag
235  IF ( global%error /= err_none ) THEN
236  CALL errorstop(global,err_deallocate,__line__,'gradxx')
237  END IF ! global%error
238 
239 ! ******************************************************************************
240 ! End
241 ! ******************************************************************************
242 
243  CALL deregisterfunction(global)
244 
245 END SUBROUTINE rflu_extractshocklocation1d
246 
247 
248 
249 
250 
252 
253 ! ******************************************************************************
254 !
255 ! RCS Revision history:
256 !
257 ! $Log: RFLU_ModExtractFlowDataUtils.F90,v $
258 ! Revision 1.4 2008/12/06 08:45:06 mtcampbe
259 ! Updated license.
260 !
261 ! Revision 1.3 2008/11/19 22:18:16 mtcampbe
262 ! Added Illinois Open Source License/Copyright
263 !
264 ! Revision 1.2 2007/04/12 00:27:49 haselbac
265 ! Changed to use zero of 2nd derivative to find shock location
266 !
267 ! Revision 1.1 2007/04/05 01:38:07 haselbac
268 ! Initial revision
269 !
270 ! ******************************************************************************
271 
272 
273 
274 
275 
276 
277 
unsigned char r() const
Definition: Color.h:68
static SURF_BEGIN_NAMESPACE double sign(double x)
subroutine, public rflu_extractshocklocation1d(pRegion, icgBeg, icgEnd, nCellsX, xs)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
void int int REAL * x
Definition: read.cpp:74
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469