mass flow over an internal surface

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: mass flow over an internal surface

Post by Yvan Fournier »

Hello,

For internal faces, always use the "i_faces" variants. The selection criteria never lead to double counts, but internal faces on MPI process boundaries can be counted twice if you do not take any precautions. For a face "i", i_face_cells[0] < n_cells is true for one rank and false for the other, so this is how we test it.

I recommend using the higher level functions for mass flow, which you can find in the examples (cs_user_extra_operations-balance_by_zone.c); the Doxygen link for that file seems incorrect so just check in the SRC/EXAMPLES subdirectory of a given case) The cs_user_extra_operations-scalar_balance.c example details a lower-level solution (similar to what you are doing).

Regards,

Yvan
JonasA
Posts: 18
Joined: Tue Feb 06, 2018 11:49 am

Re: mass flow over an internal surface

Post by JonasA »

Thanks for the helpful answer.

I did not manage to make the balance by zone function output the mass flow but changing the b into i mostly did the tricks.

I finally settle for that

Code: Select all

BFT_MALLOC(face_list, n_b_faces, cs_lnum_t);
        cs_selector_get_i_face_list("INLET2", &n_faces, face_list);
        for (int i = 0; i < n_faces; i++) {
                face_id = face_list[i];
                cell_id = (i_face_cells[face_id][0]<n_cells)?(i_face_cells[face_id][0]):(i_face_cells[face_id][1]); // associated boundary cell
                mass_1_balance += -i_face_surf[face_id] * rho[cell_id] * u[cell_id][1];
        }

        /* Free Memory */
        BFT_FREE(face_list);
        cs_parall_sum(1, CS_DOUBLE, &mass_1_balance);
to get the mass flow rate.

Regards,
Jonas
Post Reply