Page 2 of 3

Re: Tangential velocity

Posted: Mon May 07, 2018 2:48 pm
by Robert
Hello,

I tried to create a small subroutine and I get this error : "SIGSEGV signal (forbidden memory area access) intercepted!"
There's nothing else written in the error file, only this row.
I set the volumic flow rate in GUI and i wrote this code in cs_user_boundary_condition.f90 (with z=axial direction)

Code: Select all

call getfbr('Inlet',nlelt,lstelt)

do ilelt = 1, nlelt
x = cdgfbo(1,ifac)
y = cdgfbo(2,ifac)
z = cdgfbo(3,ifac)
a = atan(y/x)
b = (45/180*3.14)

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

if (x<0) then
rcodcl(ifac,iu,1) = cos(a+b)
rcodcl(ifac,iv,1) = sin(a+b)
rcodcl(ifac,iw,1) = 0
else
rcodcl(ifac,iu,1) = -cos(a+b)
rcodcl(ifac,iv,1) = -sin(a+b)
rcodcl(ifac,iw,1) = 0
end if

 enddo
Is there another way to declare a volumic flow rate and directions?

Regards,
Robert

Re: Tangential velocity

Posted: Mon May 07, 2018 9:07 pm
by Yvan Fournier
Hello,

The problem is probably that you access ifac (for x, y,z) before setting it. Moving it in dependency order:

Code: Select all

call getfbr('Inlet',nlelt,lstelt)

do ilelt = 1, nlelt

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

  x = cdgfbo(1,ifac)
  y = cdgfbo(2,ifac)
  z = cdgfbo(3,ifac)
  a = atan(y/x)
  b = (45/180*3.14)

  itypfb(ifac) = ientre

  if (x<0) then
    rcodcl(ifac,iu,1) = cos(a+b)
    rcodcl(ifac,iv,1) = sin(a+b)
    rcodcl(ifac,iw,1) = 0
  else
    rcodcl(ifac,iu,1) = -cos(a+b)
    rcodcl(ifac,iv,1) = -sin(a+b)
    rcodcl(ifac,iw,1) = 0
  end if
  
enddo
Regards,

Yvan

Re: Tangential velocity

Posted: Tue May 08, 2018 7:39 am
by Antech
Hello, Robert. Sorry for being late, your PM was in the "spam" for some reason... If you need the swirling BC, please, take a look at my code in attachment.

Re: Tangential velocity

Posted: Tue May 08, 2018 4:54 pm
by Robert
Many thanks to both of you!
Indeed, when i changed that row's position it works but I have few problems:
1) The simulation run but after saving results I get this error:
"solver script exited with status -2. /Error running the calculation. ,Check Code_Saturne log (listing) and error* files for details. /Error in calculation stage. "
In fact everything works but I have to use run_solver in order to get the listing and postprocessing files and there's no error file.
2) I get different results when I use the cs_user_boundary_condition.f90 than if I write the code in GUI/ user profile direction.
3) I changed the code to this one:

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)
a = atan(y/x)
b = (10/180*3.14)
itypfb(ifac) = ientre
if (x<0) then
rcodcl(ifac,iu,1) = (cos(a+b)-sin(a+b))
rcodcl(ifac,iv,1) = (cos(a+b)+sin(a+b))
rcodcl(ifac,iw,1) = 0
else 
rcodcl(ifac,iu,1) = -(cos(a+b)-sin(a+b))
rcodcl(ifac,iv,1) = -(cos(a+b)+sin(a+b))
rcodcl(ifac,iw,1) = 0
end if

 enddo
It doesn't matter what angle I choose, I have the same results as shown in figure 1. Also it doesn't matter what velocity or volumic flow rate I set in GUI, it doesn;t change the values that I get.
Can I set the volumic flow rate in cs_user_boundary_condition.f90 too?

Best regards,
Robert

Re: Tangential velocity

Posted: Thu May 10, 2018 1:23 pm
by Antech
Hello, Robert.

Regarding the velocity components calculation. I used other math, intended to cope with arbitrary inlet face orientation. Also, I made my "plugin" quite long ago so I don't remember details. I only can say that I found the general coordinate system rotation formulae on the Internet. If you only need the swirl-type BC you can use my program (fill the Excel table attached to my previous message, export to CSV and place in DATA directory, don't forget to copy the program to the SRC).

Regarding volumetric/mass flow rate. No, you can't. Your BC scrip overrides GUI settings. Also, from the physical standpoint, you cannot set velocity and flow rate simultanously. If you set the velocity profile, then the flow rate will be given by the surface integral of Rho*Wnormal.

Concerning errors reported when you run calculation, I think, Yvan will help you, or you can ask you IT specialist, or take a closer look to what happens (inspect the RESU subdirectory, or direct the output to GUI window in GUI settings, use only one process for testing etc; there should be some issue because, in normal way, it just says "Saving calculation results").

if I write the code in GUI/ user profile direction
I don't now the way to set profile within GUI. May be I just not aware of some options... If you mean Calculation control - Profiles, then it looks like an output of profiles to CSV files, not setting the inlet BC. So with this option you will run the solver with usual inlet parameters defined in GUI.

Re: Tangential velocity

Posted: Thu May 10, 2018 5:45 pm
by Robert
Hello,

In GUI I can set a volumic flow rate and then set a direction using user profile. I tought that if I set a volumic flow rate in GUI and then write the same formulas in subroutine then rcodcl(ifac,iu,1) would be the equivalent of dir_x for example.
About that error, I get it only when I use subroutines, it doesn't matter how many cores I use. I just get this error and I have to use run_solver which is located in RESU/-mycase- and then I get all the files and postprocessing folders etc.

Regards,
Robert

Re: Tangential velocity

Posted: Fri May 11, 2018 6:52 am
by Antech
Hello.
Thanks for the explanation. I was not aware of this option in GUI, seems that it's appeared in recent versions. I think that, if the profile is given, it should override the normal velocity or flow rate setting. But I may be wrong if Saturne is "smart" enough to scale the profile's normal component providing the given flow rate. If all things are correct, the result must be the same as with user subroutine. I hope, Yvan will clear this for us.

If you get errors only with subroutine, try to find and inspect the compile log file in RESU. Although, because it compiles and runs giving the reasonable vector directions, I don't think that there is a major error (and the code itself looks correct), but it's always useful to check the compile log to be absolutely sure.

Regarding the b value effect. I don't know what is the purpose of this variable, but, if you only need the particular case with fixed BC orientation, you may use something like Wx=magTan*cos(a), Wy=magTan*sin(a), Wz=magAxial and conditions with signs for various quadrants like in your code (magTan is tangential component magnitude [m/s], magAxial is the axial component magnitude [m/s]). So we don't need additional variable like b here. If you need the universal approach, you can use my code.

Re: Tangential velocity

Posted: Sat May 12, 2018 11:58 am
by Yvan Fournier
Hello,

As an additional precision, Code_Saturne only scales the inlet velocity when given a flow rate using the GUI. In all other cases, it is u to the user to do the scaling.

Also, in the case where there were crashes using the user subroutine, Robert did not post the error logs, or other recommended files, so I although I suspect an error in the subroutines, I can't check.

Regards,

Yvan

Re: Tangential velocity

Posted: Mon May 14, 2018 9:00 am
by Robert
Hello,

@Antech "b" value should be the angle presented in the Picture1 attached.

@Yvan Fournier
Sorry, I attached the files recommended.

Re: Tangential velocity

Posted: Mon May 14, 2018 9:02 am
by Robert
It seems that I can't select more than 3 files so here are the last ones:


Mention: I'm using code_saturne 5.0 for windows. There is no error file.