defining boundary condition on user selected interior faces

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
nvm67
Posts: 5
Joined: Fri Nov 01, 2024 2:16 pm

defining boundary condition on user selected interior faces

Post by nvm67 »

Hi, I am using ver 7.1.1.
My domain is a rectangular channel. I want to insert a circular patch of cells as boundary faces on each of the spanwise faces of the domain and I have included this function in cs_user_mesh-boundary.c

Code: Select all

void
cs_user_mesh_boundary(cs_mesh_t  *mesh)
{
  {
    cs_lnum_t   n_selected_faces = 0;
    cs_lnum_t  *selected_faces = NULL;

    /* example of multi-line character string */

    const char criteria[] = "cylinder[0.010,0.005,0.0,0.010,0.005,0.0,0.0009]"
                            " or cylinder[0.010,0.005,0.03,0.010,0.005,0.03,0.0009]";

    BFT_MALLOC(selected_faces, mesh->n_i_faces, cs_lnum_t);

    cs_selector_get_i_face_list(criteria,
                                &n_selected_faces,
                                selected_faces);

    cs_mesh_boundary_insert(mesh,
                            n_selected_faces,
                            selected_faces);
    BFT_FREE(selected_faces);
  }
}
I want to then define a BC type (inlet) on these faces.
I usually specify boundary conditions in the fortran subroutine and so I use

Code: Select all

call getfac("cylinder[0.010,0.005,0.03,0.010,0.005,0.03,0.0009]", nlelt, lstelt)
but this does not seem to specify the boundary conditions on these faces.
In the listing file it shows
Before insertion of user-defined boundary
Number of cells: 270000
Number of interior faces: 897750
Number of boundary faces: 4500
Number of vertices: 363004

After insertion of user-defined boundary
Number of cells: 270000
Number of interior faces: 807750
Number of boundary faces: 4500
Number of vertices: 363004
but the newly created boundary faces don't show up as boundary faces in the Groups list and also it's not visible in the post-processing output.

I alternatively tried to specify the boundary condition in the c-code function cs_user_boundary_conditions_setup

Code: Select all

void
cs_user_boundary_conditions_setup(cs_domain_t  *domain)
{
  CS_UNUSED(domain);

    const char criteria[] = "cylinder[0.010,0.005,0.0,0.010,0.005,0.0,0.0009]"
                            " or cylinder[0.010,0.005,0.03,0.010,0.005,0.03,0.0009]";
  {
    cs_equation_param_t  *eqp = cs_equation_param_by_name("velocity");

    cs_real_t inlet_velocity[] = {0.0, 0.0, 0.0};


    cs_equation_add_bc_by_value(eqp,
                                CS_PARAM_BC_DIRICHLET,
                                criteria,           // zone name
                                inlet_velocity);

  }
but now I get error Boundary zone "cylinder[************" is not defined.

Please could you advise the correct method of inserting boundary faces in the interior of the domain and specifying boundary condition on this. Is it possible to group the newly inserted faces and give it a name?

Many thanks
Yvan Fournier
Posts: 4226
Joined: Mon Feb 20, 2012 3:25 pm

Re: defining boundary condition on user selected interior faces

Post by Yvan Fournier »

Hello,

It is strange that the number of interior faces seems to decrease but the number of boundary faces remains constant.

I recommend testing this with a current version of the code (v8.0 or example, or v9.0 beta). Also, you can create an additional postprocessing mesh based on you selection criteria, to check that you select the desired faces, prior to mesh modification.

If none of this works or leads to a better understanding of the issue, I could test this on your mesh.

Best regards,

Yvan
nvm67
Posts: 5
Joined: Fri Nov 01, 2024 2:16 pm

Re: defining boundary condition on user selected interior faces

Post by nvm67 »

Hi Yvan,
Many thanks for the quick response. I defined a post-processing mesh to view the selected faces and to me it looks like the code is not able to select any faces that lie on the xz boundary faces of the channel domain (which are joined for periodicity before the mesh insertion function is called). I have not tried any newer versions of Code_saturne as they are not installed at my end.

For now I will try to define the faces outside Code_saturne when creating the mesh.

Thanks for your time
Yvan Fournier
Posts: 4226
Joined: Mon Feb 20, 2012 3:25 pm

Re: defining boundary condition on user selected interior faces

Post by Yvan Fournier »

Hello,

If faces are joined for periodicity, they become interior faces, so should be selectable as interior (not boundary) faces.
Combining periodicity and boundary face insertion would be another matter, as periodic faces are interior faces but one of their adjacent cell is a ghost cell, without any real connectivity, so probably not handled by the boundary insertion algorithm. Removing the periodicity condition is simpler in this case.

Best regards,

Yvan
Post Reply