Page 1 of 1
How to define a new vector field and its values?
Posted: Fri Oct 25, 2019 8:00 am
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
Re: How to define a new vector field and its values?
Posted: Fri Oct 25, 2019 10:34 am
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
Re: How to define a new vector field and its values?
Posted: Sat Oct 26, 2019 8:28 am
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.
Re: How to define a new vector field and its values?
Posted: Sun Oct 27, 2019 2:40 pm
by Yvan Fournier
Hello,
Could you specify at least the version info as per the forum usage recommendations ?
Regards,
Yvan
Re: How to define a new vector field and its values?
Posted: Sun Oct 27, 2019 2:54 pm
by Mohammad
Sorry,
My version is 5.0.9.
Re: How to define a new vector field and its values?
Posted: Sun Oct 27, 2019 3:12 pm
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
Re: How to define a new vector field and its values?
Posted: Sun Oct 27, 2019 3:51 pm
by Mohammad
Thank you Yvan.