Access time average field in the code saturne user code

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
sofenkumarjena
Posts: 35
Joined: Thu May 19, 2022 4:37 pm

Access time average field in the code saturne user code

Post by sofenkumarjena »

Hi users, for computation I need time average temperature instead of temperature for Nusselt number computation

The original field in the file is

cs_field_t *f = cs_thermal_model_field();

Here I need to call the time average temperature instead of instantaneous temperature.

I am saving the time average temperature with the name "T_Mean" in the GUI under Time Average option.

Kindly help me to figure it out.

With Thanks and Regards
Sofen
Yvan Fournier
Posts: 4082
Joined: Mon Feb 20, 2012 3:25 pm

Re: Access time average field in the code saturne user code

Post by Yvan Fournier »

Hello,

Try:

cs_field_t *f = cs_field_by_name("T_mean");

Regards,

Yvan
sofenkumarjena
Posts: 35
Joined: Thu May 19, 2022 4:37 pm

Re: Access time average field in the code saturne user code

Post by sofenkumarjena »

Thanks Yvan
already tried the same and getting the following error

/home/skjena/code_satrune/code_saturne-7.1.0/src/base/cs_field.c:3450: Fatal error.

Field "T_Mean" with type flag 48
has no value associated with key 50 ("var_cal_opt").
Yvan Fournier
Posts: 4082
Joined: Mon Feb 20, 2012 3:25 pm

Re: Access time average field in the code saturne user code

Post by Yvan Fournier »

Hello,

What is the call stack / backtrace leading to this error ?

The var_cal_opt/equation parameter member should be optional in this case.

Also, be careful of some old examples which use a "near-boundary" value instead of a bulk value for the Nusselt computation.

So you may get a good estimate of the Nusselt number to simply compute the time average of the boundary wall temperature and the thermal flux (activating the output of that temperature in the GUI so that everything is automatic, and you do not need to go into the details of boundary value update,s which involves gradient computations, T*, and T+), compute the time average of the volume temperature (which you are already doing), and select boundary and volume ones over which to compute a spatial average of the wall temperature and flux, and bulk temperature (and neglecting the unsteady terms).

We do need to replace the current Nusselt computation example with a better one or a dedicated postprocessing operator, but that is not done yet.

Best regards,

Yvan
sofenkumarjena
Posts: 35
Joined: Thu May 19, 2022 4:37 pm

Re: Access time average field in the code saturne user code

Post by sofenkumarjena »

Dear Yuvan,
I am now more confused with these jargon than earlier. I have not used any old code, rather the attached code is from V7.0 for Nusselt number calculation, in which I am trying to replace the instantaneous temperature field with the average temperature field and getting error. I have instantaneous temperature and time average temperature in my solution. Now please tell me how to extract heat flux at a particular boundary. If I can able to extract the heat flux then I can able to scaled it to compute local Nusselt number. The heat flux that, I am obtaining for post-processing in Para view are based on instantaneous temperature and not on average temperature. I am stuck here. please help me.

With Regards

Sofen
Attachments
cs_user_extra_operations-nusselt_and_friction_calculation.c
Nusselt Calculation file
(9.55 KiB) Downloaded 48 times
Yvan Fournier
Posts: 4082
Joined: Mon Feb 20, 2012 3:25 pm

Re: Access time average field in the code saturne user code

Post by Yvan Fournier »

Hello,

By old code, I mean the example is in v7.0 but has not been updated in a while, and I am not too comfortable with a "local" Nusselt number used in some examples, whose value may depend on the refinement of the mesh art the boundary.

In your case, it seems you provide the reference length and bult temperature, so all you need is the flux, so that is fine (in the sense that if you refine your mesh, your result will be more and more precise (assuming the wall law model is a good fit), and not change depending on whether you are inside or outside the viscous sublayer region. So that part is good.

The difficulty you encounter is probably related to the fact that In any case, it is not possible in code_saturne to directly compute the average heat flux at the wall (because that in turn requires T+ and T*, and the way tet are updated is related to the time scheme).

But if you activate the wall heat flux computation (simply by activating its postprocessing output), you can also compute its time avergae, the same as for the mean temperature. Unfortunately, this is not available using the GUI for boundary fields, so you need to activate this with a user-defined function. Search for example 5 under "Time Moment" here https://www.code-saturne.org/documentat ... eters.html. It is exactly what you need.

Regards,

Yvan
Post Reply