Page 1 of 2
mass flow over an internal surface
Posted: Thu Jun 09, 2016 3:12 pm
by frpageot
Hello,
I inserted a small loop in the cs_f_user_extra_operations subroutine to calculate the mass flow rate passing thru this internal surface (perpendicular to x). Here is the code I used :
call field_get_key_int(ivarfl(iu), kimasf, iflmas)
call field_get_val_s(iflmas, imasfl)
call field_get_val_s(iprpfl(irom), cpro_rom)
flown = 0.0d0
surf = 0.0d0
cptfac = 0
call getfac('border', nlfac, lstfac)
do ielt = 1, nlfac
ifac = lstfac(ielt)
surf = surf + surfan(ifac)
flown = flown +imasfl(ifac)
cptfac = cptfac + 1
enddo
if (irangp.ge.0) then
call parsom(surf)
call parsom(flown)
call parcpt(cptfac)
endif
My question is relative to the sign of the mass flux. On boundary if the mass flux is positive it means the flow rate is outgoing, and if it is negative, it is ingoing due to normal orientation. I am wandering on the internal faces how it works. Normally internal faces has 2 surface vectors (ifacel(1,ifac) and ifeacel(2,ifac)), but in the code shown above i did not took this into account. How can I figure out what is the direction of the mass flow ? Thanks.
Re: mass flow over an internal surface
Posted: Thu Jun 09, 2016 3:50 pm
by frpageot
I may have posted to fast. Could it be that the direction is given by the sign relative to the iu : if positive it flows thru the positive x, if negative it flow thru the negative x ?
Re: mass flow over an internal surface
Posted: Thu Jun 09, 2016 8:44 pm
by Luciano Garelli
Hello,
Generally the mass flow rate is computed as

. In the documentation is mention that the surface vector of the faces are oriented outwards. Also, I think that a simple example like a fluid flow in a tube with an inlet and outlet can answer this question.
Regards,
Luciano
Re: mass flow over an internal surface
Posted: Fri Jun 10, 2016 8:11 am
by frpageot
not really because as I told the interior faces have 2 surface vectors, unlike the boundaries.
Re: mass flow over an internal surface
Posted: Fri Jun 10, 2016 8:47 am
by Yvan Fournier
Hello,
The mass flux sign is given relative to a face's normal. For interior faces, there is no guaranteed way of determining orientation relative to the geometry (it depends on the initial numbering).
To determine the mass flow rate, you need to compare the face normal to your "reference" normal. You also need to be careful in case of parallelism, as some faces may appear on 2 parallel ranks (on parallel domain boundaries).
This is one of the reasons why the built-in "balance by zone" operators (for example
http://code-saturne.org/doxygen/src/cs_ ... one_p.html) use volume region selections rather than just faces.
Regards,
Yvan
Re: mass flow over an internal surface
Posted: Fri Jun 10, 2016 9:31 am
by frpageot
OK Yvan,
What I did is that I changed the getfac instruction into : call getfac('border and normal[-1, 0, 0, 0.1]', nlfac, lstfac), as the face is perpendicular to the x axis. I determined -1 instead of 1 by a trial, and then I know that 1 gives a "0" while -1 gives a figure different than "0". using -1 on the normal seems to reflect then the orientation of the surface vector for this internal face. This is not really clean but it seems to work.
Re: mass flow over an internal surface
Posted: Tue Jun 14, 2016 9:37 am
by frpageot
Hello Yvan,
I did a small test on that. I run a calculation with 1 proc, and use a counter on the face number of the surface : 3653 faces which is in line with the face number out of the check mesh.But if I use 16 procs, then the number of faces rose to 3685...
So when you wrote :
Yvan Fournier wrote:You also need to be careful in case of parallelism, as some faces may appear on 2 parallel ranks (on parallel domain boundaries).
is that what you meant ? no way to overcome this ?
Thanks.
Re: mass flow over an internal surface
Posted: Tue Jun 14, 2016 1:40 pm
by Yvan Fournier
Hello,
Yes, to overcome this, we often add:
Code: Select all
if (ifacel(1,iel).le.ncel) then
...add face contribution...
endif
in Fortran, or
Code: Select all
if (cs_glob_mesh->i_face_cells[face_id][0] < cs_glob_mesh->n_cells) {
...
}
in C.
This works well when looping over all interior faces, but when looping on a subset of those faces, you mus then make sure interior faces on parallel boundaries are selected on both sides (always the case using getfac, but may not be the case in some user operations based on connectivities, and selecting faces adjacent to preselected cells for example)..
Regards,
Yvan
Re: mass flow over an internal surface
Posted: Wed Jun 15, 2016 9:52 am
by frpageot
Hello,
Sorry to bother you again with that, but if I want to use the CS_balance_by_zone to have the mass flow rate from one region to another region, i have to modify the code isn't it ?
Re: mass flow over an internal surface
Posted: Mon Apr 30, 2018 10:15 am
by JonasA
Hi!
I have also tried to compute the mass flow over an internal surface.
Fortunately, my surface are horizontal so I don't need to get the faces normal as they are already known. The mass flow would be
D= rho u_y A
I am unsure about which C function to use. The selection group INLET1 where I want to compute the mass flow is of type internal faces.
So should I use
Code: Select all
cs_selector_get_i_face_list("INLET1", &n_faces, face_list);
or
Code: Select all
cs_selector_get_b_face_list("INLET1", &n_faces, face_list);
to get the faces that belongs to it?
Then should I use i_face_cells or b_face_cells to get the associated cell, and rho or rho_b to get the density of this cell and b_face_surf or i_face_surf to get the surface of the face?
Then I will do a straigthforward
Code: Select all
BFT_MALLOC(face_list, n_b_faces, cs_lnum_t);
cs_selector_get_?_face_list("INLET1", &n_faces, face_list);
for (int i = 0; i < n_faces; i++) {
face_id = face_list[i];
cell_id = ?_face_cells[face_id][0]; // associated boundary cell
mass_1_balance += ?_face_surf[face_id] * ?rho[cell_id]*u[face_id][1];
}
with the "?" replaced by i or b accordingly to what is needed. I have tried with some combination of b and i without success.
Is it okay or will there be double count of some faces? Knowing that there is no double count in the group INLET1, the faces with which they are joined are in the group INLET2.
Regards
Jonas