Page 1 of 2
How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 12:15 pm
by Jundi He
Hi Code Saturne develop team:
In one of my script, I need to visit the mass flow of a cross section of the fluid channel. From the cs_field API, I can only get access to the variables stored in cells. How can I get the mass flow of a cross section (a certain layer of internal faces)? Thank you!
Regards!
Jundi
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 2:17 pm
by Luciano Garelli
Hello,
You can check the "cs_user_extra_operations-energy_balance.f90" in the example directory. In this example the kimasf (interior convective mass flux key ids of the variables) is used to access to the mass flow on internal faces.
Code: Select all
....
call field_get_key_int(ivarfl(ivar), kimasf, iflmas)
call field_get_val_s(iflmas, imasfl)
.....
Maybe this can help you.
Regards,
Luciano
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 6:45 pm
by Jundi He
Thanks for the example script, it;s useful. So after calling the two functions:
call field_get_key_int(ivarfl(ivar), kimasf, iflmas)
call field_get_val_s(iflmas, imasfl)
if ifac is the id of the internal face, I can access to the mass flow of this face by:
imasfl(ifac)
is it correct? Thanks!
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 7:00 pm
by Luciano Garelli
Hello,
Yes, it is correct.
Also, you can use the balance by zone in the GUI. The output is printed in the listing file and you can get the mass flow rate.
Regards,
Luciano
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 7:12 pm
by Jundi He
Normally I will use a do loop to all the internal faces:
do ifac = 1, nfac
can I directly use nfac (the total number of all the faces), or I need to first define it?
Another question is that if I have a face id, ifac, can I access to the coordinate of the face centre? Like the way I visit the coordinate of the cell centre: xyzcen(1,iel). Many thanks.
Regards!
Jundi
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 7:21 pm
by Luciano Garelli
Hello,
I suppose that you need to compute the mass flow over a subset of internal faces (because you ask about a cross section). If you need to compute the mass flow over all the internal faces you can use nfac (Fortran variables are global in the code, accessible directly by their name).
If you need to access to mesh entities or mesh quantities, this doxygen pages has the information
https://www.code-saturne.org/doxygen/src/mesh.html
To access to the interior faces coordinate use cdgfac (Center of gravity of interior faces).
Regards,
Luciano
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 7:26 pm
by Jundi He
OK, global variables means that I can directly visit in the scripts.
About the coordinate of the internal faces, if ifac is the face id, and I visit the z coordinate of the face centre:
cdgfac(3,ifac)
is this the correct way? Thanks!
Regards!
Jundi
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 7:33 pm
by Luciano Garelli
Yes, This is the correct way.
Regards,
Luciano
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 7:44 pm
by Jundi He
Thank you, this helps me a lot.
Jundi
Re: How to access to the mass flow of a cross section?
Posted: Tue Dec 12, 2017 8:06 pm
by Jundi He
Hi:
Can I visit the current number of iteration in the script? I guess it is another global number which I can directly access. Thanks!
Jundi