after some debugging the function is working, the boundary condition is transmitted to the i_face. Here the debugged code:
Code: Select all
static void
bounfunc(void *input,
cs_lnum_t *n_cells,
cs_lnum_t **cell_ids)
{
cs_lnum_t i, face_id;
cs_lnum_t _n_cells = 0;
cs_lnum_t *_cell_ids = NULL;
cs_lnum_t n_b_faces = 0;
//cs_lnum_t *b_face_ids = NULL;
/* import the mesh */
const cs_mesh_t *mesh = cs_glob_mesh;
/* define variable and pointers*/
cs_lnum_t n_elts;
cs_lnum_t *elt_ids;
/*import all cells, also with halo - ghost */
const int n_cells_ext = mesh->n_cells_with_ghosts;
/* Initialize cell marker */
int *cell_marker;
/* malloc in cell marker the size of the cells, ghost included*/
BFT_MALLOC(cell_marker, n_cells_ext, int);
/* mark all cells as 0 */
for (i = 0; i < mesh->n_cells; i++)
cell_marker[i] = 0;
/* Select boundary faces belonging to "heat" and save
* their number and id */
BFT_MALLOC(elt_ids, mesh->n_b_faces, cs_lnum_t);
cs_selector_get_b_face_list("heat", &n_elts, elt_ids);
/* Mark adjacent cells (with boundary face family) */
/* scroll all the selected element list */
for (i = 0; i < n_elts; i++) {
cs_lnum_t face_id = elt_ids[i];
/* marking cells cell_marker[cell_id]= Boundary face family */
cell_marker[mesh->b_face_cells[face_id]] = mesh->b_face_family[face_id];
}
/* Now propagate to interior faces */
for (i = 0; i < mesh->n_i_faces; i++) { //for all the i_faces
for (cs_lnum_t j = 0; j < 2; j++) {
cs_lnum_t cell_id = mesh->i_face_cells[i][j]; //pick the cell id of i_face
if (cell_marker[cell_id] != 0) //if it is the cell to be removed
mesh->i_face_family[i] = cell_marker[cell_id];
}
}
/* now pick only the all - undesired cells to a new mesh*/
BFT_MALLOC(_cell_ids, mesh->n_cells, cs_lnum_t); /* Allocate selection list */
for (i = 0; i < mesh->n_cells; i++) {
if (cell_marker[i] == 0) {
_cell_ids[_n_cells] = i;
_n_cells += 1;
}
}
BFT_REALLOC(_cell_ids, _n_cells, cs_lnum_t); /* Adjust size(good practice,but not required) */
/* Set return values */
*n_cells = _n_cells;
*cell_ids = _cell_ids;
BFT_FREE(cell_marker);
BFT_FREE(elt_ids);
}
Thanks
Andrea