specify different head losses for different subdomains

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
daniele
Posts: 149
Joined: Wed Feb 01, 2017 11:42 am

Re: specify different head losses for different subdomains

Post by daniele »

Hello,

anybody can help me with this issue?
I would like to pick a specific zone of the domain (here called "Zone_1") and select only its cells satisfying the condition "x>0".
I tried the following inside the cs_user_head_losses.c, but it does not work (no head loss is added nowhere):

Code: Select all

const char criteria[] = "x>0";
  cs_lnum_t   n_selected_cells = 0;
  cs_lnum_t  *selected_cells = NULL;
  
    if (strcmp(zone->name, "Zone_1") == 0) {

   BFT_MALLOC(selected_cells, zone->n_cells, cs_lnum_t);
   cs_selector_get_cell_list(criteria,
                              &n_selected_cells,
                              selected_cells);
       
       for (cs_lnum_t i = 0; i < selected_cells; i++) {
        cs_lnum_t c_id = zone->cell_ids[i];
 
    	cku[i][0] = 0.0;
        cku[i][1] = 0.0;
        cku[i][2] = 0.5*10*fabs(cvara_vel[c_id][2]);
      }
     BFT_FREE(selected_cells);
      }

I also tried to define a new region through the cs_user_zones.c, but I do not know how to fix at the same time the two criteria "pick Zone_1" and "x>0", such as:

Code: Select all

    cs_volume_zone_define("head_loss_1",  "Zone_1 & x>0", CS_VOLUME_ZONE_HEAD_LOSS);
Many thanks in advance.

Best regards,

daniele
Post Reply