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
mass flow over an internal surface
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: mass flow over an internal surface
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
to get the mass flow rate.
Regards,
Jonas
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);
Regards,
Jonas