How to define a new vector field and its values?

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

How to define a new vector field and its values?

Post by Mohammad »

Hi,
I want to create a new vector field like velocity field.
How can I do that? in which file? Is there an example?
Also, I want to know that if I define a field in a C file, can I call and use that field values in a Fortran file?
Thank you
joubanba
Posts: 9
Joined: Fri Oct 04, 2019 9:42 am

Re: How to define a new vector field and its values?

Post by joubanba »

Hello,

You can add a new scalar or vector field in the subroutine cs_user_parameter.c by using the function: cs_parameters_add_variable (name, dimension).

you can find here an example of adding a scalar field: https://www.code-saturne.org/cms/sites/ ... eters.html

And you can get the field values by using the functions:

C function: const cs_real_3_t *cvar_vector = (const cs_real_3_t *)cs_field_by_name("vector_name")->val ;

Fortran function: call field_get_val_v_by_name('vector_name', cvar_vector)

Regards,

Jamal
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: How to define a new vector field and its values?

Post by Mohammad »

Thanks a lot.
When I use this code:

Code: Select all

cs_parameters_add_variable("vector_name", 3);
The compiler ends with the following error:
Only user variables of dimension 1 are currently handled,
but vector_name is defined with dimension 3.
Where's the problem?

I appreciate your helps.
Last edited by Mohammad on Sun Oct 27, 2019 2:58 pm, edited 1 time in total.
Yvan Fournier
Posts: 4077
Joined: Mon Feb 20, 2012 3:25 pm

Re: How to define a new vector field and its values?

Post by Yvan Fournier »

Hello,

Could you specify at least the version info as per the forum usage recommendations ?

Regards,

Yvan
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: How to define a new vector field and its values?

Post by Mohammad »

Sorry,
My version is 5.0.9.
Yvan Fournier
Posts: 4077
Joined: Mon Feb 20, 2012 3:25 pm

Re: How to define a new vector field and its values?

Post by Yvan Fournier »

Hello,

Looking at the code, it seems you can add a user vector in version 6.0, not in 5.0.

Regards,

Yvan
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: How to define a new vector field and its values?

Post by Mohammad »

Thank you Yvan.
Post Reply