Page 1 of 1

space coordinates with C subroutines

Posted: Fri Oct 06, 2017 3:57 pm
by daniele
Hello,

I have a simple question... How can I call the x,y,z cell centroid coordinates in C subroutines?
For example if I have to write:

if (x>2[m]) then source_term=s

I found examples on how to do that in Fortran, but no examples with C routines.

Thanks a lot in advance.

Best regards,

daniele

Re: space coordinates with C subroutines

Posted: Sat Oct 07, 2017 8:25 pm
by Luciano Garelli
Hello,

In the Doxygen documentation you can find a specific section about "How to access and manage the mesh entities and mesh quantities ?", for both Fortran and C. This is the link http://code-saturne.org/doxygen/src/mesh.html.

Also, in the file " cs_user_mesh-modify.c" in the EXAMPLE directory you can view some example anout how to access.

Regards,

Luciano

Re: space coordinates with C subroutines

Posted: Wed Oct 11, 2017 1:12 pm
by daniele
Dear Luciano,

Thank you very much for your help.
Nevertheless, in the documents you suggested I could not find exactly what I need.
In order to use a more practical example, if we consider the cs_user_head_losses.f90 of version 4, we find a getcel as the following:

call getcel('X <= 6.0 and X >=4.0 and Y >=2.0 and Y<=8.0',nlelt,lstelt)

How can I write the same space conditions in the cs_user_head_losses.c? I mean, can I simply still use "X" and "Y" name variable in c subroutines?

Many thanks in advance.

Best regards,

Daniele

Re: space coordinates with C subroutines

Posted: Wed Oct 11, 2017 5:27 pm
by Luciano Garelli
Hello Daniele,

In the file " cs_user_mesh-modify.c" there is an example of cells selection for a specific criteria using the function "cs_selector_get_cell_list()"

Code: Select all

cs_lnum_t   n_selected_cells = 0;
cs_lnum_t  *selected_cells = NULL;

const char criteria[] = "box[0.5, 0.5, 0, 1, 1, 0.05]";

BFT_MALLOC(selected_cells, mesh->n_cells, cs_lnum_t);

cs_selector_get_cell_list(criteria, &n_selected_cells, selected_cells);

Regards,

Luciano