Page 1 of 1

How to calcule the Drag Coefficient and Rotating Cylinder

Posted: Mon Mar 19, 2012 11:39 am
by Renan Neves Nascimento
Hi,
 
I wanna know what do I need to do to obtain the Drag Coefficient using Code Saturne (using Salomé to do the mesh)
Also, I'd like to know how can I simulate a rotating cylinder in the Code Saturne.
 
Thanks in advance.
 
Renan Neves Nascimento

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Posted: Mon Mar 19, 2012 3:04 pm
by James McNaughton
What version do you use?

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Posted: Wed Mar 21, 2012 11:37 am
by Renan Neves Nascimento
James,
I use the version 2.0.4

Re: How to calcule the Drag Coefficient and Rotating Cylinde

Posted: Wed Mar 21, 2012 3:57 pm
by James McNaughton
The following is what I do for my rotating cylinder case you'll need to tweak it I guess. There are other ways to do this too but it works for me :)
In usclim:

Code: Select all

alpha = 10.0d0 ! non dim rotation rate = omega*cyl_radius/U

! --- Cylinder (walls)
call getfbr('BODY', nlelt, lstelt)
!==========
do ilelt = 1, nlelt

  ifac = lstelt(ilelt)
  iphas = 1

  itypfb(ifac,iphas)   = iparoi

  xx = cdgfbo(1,ifac)
  yy = cdgfbo(3,ifac)

  theta  = atan(abs(yy/xx))

  if(xx.ge.0.d0.and.yy.ge.0.d0) theta  =   theta
  if(xx.lt.0.d0.and.yy.ge.0.d0) theta  = - theta +      pi
  if(xx.lt.0.d0.and.yy.lt.0.d0) theta  =   theta +      pi
  if(xx.ge.0.d0.and.yy.lt.0.d0) theta  = - theta + 2.d0*pi

  ctheta = cos(theta)
  stheta = sin(theta)

  rcodcl(ifac, iu(iphas), 1) = alpha*(ctheta - stheta)
  rcodcl(ifac, iv(iphas), 1) = 0.d0
  rcodcl(ifac, iw(iphas), 1) = alpha*(stheta + ctheta)

enddo
The drag's an example in usproj and been discussed loads on this board (search for efforts).

Eg:

Code: Select all

!initialise
do ii=1,ndim
  xfor(ii) = 0.d0
enddo

call getfbr('BODY',nlelt,lstelt)
!    ======

do ilelt = 1, nlelt

  ifac  = lstelt(ilelt)

  ! xfor is force in ii direction
  do ii=1,ndim
    xfor(ii) = xfor(ii) + ra(iforbr + (ifac-1)*ndim + ii-1)
  enddo

enddo

!sum in parallel
if (irangp.ge.0) then
  call parrsm(ndim,xfor)
endif
Hope that helps.

James

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Posted: Thu Mar 22, 2012 12:22 am
by Renan Neves Nascimento
I'll try it!
Thank you, James!

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Posted: Tue Apr 03, 2012 4:53 pm
by Guillaume Mercier
Hi James,
 
For your information, it exist in Fortran a function called "atan2" which does the job you've done with 4 lines.
atan2(x,y) gives you the argument of the complexe x+iy
 
not crucial but helpful,
 
Cheers,
Guillaume