How to calcule the Drag Coefficient and Rotating Cylinder

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Renan Neves Nascimento

How to calcule the Drag Coefficient and Rotating Cylinder

Post 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
James McNaughton

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Post by James McNaughton »

What version do you use?
Renan Neves Nascimento

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Post by Renan Neves Nascimento »

James,
I use the version 2.0.4
James McNaughton

Re: How to calcule the Drag Coefficient and Rotating Cylinde

Post 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
Renan Neves Nascimento

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Post by Renan Neves Nascimento »

I'll try it!
Thank you, James!
Guillaume Mercier

Re: How to calcule the Drag Coefficient and Rotating Cylinder

Post 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
Post Reply