How to access to the mass flow of a cross section?

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

How to access to the mass flow of a cross section?

Post 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
Luciano Garelli
Posts: 284
Joined: Fri Dec 04, 2015 1:42 pm

Re: How to access to the mass flow of a cross section?

Post 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
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: How to access to the mass flow of a cross section?

Post 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!
Luciano Garelli
Posts: 284
Joined: Fri Dec 04, 2015 1:42 pm

Re: How to access to the mass flow of a cross section?

Post 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
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: How to access to the mass flow of a cross section?

Post 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
Luciano Garelli
Posts: 284
Joined: Fri Dec 04, 2015 1:42 pm

Re: How to access to the mass flow of a cross section?

Post 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
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: How to access to the mass flow of a cross section?

Post 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
Luciano Garelli
Posts: 284
Joined: Fri Dec 04, 2015 1:42 pm

Re: How to access to the mass flow of a cross section?

Post by Luciano Garelli »

Yes, This is the correct way.

Regards,

Luciano
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: How to access to the mass flow of a cross section?

Post by Jundi He »

Thank you, this helps me a lot.

Jundi
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: How to access to the mass flow of a cross section?

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