Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ComputeIntegral2OLES.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 integral 2 of optimal LES approach.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! pRegion Pointer to current region
31 !
32 ! Output: None.
33 !
34 ! Notes: None.
35 !
36 !******************************************************************************
37 !
38 ! $Id: RFLU_ComputeIntegral2OLES.F90,v 1.7 2008/12/06 08:44:29 mtcampbe Exp $
39 !
40 ! Copyright: (c) 2002 by the University of Illinois
41 !
42 !******************************************************************************
43 
44 SUBROUTINE rflu_computeintegral2oles(pRegion)
45 
46  USE moddatatypes
47  USE moddatastruct, ONLY : t_region
48  USE modgrid, ONLY: t_grid
49  USE moderror
50  USE modglobal, ONLY: t_global
51  USE modparameters
52  USE modmpi
53 
55 
56  USE rflu_modoles
57 
58  IMPLICIT NONE
59 
60 ! --- parameters
61 
62  TYPE(t_region), POINTER :: pregion
63 
64 ! --- local variables
65 
66  INTEGER :: c1g,c2g,errorflag,hloc,iint,ic1l,ic2l,ifc,ifcp,ifun,ifunnz,j, &
67  key,l,loopcounter,m,n,ncells,nfun,nfunnz,restartflag,vloc
68  REAL(RFREAL) :: normfact,normfactterm
69 
70  TYPE(t_grid), POINTER :: pgrid
71  TYPE(t_global), POINTER :: global
72 
73 ! ==============================================================================
74 ! Start
75 ! ==============================================================================
76 
77  global => pregion%global
78 
79  CALL registerfunction(global,'RFLU_ComputeIntegral2OLES',&
80  'RFLU_ComputeIntegral2OLES.F90')
81 
82  IF ( global%myProcid == masterproc .AND. &
83  global%verbLevel > verbose_low ) THEN
84  WRITE(stdout,'(A,3X,A)') solver_name,'Computing integral 2...'
85  END IF ! global%verbLevel
86 
87 ! ==============================================================================
88 ! Set grid pointer
89 ! ==============================================================================
90 
91  pgrid => pregion%grid
92 
93 ! ==============================================================================
94 ! Set various quantities
95 ! ==============================================================================
96 
97 ! ------------------------------------------------------------------------------
98 ! Set normalization factor term, modified inside face loop
99 ! ------------------------------------------------------------------------------
100 
101  normfactterm = 1.0_rfreal/pgrid%deltaOLES**6
102 
103 ! ------------------------------------------------------------------------------
104 ! Set DCUHRE parameters
105 ! ------------------------------------------------------------------------------
106 
107  ndim = 6
108  nfun = 9
109  nfunnz = 3
110  key = 0 ! Use accurate integration
111 
112  errabsreq = 10.0_rfreal*epsilon(1.0_rfreal)
113  errrelreq = 2.0e-3_rfreal
114 
115 ! ------------------------------------------------------------------------------
116 ! Compute DCUHRE information and allocate arrays
117 ! ------------------------------------------------------------------------------
118 
119  maxcalls = max_calls_limit
120 
121  CALL rflu_computedcuhreinfo(global,ndim,nfun,key,maxcalls,workarraysize)
122  CALL rflu_allocatedcuhrearrays(global,ndim,nfunnz,nfun)
123 
124  ALLOCATE(workarray(workarraysize),stat=errorflag)
125  global%error = errorflag
126  IF ( global%error /= err_none ) THEN
127  CALL errorstop(global,err_allocate,__line__,'workArray')
128  END IF ! global%error
129 
130  ALLOCATE(integral(nfun),stat=errorflag)
131  global%error = errorflag
132  IF ( global%error /= err_none ) THEN
133  CALL errorstop(global,err_allocate,__line__,'integral')
134  END IF ! global%error
135 
136  integral(:) = 0.0_rfreal
137  integralnz(:) = 0.0_rfreal
138 
139 ! ------------------------------------------------------------------------------
140 ! Set non-zero functions
141 ! ------------------------------------------------------------------------------
142 
143  CALL rflu_setmapfunnz2funcorr22(nfunnz)
144 
145 ! ==============================================================================
146 ! Loop over protoype faces
147 ! ==============================================================================
148 
149  DO ifcp = 1,3
150  ifc = pgrid%fp2fOLES(ifcp)
151 
152  ncells = SIZE(pgrid%fsOLES,1)
153 
154 ! ------------------------------------------------------------------------------
155 ! Loop over cells
156 ! ------------------------------------------------------------------------------
157 
158  DO ic1l = 1,ncells
159  c1g = pgrid%fsOLES(ic1l,ifc)
160 
161  lowlim(1) = pgrid%intLimOLES(int_lim_low,xcoord,c1g)
162  lowlim(2) = pgrid%intLimOLES(int_lim_low,ycoord,c1g)
163  lowlim(3) = pgrid%intLimOLES(int_lim_low,zcoord,c1g)
164 
165  upplim(1) = pgrid%intLimOLES(int_lim_upp,xcoord,c1g)
166  upplim(2) = pgrid%intLimOLES(int_lim_upp,ycoord,c1g)
167  upplim(3) = pgrid%intLimOLES(int_lim_upp,zcoord,c1g)
168 
169  DO ic2l = 1,ncells
170  c2g = pgrid%fsOLES(ic2l,ifc)
171 
172  lowlim(4) = pgrid%intLimOLES(int_lim_low,xcoord,c2g)
173  lowlim(5) = pgrid%intLimOLES(int_lim_low,ycoord,c2g)
174  lowlim(6) = pgrid%intLimOLES(int_lim_low,zcoord,c2g)
175 
176  upplim(4) = pgrid%intLimOLES(int_lim_upp,xcoord,c2g)
177  upplim(5) = pgrid%intLimOLES(int_lim_upp,ycoord,c2g)
178  upplim(6) = pgrid%intLimOLES(int_lim_upp,zcoord,c2g)
179 
180 ! ----- Loop over integrals --------------------------------------------------
181 
182  DO iint = 1,2
183  errorflag = 0
184  maxcalls = max_calls_start
185  restartflag = 0
186 
187  DO loopcounter = 1,dcuhre_loop_limit
188  IF ( iint == 1 ) THEN
189  CALL dcuhre(ndim,nfunnz,lowlim,upplim,min_calls,maxcalls, &
190  rflu_definecorrelation220,errabsreq,errrelreq, &
191  key,workarraysize,restartflag,integralnz, &
192  errabsest,neval,errorflag,workarray)
193  ELSE
194  CALL dcuhre(ndim,nfunnz,lowlim,upplim,min_calls,maxcalls, &
195  rflu_definecorrelation221,errabsreq,errrelreq, &
196  key,workarraysize,restartflag,integralnz, &
197  errabsest,neval,errorflag,workarray)
198  END IF ! iInt
199 
200  IF ( errorflag == 0 .OR. loopcounter == dcuhre_loop_limit ) THEN
201  EXIT
202  ELSE IF ( errorflag == 1 ) THEN
203  restartflag = 1
204  maxcalls = max_calls_factor*maxcalls
205 
206  CALL rflu_computedcuhreinfo(global,ndim,nfunnz,key,maxcalls, &
207  workarraysizenew)
208 
209  IF ( workarraysizenew > workarraysize ) THEN
210  EXIT
211  END IF ! workArraySizeNew
212  ELSE
213  CALL errorstop(global,err_dcuhre_output,__line__)
214  END IF ! errorFlag
215  END DO ! loopCounter
216 
217 ! ------- Normalize integral ---------------------------------------------------
218 
219  IF ( iint == 1 ) THEN
220  normfact = normfactterm
221  ELSE
222  normfact = normfactterm*const_kolmogorov/ &
223  (6.0_rfreal*pgrid%rhoOLES(ifc)**(2.0_rfreal/3.0_rfreal))
224  END IF ! iInt
225 
226  DO ifunnz = 1,nfunnz
227  ifun = mapfunnz2funcorr22(ifunnz)
228  integral(ifun) = normfact*integralnz(ifunnz)
229  END DO ! iFunNZ
230 
231 ! ------- Store integral in array ----------------------------------------------
232 
233  DO ifun = 1,nfun
234  CALL rflu_mapk2ij(ifun,l,j)
235 
236  vloc = rflu_geti1posoles(l,ic1l)
237  hloc = rflu_getlposoles(j,ic2l)
238 
239  IF ( iint == 1 ) THEN
240  pgrid%int20OLES(ifcp,vloc,hloc) = integral(ifun)
241  ELSE
242  pgrid%int21OLES(ifcp,vloc,hloc) = integral(ifun)
243  END IF ! iInt
244 
245  END DO ! iFun
246  END DO ! iInt
247 
248  END DO ! icl2
249  END DO ! icl1
250  END DO ! ifc
251 
252 #ifdef CHECK_DATASTRUCT
253 ! --- Data structure output for checking
254  WRITE(stdout,'(A)') solver_name
255  WRITE(stdout,'(A,1X,A)') solver_name,'### START CHECK OUTPUT ###'
256  WRITE(stdout,'(A,1X,A)') solver_name,'Optimal LES I20 integral matrix'
257  DO ifcp = 1,3 ! loop over prototype faces
258  WRITE(stdout,'(A,3X,A,1X,I2)') solver_name,'Face:',ifcp
259  DO vloc = 1,3*ncells ! loop over components
260  WRITE(stdout,'(A,1X,I6,6(1X,E11.4))') solver_name,vloc, &
261  pgrid%int20OLES(ifcp,vloc,1:3*ncells)
262  END DO ! vLoc
263  END DO ! ifcp
264  WRITE(stdout,'(A,1X,A)') solver_name,'Optimal LES I21 integral matrix'
265  DO ifcp = 1,3 ! loop over prototype faces
266  WRITE(stdout,'(A,3X,A,1X,I2)') solver_name,'Face:',ifcp
267  DO vloc = 1,3*ncells ! loop over components
268  WRITE(stdout,'(A,1X,I6,6(1X,E11.4))') solver_name,vloc, &
269  pgrid%int21OLES(ifcp,vloc,1:3*ncells)
270  END DO ! vLoc
271  END DO ! ifcp
272  WRITE(stdout,'(A,1X,A)') solver_name,'### END CHECK OUTPUT ###'
273  WRITE(stdout,'(A)') solver_name
274 #endif
275 
276 ! ==============================================================================
277 ! Deallocate arrays
278 ! ==============================================================================
279 
280  CALL rflu_deallocatedcuhrearrays(global)
281 
282  DEALLOCATE(integral,stat=errorflag)
283  global%error = errorflag
284  IF ( global%error /= err_none ) THEN
285  CALL errorstop(global,err_deallocate,__line__,'integral')
286  END IF ! global%error
287 
288  DEALLOCATE(workarray,stat=errorflag)
289  global%error = errorflag
290  IF ( global%error /= err_none ) THEN
291  CALL errorstop(global,err_deallocate,__line__,'workArray')
292  END IF ! global%error
293 
294 ! ==============================================================================
295 ! End
296 ! ==============================================================================
297 
298  CALL deregisterfunction(global)
299 
300 END SUBROUTINE rflu_computeintegral2oles
301 
302 !*******************************************************************************
303 !
304 ! RCS Revision history:
305 !
306 ! $Log: RFLU_ComputeIntegral2OLES.F90,v $
307 ! Revision 1.7 2008/12/06 08:44:29 mtcampbe
308 ! Updated license.
309 !
310 ! Revision 1.6 2008/11/19 22:17:42 mtcampbe
311 ! Added Illinois Open Source License/Copyright
312 !
313 ! Revision 1.5 2003/03/15 18:30:58 haselbac
314 ! Added footer
315 !
316 !*******************************************************************************
317 
318 
319 
320 
321 
322 
323 
subroutine rflu_computedcuhreinfo(global, NDIM, NF, KEY, MAXCLS, NW)
FT m(int i, int j) const
subroutine, public rflu_definecorrelation221(nDim, z, nFunNZ, f)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
INTEGER function, public rflu_geti1posoles(l, d)
subroutine rflu_allocatedcuhrearrays(nDim, nFunNZ, nFun)
INTEGER function, public rflu_getlposoles(j, a)
subroutine, public rflu_mapk2ij(k, i, j)
subroutine, public rflu_setmapfunnz2funcorr22(nFunNZ)
const NT & n
subroutine rflu_deallocatedcuhrearrays
subroutine rflu_computeintegral2oles(pRegion)
j indices j
Definition: Indexing.h:6
subroutine, public rflu_definecorrelation220(nDim, z, nFunNZ, f)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
static T_Key key
Definition: vinci_lass.c:76
subroutine deregisterfunction(global)
Definition: ModError.F90:469