80 TYPE(t_region
),
POINTER :: pregion
86 LOGICAL :: outsiderflag,xflatflag,yflatflag,zflatflag
87 CHARACTER(CHRLEN) :: movebctypestring,rcsidentstring
88 INTEGER :: errorflag,ibv,ipatch
89 INTEGER,
DIMENSION(2) :: maxnormloc
90 REAL(RFREAL),
PARAMETER :: eqtol = 1.0e-6_rfreal
91 REAL(RFREAL) ::
term,xnorm,xnormmax,xnormmin,ynorm,ynormmax,ynormmin, &
92 znorm,znormmax,znormmin
93 REAL(RFREAL),
DIMENSION(:,:),
ALLOCATABLE :: globalvals,localvals
94 REAL(RFREAL),
DIMENSION(:,:,:),
ALLOCATABLE :: bvnext
96 TYPE(t_patch),
POINTER :: ppatch
102 rcsidentstring =
'$RCSfile: RFLU_SetMoveGridOptions.F90,v $ $Revision: 1.15 $'
104 global => pregion%global
107 'RFLU_SetMoveGridOptions.F90')
109 IF ( global%myProcid == masterproc .AND. &
110 global%verbLevel > verbose_none )
THEN
111 WRITE(stdout,
'(A,1X,A)') solver_name,
'Setting grid motion options...'
112 WRITE(stdout,
'(A,3X,A,1X,E15.8)') solver_name,
'Equality tolerance:',eqtol
113 WRITE(stdout,
'(A,3X,A,3X,A,2X,A)') solver_name,
'Local',
'Global',
'Option'
120 ALLOCATE(bvnext(min_val:max_val,xcoord:zcoord,global%nPatches),stat=errorflag)
121 global%error = errorflag
122 IF ( global%error /= err_none )
THEN
123 CALL
errorstop(global,err_allocate,__line__,
'bvnExt')
126 DO ipatch = 1,global%nPatches
127 bvnext(min_val,xcoord:zcoord,ipatch) = huge(1.0_rfreal)
128 bvnext(max_val,xcoord:zcoord,ipatch) = -huge(1.0_rfreal)
131 ALLOCATE(localvals(xcoord:zcoord,global%nPatches),stat=errorflag)
132 global%error = errorflag
133 IF ( global%error /= err_none )
THEN
134 CALL
errorstop(global,err_allocate,__line__,
'localVals')
137 ALLOCATE(globalvals(xcoord:zcoord,global%nPatches),stat=errorflag)
138 global%error = errorflag
139 IF ( global%error /= err_none )
THEN
140 CALL
errorstop(global,err_allocate,__line__,
'globalVals')
147 DO ipatch = 1,pregion%grid%nPatches
148 ppatch => pregion%patches(ipatch)
150 xnormmin = huge(1.0_rfreal)
151 xnormmax = -huge(1.0_rfreal)
152 ynormmin = huge(1.0_rfreal)
153 ynormmax = -huge(1.0_rfreal)
154 znormmin = huge(1.0_rfreal)
155 znormmax = -huge(1.0_rfreal)
157 DO ibv = 1,ppatch%nBVertTot
158 xnorm = ppatch%bvn(xcoord,ibv)
159 ynorm = ppatch%bvn(ycoord,ibv)
160 znorm = ppatch%bvn(zcoord,ibv)
162 IF ( xnorm < xnormmin )
THEN
164 ELSE IF ( xnorm > xnormmax )
THEN
168 IF ( ynorm < ynormmin )
THEN
170 ELSE IF ( ynorm > ynormmax )
THEN
174 IF ( znorm < znormmin )
THEN
176 ELSE IF ( znorm > znormmax )
THEN
181 bvnext(min_val,xcoord,ppatch%iPatchGlobal) = xnormmin
182 bvnext(min_val,ycoord,ppatch%iPatchGlobal) = ynormmin
183 bvnext(min_val,zcoord,ppatch%iPatchGlobal) = znormmin
185 bvnext(max_val,xcoord,ppatch%iPatchGlobal) = xnormmax
186 bvnext(max_val,ycoord,ppatch%iPatchGlobal) = ynormmax
187 bvnext(max_val,zcoord,ppatch%iPatchGlobal) = znormmax
194 DO ipatch = 1,global%nPatches
195 localvals(xcoord,ipatch) = bvnext(min_val,xcoord,ipatch)
196 localvals(ycoord,ipatch) = bvnext(min_val,ycoord,ipatch)
197 localvals(zcoord,ipatch) = bvnext(min_val,zcoord,ipatch)
200 CALL mpi_reduce(localvals,globalvals,(zcoord-xcoord+1)*global%nPatches, &
201 mpi_rfreal,mpi_min,masterproc,global%mpiComm,errorflag)
202 global%error = errorflag
203 IF ( global%error /= err_none )
THEN
204 CALL
errorstop(global,err_mpi_trouble,__line__)
207 DO ipatch = 1,global%nPatches
208 bvnext(min_val,xcoord,ipatch) = globalvals(xcoord,ipatch)
209 bvnext(min_val,ycoord,ipatch) = globalvals(ycoord,ipatch)
210 bvnext(min_val,zcoord,ipatch) = globalvals(zcoord,ipatch)
212 localvals(xcoord,ipatch) = bvnext(max_val,xcoord,ipatch)
213 localvals(ycoord,ipatch) = bvnext(max_val,ycoord,ipatch)
214 localvals(zcoord,ipatch) = bvnext(max_val,zcoord,ipatch)
217 CALL mpi_reduce(localvals,globalvals,(zcoord-xcoord+1)*global%nPatches, &
218 mpi_rfreal,mpi_min,masterproc,global%mpiComm,errorflag)
219 global%error = errorflag
220 IF ( global%error /= err_none )
THEN
221 CALL
errorstop(global,err_mpi_trouble,__line__)
224 DO ipatch = 1,global%nPatches
225 bvnext(max_val,xcoord,ipatch) = globalvals(xcoord,ipatch)
226 bvnext(max_val,ycoord,ipatch) = globalvals(ycoord,ipatch)
227 bvnext(max_val,zcoord,ipatch) = globalvals(zcoord,ipatch)
234 DO ipatch = 1,pregion%grid%nPatches
235 ppatch => pregion%patches(ipatch)
237 ppatch%moveBcType = movegrid_bctype_none
243 IF ( (ppatch%movePatch .EQV. .false.) .AND. &
244 (ppatch%smoothGrid .EQV. .true.) )
THEN
250 xnormmin = bvnext(min_val,xcoord,ppatch%iPatchGlobal)
251 xnormmax = bvnext(max_val,xcoord,ppatch%iPatchGlobal)
253 ynormmin = bvnext(min_val,ycoord,ppatch%iPatchGlobal)
254 ynormmax = bvnext(max_val,ycoord,ppatch%iPatchGlobal)
256 znormmin = bvnext(min_val,zcoord,ppatch%iPatchGlobal)
257 znormmax = bvnext(max_val,zcoord,ppatch%iPatchGlobal)
267 IF ( (
sign(1.0_rfreal,xnormmin) ==
sign(1.0_rfreal,xnormmax)) )
THEN
268 IF (
floatequal(xnormmin,xnormmax,eqtol) .EQV. .true. )
THEN
274 IF ( (
floatequal(abs(xnormmin),epsilon(1.0_rfreal),eqtol)) .AND. &
275 (
floatequal(abs(xnormmax),epsilon(1.0_rfreal),eqtol)) )
THEN
284 IF ( (
sign(1.0_rfreal,ynormmin) ==
sign(1.0_rfreal,ynormmax)) )
THEN
285 IF (
floatequal(ynormmin,ynormmax,eqtol) .EQV. .true. )
THEN
291 IF ( (
floatequal(abs(ynormmin),epsilon(1.0_rfreal),eqtol)) .AND. &
292 (
floatequal(abs(ynormmax),epsilon(1.0_rfreal),eqtol)) )
THEN
301 IF ( (
sign(1.0_rfreal,znormmin) ==
sign(1.0_rfreal,znormmax)) )
THEN
302 IF (
floatequal(znormmin,znormmax,eqtol) .EQV. .true. )
THEN
308 IF ( (
floatequal(abs(znormmin),epsilon(1.0_rfreal),eqtol)) .AND. &
309 (
floatequal(abs(znormmax),epsilon(1.0_rfreal),eqtol)) )
THEN
323 IF ( (xflatflag .EQV. .true.) .AND. &
324 (yflatflag .EQV. .true.) .AND. &
325 (zflatflag .EQV. .true.) )
THEN
326 term =
max(abs(xnormmin),abs(xnormmax), &
327 abs(ynormmin),abs(ynormmax), &
328 abs(znormmin),abs(znormmax))
335 IF (
term == abs(xnormmin) .OR.
term == abs(xnormmax) )
THEN
336 ppatch%moveBcType = xcoord
337 ELSE IF (
term == abs(ynormmin) .OR.
term == abs(ynormmax) )
THEN
338 ppatch%moveBcType = ycoord
339 ELSE IF (
term == abs(znormmin) .OR.
term == abs(znormmax) )
THEN
340 ppatch%moveBcType = zcoord
349 ppatch%moveBcType = movegrid_bctype_neumann
358 IF ( ppatch%moveBcType == movegrid_bctype_none )
THEN
359 ppatch%smoothGrid = .false.
361 global%warnCounter = global%warnCounter + 1
363 IF ( global%myProcid == masterproc .AND. &
364 global%verbLevel > verbose_none )
THEN
365 WRITE(stdout,
'(A,3X,A,I3,A)') solver_name, &
366 '*** WARNING *** Invalid smoothing input for patch ',ipatch, &
367 '. Overriding user input for grid smoothing.'
376 IF ( global%myProcid == masterproc .AND. &
377 global%verbLevel > verbose_none )
THEN
378 IF ( ppatch%moveBcType == movegrid_bctype_none )
THEN
379 movebctypestring =
'None'
380 ELSE IF ( ppatch%moveBcType == movegrid_bctype_neumann )
THEN
381 movebctypestring =
'von Neumann (homogeneous)'
382 ELSE IF ( ppatch%moveBcType == movegrid_bctype_dirichx )
THEN
383 movebctypestring =
'Dirichlet (homogeneous in x)'
384 ELSE IF ( ppatch%moveBcType == movegrid_bctype_dirichy )
THEN
385 movebctypestring =
'Dirichlet (homogeneous in y)'
386 ELSE IF ( ppatch%moveBcType == movegrid_bctype_dirichz )
THEN
387 movebctypestring =
'Dirichlet (homogeneous in z)'
389 CALL
errorstop(global,err_reached_default,__line__)
392 WRITE(stdout,
'(A,2X,I4,5X,I4,4X,A)') solver_name,ipatch, &
393 ppatch%iPatchGlobal, &
394 trim(movebctypestring)
402 DO ipatch = 1,pregion%grid%nPatches
403 ppatch => pregion%patches(ipatch)
405 IF ( (ppatch%smoothGrid .EQV. .true.) .AND. &
406 (ppatch%moveBcType == movegrid_bctype_none) )
THEN
407 CALL
errorstop(global,err_movepatch_bc_invalid,__line__)
415 DEALLOCATE(bvnext,stat=errorflag)
416 global%error = errorflag
417 IF ( global%error /= err_none )
THEN
418 CALL
errorstop(global,err_deallocate,__line__,
'bvnExt')
421 DEALLOCATE(localvals,stat=errorflag)
422 global%error = errorflag
423 IF ( global%error /= err_none )
THEN
424 CALL
errorstop(global,err_deallocate,__line__,
'localVals')
427 DEALLOCATE(globalvals,stat=errorflag)
428 global%error = errorflag
429 IF ( global%error /= err_none )
THEN
430 CALL
errorstop(global,err_deallocate,__line__,
'globalVals')
437 IF ( global%myProcid == masterproc .AND. &
438 global%verbLevel > verbose_none )
THEN
439 WRITE(stdout,
'(A,1X,A)') solver_name,
'Setting grid motion options done.'
static SURF_BEGIN_NAMESPACE double sign(double x)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
subroutine registerfunction(global, funName, fileName)
subroutine rflu_setmovegridoptions(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
subroutine deregisterfunction(global)