How to collect time-averaged values for boundary variables?
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
How to collect time-averaged values for boundary variables?
Dear developers,
Please could you help me with this question?
I am doing LES in Code_Saturne 6.0.5 via GUI. For collecting time-averaged values of the variables, in GUI, I am using "Postprocessing-Time averages", as shown in the figure below.
But here, I can only select variables in "fluid domain", not on boundary. Now I want to collect time-averaged values on boundary, such as "Yplus, Tplus, Input_thermal flux" etc, as shown below. Could you suggest to me, which user subroutine should I use to achieve this?
Best regards,
Ruonan
Please could you help me with this question?
I am doing LES in Code_Saturne 6.0.5 via GUI. For collecting time-averaged values of the variables, in GUI, I am using "Postprocessing-Time averages", as shown in the figure below.
But here, I can only select variables in "fluid domain", not on boundary. Now I want to collect time-averaged values on boundary, such as "Yplus, Tplus, Input_thermal flux" etc, as shown below. Could you suggest to me, which user subroutine should I use to achieve this?
Best regards,
Ruonan
-
- Posts: 4077
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to collect time-averaged values for boundary variables?
Hello,
Yes, the handling of boundary fields in the GUI is still very limited, and needs to be rewritten/aligned with that of the volume fields.
But for the short term solution, you can check the examples in cs_user_parameters-time_moments.c.
There is one example for a boundary field which is a bit complex (with an evaluation callback function), but for simple fields which are already present (such as y+), you can check the examples with "cs_time_moment_define_by_field_ids".
Best regards,
Yvan
Yes, the handling of boundary fields in the GUI is still very limited, and needs to be rewritten/aligned with that of the volume fields.
But for the short term solution, you can check the examples in cs_user_parameters-time_moments.c.
There is one example for a boundary field which is a bit complex (with an evaluation callback function), but for simple fields which are already present (such as y+), you can check the examples with "cs_time_moment_define_by_field_ids".
Best regards,
Yvan
Re: How to collect time-averaged values for boundary variables?
Hello Yvan,
Thanks for your reply. I tried but without success, could you please help me to check.
I started with a simple test, calculating time-averaged value of velocity, which is available via GUI. First, I set up in "GUI-Postprocessing-Time averages", and got the time-averaged values successfully.
Then I tried to use the user subroutine "cs_user_parameters.c". I referred to the example from "cs_user_parameters-time_moments.c", but without success. I didn't get the time-averaged results in "postprocessing" folder. But in the setup.log file, I can find "U_mean", what I added in the subroutine. So I am confused about what I'm doing wrong.
I attached the mesh, xml file, user subroutine and setup.log below. Thank you very much for your help.
Best regards,
Ruonan
Thanks for your reply. I tried but without success, could you please help me to check.
I started with a simple test, calculating time-averaged value of velocity, which is available via GUI. First, I set up in "GUI-Postprocessing-Time averages", and got the time-averaged values successfully.
Then I tried to use the user subroutine "cs_user_parameters.c". I referred to the example from "cs_user_parameters-time_moments.c", but without success. I didn't get the time-averaged results in "postprocessing" folder. But in the setup.log file, I can find "U_mean", what I added in the subroutine. So I am confused about what I'm doing wrong.
I attached the mesh, xml file, user subroutine and setup.log below. Thank you very much for your help.
Best regards,
Ruonan
- Attachments
-
- cs_user_parameters.c
- user subroutine
- (4.56 KiB) Downloaded 109 times
Re: How to collect time-averaged values for boundary variables?
following the last post
- Attachments
-
- sealed rotor stator cavity for wmles 20210323.cgns
- mesh
- (3.05 MiB) Downloaded 100 times
-
- setup.log
- (28.34 KiB) Downloaded 96 times
-
- les_test_sealed_cavity.xml
- (10.5 KiB) Downloaded 104 times
-
- Posts: 4077
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to collect time-averaged values for boundary variables?
Hello,
You probably defined/activated the time averages but did not activate their postprocessing output (you can check that the value of the "post_vis" flag for U_mean does not appear in the setup.log).
So you need to add something like this:
Best regards,
Yvan
Remark: you should also remove the #pragma week line in your user subroutine. It is there to help ensure user-edited files have priority over the (empty) reference version, so if you leave the #pragma from the reference version, you lose that aspect.
You probably defined/activated the time averages but did not activate their postprocessing output (you can check that the value of the "post_vis" flag for U_mean does not appear in the setup.log).
So you need to add something like this:
Code: Select all
cs_field_set_key_int_bits(cs_field_by_name("U_mean"),
cs_field_key_id("post_vis"),
CS_POST_ON_LOCATION);
Best regards,
Yvan
Remark: you should also remove the #pragma week line in your user subroutine. It is there to help ensure user-edited files have priority over the (empty) reference version, so if you leave the #pragma from the reference version, you lose that aspect.
Re: How to collect time-averaged values for boundary variables?
Hello Yvan,
Thank you very much. Following your kind guidance, I succeed in calculating the time-averaged velocity values. Here are the codes added in cs_user_parameters.c:
Then I moved to the next step, trying to get the time-averaged values for variables on boundary faces. My final aim is to get time-averaged thermal flux values for heat transfer prediction. As I didn't find "thermal flux" in "post_vis" in setup.log, I suppose thermal flux is calculated by yplus, tplus, temperature, etc, not calculated directly by the solver.
I first tried to get the time-averaged yplus. In the codes above, I changed CS_F_(vel) to CS_F_(yplus). As I found the variable "yplus" in cs_field_pointer_id_t, I think it should work. But an error occurred in the initialization:
The subroutine, listing, xml are attached. Actually if I get time-averaged yplus, I think I can get thermal flux, calculating by hand, using wall functions and Fourier's law. Thank you so much!
Best regards,
Ruonan
Thank you very much. Following your kind guidance, I succeed in calculating the time-averaged velocity values. Here are the codes added in cs_user_parameters.c:
Code: Select all
void
cs_user_time_moments(void)
{
{
int moment_f_id[] = {CS_F_(vel)->id};
int moment_c_id[] = {-1};
int n_fields = 1;
cs_time_moment_define_by_field_ids("U_mean",
n_fields,
moment_f_id,
moment_c_id,
CS_TIME_MOMENT_MEAN,
106841, /* nt_start */
-1, /* t_start */
CS_TIME_MOMENT_RESTART_AUTO,
NULL);
}
cs_field_set_key_int_bits(cs_field_by_name("U_mean"),
cs_field_key_id("post_vis"),
CS_POST_ON_LOCATION);
}
I first tried to get the time-averaged yplus. In the codes above, I changed CS_F_(vel) to CS_F_(yplus). As I found the variable "yplus" in cs_field_pointer_id_t, I think it should work. But an error occurred in the initialization:
Please could you suggest to me how to deal with this error? Or how to get the time-averaged values on boundary faces, maybe in another way?===============================================================
CALCULATION PREPARATION
=======================
===========================================================
SIGSEGV signal (forbidden memory area access) intercepted!
Call stack:
1: 0x562ec30c90b8 <cs_user_time_moments+0x48> (cs_solver)
2: 0x7f61f50471f9 <initi1_+0x156> (libsaturne-7.1.so)
3: 0x7f61f5fe9876 <main+0x5c6> (libcs_solver-7.1.so)
4: 0x7f61f4a74b97 <__libc_start_main+0xe7> (libc.so.6)
5: 0x562ec30c8bba <_start+0x2a> (cs_solver)
End of stack
The subroutine, listing, xml are attached. Actually if I get time-averaged yplus, I think I can get thermal flux, calculating by hand, using wall functions and Fourier's law. Thank you so much!
Best regards,
Ruonan
- Attachments
-
- les_test_sealed_cavity.xml
- (10.47 KiB) Downloaded 113 times
-
- listing.log
- (2.44 KiB) Downloaded 101 times
-
- cs_user_parameters.c
- (4.69 KiB) Downloaded 102 times
-
- Posts: 4077
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to collect time-averaged values for boundary variables?
Hello,
Yes, thermal flux is computed on the fly, using the cs_post_boundary_flux function.
You can use that same function with time moments, but instead of using cs_time_moment_define_by_field_ids, you need to use cs_time_moment_define_by_func. There is already an example for the boundary thermal flux, which you can find here: https://www.code-saturne.org/cms/sites/ ... eters.html (search for "Example 5").
Best regards,
Yvan
Yes, thermal flux is computed on the fly, using the cs_post_boundary_flux function.
You can use that same function with time moments, but instead of using cs_time_moment_define_by_field_ids, you need to use cs_time_moment_define_by_func. There is already an example for the boundary thermal flux, which you can find here: https://www.code-saturne.org/cms/sites/ ... eters.html (search for "Example 5").
Best regards,
Yvan
Re: How to collect time-averaged values for boundary variables?
Hi Yvan,
Thank you very much. The example 5 is exactly what I was looking for. I have succeeded in getting the time-averaged thermal flux values.
Please I also want to calculate the time-averaged wall shear stress values on boundary faces. But I didn't find a related example. Could you suggest to me how to achieve this?
Alternatively (if it's easier) maybe you could also suggest to me how to get the time-averaged yplus values. Then I can calculate wall shear stress by yplus.
Many thanks,
Ruonan
Thank you very much. The example 5 is exactly what I was looking for. I have succeeded in getting the time-averaged thermal flux values.
Please I also want to calculate the time-averaged wall shear stress values on boundary faces. But I didn't find a related example. Could you suggest to me how to achieve this?
Alternatively (if it's easier) maybe you could also suggest to me how to get the time-averaged yplus values. Then I can calculate wall shear stress by yplus.
Many thanks,
Ruonan
-
- Posts: 4077
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to collect time-averaged values for boundary variables?
Hello,
Y+ is stored as a field (located on boundary faces), which may be defined based on various other options. Check your setup.log to see if it is already available. Otherwise, I think you can force its creation by activating its postprocessing output in boundary outputs in the GUI. There is a way to force its existence independently from the GUI or postprocessing; bu I do not remember the syntax (it should be in the user documentation, though I am not 100%sure).
Otherwise, the wall shear stress can be computed on the fly using the "cs_post_stress_tangential" function, similarly to they way "cs_post_boundary_flux" is used for the thermal flux (except is is a 3d vector field instead of a scalar field). Check cs_post_util.h for the exact function description. So you should pretty easily be able to adapt the same example for this.
Best regards,
Yvan
Y+ is stored as a field (located on boundary faces), which may be defined based on various other options. Check your setup.log to see if it is already available. Otherwise, I think you can force its creation by activating its postprocessing output in boundary outputs in the GUI. There is a way to force its existence independently from the GUI or postprocessing; bu I do not remember the syntax (it should be in the user documentation, though I am not 100%sure).
Otherwise, the wall shear stress can be computed on the fly using the "cs_post_stress_tangential" function, similarly to they way "cs_post_boundary_flux" is used for the thermal flux (except is is a 3d vector field instead of a scalar field). Check cs_post_util.h for the exact function description. So you should pretty easily be able to adapt the same example for this.
Best regards,
Yvan
Re: How to collect time-averaged values for boundary variables?
Hello Yvan,
Thanks a lot for your reply. Yes, I have the yplus values in my results, but it seems not easy to compute the time-averaged yplus values on the fly. The "cs_post_stress_tangential" function seems what I want. I will definitely try this function.
Best regards,
Ruonan
Thanks a lot for your reply. Yes, I have the yplus values in my results, but it seems not easy to compute the time-averaged yplus values on the fly. The "cs_post_stress_tangential" function seems what I want. I will definitely try this function.
Best regards,
Ruonan