simple solid tube - gradient of the temperature

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
jacob
Posts: 16
Joined: Fri Sep 02, 2022 5:29 pm

simple solid tube - gradient of the temperature

Post by jacob »

Hello,
I am trying to simulate simple steel tube with prescribed temperature.
I would like to know how to get temperature gradient, and later heat flux.
I read that I have to create cs_user_extra_operations and put it into SRC, but I don't know what code to write.
Every time I find some example, it has hundreds lines of code and I do not know how to change it according to my example.

I tried computing gradient in paraview, but the results look weird on the BC. Is it normal?

Also, I would like to know why the temperature on the domain is little less than on the boundary?

Last question is about units. Do I have to use Si units? I would like to import temperature field to code_aster, where I use mm, Is there a way to scale the solution?

Thank you
Attachments
tube_solid.rar
(963.26 KiB) Downloaded 52 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: simple solid tube - gradient of the temperature

Post by Yvan Fournier »

Hello,

Do you need the temperature gradient if you can directly obtain the heat flux ? You can get the heat flux at the boundary simply by activating its postprocessing output in the graphical user interface.

ParaView ignores / has no information on boundary conditions when computing gradients, so gradients will look as if you have Neumann BC conditions. And even in the domain, I am not sure ParaView gradients have 2nd order convergence as those in code_saturne.

An yes, ony SI units can be used in code_saturne (otherwise, all physical constants ans some model constants would need to be adjusted accordingly...). If you want to use your results in code_aster, I assume your are exporting results in the MED format. Using the MEDCoupling library (or its associated "Fields" module in Salome), you can do the scaling.

Best regards,

Yvan
jacob
Posts: 16
Joined: Fri Sep 02, 2022 5:29 pm

Re: simple solid tube - gradient of the temperature

Post by jacob »

Thanks for reply.

I know that I can get heat flux at the boundary, but how to obtain heat flux and temperature gradient in the whole volume domain?

And why the temperature on the volume domain is little less than on the boundary?

I tried to use consistent units, but code saturne doesn't like for example 5000 m/s (my case 5000 mm/s)
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: simple solid tube - gradient of the temperature

Post by Yvan Fournier »

Hello,

The temperature is lower in the domain than at the boundaries because the domain values are those at cell centers, and the temperature extrema are reached at the hot and cold boundaries, not inside the domain.

To compute the temperature gradient, search (or better, "grep" for "cs_field_gradient" in the user examples).

As for 5000 m/s, what variable is this for ?.

Regards,

Yvan
jacob
Posts: 16
Joined: Fri Sep 02, 2022 5:29 pm

Re: simple solid tube - gradient of the temperature

Post by jacob »

For example velocity in inlet.
Runaway computation:
At least one field exceeded allowed bounds (see log).

I was searching for "cs_field_gradient" , but couldn't find any full example with mesh.

I tried for example put this code into cs_user_extra_operations.c but it doesnť work.
https://www.code-saturne.org/documentat ... eld_p.html

const cs_lnum_t n_cells_ext = cs_glob_mesh->n_cells_with_ghosts;
const cs_lnum_t n_cells = cs_glob_mesh->n_cells;
cs_real_33_t *gradv;

BFT_MALLOC(gradv, n_cells_ext, cs_real_33_t);

bool use_previous_t = false;
int inc = 1;
cs_field_gradient_vector(CS_F_(vel),
use_previous_t,
inc,
gradv);

cs_field_t *vort = cs_field_by_name_try("vorticity");

if (vort != NULL) {
for (cs_lnum_t i = 0; i < n_cells; i++) {
vort->val = gradv[1][0] - gradv[0][1];
}
}

BFT_FREE(gradv);


Error in compile or link stage.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: simple solid tube - gradient of the temperature

Post by Yvan Fournier »

Hello,

In case of compilation error, you need to look at the compile.log file to get the detailed explanation.

But I do not understand why you are using the vorticity, when you are looking for the gradient of the temperature.
Please check the documentation: https://www.code-saturne.org/documentat ... _dico.html

Regards,

Yvan
jacob
Posts: 16
Joined: Fri Sep 02, 2022 5:29 pm

Re: simple solid tube - gradient of the temperature

Post by jacob »

Hello,
I looked into the documentation but it is quite overwhelming. Isn't there some example with mesh and defined groups, where is computed some user field and I could just run it?

I tried the vorticity example to try if I could even make work any user field.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: simple solid tube - gradient of the temperature

Post by Yvan Fournier »

Hello,

No, I suggested the simplest examples I could think of. Most of the really simple things can be don using the GUI only, but for post-processing, although we have some "macro' functions, many people wnat/need different variants, so examples are often similar but rarely exactly what you need.

If other members of this forum have available examples, they are welcome to provide them here...

Regards,

Yvan
Post Reply