Cell_Gradient_Upwind

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
C0st4s
Posts: 48
Joined: Fri May 11, 2018 12:21 pm

Cell_Gradient_Upwind

Post 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
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Cell_Gradient_Upwind

Post 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
C0st4s
Posts: 48
Joined: Fri May 11, 2018 12:21 pm

Re: Cell_Gradient_Upwind

Post 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
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Cell_Gradient_Upwind

Post 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
Post Reply