## Imposed velocity profile

Questions and remarks about code_saturne usage
Forum rules
stage75
Posts: 144
Joined: Tue Jun 12, 2012 8:21 pm

### Imposed velocity profile

Hi,

I want to imposed a profile of velocity at the inlet,

Each coordinate (x, y, z) has a value corresponding to the velocity, exemple :

x y z Axial velocity (Ua)

0 0 0 4
0 0,5 0,6 10
1 0,8 1,2 25
.......
...... Etc.

How could I do to impose this profile in "USCLIM.F90" subroutine ?

Could I just call my table ".txt" [coordinates, velocity] direct in the subroutine.

Thanks a lot
stage75
Posts: 144
Joined: Tue Jun 12, 2012 8:21 pm

### Re: Imposed velocity profile

Please is there someone who knows how I could impose a velocity prfofil speed at the inlet (for exemple, read a table format ".txt " if possible).

Code: Select all

``````! --- For boundary faces of color 1 assign an inlet for all phases
call getfbr('1', nlelt, lstelt)
!==========

do ilelt = 1, nlelt

ifac = lstelt(ilelt)
iel = ifabor(ifac)

do iphas = 1, nphas

itypfb(ifac,iphas) = ientre
if (xyznod (ndim, nnod).eq.0.5) then
rcodcl(ifac, iv, 1) = 0.8

else if ...

``````
JamesMcNaughton
Posts: 72
Joined: Mon Mar 19, 2012 1:21 pm

### Re: Imposed velocity profile

The best way is to define a function that represents the velocity profile. Curve fitting can be done to most profiles that I have tried so I would recommend this route.

Assuming it's complicated and 3D then you might need to read in the data from your text file. As saturne is unstructured there's no easy way to assign a face to a coordinate other than searching and minimising the distance - I hope someone will correct me if I am wrong here.

You did not say if the boundary coordinates are equal to those in the text file? If they are not you may prefer to extrapolate / interpolate from the values in your text file. Or you can assume the value is equal to that at the nearest point (as I will below).

So what you should do is read in the text file and store the coordinates and value in an array. When you loop over the inlet you need to perform another loop for each face coordinate that finds the minimum distance between the current face and all the coordinates in the array. Once you have the minimum distance you have the value for that face.

Depending on the size of inlet and data file the search is quite an expensive operation so you might want to consider doing this only at the first time-step and then storing the values
stage75
Posts: 144
Joined: Tue Jun 12, 2012 8:21 pm

### Re: Imposed velocity profile

Hi James,

Firstly I want to thank you for answering me.

I'll try to see is that I can define a profile of the speed from Table I. (I know it's difficult and it will take me a lot of time if it is feasible).

Effectively for the coordinates of Table I have done the interpolation of these values.

Otherwise to impose a uniform velocity at the inlet I write like this (is that's right):

Code: Select all

``````call getfbr('1', nlelt, lstelt)
!==========

do ilelt = 1, nlelt

ifac = lstelt(ilelt)
iel = ifabor(ifac)

do iphas = 1, nphas

itypfb(ifac,iphas) = ientre

rcodcl(ifac,iv(iphas),1) = 20

end do
end do``````
Thank's
stage75
Posts: 144
Joined: Tue Jun 12, 2012 8:21 pm

### Re: Imposed velocity profile

Hi,

Finally, I found my function corresponds to my velocity table,

Velocity (X) = 51000.X^4 -10655.X^3 + 756.X^-21.4*X + 0.408

X : its the coordinate

Please how can I write my code in the subroutine now, its this is correct?

Code: Select all

``````! --- For boundary faces of color 1 assign an inlet for all phases
call getfbr('1', nlelt, lstelt)
!==========

do ilelt = 1, nlelt

ifac = lstelt(ilelt)
iel = ifabor(ifac)

do iphas = 1, nphas

itypfb(ifac,iphas) = ientre

rcodcl(ifac, iv, 1) = 51000.X^4 -10655.X^3 + 756.X^-21.4*X + 0.408

``````
JamesMcNaughton
Posts: 72
Joined: Mon Mar 19, 2012 1:21 pm

### Re: Imposed velocity profile

This will give the y-component of velocity the value V = 2z^3:

Code: Select all

``rcodcl(ifac, iv(iphas), 1) = 2.d0 * cdgfbo(3,ifac) **3.d0``
From that you will be able to figure out the rest
stage75
Posts: 144
Joined: Tue Jun 12, 2012 8:21 pm

### Re: Imposed velocity profile

So if I understood:

Code: Select all

``````cdgfbo(3,ifac) corresponds to (Z axis)
cdgfbo(2,ifac) corresponds to (Y axis)
and
cdgfbo(1,ifac)  to (X axis)``````
I have a probleme when I imposed "ientre",

when I put other boundary condition that "input" (iparoi, isymet, etc.) the simulation work normaly, but when I change it in "ientre" I obteined the erreur (boundary condition are note correct or not complet!!)

Code: Select all

``````call getfbr('Face_68', nlelt, lstelt)
!==========
do ilelt = 1, nlelt

ifac = lstelt(ilelt)
do iphas = 1, nphas
itypfb(ifac,iphas)   = iparoi
enddo

enddo

call getfbr('Face_69', nlelt, lstelt)
!==========
do ilelt = 1, nlelt

ifac = lstelt(ilelt)

iel = ifabor(ifac)
do iphas = 1, nphas
itypfb(ifac,iphas)   = ientre

rcodcl(ifac,iv(iphas),1) =  50998.d0*cdgfbo(1,ifac)**4.d0- 10655.d0*cdgfbo(1,ifac)**3.d0+756.4d0*cdgfbo(1,ifac)**2.d0 - 21424.d0*cdgfbo(1,ifac) + 0.4078d0

enddo

enddo

call getfbr('Face_70', nlelt, lstelt)
!==========
do ilelt = 1, nlelt

ifac = lstelt(ilelt)
do iphas = 1, nphas
itypfb(ifac,iphas)   = iparoi
enddo

enddo``````
stage75
Posts: 144
Joined: Tue Jun 12, 2012 8:21 pm

### Re: Imposed velocity profile

For information,

The error persists even when I put a simple value at the inlet
exemple:

Code: Select all

``````call getfbr('Face_69', nlelt, lstelt)
!==========
do ilelt = 1, nlelt

ifac = lstelt(ilelt)

iel = ifabor(ifac)
do iphas = 1, nphas
itypfb(ifac,iphas)   = ientre

rcodcl(ifac,iv(iphas),1) =  5.d0

enddo``````
JamesMcNaughton
Posts: 72
Joined: Mon Mar 19, 2012 1:21 pm

### Re: Imposed velocity profile

What is the error?
stage75
Posts: 144
Joined: Tue Jun 12, 2012 8:21 pm

### Re: Imposed velocity profile

Hi James,

FOr be precise, When I run the simulation for 1iteration ) I have the results normal but when I run the simulation for 3 iteration I have this error, Once I change (iparoi, isymet etc..) by "ientre, I have this error!:

Code: Select all

``some boundary conditions are not defined or poorly defined``