How to set the relaxation factor in Code_Saturne?

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 set the relaxation factor in Code_Saturne?

Post 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
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: How to set the relaxation factor in Code_Saturne?

Post 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
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: How to set the relaxation factor in Code_Saturne?

Post 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 174 times
Regards,

Mohammad
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: How to set the relaxation factor in Code_Saturne?

Post 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
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: How to set the relaxation factor in Code_Saturne?

Post 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
Post Reply