Page 1 of 1

Define a new variable and calculate its time-averaged value

Posted: Sat Apr 10, 2021 7:46 pm
by Ruonan
Dear Code_Saturne developers,

Hello and could you please give me some suggestions about this question:

I am using Code_Saturne 6.0.5 via GUI to calculate the time-averaged values of some variables, as shown in the figure below. But now, I want to define a new variable, "Velocity[1]*Velocity[2]", and get its time-averaged value in the calculation.

I suppose this is not able to achieve in GUI? If so, what user subroutine should I revise to add this new variable? And what subroutine to calculate the time-averaged value of this variable?

Many thanks and best regards,
Ruonan

Image

Re: Define a new variable and calculate its time-averaged value

Posted: Sun Apr 11, 2021 11:09 pm
by Yvan Fournier
Hello,

Search for "Time moment" here https://www.code-saturne.org/cms/sites/ ... eters.html

Regards,

Yvan

Re: Define a new variable and calculate its time-averaged value

Posted: Thu Jun 10, 2021 2:13 pm
by Ruonan
Hello Yvan,

Thank you very much for your help. I got the codes for calculating time-averaged "Velocity[1]*Velocity[2]" on the fly.

Code: Select all

void
cs_user_time_moments(void)
{
  {
    int moment_f_id[] = {CS_F_(vel)->id, CS_F_(vel)->id};
    int moment_c_id[] = {1, 2};
    int n_fields = 2;
    cs_time_moment_define_by_field_ids("v_w_mean",
                                       n_fields,
                                       moment_f_id,
                                       moment_c_id,
                                       CS_TIME_MOMENT_MEAN,
                                       1,     /* nt_start */
                                       -1,   /* t_start */
                                       CS_TIME_MOMENT_RESTART_AUTO,
                                       NULL);
  }

cs_field_set_key_int_bits(cs_field_by_name("v_w_mean"),
                          cs_field_key_id("post_vis"),
                          CS_POST_ON_LOCATION);                       
}
I used these values to calculate the Reynolds stress (velocity fluctuation), got good agreements compared with experimental data.

Best regards,
Ruonan