Page 1 of 1

Cell_Gradient_Upwind

Posted: Sun Jul 05, 2020 5:17 pm
by C0st4s
Hi,

I know that if I want to get the gradient of a vector or scalar field in a cell volume, there is the predefined 'field_gradient_scalar' function which returns based on the least square or iterative process etc.. However, say that I want to compute the dU/dx across a cell but instead to use upwind to get the east or west face velocity. Is there a function that can I use for that or even is it possible to modify the 'field_gradient_scalar' and add an argument say to return the upwind gradient? Any ideas?

Thanks,
Costas

Re: Cell_Gradient_Upwind

Posted: Mon Jul 06, 2020 10:15 am
by Yvan Fournier
Hello,

In src/alge/convection_diffusion.c there is an upwind_gradient function. I'll let you check if this is what you need.

Regards,

Yvan

Re: Cell_Gradient_Upwind

Posted: Mon Jul 06, 2020 12:19 pm
by C0st4s
Dear Yvan,

Many thanks for the reply. I saw that function, but I thought you have to have ischcp == 2 (UPWIND) for all the convective gradients in the domain. Two questions then:
1) Correct me if I am wrong, but the src/alge/convection_diffusion.c upwind_gradient function is it local for the .c file? How can you call it from cs_user_extra_operations.f90 for instance?
2) If I want to have second order for the convective terms of each equation and just compute the upwind gradient for certain cells locally can I use that?

Cheers,
Costas

Re: Cell_Gradient_Upwind

Posted: Mon Jul 06, 2020 6:39 pm
by Yvan Fournier
Hello,

The function is defined in cs_convection_diffusion.h, so you can use it from any other C file, such as cs_user_extra_operations.c. From Fortran, you would need to add the matching iso_c_binding.

If you need it only for certain cells you will need to look at the content of the function and adapt that.

Best regards,

Yvan