How to calculate scalar based on frozen average velocity?
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
How to calculate scalar based on frozen average velocity?
Hello,
Now I am wondering how to solve scalar equation based on average velocityand pressure field.
In the GUI, we can select "Calculation on frozen velocity and pressure fields".
However, as far as I understand, the frozen velocity and pressure field are the field, which is obtained latest time step in previous calculation. Than's why it is instantaneous field, but not average field.
However, What I want to do now is:
Step1: calculation by URANS
Step2: get average velocity field and pressure field obtained by URANS (Time averages in GUI)
Step3: calculation scalar equation based on average velocity field and pressure field
Would someone give me tips?
Best regards,
Tsubasa
Now I am wondering how to solve scalar equation based on average velocityand pressure field.
In the GUI, we can select "Calculation on frozen velocity and pressure fields".
However, as far as I understand, the frozen velocity and pressure field are the field, which is obtained latest time step in previous calculation. Than's why it is instantaneous field, but not average field.
However, What I want to do now is:
Step1: calculation by URANS
Step2: get average velocity field and pressure field obtained by URANS (Time averages in GUI)
Step3: calculation scalar equation based on average velocity field and pressure field
Would someone give me tips?
Best regards,
Tsubasa
-
- Posts: 4089
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to calculate scalar based on frozen average velocity?
Hello,
Although it is rarely used, you can remap a field to another when restarting.
For this, you need to edit a user-defined function, either cs_user_parameters, or cs_user_finalize_setup (both in cs_user_parameters.c).
Something such as this should work :
Adapting "velocity_mean" if your mean velocity field has another name.
This should work, though again, I have not used/checked this in a while.
Best regards,
Yvan
Although it is rarely used, you can remap a field to another when restarting.
For this, you need to edit a user-defined function, either cs_user_parameters, or cs_user_finalize_setup (both in cs_user_parameters.c).
Something such as this should work :
Code: Select all
const int kr = cs_field_key_id_try("restart_name");
cs_field_t *vel = cs_field_by_name("velocity");
cs_field_set_key_str(vel, kr, "velocity_mean");
This should work, though again, I have not used/checked this in a while.
Best regards,
Yvan
Re: How to calculate scalar based on frozen average velocity?
Hello Yvan,
Thank you for the reply.
Should I also change the name ""restart_name"" in your example?
Best regards,
Tsubasa
Thank you for the reply.
Should I also change the name ""restart_name"" in your example?
Best regards,
Tsubasa
-
- Posts: 4089
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to calculate scalar based on frozen average velocity?
Hello,
no, "restart_name" is the name of the field keyword, so should not be changed.
Another possible issue is that the mass flux (defined at faces) stored in checkpoints is also that of the lat time step.
A minor change was done in the master branch (v7.1) to allow to also compute its mean, but this is not easily available in v7.0.
If the mass flux is not available (avoid reading or move/remove the checkpoint/auxiliary.csc file), it should be rebuilt, so if you switched to the mean velocity, that should be good in theory, but I remember that in past versions, this was not handled well, and scalars would not be convected (easy to check: if that bug is still present, no convection is present, so not much happens).
So would also recommend moving/removing the checkpoint/auxilliary.csc and post-processing to check that scalars seem convected as expected.
Best regards,
Yvan
no, "restart_name" is the name of the field keyword, so should not be changed.
Another possible issue is that the mass flux (defined at faces) stored in checkpoints is also that of the lat time step.
A minor change was done in the master branch (v7.1) to allow to also compute its mean, but this is not easily available in v7.0.
If the mass flux is not available (avoid reading or move/remove the checkpoint/auxiliary.csc file), it should be rebuilt, so if you switched to the mean velocity, that should be good in theory, but I remember that in past versions, this was not handled well, and scalars would not be convected (easy to check: if that bug is still present, no convection is present, so not much happens).
So would also recommend moving/removing the checkpoint/auxilliary.csc and post-processing to check that scalars seem convected as expected.
Best regards,
Yvan
Re: How to calculate scalar based on frozen average velocity?
Hello Yvan,
Thank you for the reply.
As you said, I edit the SRC file like this:
However, the scalar is calculated based on the velocity field of last time step, not average velocity field. Scalar seems to be convected (but this result is based on the velocity field of last time step).
Would you give me some tips?
Best regards,
Hamada
Thank you for the reply.
As you said, I edit the SRC file like this:
Code: Select all
void
cs_user_finalize_setup(cs_domain_t *domain)
{
const int kr = cs_field_key_id_try("restart_name");
cs_field_t *vel = cs_field_by_name("velocity");
cs_field_set_key_str(vel, kr, "ave_vel");
}
Would you give me some tips?
Best regards,
Hamada
Re: How to calculate scalar based on frozen average velocity?
Hello Yvan,
Is it correct to put a name "ave_vel" written in a picture into ""cs_field_set_key_str(vel, kr, "velocity_mean")""? Best regards,
Hamada
Is it correct to put a name "ave_vel" written in a picture into ""cs_field_set_key_str(vel, kr, "velocity_mean")""? Best regards,
Hamada
-
- Posts: 4089
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to calculate scalar based on frozen average velocity?
Hello,
Yes, if you named the field ave_velocity, you should use that instead of velocity_mean.
Best regards,
Yvan
Yes, if you named the field ave_velocity, you should use that instead of velocity_mean.
Best regards,
Yvan
Re: How to calculate scalar based on frozen average velocity?
Hello,
I tried your script a few time, but it did not work. Scalar transport is calclated on velocity field of last time step.
The script is here:
on cs_user_parameters.c in SRC folder.
To check the script, can I tried "test the compilation of user function inside the SRC folder" in GUI?
When I did it, I always have this kind of message but this message can be seen when I used another script, which can be used correctly.
"test the compilation of user function inside the SRC folder" in GUI is not so important?
Best regards,
Hamada
I tried your script a few time, but it did not work. Scalar transport is calclated on velocity field of last time step.
The script is here:
Code: Select all
void
cs_user_parameters(cs_domain_t *domain)
{
const int kr = cs_field_key_id_try("restart_name");
cs_field_t *vel = cs_field_by_name("velocity");
cs_field_set_key_str(vel, kr, "ave_vel");
}
To check the script, can I tried "test the compilation of user function inside the SRC folder" in GUI?
When I did it, I always have this kind of message but this message can be seen when I used another script, which can be used correctly.
"test the compilation of user function inside the SRC folder" in GUI is not so important?
Best regards,
Hamada
-
- Posts: 4089
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to calculate scalar based on frozen average velocity?
Hello,
This is just a warning about an unused parameter, so not a problem.
Best regards,
Yvan
This is just a warning about an unused parameter, so not a problem.
Best regards,
Yvan
Re: How to calculate scalar based on frozen average velocity?
Hello Yvan,
If your suggested script doesn't work, do you think I should I it with Ver.7.0?
Best regards,
Tsubasa
If your suggested script doesn't work, do you think I should I it with Ver.7.0?
Best regards,
Tsubasa