Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TURB_coRansWallDistOVFlo.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 distance of each cell centers to the nearest no-slip wall
26 !
27 ! Description: distance to nearest wall (walldist) using this direct method
28 ! is computed by collecting coordinates of no-slip wall patches
29 ! in all regions and stored in a buffer. The wall distance is
30 ! the minimum of the distance between the coordinates in the
31 ! buffer and each cell centroid. In this way, global wall distance
32 ! is obtained, assuming open view (OV) from cell centers to
33 ! the nearest wall.
34 !
35 ! Input: region = data of current region.
36 !
37 ! Output: region%levels%turb%lens = turbulence length scale.
38 !
39 ! Notes: this method is computationally intensive, not suitable for moving
40 ! grid. More efficient method is provided by other routines.
41 !
42 !******************************************************************************
43 !
44 ! $Id: TURB_coRansWallDistOVFlo.F90,v 1.7 2009/08/26 12:28:53 mtcampbe Exp $
45 !
46 ! Copyright: (c) 2003 by the University of Illinois
47 !
48 !******************************************************************************
49 
50 SUBROUTINE turb_coranswalldistov( regions )
51 
52  USE moddatatypes
53  USE moddatastruct, ONLY : t_region
54  USE modglobal, ONLY : t_global
59  USE moderror
60  USE modmpi
61  USE modparameters
63  IMPLICIT NONE
64 
65 #include "Indexing.h"
66 
67 ! ... parameters
68  TYPE(t_region), POINTER :: regions(:)
69 
70 ! ... loop variables
71  INTEGER :: ireg, i, j, k, n, ipatch, ilev
72 
73 ! ... local variables
74  TYPE(t_global), POINTER :: global
75 
76 #ifdef MPI
77  INTEGER :: status(mpi_status_size)
78 #endif
79  INTEGER :: ilevbeg,ilevend, ipcbeg,ipcend,jpcbeg,jpcend,kpcbeg,kpcend
80  INTEGER :: icoff,ijcoff,inoff,ijnoff, ic,ijkn,ijkni,ijknj,ijknk
81  INTEGER :: snddim, rcvdim, ncount, icount, accwalldim
82  INTEGER, POINTER :: walldim(:)
83  REAL(RFREAL) :: distance, xdist, ydist, zdist, loclens, cdes
84  REAL(RFREAL) :: adsi, adsj, adsk, dsi(3), dsj(3), dsk(3)
85  REAL(RFREAL), POINTER :: xyz(:,:), cofg(:,:), lens(:)
86 
87 !******************************************************************************
88 
89  global => regions(1)%global
90  CALL registerfunction( global,'TURB_CoRansWallDistOV',&
91  'TURB_coRansWallDistOVFlo.F90' )
92 
93  IF (global%turbWallDim == 0) goto 888
94 
95 ! allocation and initialisation -----------------------------------------------
96 
97  ALLOCATE( walldim(global%nRegions) ) ! wall dimension/region, all processors
98 
99  IF (.NOT. (global%turbWorkUnused .eqv. .true.)) &
100  CALL errorstop( global,err_turb_workspace,__line__ )
101  global%turbWorkDim = ndir*global%turbWallDim
102  ALLOCATE( global%turbWork1D(global%turbWorkDim) )
103 
104  global%turbWorkUnused = .false.
105  walldim(:) = 0
106  ncount = 0
107  icount = 0
108  accwalldim = 0
109  global%turbWorkDim = 0
110 
111 ! search for ns patch at finest level (iLev=1) and store wall xyz in
112 ! global%turbWork1D
113 
114  DO ireg=1,global%nRegions
115 
116  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
117  regions(ireg)%active==active) THEN ! on my processor
118  DO ipatch=1,regions(ireg)%nPatches
119  CALL turb_ranswalldistovpatch( regions(ireg), &
120  regions(ireg)%levels(1)%patches(ipatch) )
121  ENDDO ! iPatch
122  walldim(ireg) = global%turbWorkDim - accwalldim
123  accwalldim = accwalldim + walldim(ireg)
124  ENDIF
125 
126 #ifdef MPI
127 ! - distribut wall dimension acquired from each region/processor to all procs.
128 
129  CALL mpi_bcast( walldim(ireg),1,mpi_integer,regions(ireg)%procId, &
130  global%mpiComm,global%mpierr )
131  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
132 
133 ! - screen output check
134 ! write(*,*)global%myProcid,iReg,global%turbWorkDim,wallDim(iReg), &
135 ! NDIR*global%turbWallDim
136 
137 ! - collect wall coordinates (xyz) from all processors to Master processor
138 
139  IF (global%myProcid == masterproc) THEN
140 
141  IF (walldim(ireg) > 0) THEN
142  IF (regions(ireg)%procid /= global%myProcid) THEN
143 
144  CALL mpi_recv( global%turbWork1D(1+ncount),walldim(ireg),mpi_rfreal, &
145  regions(ireg)%procId,ireg,global%mpiComm,status,global%mpierr )
146  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
147 
148  ENDIF
149 
150  ncount = ncount + walldim(ireg)
151 
152 ! ----- screen output check
153 ! write(*,*) 'ncount',ireg,ncount
154 
155  ENDIF
156  ELSE
157  IF (regions(ireg)%procid == global%myProcid) THEN
158  IF (walldim(ireg) > 0) THEN
159 
160 ! ------- screen output check
161 ! write(*,*)'send=',ireg
162 
163  CALL mpi_send( global%turbWork1D(1+icount),walldim(ireg),mpi_rfreal, &
164  masterproc,ireg,global%mpiComm,status,global%mpierr )
165  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
166 
167  icount = icount + walldim(ireg)
168 
169  ENDIF ! wallDim
170  ENDIF ! region%procId
171  ENDIF ! myProcId
172 #endif
173  ENDDO ! iReg
174 
175 ! check consistency of total wall dimension
176 
177  IF (global%myProcid == masterproc) THEN
178 #ifdef MPI
179  global%turbWorkDim = ncount
180 #endif
181  IF (global%turbWorkDim /= ndir*global%turbWallDim) &
182  CALL errorstop( global,err_turb_ransinput,__line__, &
183  'work array dim. is not consistent with wall array dim.')
184  ENDIF
185 
186 ! distribute wall coordinates from Master processor to all
187 
188 #ifdef MPI
189  CALL mpi_bcast( global%turbWork1D,ndir*global%turbWallDim,mpi_rfreal, &
190  masterproc,global%mpiComm,global%mpierr )
191  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
192 #endif
193 
194 888 CONTINUE
195 
196 ! compute turbulence length scale for RaNS and modified if DES is selected
197 
198  DO ireg=1,global%nRegions
199  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
200  regions(ireg)%active==active) THEN ! on my processor
201 
202  IF (regions(ireg)%mixtInput%moveGrid .eqv. .true.) THEN
203  ilevbeg = regions(ireg)%currLevel
204  ilevend = regions(ireg)%currLevel
205  ELSE
206  ilevbeg = 1
207  ilevend = regions(ireg)%nGridLevels
208  ENDIF
209 
210  cdes = regions(ireg)%turbInput%cDes
211 
212  DO ilev = ilevbeg, ilevend
213  CALL rflo_getdimensphys( regions(ireg),ilev,ipcbeg,ipcend, &
214  jpcbeg,jpcend,kpcbeg,kpcend )
215  CALL rflo_getcelloffset( regions(ireg),ilev,icoff,ijcoff )
216  CALL rflo_getnodeoffset( regions(ireg),ilev,inoff,ijnoff )
217 
218  xyz => regions(ireg)%levels(ilev)%grid%xyz
219  cofg => regions(ireg)%levels(ilev)%grid%cofg
220  lens => regions(ireg)%levels(ilev)%turb%lens
221  lens = global%refLength
222 
223 ! ----- RaNS wall distance providing no-slip wall exist
224 
225  DO k=kpcbeg,kpcend
226  DO j=jpcbeg,jpcend
227  DO i=ipcbeg,ipcend
228  ic = indijk(i,j,k,icoff,ijcoff)
229  lens(ic) = 1.e+32_rfreal
230  DO n = 1,ndir*global%turbWallDim,ndir
231  xdist = cofg(xcoord,ic)-global%turbWork1D(n)
232  ydist = cofg(ycoord,ic)-global%turbWork1D(n+1)
233  zdist = cofg(zcoord,ic)-global%turbWork1D(n+2)
234  distance = sqrt( xdist**2 + ydist**2 + zdist**2 )
235  lens(ic) = min( lens(ic),distance )
236  ENDDO ! n
237 
238 ! ----------- screen output check
239 ! IF(i==30 .and.k==2) write(*,*)ireg,j,lens(iC)
240  ENDDO ! i
241  ENDDO ! j
242  ENDDO ! k
243 
244 ! ----- DES length scale and flows without no-slip walls
245 
246  IF ((regions(ireg)%mixtInput%turbModel == turb_model_dessa) .OR. &
247  (regions(ireg)%mixtInput%turbModel == turb_model_hdessa) .OR. &
248  (global%turbWallDim == 0)) THEN
249  DO k=kpcbeg,kpcend
250  DO j=jpcbeg,jpcend
251  DO i=ipcbeg,ipcend
252  ic = indijk(i ,j ,k ,icoff,ijcoff)
253  ijkn = indijk(i ,j ,k ,inoff,ijnoff)
254  ijkni = indijk(i+1,j ,k ,inoff,ijnoff)
255  ijknj = indijk(i ,j+1,k ,inoff,ijnoff)
256  ijknk = indijk(i ,j ,k+1,inoff,ijnoff)
257  dsi(1:3) = xyz(xcoord:zcoord,ijkni)-xyz(xcoord:zcoord,ijkn)
258  dsj(1:3) = xyz(xcoord:zcoord,ijknj)-xyz(xcoord:zcoord,ijkn)
259  dsk(1:3) = xyz(xcoord:zcoord,ijknk)-xyz(xcoord:zcoord,ijkn)
260  adsi = sqrt( dsi(1)*dsi(1)+dsi(2)*dsi(2)+dsi(3)*dsi(3) )
261  adsj = sqrt( dsj(1)*dsj(1)+dsj(2)*dsj(2)+dsj(3)*dsj(3) )
262  adsk = sqrt( dsk(1)*dsk(1)+dsk(2)*dsk(2)+dsk(3)*dsk(3) )
263  loclens = max( adsi,adsj,adsk )
264  lens(ic) = min( lens(ic),cdes*loclens )
265  ENDDO ! i
266  ENDDO ! j
267  ENDDO ! k
268  ENDIF ! DES or noWall
269  ENDDO ! iLev
270 
271 ! --- extrapolate solution to dummy cells
272 
273  CALL turb_floextrapintcellscal( regions(ireg),lens )
274 
275  ENDIF ! region on this processor and active
276  ENDDO ! iReg
277 
278 ! finalize --------------------------------------------------------------------
279 
280  DEALLOCATE( global%turbWork1D, walldim )
281  global%turbWorkUnused = .true.
282 
283  CALL deregisterfunction( global )
284 
285 END SUBROUTINE turb_coranswalldistov
286 
287 !******************************************************************************
288 !
289 ! RCS Revision history:
290 !
291 ! $Log: TURB_coRansWallDistOVFlo.F90,v $
292 ! Revision 1.7 2009/08/26 12:28:53 mtcampbe
293 ! Ported to Hera. Fixed logical expression syntax errors. Replaced all
294 ! IF (logical_variable) with IF (logical_variable .eqv. .true.) as
295 ! consistent with the specification. Also changed: IF( ASSOCIATED(expr) )
296 ! to IF ( ASSOCIATED(expr) .eqv. .true. ). Intel compilers produce code
297 ! which silently fails for some mal-formed expressions, so these changes
298 ! are a net which should ensure that they are evaluated as intended.
299 !
300 ! Revision 1.6 2008/12/06 08:44:43 mtcampbe
301 ! Updated license.
302 !
303 ! Revision 1.5 2008/11/19 22:17:55 mtcampbe
304 ! Added Illinois Open Source License/Copyright
305 !
306 ! Revision 1.4 2005/03/09 06:36:11 wasistho
307 ! incorporated HDESSA
308 !
309 ! Revision 1.3 2004/03/13 03:12:16 wasistho
310 ! get rid of flo/flu identifier in TURB_Co.. routines
311 !
312 ! Revision 1.2 2004/03/12 02:55:35 wasistho
313 ! changed rocturb routine names
314 !
315 ! Revision 1.1 2004/03/08 23:33:31 wasistho
316 ! changed turb nomenclature
317 !
318 ! Revision 1.8 2004/02/13 03:31:27 wasistho
319 ! fixed bug in case a processor has multi regions
320 !
321 ! Revision 1.7 2004/02/12 03:46:48 wasistho
322 ! filled in RaNS lengthscale in dummy cells
323 !
324 ! Revision 1.6 2004/01/21 03:47:10 wasistho
325 ! modify k index in screen output check
326 !
327 ! Revision 1.5 2003/10/20 00:45:42 wasistho
328 ! initiate lens to reference length
329 !
330 ! Revision 1.4 2003/10/09 20:48:29 wasistho
331 ! added DES lengthscale coefficient CDES
332 !
333 ! Revision 1.3 2003/10/07 23:55:30 wasistho
334 ! bug fixed missing nodeOffsets
335 !
336 ! Revision 1.2 2003/10/07 20:32:16 wasistho
337 ! turbWork2D to turbWork1D
338 !
339 !
340 !******************************************************************************
341 
342 
343 
344 
345 
346 
347 
j indices k indices k
Definition: Indexing.h:6
**********************************************************************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 kpcbeg
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
**********************************************************************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
**********************************************************************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 jpcbeg
**********************************************************************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 ipcend
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
subroutine turb_coranswalldistov(regions)
**********************************************************************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 ipcbeg
blockLoc i
Definition: read.cpp:79
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
subroutine turb_floextrapintcellscal(region, fVec)
const NT & n
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
j indices j
Definition: Indexing.h:6
**********************************************************************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 jpcend
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
CImg< T > & distance(const T isovalue, const float sizex=1, const float sizey=1, const float sizez=1, const bool compute_sqrt=true)
Compute the Euclidean distance map to a shape of specified isovalue.
Definition: CImg.h:20441
subroutine turb_ranswalldistovpatch(region, patch)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_getdimensphys(region, iLev, ipcbeg, ipcend, jpcbeg, jpcend, kpcbeg, kpcend)