Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_ModForcesMoments.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: Collection of routines to compute force and moment coefficients.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLO_ModForcesMoments.F90,v 1.6 2008/12/06 08:44:16 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2004-2005 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE modparameters
42  USE moddatatypes
43  USE modglobal, ONLY: t_global
44  USE modgrid, ONLY: t_grid
45  USE modbndpatch, ONLY: t_patch
46  USE moddatastruct, ONLY: t_region
47  USE moderror
48  USE modmpi
49 
50  IMPLICIT NONE
51 
52  PRIVATE
53  PUBLIC :: rflo_computeintegralforcemomco, &
59 
60 ! private :
61 
62 ! ******************************************************************************
63 ! Declarations and definitions
64 ! ******************************************************************************
65 
66  CHARACTER(CHRLEN) :: &
67  RCSIdentString = '$RCSfile: RFLO_ModForcesMoments.F90,v $ $Revision: 1.6 $'
68 
69 ! ******************************************************************************
70 ! Routines
71 ! ******************************************************************************
72 
73  CONTAINS
74 
75 
76 
77 
78 ! *******************************************************************************
79 !
80 ! Purpose: Compute patch force and moment coefficients.
81 !
82 ! Description: none.
83 !
84 ! Input: region = current region data
85 !
86 ! Output: patch%forceCoeffs, patch%momentCoeffs =
87 ! patch force and moment coefficients computed
88 !
89 ! Notes: none.
90 !
91 !*******************************************************************************
92 
93 SUBROUTINE rflo_computepatchforcemomco( region )
94 
95  USE modinterfaces, ONLY : rflo_getpatchindices, &
98  IMPLICIT NONE
99 
100 #include "Indexing.h"
101 
102 ! ... parameters
103  TYPE (t_region) :: region
104 
105 ! ... loop variables
106  INTEGER :: ipatch, i, j, k
107 
108 ! ... local variables
109  INTEGER :: ilev, lbound, bctype, ibeg, iend, jbeg, jend, kbeg, kend
110  INTEGER :: inbeg, inend, jnbeg, jnend, knbeg, knend, noff, inoff, ijnoff
111  INTEGER :: idir, jdir, kdir, inode, jnode, knode, n1, n2, i2d, ijkn
112  REAL(RFREAL) :: boxxmin, boxxmax, boxymin, boxymax, boxzmin, boxzmax
113  REAL(RFREAL) :: xref, yref, zref, xmin, xmax, ymin, ymax, zmin, zmax
114  REAL(RFREAL) :: fpx, fpy, fpz, fvx, fvy, fvz, mpx, mpy, mpz, mvx, mvy, mvz
115  REAL(RFREAL) :: sfx, sfy, sfz, sfm, xc, yc, zc, cp, cfx, cfy, cfz, ch
116  REAL(RFREAL), POINTER :: xyz(:,:), sface(:,:), cface(:,:)
117  TYPE (t_global), POINTER :: global
118  TYPE (t_patch), POINTER :: patch
119 
120 ! ******************************************************************************
121 
122  global => region%global
123  CALL registerfunction(global,'RFLO_ComputePatchForceMomCo',&
124  'RFLO_ModForcesMoments.F90')
125 
126 ! get dimensions, parameters and pointers --------------------------------------
127 
128  ilev = region%currLevel
129  CALL rflo_getnodeoffset( region,ilev,inoff,ijnoff )
130 
131  xref = global%forceRefXCoord
132  yref = global%forceRefYCoord
133  zref = global%forceRefZCoord
134 
135  boxxmin = global%acBndBoxXmin
136  boxxmax = global%acBndBoxXmax
137  boxymin = global%acBndBoxYmin
138  boxymax = global%acBndBoxYmax
139  boxzmin = global%acBndBoxZmin
140  boxzmax = global%acBndBoxZmax
141 
142  xyz => region%levels(ilev)%grid%xyz
143 
144 ! initialize global values
145 
146  global%forceCoeffs = 0._rfreal
147  global%momentCoeffs = 0._rfreal
148 
149 ! loop over patches ------------------------------------------------------------
150 
151  DO ipatch = 1,region%nPatches
152  patch => region%levels(ilev)%patches(ipatch)
153  lbound = patch%lbound
154  bctype = patch%bcType
155  noff = abs(patch%l1end-patch%l1beg) + 1
156 
157 ! - initialized local variables
158 
159  fpx = 0.0_rfreal
160  fpy = 0.0_rfreal
161  fpz = 0.0_rfreal
162 
163  fvx = 0.0_rfreal
164  fvy = 0.0_rfreal
165  fvz = 0.0_rfreal
166 
167  mpx = 0.0_rfreal
168  mpy = 0.0_rfreal
169  mpz = 0.0_rfreal
170 
171  mvx = 0.0_rfreal
172  mvy = 0.0_rfreal
173  mvz = 0.0_rfreal
174 
175 ! - get patch dimensions and appropriate face vector
176 
177  CALL rflo_getpatchindices( region,patch,ilev,ibeg,iend,jbeg,jend,kbeg,kend )
178  CALL rflo_getpatchindicesnodes( region,patch,ilev, &
179  inbeg,inend,jnbeg,jnend,knbeg,knend )
181 
182  inode = 0
183  jnode = 0
184  knode = 0
185  IF (lbound==2 .OR. lbound==4 .OR. lbound==6) THEN
186  inode = -idir
187  jnode = -jdir
188  knode = -kdir
189  ENDIF
190 
191  IF (lbound==1 .OR. lbound==2) THEN
192  sface => region%levels(ilev)%grid%si
193  cface => region%levels(ilev)%grid%cfcI
194  ELSE IF (lbound==3 .OR. lbound==4) THEN
195  sface => region%levels(ilev)%grid%sj
196  cface => region%levels(ilev)%grid%cfcJ
197  ELSE IF (lbound==5 .OR. lbound==6) THEN
198  sface => region%levels(ilev)%grid%sk
199  cface => region%levels(ilev)%grid%cfcK
200  ENDIF
201 
202 ! - search for min/max xyz
203 
204  xmin = huge( 1._rfreal )
205  xmax = -huge( 1._rfreal )
206  ymin = huge( 1._rfreal )
207  ymax = -huge( 1._rfreal )
208  zmin = huge( 1._rfreal )
209  zmax = -huge( 1._rfreal )
210 
211  DO k=knbeg,knend
212  DO j=jnbeg,jnend
213  DO i=inbeg,inend
214  ijkn = indijk(i,j,k,inoff,ijnoff)
215  xmin = min( xmin,xyz(xcoord,ijkn) )
216  xmax = max( xmax,xyz(xcoord,ijkn) )
217  ymin = min( ymin,xyz(ycoord,ijkn) )
218  ymax = max( ymax,xyz(ycoord,ijkn) )
219  zmin = min( zmin,xyz(zcoord,ijkn) )
220  zmax = max( zmax,xyz(zcoord,ijkn) )
221  ENDDO
222  ENDDO
223  ENDDO
224 
225 ! - loop over faces ----------------------------------------------------------
226 
227  IF (((bctype>=bc_slipwall .AND. bctype<=bc_slipwall+bc_range) .OR. &
228  (bctype>=bc_noslipwall .AND. bctype<=bc_noslipwall+bc_range) .OR. &
229  (bctype>=bc_injection .AND. bctype<=bc_injection+bc_range)) .AND. &
230  ((xmin > boxxmin .AND. xmax < boxxmax) .AND. &
231  (ymin > boxymin .AND. ymax < boxymax) .AND. &
232  (zmin > boxzmin .AND. zmax < boxzmax))) THEN
233 
234  DO k=kbeg,kend
235  DO j=jbeg,jend
236  DO i=ibeg,iend
237 
238  ijkn = indijk(i+inode,j+jnode,k+knode,inoff,ijnoff)
239 
240  sfx = sface(xcoord,ijkn)
241  sfy = sface(ycoord,ijkn)
242  sfz = sface(zcoord,ijkn)
243  sfm = sface(xyzmag,ijkn)
244 
245  xc = cface(xcoord,ijkn)
246  yc = cface(ycoord,ijkn)
247  zc = cface(zcoord,ijkn)
248 
249 ! --------- get coefficients
250 
251  IF (lbound==1 .OR. lbound==2) THEN
252  n1 = j - jbeg
253  n2 = k - kbeg
254  ELSE IF (lbound==3 .OR. lbound==4) THEN
255  n1 = k - kbeg
256  n2 = i - ibeg
257  ELSE IF (lbound==5 .OR. lbound==6) THEN
258  n1 = i - ibeg
259  n2 = j - jbeg
260  ENDIF
261  i2d = indij(n1,n2,noff)
262 
263  cp = patch%cp(i2d)
264  cfx = patch%cf(xcoord,i2d)
265  cfy = patch%cf(ycoord,i2d)
266  cfz = patch%cf(zcoord,i2d)
267  ch = patch%ch(i2d)
268 
269 ! --------- compute contributions to force and moment coefficients
270 
271  fpx = fpx + cp*sfx*sfm
272  fpy = fpy + cp*sfy*sfm
273  fpz = fpz + cp*sfz*sfm
274 
275  fvx = fvx + cfx*sfm
276  fvy = fvy + cfy*sfm
277  fvz = fvz + cfz*sfm
278 
279  mpx = mpx - cp*(sfy*(zc - zref) + sfz*(yc - yref))*sfm
280  mpy = mpy + cp*(sfx*(zc - zref) - sfz*(xc - xref))*sfm
281  mpz = mpz + cp*(sfy*(xc - xref) - sfx*(yc - yref))*sfm
282 
283  mvx = mvx - (cfy*(zc - zref) + cfz*(yc - yref))*sfm
284  mvy = mvy + (cfx*(zc - zref) - cfz*(xc - xref))*sfm
285  mvz = mvz + (cfy*(xc - xref) - cfx*(yc - yref))*sfm
286  ENDDO ! i
287  ENDDO ! j
288  ENDDO ! k
289 
290 ! --- normalize and store coefficients ----------------------------------------
291 
292  patch%forceCoeffs(xcoord,forces_press) = fpx
293  patch%forceCoeffs(ycoord,forces_press) = fpy
294  patch%forceCoeffs(zcoord,forces_press) = fpz
295 
296  patch%forceCoeffs(xcoord,forces_visc) = fvx
297  patch%forceCoeffs(ycoord,forces_visc) = fvy
298  patch%forceCoeffs(zcoord,forces_visc) = fvz
299 
300  patch%momentCoeffs(xcoord,forces_press) = mpx
301  patch%momentCoeffs(ycoord,forces_press) = mpy
302  patch%momentCoeffs(zcoord,forces_press) = mpz
303 
304  patch%momentCoeffs(xcoord,forces_visc) = mvx
305  patch%momentCoeffs(ycoord,forces_visc) = mvy
306  patch%momentCoeffs(zcoord,forces_visc) = mvz
307 
308  global%forceCoeffs(xcoord,1) = global%forceCoeffs(xcoord,1) + fpx
309  global%forceCoeffs(ycoord,1) = global%forceCoeffs(ycoord,1) + fpy
310  global%forceCoeffs(zcoord,1) = global%forceCoeffs(zcoord,1) + fpz
311  global%forceCoeffs(xcoord,2) = global%forceCoeffs(xcoord,2) + fvx
312  global%forceCoeffs(ycoord,2) = global%forceCoeffs(ycoord,2) + fvy
313  global%forceCoeffs(zcoord,2) = global%forceCoeffs(zcoord,2) + fvz
314  global%momentCoeffs(xcoord,1) = global%momentCoeffs(xcoord,1) + mpx
315  global%momentCoeffs(ycoord,1) = global%momentCoeffs(ycoord,1) + mpy
316  global%momentCoeffs(zcoord,1) = global%momentCoeffs(zcoord,1) + mpz
317  global%momentCoeffs(xcoord,2) = global%momentCoeffs(xcoord,2) + mvx
318  global%momentCoeffs(ycoord,2) = global%momentCoeffs(ycoord,2) + mvy
319  global%momentCoeffs(zcoord,2) = global%momentCoeffs(zcoord,2) + mvz
320 
321  ENDIF ! bcType and boxBnd
322  ENDDO ! iPatch
323 
324 ! finalize ---------------------------------------------------------------------
325 
326  CALL deregisterfunction(global)
327 
328 END SUBROUTINE rflo_computepatchforcemomco
329 
330 
331 
332 
333 
334 ! *******************************************************************************
335 !
336 ! Purpose: Compute global force and moment coefficients.
337 !
338 ! Description: none.
339 !
340 ! Input: global = global data
341 !
342 ! Output: global%forceCoeffs, global%momentCoeffs =
343 ! global force and moment coefficients computed
344 !
345 ! Notes: none.
346 !
347 !*******************************************************************************
348 
349 SUBROUTINE rflo_computeintegralforcemomco( global )
350 
351  IMPLICIT NONE
352 
353 ! ... parameters
354  TYPE(t_global), POINTER :: global
355 
356 ! ... loop variables
357 
358 ! ... local variables
359  REAL(RFREAL) :: ffact, mfact
360  REAL(RFREAL), DIMENSION(12) :: globalvals, localvals
361 
362 ! *****************************************************************************
363 
364  CALL registerfunction(global,'RFLO_ComputeIntegralForceMomCo',&
365  'RFLO_ModForcesMoments.F90')
366 
367 ! Get constants ---------------------------------------------------------------
368 
369  ffact = 1.0_rfreal/global%forceRefArea
370  mfact = 1.0_rfreal/(global%forceRefArea*global%forceRefLength)
371 
372 ! Gather data -----------------------------------------------------------------
373 
374  localvals(1:3) = global%forceCoeffs(xcoord:zcoord,1)
375  localvals(4:6) = global%forceCoeffs(xcoord:zcoord,2)
376  localvals(7:9) = global%momentCoeffs(xcoord:zcoord,1)
377  localvals(10:12) = global%momentCoeffs(xcoord:zcoord,2)
378 
379 ! Perform reduction operation -------------------------------------------------
380 
381 #ifdef MPI
382  CALL mpi_allreduce( localvals,globalvals,SIZE(localvals),mpi_rfreal,mpi_sum,&
383  global%mpiComm,global%mpierr )
384  IF (global%mpierr /= 0) CALL errorstop( global,err_mpi_trouble,&
385  __line__ )
386 #else
387  globalvals = localvals
388 #endif
389 
390 ! Assign data -----------------------------------------------------------------
391 
392  global%forceCoeffs(:,1) = ffact*globalvals(1:3)
393  global%forceCoeffs(:,2) = ffact*globalvals(4:6)
394  global%momentCoeffs(:,1) = mfact*globalvals(7:9)
395  global%momentCoeffs(:,2) = mfact*globalvals(10:12)
396 
397 ! Finalize --------------------------------------------------------------------
398 
399  CALL deregisterfunction(global)
400 
401 END SUBROUTINE rflo_computeintegralforcemomco
402 
403 
404 
405 
406 
407 ! *******************************************************************************
408 !
409 ! Purpose: Write time dependent global force and moment coefficients to file.
410 !
411 ! Description: None.
412 !
413 ! Input: global = global force and moment coefficients
414 !
415 ! Output: None.
416 !
417 ! Notes: only master processor writes to file
418 !
419 ! ******************************************************************************
420 
421  SUBROUTINE rflo_writeintegralforcemomco( global )
422 
423  IMPLICIT NONE
424 
425 ! ... parameters
426  TYPE(t_global), POINTER :: global
427 
428 ! ... loop variables
429 
430 ! ... local variables
431  CHARACTER(CHRLEN+9) :: fname
432 
433  INTEGER :: errorflag
434  REAL(RFREAL) :: fpco(3), fvco(3), mpco(3), mvco(3)
435 
436 !******************************************************************************
437 
438  CALL registerfunction(global,'RFLO_WriteIntegralForceMomCo',&
439  'RFLO_ModForcesMoments.F90')
440 
441 ! Write global force and moment coefficients ----------------------------------
442 
443  IF (global%myProcid==masterproc) THEN
444 
445  fpco(1:3) = global%forceCoeffs(xcoord:zcoord,1)
446  fvco(1:3) = global%forceCoeffs(xcoord:zcoord,2)
447  mpco(1:3) = global%momentCoeffs(xcoord:zcoord,1)
448  mvco(1:3) = global%momentCoeffs(xcoord:zcoord,2)
449 
450  IF (global%flowType == flow_steady) THEN
451  WRITE(if_formom,1000,iostat=errorflag) global%currentIter, &
452  fpco(1:3),fvco(1:3),mpco(1:3),mvco(1:3)
453  ELSE
454  WRITE(if_formom,1005,iostat=errorflag) global%currentTime, &
455  fpco(1:3),fvco(1:3),mpco(1:3),mvco(1:3)
456  ENDIF
457 
458  global%error = errorflag
459  IF (global%error /= 0) THEN
460  CALL errorstop( global,err_file_write,&
461  __line__, &
462  'force-moment coeffs file' )
463  ENDIF
464 
465 ! - Close and open .fom file (instead of fflush) ------------------------------
466 
467  IF (global%probeOpenClose) THEN
468  WRITE(fname,'(A)') trim(global%outDir)//trim(global%casename)//'.fom'
469  CLOSE(if_formom)
470  OPEN( if_formom,file=fname,form='FORMATTED',status='OLD', &
471  position='APPEND')
472  ENDIF
473 
474  ENDIF ! only masterproc
475 
476 ! Finalize --------------------------------------------------------------------
477 
478  CALL deregisterfunction(global)
479 
480 1000 FORMAT(i6,12(1pe13.5))
481 1005 FORMAT(1pe14.7,12(1pe13.5))
482 
483 END SUBROUTINE rflo_writeintegralforcemomco
484 
485 
486 
487 !******************************************************************************
488 !
489 ! Purpose: open file for force and moment coefficients, write header.
490 !
491 ! Description: none.
492 !
493 ! Input: global = global force/moment coeffs, flow type, restart.
494 !
495 ! Output: to file.
496 !
497 ! Notes:
498 ! This routine should only be called for the master process. It will not
499 ! do anything if called by any other process (safeguard).
500 !
501 !******************************************************************************
502 
503 SUBROUTINE rflo_openforcemomcofile( global )
504 
505  USE modtools, ONLY: floatless
506  IMPLICIT NONE
507 
508 ! ... parameters
509  TYPE (t_global), POINTER :: global
510 
511 ! ... loop variables
512 
513 ! ... local variables
514  CHARACTER(CHRLEN+9) :: fname
515 
516  LOGICAL :: fileexists, fileappend
517  INTEGER :: ifile, lastiter, errorflag
518  REAL(RFREAL) :: lasttime
519 
520 !******************************************************************************
521 
522  CALL registerfunction( global,'RFLO_OpenForceMomCoFile',&
523  'RFLO_ModForcesMoments.F90' )
524 
525 ! store id and generate file name ---------------------------------------------
526 
527  ifile = if_formom
528 
529  WRITE(fname,'(A)') trim(global%outDir)//trim(global%casename)//'.fom'
530 
531 ! append to existing file (restart) or create new file ------------------------
532 
533  IF ((global%flowType==flow_unsteady .AND. &
534  global%currentTime>0._rfreal) .OR. &
535  (global%flowType==flow_steady .AND. &
536  global%currentIter>1)) THEN
537 
538  INQUIRE( file=fname,exist=fileexists )
539  IF (fileexists) THEN
540  fileappend = .true.
541  print *,solver_name,' Appending to ',trim(fname)
542  OPEN(ifile,file=fname,form='formatted',status='old',position='append', &
543  iostat=errorflag)
544  ELSE
545  fileappend = .false.
546  print *,solver_name,' Overwriting ',trim(fname)
547  OPEN(ifile,file=fname,form='formatted',status='unknown',iostat=errorflag)
548  ENDIF
549  ELSE ! new file
550 
551  fileappend = .false.
552  print *,solver_name,' Creating new ',trim(fname)
553  OPEN(ifile,file=fname,form='formatted',status='unknown',iostat=errorflag)
554  ENDIF ! fileStatus
555 
556  global%error = errorflag
557  IF (global%error /= 0) &
558  CALL errorstop( global,err_file_open,&
559  __line__,'File: '//trim(fname) )
560 
561 ! write header ----------------------------------------------------------------
562 
563  IF (.NOT. fileappend) THEN
564 
565  IF (global%flowType==flow_steady) THEN
566  WRITE(ifile,1000,iostat=errorflag)
567  ELSE
568  WRITE(ifile,1005,iostat=errorflag)
569  ENDIF
570 
571  global%error = errorflag
572  IF (global%error /= err_none) &
573  CALL errorstop( global,err_file_write,&
574  __line__,'File: '//trim(fname) )
575  ELSE
576 
577 ! - read the last line to get the last dump time. If the current time is
578 ! earlier, back up to a time prior to the current one.
579 
580  IF ( global%flowType == flow_unsteady ) THEN
581  lasttime = huge( 1.0_rfreal )
582 
583  loopunsteady: DO
584  backspace( ifile,iostat=errorflag )
585  IF (errorflag /= err_none) EXIT loopunsteady
586  READ(ifile, fmt=*, iostat=errorflag) lasttime
587  IF (errorflag /= err_none) EXIT loopunsteady
588  IF (floatless( lasttime,global%currentTime )) THEN
589  EXIT loopunsteady
590  ELSE
591  backspace( ifile,iostat=errorflag )
592  IF (errorflag /= err_none) EXIT loopunsteady
593  ENDIF
594  ENDDO loopunsteady
595 
596  print *,solver_name,' positioned ',trim(fname),' at time ',lasttime
597 
598  ELSE
599  lastiter = huge( 1 )
600 
601  loopsteady: DO
602  backspace( ifile,iostat=errorflag )
603  IF (errorflag /= err_none) EXIT loopsteady
604  READ(ifile, fmt=*, iostat=errorflag) lastiter
605  IF (errorflag /= err_none) EXIT loopsteady
606  IF (lastiter < global%currentIter) THEN
607  EXIT loopsteady
608  ELSE
609  backspace( ifile,iostat=errorflag )
610  IF (errorflag /= err_none) EXIT loopsteady
611  ENDIF
612  ENDDO loopsteady
613 
614  print *,solver_name,' positioned ',trim(fname),' at iteration ',lastiter
615 
616  ENDIF ! flowType
617  ENDIF ! append or new
618 
619 ! finalize --------------------------------------------------------------------
620 
621  CALL deregisterfunction( global )
622 
623 1000 FORMAT('iter, fpCoef(X,Y,Z), fvCoef(X,Y,Z), mpCoef(X,Y,Z), mvCoef(X,Y,Z)')
624 1005 FORMAT('time, fpCoef(X,Y,Z), fvCoef(X,Y,Z), mpCoef(X,Y,Z), mvCoef(X,Y,Z)')
625 
626 END SUBROUTINE rflo_openforcemomcofile
627 
628 
629 
630 ! *******************************************************************************
631 !
632 ! Purpose: Find region and patches contributing to global force and moment
633 ! coefficients.
634 !
635 ! Description: none.
636 !
637 ! Input: regions = global input and patches%bcType in all regions
638 !
639 ! Output: patch%globalAeroCoeffs==.true. = contributing regions and patches
640 !
641 ! Notes: the search and write to file hereafter is done in parallel manner
642 ! to mimic the actual process in computing the coefficients, hence
643 ! minimizing generation of incorrect info.
644 !
645 !*******************************************************************************
646 
647 SUBROUTINE rflo_findpatchcoeffsglo( regions )
648 
650  IMPLICIT NONE
651 
652 #include "Indexing.h"
653 
654 ! ... parameters
655  TYPE (t_region), POINTER :: regions(:)
656 
657 ! ... loop variables
658  INTEGER :: ireg, ipatch, i, j, k
659 
660 ! ... local variables
661  INTEGER :: ilev, bctype, ijkn, inoff, ijnoff
662  INTEGER :: inbeg, inend, jnbeg, jnend, knbeg, knend
663  REAL(RFREAL) :: boxxmin, boxxmax, boxymin, boxymax, boxzmin, boxzmax
664  REAL(RFREAL) :: xmin, xmax, ymin, ymax, zmin, zmax
665  REAL(RFREAL), POINTER :: xyz(:,:)
666  TYPE (t_global), POINTER :: global
667  TYPE (t_patch), POINTER :: patch
668 
669 ! ******************************************************************************
670 
671  global => regions(1)%global
672  CALL registerfunction(global,'RFLO_FindPatchCoeffsGlo',&
673  'RFLO_ModForcesMoments.F90')
674 
675 ! get needed parameters --------------------------------------------------------
676 
677  ilev = 1
678 
679  boxxmin = global%acBndBoxXmin
680  boxxmax = global%acBndBoxXmax
681  boxymin = global%acBndBoxYmin
682  boxymax = global%acBndBoxYmax
683  boxzmin = global%acBndBoxZmin
684  boxzmax = global%acBndBoxZmax
685 
686 ! loop over all regions and patches in parallel --------------------------------
687 
688  DO ireg = 1,global%nRegions
689  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
690  regions(ireg)%active==active) THEN ! on my processor
691 
692 
693  CALL rflo_getnodeoffset( regions(ireg),ilev,inoff,ijnoff )
694  xyz => regions(ireg)%levels(ilev)%grid%xyz
695 
696  DO ipatch = 1,regions(ireg)%nPatches
697  patch => regions(ireg)%levels(ilev)%patches(ipatch)
698  bctype = patch%bcType
699 
700 ! ----- get patch dimensions
701 
702  CALL rflo_getpatchindicesnodes( regions(ireg),patch,ilev, &
703  inbeg,inend,jnbeg,jnend,knbeg,knend )
704 
705 ! ----- search for min/max xyz
706 
707  xmin = huge( 1._rfreal )
708  xmax = -huge( 1._rfreal )
709  ymin = huge( 1._rfreal )
710  ymax = -huge( 1._rfreal )
711  zmin = huge( 1._rfreal )
712  zmax = -huge( 1._rfreal )
713 
714  DO k=knbeg,knend
715  DO j=jnbeg,jnend
716  DO i=inbeg,inend
717  ijkn = indijk(i,j,k,inoff,ijnoff)
718  xmin = min( xmin,xyz(xcoord,ijkn) )
719  xmax = max( xmax,xyz(xcoord,ijkn) )
720  ymin = min( ymin,xyz(ycoord,ijkn) )
721  ymax = max( ymax,xyz(ycoord,ijkn) )
722  zmin = min( zmin,xyz(zcoord,ijkn) )
723  zmax = max( zmax,xyz(zcoord,ijkn) )
724  ENDDO
725  ENDDO
726  ENDDO
727 
728 ! ----- test for globalAeroCoeffs
729 
730  IF (((bctype>=bc_slipwall .AND. bctype<=bc_slipwall+bc_range) .OR. &
731  (bctype>=bc_noslipwall .AND. bctype<=bc_noslipwall+bc_range) .OR. &
732  (bctype>=bc_injection .AND. bctype<=bc_injection+bc_range)) .AND.&
733  ((xmin > boxxmin .AND. xmax < boxxmax) .AND. &
734  (ymin > boxymin .AND. ymax < boxymax) .AND. &
735  (zmin > boxzmin .AND. zmax < boxzmax))) THEN
736 
737  patch%globalAeroCoeffs = .true.
738 
739  ENDIF ! bcType and boxBnd
740  ENDDO ! iPatch
741 
742  ENDIF ! myProcid
743  ENDDO ! iReg
744 
745 ! finalize ---------------------------------------------------------------------
746 
747  CALL deregisterfunction(global)
748 
749 END SUBROUTINE rflo_findpatchcoeffsglo
750 
751 
752 
753 ! ******************************************************************************
754 !
755 ! Purpose: write location of region and patches where global force and moment
756 ! coefficients are defined.
757 !
758 ! Description: only MASTERPROC write the information.
759 !
760 ! Notes: none.
761 !
762 ! ******************************************************************************
763 
764 SUBROUTINE rflo_writepatchcoeffsinfo( regions )
765 
766  IMPLICIT NONE
767 
768 ! ... parameters
769  TYPE(t_region), POINTER :: regions(:)
770 
771 ! ... loop variables
772  INTEGER :: ireg, ipatch
773 
774 ! ... local variables
775  CHARACTER(CHRLEN) :: fname
776  TYPE(t_global), POINTER :: global
777  TYPE(t_patch), POINTER :: patch
778 
779 #ifdef MPI
780  INTEGER :: status(mpi_status_size)
781 #endif
782  INTEGER :: ilev, errorflag, ifile, tag
783 
784 ! ******************************************************************************
785 
786  global => regions(1)%global
787 
788  CALL registerfunction(global,'RFLO_WritePatchCoeffsInfo',&
789  'RFLO_ModForcesMoments.F90')
790 
791 ! open file --------------------------------------------------------------------
792 
793  IF (global%myProcid == masterproc) THEN
794 
795  ifile = if_patch_coef
796  WRITE(fname,'(A)') trim(global%outDir)//trim(global%casename)//'.pcoin'
797 
798  OPEN(ifile,file=fname,form="formatted",status="unknown",iostat=errorflag)
799  global%error = errorflag
800 
801  IF ( global%error /= err_none ) &
802  CALL errorstop(global,err_file_open,&
803  __line__,fname)
804 
805  ENDIF ! MASTERPROC
806 
807 ! header and general information ---------------------------------------------
808 
809  IF (global%myProcid == masterproc) THEN
810  WRITE(ifile,1005)' Regions and patches of force and moment coefficients'
811  WRITE(ifile,1000)
812  WRITE(ifile,1005)' region-number patch-number'
813  WRITE(ifile,1000)
814  ENDIF
815 
816 ! print region and patches of global aero coeffs -----------------------------
817 
818  DO ireg=1,global%nRegions
819  ilev = regions(ireg)%currLevel
820 
821  DO ipatch=1,regions(ireg)%nPatches
822  patch => regions(ireg)%levels(ilev)%patches(ipatch)
823  tag = regions(ireg)%localNumber + mpi_patchoff*ipatch
824 
825 ! --- master receives and writes data, others send them
826 
827  IF (global%myProcid == masterproc) THEN
828 #ifdef MPI
829  IF (regions(ireg)%procid /= masterproc) THEN
830  CALL mpi_recv( patch%globalAeroCoeffs,1,mpi_logical, &
831  regions(ireg)%procid,tag,global%mpiComm,status, &
832  global%mpierr )
833  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,&
834  __line__ )
835  ENDIF
836 #endif
837  IF (patch%globalAeroCoeffs) WRITE(ifile,'(2I10)') ireg, ipatch
838 
839  ELSE ! not the master
840 #ifdef MPI
841  IF (regions(ireg)%procid == global%myProcid) THEN
842  CALL mpi_send( patch%globalAeroCoeffs,1,mpi_logical,masterproc,tag, &
843  global%mpiComm,global%mpierr )
844  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,&
845  __line__ )
846  ENDIF
847 #endif
848  ENDIF
849 
850  ENDDO ! iPatch
851  ENDDO ! iReg
852 
853 ! close file -------------------------------------------------------------------
854 
855  IF (global%myProcid == masterproc) THEN
856  CLOSE(ifile,iostat=errorflag)
857  global%error = errorflag
858  IF ( global%error /= err_none ) &
859  CALL errorstop(global,err_file_close,&
860  __line__,fname)
861  ENDIF
862 
863 ! finalize ---------------------------------------------------------------------
864 
865  CALL deregisterfunction( global )
866 
867 1000 FORMAT(/,1x,40('-'))
868 1005 FORMAT(/,a)
869 
870 END SUBROUTINE rflo_writepatchcoeffsinfo
871 
872 ! ******************************************************************************
873 ! End
874 ! ******************************************************************************
875 
876 END MODULE rflo_modforcesmoments
877 
878 ! ******************************************************************************
879 !
880 ! RCS Revision history:
881 !
882 ! $Log: RFLO_ModForcesMoments.F90,v $
883 ! Revision 1.6 2008/12/06 08:44:16 mtcampbe
884 ! Updated license.
885 !
886 ! Revision 1.5 2008/11/19 22:17:27 mtcampbe
887 ! Added Illinois Open Source License/Copyright
888 !
889 ! Revision 1.4 2006/03/25 04:34:49 wasistho
890 ! only masterproc write .pcoin and .fom files
891 !
892 ! Revision 1.3 2006/03/25 01:14:46 wasistho
893 ! cosmetics
894 !
895 ! Revision 1.2 2006/03/24 23:32:47 wasistho
896 ! added RFLO_FindPatchCoeffsGlo
897 !
898 ! Revision 1.1 2006/03/24 05:05:51 wasistho
899 ! initial import
900 !
901 !
902 ! ******************************************************************************
903 
904 
905 
906 
907 
908 
909 
910 
911 
912 
913 
914 
**********************************************************************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 ibeg
subroutine rflo_getpatchdirection(patch, idir, jdir, kdir)
double ymin() const
**********************************************************************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 inode
double xmax() const
subroutine, public rflo_writeintegralforcemomco(global)
j indices k indices k
Definition: Indexing.h:6
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
double xmin() const
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine rflo_getpatchindices(region, patch, iLev, ibeg, iend, jbeg, jend, kbeg, kend)
double zmin() const
subroutine, public rflo_computepatchforcemomco(region)
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
LOGICAL function floatless(a, b)
Definition: ModTools.F90:140
subroutine, public rflo_computeintegralforcemomco(global)
**********************************************************************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 jdir
Definition: patch.h:74
**********************************************************************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 knode iend
subroutine rflo_getpatchindicesnodes(region, patch, iLev, ibeg, iend, jbeg, jend, kbeg, kend)
blockLoc i
Definition: read.cpp:79
**********************************************************************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 idir
void int int REAL * x
Definition: read.cpp:74
subroutine, public rflo_writepatchcoeffsinfo(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 form
double zmax() const
subroutine, public rflo_openforcemomcofile(global)
double ymax() const
virtual std::ostream & print(std::ostream &os) const
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 knode jend
**********************************************************************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 kdir
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
**********************************************************************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 knode jbeg
**********************************************************************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 knode kbeg
subroutine deregisterfunction(global)
Definition: ModError.F90:469
**********************************************************************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 jnode
RT a() const
Definition: Line_2.h:140
subroutine, public rflo_findpatchcoeffsglo(regions)