Import velocity profile

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Re: Import velocity profile

Post by Antech »

Hello. This code will set the profile for the Z velocity component with the function w(z)=-0.7012*(z**2)... leaving other components zero. If it's what you need, try to run the case with it. If you only need the function for the fixed circular profile, you don't need profile files.
Robert
Posts: 26
Joined: Mon May 22, 2017 11:14 am

Re: Import velocity profile

Post by Robert »

Hello, yes, this is what I'm trying to do. I have two meshes with different quality (but same geometry references- a simple pipe). So I exported from Paraview the Velocity on x, y, z directions on the inlet of the Mesh1 (I used the GUI in this runcase). I found the function for each of them and now I'm trying to set them on the inlet of the Mesh2 using this subroutine. I did try w(z)=-0.7012*(z**2) but the results are not even close. I also tried as you suggested, to modify the code and call the values of the diameter from a .txt file but again I got "error -1" - it didn't create and error file to see what's wrong.
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Re: Import velocity profile

Post by Antech »

Hello.
Sorry, I was not precise enough... I meant rcodcl(ifac,iw,1) = -0.7012*(z**2)+0.1144*z+0.0057 as you mentioned in your code (just shorted it in my post). Hard-code it into subroutine and check the result with the "plot over line" in ParaView.

If it's wrong, check that the Z value in simulation is consistent with expression (i.e. the coordinate system of the geometry/mesh is placed correctly relative to the inlet), this is very common to mismatch (shift) coordinates setting BC profile. The simplest test is rcodcl(ifac,iw,1) = z, you will see Z values as the velocity component at the inlet.

Don't spend the time on profile files, you don't need them if you have an expression that represents the profile well and it's OK to hard-code the profile in your case. You need to read profile from file only if you need the universal tool or there is no appropriate expression.
Robert
Posts: 26
Joined: Mon May 22, 2017 11:14 am

Re: Import velocity profile

Post by Robert »

Hello,
You was precise, I wasn't. I wrote rcodcl(ifac,iw,1) = -0.7012*(z**2)+0.1144*z+0.0057 in the subroutine and it didn't work.
Anyway the correct way, when z is the axial direction, seems to be something like:

Code: Select all

do ilelt = 1, nlelt
ifac = lstelt(ilelt)
iel = ifabor(ifac)
x = cdgfbo(1,ifac)
y = cdgfbo(2,ifac)
z = cdgfbo(3,ifac)
Rad='measured/known value of the radius'
Rc = sqrt(x**2+y**2)
R=Rad-Rc

itypfb(ifac) = ientre

rcodcl(ifac,iu,1) = 0
rcodcl(ifac,iv,1) = 0
rcodcl(ifac,iw,1) = -0.7012*(R**2)+0.1144*R+0.0057
Regards,
Robert
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Re: Import velocity profile

Post by Antech »

Hello.
We both have forgot to convert the radius :) Hope this version works.
Robert
Posts: 26
Joined: Mon May 22, 2017 11:14 am

Re: Import velocity profile

Post by Robert »

Hello,
It doesn't. For the axial direction the profiles fit in both cases, but when it comes to `u` and `v` they don't fit. I tried to do something like:

Code: Select all

do ilelt = 1, nlelt
ifac = lstelt(ilelt)
iel = ifabor(ifac)
x = cdgfbo(1,ifac)
y = cdgfbo(2,ifac)
z = cdgfbo(3,ifac)
Rad='measured/known value of the radius'
Rc = sqrt(x**2+y**2)
R=Rad-Rc
a=atan(y/x)
V1= aR**2+b*R+c
V2=eR**2+f*R+g
 / where a, b, c, e, f, g are exported constants /
itypfb(ifac) = ientre

rcodcl(ifac,iu,1) = V1  or  V1*cos(a)+V2*sin(a) or  V1*cos(a)
rcodcl(ifac,iv,1) = V2 or  V1*cos(a)-V2*sin(a) or  V2*sin(a)
rcodcl(ifac,iw,1) = -0.7012*(R**2)+0.1144*R+0.0057
'`
konst
Posts: 30
Joined: Sun Sep 17, 2017 7:41 pm

Re: Import velocity profile

Post by konst »

Hello.

I have a similar task. I was reading from GUI-defined csv-profile with velocity and turbulence statistics and use as boundary conditions. I was using C-version of files. You can find it here https://github.com/kikuznetsov/Code_Saturne-SRC . The source code is adapted for k-epsilon and Rij-epsilon turbulence model. Do not hesitate to ask If you have some questions about these code.
Robert
Posts: 26
Joined: Mon May 22, 2017 11:14 am

Re: Import velocity profile

Post by Robert »

Hello,
Thank you, I will try them!
Regards,
Robert
Post Reply