Page 1 of 1

How to set the relaxation factor in Code_Saturne?

Posted: Tue Jul 28, 2020 1:10 am
by Mohammad
Hello,

I want to change the relaxation factor for pressure from 1 to 0.7 in a simulation with LES.
According to this post I think I should add relaxv(ipr)=0.7 in to the cs_user_parameters.f90 file in the usipsu subroutine. But when I add this line, the compiler says:
The function relaxv does not have an implicit type.
And when I define it as double precision it gives this error:
Unclassified statement at (1).
Can you please help me with this? I'm not good in FORTRAN.

Regards,

Mohammad

Re: How to set the relaxation factor in Code_Saturne?

Posted: Tue Jul 28, 2020 2:29 am
by Yvan Fournier
Hello,

The post is obsolete. The syntax has changed. relaxv is now a member of the var_cal_opt structure (usable from both C and Fortran), for which the Doxygen examples should show how to access/modify members (see examples in cs_user_parameters-base.c for iwarni or blencv, and do the same for relaxv).

Regards,

Yvan

Re: How to set the relaxation factor in Code_Saturne?

Posted: Tue Jul 28, 2020 8:24 am
by Mohammad
Yvan Fournier wrote: Tue Jul 28, 2020 2:29 am Hello,

The post is obsolete. The syntax has changed. relaxv is now a member of the var_cal_opt structure (usable from both C and Fortran), for which the Doxygen examples should show how to access/modify members (see examples in cs_user_parameters-base.c for iwarni or blencv, and do the same for relaxv).

Regards,

Yvan
Thank you for your great support Yvan!
I did the same for relaxv in cs_user_parameters.f90 and in the usipsu subroutine.
My code is:

Code: Select all

call field_get_key_struct_var_cal_opt(ivarfl(ipr), vcopt)
vcopt%relaxv = 0.7d0
There is no compiler error now, but the setup.log still shows relaxation factor of 1 for pressure. And surprisingly the simulation seems converging now!
setup.log
(23.04 KiB) Downloaded 253 times
Regards,

Mohammad

Re: How to set the relaxation factor in Code_Saturne?

Posted: Tue Jul 28, 2020 10:55 am
by Yvan Fournier
Hello,

Did you also copy the settings back (in C, we can get the pointer to avoid needing this, but in Fortran,
you need to copy local values back to the field data); if you have not done it, it explains why it does not appear modified in setup.log:

Code: Select all

call field_set_key_struct_var_cal_opt(ivarfl(ipr), vcopt)
Regards,

Yvan

Re: How to set the relaxation factor in Code_Saturne?

Posted: Tue Jul 28, 2020 5:52 pm
by Mohammad
Yvan Fournier wrote: Tue Jul 28, 2020 10:55 am Hello,

Did you also copy the settings back (in C, we can get the pointer to avoid needing this, but in Fortran,
you need to copy local values back to the field data); if you have not done it, it explains why it does not appear modified in setup.log:

Code: Select all

call field_set_key_struct_var_cal_opt(ivarfl(ipr), vcopt)
Regards,

Yvan
Hello,

I appreciate your help Yvan.

Regards,

Mohammad