Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ComputeIntegral5OLES.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 5 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_ComputeIntegral5OLES.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_computeintegral5oles(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,c3g,c4g,errorflag,hloc,iint,ic1l,ic2l,ic3l,ic4l,ifc, &
67  ifcp,ifun,ifunnz,j,k,key,l,loopcounter,m,ncells,nfun,nfunnz, &
68  restartflag,vloc
69  REAL(RFREAL) :: normfact,normfactterm
70 
71  TYPE(t_grid), POINTER :: pgrid
72  TYPE(t_global), POINTER :: global
73 
74 ! ==============================================================================
75 ! Start
76 ! ==============================================================================
77 
78  CALL registerfunction(global,'RFLU_ComputeIntegral5OLES',&
79  'RFLU_ComputeIntegral5OLES.F90')
80 
81  IF ( global%myProcid == masterproc .AND. &
82  global%verbLevel > verbose_low ) THEN
83  WRITE(stdout,'(A,3X,A)') solver_name,'Computing integral 5...'
84  END IF ! global%verbLevel
85 
86 ! ==============================================================================
87 ! Set grid pointer
88 ! ==============================================================================
89 
90  pgrid => pregion%grid
91 
92 ! ==============================================================================
93 ! Set various quantities
94 ! ==============================================================================
95 
96 ! ------------------------------------------------------------------------------
97 ! Set DCUHRE parameters
98 ! ------------------------------------------------------------------------------
99 
100  ndim = 12
101  nfun = 81
102  nfunnz = 21
103  key = 4
104 
105  errabsreq = 10.0_rfreal*epsilon(1.0_rfreal)
106  errrelreq = 1.0e-2_rfreal
107 
108 ! ------------------------------------------------------------------------------
109 ! Compute DCUHRE information and allocate work array
110 ! ------------------------------------------------------------------------------
111 
112  maxcalls = max_calls_limit
113 
114  CALL rflu_computedcuhreinfo(global,ndim,nfunnz,key,maxcalls,workarraysize)
115  CALL rflu_allocatedcuhrearrays(global,ndim,nfunnz,nfun)
116 
117  ALLOCATE(integral(nfun),stat=errorflag)
118  global%error = errorflag
119  IF ( global%error /= err_none ) THEN
120  CALL errorstop(global,err_allocate,__line__,'integral')
121  END IF ! global%error
122 
123  ALLOCATE(workarray(workarraysize),stat=errorflag)
124  global%error = errorflag
125  IF ( global%error /= err_none ) THEN
126  CALL errorstop(global,err_allocate,__line__,'workArray')
127  END IF ! global%error
128 
129 ! ------------------------------------------------------------------------------
130 ! Set normalization factor
131 ! ------------------------------------------------------------------------------
132 
133  normfactterm = 1.0_rfreal/(pgrid%deltaOLES**12)
134 
135 ! ------------------------------------------------------------------------------
136 ! Set non-zero integral components
137 ! ------------------------------------------------------------------------------
138 
139  CALL rflu_setmapfunnz2funcorr44(nfunnz)
140 
141 ! ==============================================================================
142 ! Loop over protoype faces
143 ! ==============================================================================
144 
145  DO ifcp = 1,3
146  ifc = pgrid%fp2fOLES(ifcp)
147 
148 ! ------------------------------------------------------------------------------
149 ! Loop over cells
150 ! ------------------------------------------------------------------------------
151 
152  ncells = SIZE(pgrid%fsOLES,1)
153 
154  DO ic1l = 1,ncells
155  c1g = pgrid%fsOLES(ic1l,ifc)
156 
157  lowlim(1) = pgrid%intLimOLES(int_lim_low,xcoord,c1g)
158  lowlim(2) = pgrid%intLimOLES(int_lim_low,ycoord,c1g)
159  lowlim(3) = pgrid%intLimOLES(int_lim_low,zcoord,c1g)
160 
161  upplim(1) = pgrid%intLimOLES(int_lim_upp,xcoord,c1g)
162  upplim(2) = pgrid%intLimOLES(int_lim_upp,ycoord,c1g)
163  upplim(3) = pgrid%intLimOLES(int_lim_upp,zcoord,c1g)
164 
165  DO ic2l = 1,ncells
166  c2g = pgrid%fsOLES(ic2l,ifc)
167 
168  lowlim(4) = pgrid%intLimOLES(int_lim_low,xcoord,c2g)
169  lowlim(5) = pgrid%intLimOLES(int_lim_low,ycoord,c2g)
170  lowlim(6) = pgrid%intLimOLES(int_lim_low,zcoord,c2g)
171 
172  upplim(4) = pgrid%intLimOLES(int_lim_upp,xcoord,c2g)
173  upplim(5) = pgrid%intLimOLES(int_lim_upp,ycoord,c2g)
174  upplim(6) = pgrid%intLimOLES(int_lim_upp,zcoord,c2g)
175 
176 
177  DO ic3l = 1,ncells
178  c3g = pgrid%fsOLES(ic3l,ifc)
179 
180  lowlim(7) = pgrid%intLimOLES(int_lim_low,xcoord,c3g)
181  lowlim(8) = pgrid%intLimOLES(int_lim_low,ycoord,c3g)
182  lowlim(9) = pgrid%intLimOLES(int_lim_low,zcoord,c3g)
183 
184  upplim(7) = pgrid%intLimOLES(int_lim_upp,xcoord,c3g)
185  upplim(8) = pgrid%intLimOLES(int_lim_upp,ycoord,c3g)
186  upplim(9) = pgrid%intLimOLES(int_lim_upp,zcoord,c3g)
187 
188  DO ic4l = 1,ncells
189  c4g = pgrid%fsOLES(ic4l,ifc)
190 
191  lowlim(10) = pgrid%intLimOLES(int_lim_low,xcoord,c4g)
192  lowlim(11) = pgrid%intLimOLES(int_lim_low,ycoord,c4g)
193  lowlim(12) = pgrid%intLimOLES(int_lim_low,zcoord,c4g)
194 
195  upplim(10) = pgrid%intLimOLES(int_lim_upp,xcoord,c4g)
196  upplim(11) = pgrid%intLimOLES(int_lim_upp,ycoord,c4g)
197  upplim(12) = pgrid%intLimOLES(int_lim_upp,zcoord,c4g)
198 
199 ! --------- Loop over integrals -----------------------------------------------
200 
201  DO iint = 1,3
202  errorflag = 0
203  maxcalls = max_calls_start
204  restartflag = 0
205 
206  integral(:) = 0.0_rfreal
207  integralnz(:) = 0.0_rfreal
208 
209  DO loopcounter = 1,dcuhre_loop_limit
210  IF ( iint == 1 ) THEN
211  CALL dcuhre(ndim,nfunnz,lowlim,upplim,min_calls,maxcalls, &
212  rflu_definecorrelation540,errabsreq,errrelreq, &
213  key,workarraysize,restartflag,integralnz, &
214  errabsest,neval,errorflag,workarray)
215  ELSE IF ( iint == 2 ) THEN
216  CALL dcuhre(ndim,nfunnz,lowlim,upplim,min_calls,maxcalls, &
217  rflu_definecorrelation541,errabsreq,errrelreq, &
218  key,workarraysize,restartflag,integralnz, &
219  errabsest,neval,errorflag,workarray)
220  ELSE IF ( iint == 3 ) THEN
221  CALL dcuhre(ndim,nfunnz,lowlim,upplim,min_calls,maxcalls, &
222  rflu_definecorrelation542,errabsreq,errrelreq, &
223  key,workarraysize,restartflag,integralnz, &
224  errabsest,neval,errorflag,workarray)
225  END IF ! iInt
226 
227  IF ( errorflag == 0 .OR. loopcounter == dcuhre_loop_limit ) THEN
228  EXIT
229  ELSE IF ( errorflag == 1 ) THEN
230  restartflag = 1
231  maxcalls = max_calls_factor*maxcalls
232 
233  CALL rflu_computedcuhreinfo(global,ndim,nfunnz,key,maxcalls, &
234  workarraysizenew)
235 
236  IF ( workarraysizenew > workarraysize ) THEN
237  EXIT
238  END IF ! workArraySizeNew
239  ELSE
240  CALL errorstop(global,err_dcuhre_output,__line__)
241  END IF ! errorFlag
242  END DO ! loopCounter
243 
244 ! ----------- Normalize integral -----------------------------------------------
245 
246  IF ( iint == 1 ) THEN
247  normfact = normfactterm
248  ELSE IF ( iint == 2 ) THEN
249  normfact = normfactterm*const_kolmogorov/ &
250  (6.0_rfreal*pgrid%rhoOLES(ifc)**(2.0_rfreal/3.0_rfreal))
251  ELSE IF ( iint == 3 ) THEN
252  normfact = normfactterm*const_kolmogorov*const_kolmogorov/ &
253  (36.0_rfreal*pgrid%rhoOLES(ifc)**(4.0_rfreal/3.0_rfreal))
254  END IF ! iInt
255 
256  DO ifunnz = 1,nfunnz
257  ifun = mapfunnz2funcorr44(ifunnz)
258  integral(ifun) = normfact*integralnz(ifunnz)
259  END DO ! iFunNZ
260 
261 ! ----------- Store integral in array ------------------------------------------
262 
263  DO ifun = 1,nfun
264  CALL rflu_mapm2ijkl(ifun,l,m,j,k)
265 
266  vloc = rflu_getqposoles(j,k,ic3l,ic4l,ncells)
267  hloc = rflu_geti4posoles(l,m,ic1l,ic2l,ncells)
268 
269  IF ( iint == 1 ) THEN
270  pgrid%int50OLES(ifcp,vloc,hloc) = integral(ifun)
271  ELSE IF ( iint == 2 ) THEN
272  pgrid%int51OLES(ifcp,vloc,hloc) = integral(ifun)
273  ELSE
274  pgrid%int52OLES(ifcp,vloc,hloc) = integral(ifun)
275  END IF ! iInt
276 
277  END DO ! iFun
278 
279  END DO ! iInt
280 
281  END DO ! ic4l
282  END DO ! ic3l
283  END DO ! ic2l
284  END DO ! ic1l
285  END DO ! ifcp
286 
287 
288 #ifdef CHECK_DATASTRUCT
289 ! Data structure output for checking
290  WRITE(stdout,'(A)') solver_name
291  WRITE(stdout,'(A,1X,A)') solver_name,'### START CHECK OUTPUT ###'
292  WRITE(stdout,'(A,1X,A)') solver_name,'Optimal LES I50 integral matrix'
293  DO ifcp = 1,3 ! loop over prototype faces
294  WRITE(stdout,'(A,3X,A,1X,I2)') solver_name,'Face:',ifcp
295  DO vloc = 1,9*ncells*ncells ! loop over components
296  WRITE(stdout,'(A,1X,I6,36(1X,E11.4))') solver_name,vloc, &
297  pgrid%int50OLES(ifcp,vloc,1:9*ncells*ncells)
298  END DO ! vLoc
299  END DO ! ifcp
300  WRITE(stdout,'(A,1X,A)') solver_name,'Optimal LES I51 integral matrix'
301  DO ifcp = 1,3 ! loop over prototype faces
302  WRITE(stdout,'(A,3X,A,1X,I2)') solver_name,'Face:',ifcp
303  DO vloc = 1,9*ncells*ncells ! loop over components
304  WRITE(stdout,'(A,1X,I6,36(1X,E11.4))') solver_name,vloc, &
305  pgrid%int51OLES(ifcp,vloc,1:9*ncells*ncells)
306  END DO ! vLoc
307  END DO ! ifcp
308  WRITE(stdout,'(A,1X,A)') solver_name,'Optimal LES I52 integral matrix'
309  DO ifcp = 1,3 ! loop over prototype faces
310  WRITE(stdout,'(A,3X,A,1X,I2)') solver_name,'Face:',ifcp
311  DO vloc = 1,9*ncells*ncells ! loop over components
312  WRITE(stdout,'(A,1X,I6,36(1X,E11.4))') solver_name,vloc, &
313  pgrid%int52OLES(ifcp,vloc,1:9*ncells*ncells)
314  END DO ! vLoc
315  END DO ! ifcp
316  WRITE(stdout,'(A,1X,A)') solver_name,'### END CHECK OUTPUT ###'
317  WRITE(stdout,'(A)') solver_name
318 #endif
319 
320 
321 ! ==============================================================================
322 ! Deallocate arrays
323 ! ==============================================================================
324 
325  CALL rflu_deallocatedcuhrearrays(global)
326 
327  DEALLOCATE(integral,stat=errorflag)
328  global%error = errorflag
329  IF ( global%error /= err_none ) THEN
330  CALL errorstop(global,err_deallocate,__line__,'integral')
331  END IF ! global%error
332 
333  DEALLOCATE(workarray,stat=errorflag)
334  global%error = errorflag
335  IF ( global%error /= err_none ) THEN
336  CALL errorstop(global,err_deallocate,__line__,'workArray')
337  END IF ! global%error
338 
339 ! ==============================================================================
340 ! End
341 ! ==============================================================================
342 
343  CALL deregisterfunction(global)
344 
345 END SUBROUTINE rflu_computeintegral5oles
346 
347 
348 
349 
350 
351 
352 
subroutine rflu_computedcuhreinfo(global, NDIM, NF, KEY, MAXCLS, NW)
FT m(int i, int j) const
j indices k indices k
Definition: Indexing.h:6
subroutine rflu_computeintegral5oles(pRegion)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine rflu_allocatedcuhrearrays(nDim, nFunNZ, nFun)
subroutine, public rflu_setmapfunnz2funcorr44(nFunNZ)
subroutine, public rflu_definecorrelation542(nDim, z, nFunNZ, f)
subroutine, public rflu_definecorrelation540(nDim, z, nFunNZ, f)
subroutine, public rflu_mapm2ijkl(m, i, j, k, l)
subroutine rflu_deallocatedcuhrearrays
subroutine, public rflu_definecorrelation541(nDim, z, nFunNZ, f)
INTEGER function, public rflu_geti4posoles(l, m, d, e, nCells)
j indices j
Definition: Indexing.h:6
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
static T_Key key
Definition: vinci_lass.c:76
INTEGER function, public rflu_getqposoles(j, k, b, g, nCells)
subroutine deregisterfunction(global)
Definition: ModError.F90:469