CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Question about using Macro F_FLUX(f,t) (https://www.cfd-online.com/Forums/fluent-udf/228269-question-about-using-macro-f_flux-f-t.html)

Kaazem_RA June 25, 2020 03:55

Question about using Macro F_FLUX(f,t)
 
1 Attachment(s)
Hello everybody,
I want to implement an equation (governing equation of flow in porous media) which is very similar to Navier-Stokes equation, in ansys fluent. I have attached a photo of the equation. As can be seen from the photo i need to change the convective term. In fact the convective term is multiplied by a constant (1/phi^2 phi is porosity). I think the appropriate macro is F_FLUX(f,t) and i also wrote UDF to do that however after compiling the UDF i receive fatal signal (segmentation fault). Below is the UDF i have developed. It would be highly appreciate if anyone helps me to fix this problem.

#include "udf.h"
#include "mem.h"
#include "math.h"
DEFINE_ADJUST(set_convective_flux, d)
{
real porosity = 0.95;
Thread *t;
cell_t c;
face_t f;
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
thread_loop_f(t,d)
{
begin_f_loop(f,t)
{
F_FLUX(f,t) = F_FLUX(f,t)/(porosity*porosity);
}
end_f_loop(t, d)
}
}
end_c_loop(c,t)
}
}

vinerm June 25, 2020 04:06

Loop
 
That's because you are using two loops. You don't need two outermost loops. Just thread_loop_f and begin_f_loop.

However, there are other problems with the code. You can looping over all the boundaries, while F_FLUX exists only for openings, such as, inlet, outlet, etc.

Kaazem_RA June 25, 2020 05:21

Quote:

Originally Posted by vinerm (Post 775956)
That's because you are using two loops. You don't need two outermost loops. Just thread_loop_f and begin_f_loop.

However, there are other problems with the code. You can looping over all the boundaries, while F_FLUX exists only for openings, such as, inlet, outlet, etc.

Thank you very much for your reply. I removed the outermost loops in the code and i successfully ran the simulation. You said that "F_FLUX(f,t) exists only for openings". It means that i do not correctly implement the equation. right? I think there is no other macro that returns convective flux through all faces (internal and external). Do you have any suggestion on implementing the equation?

vinerm June 25, 2020 05:54

F_flux
 
The function exists irrespective of the condition. What I meant is that the fluxes will have a non-zero value only for the openings. Of course, you wouldn't expect fluxes for the walls or symmetry. Periodic conditions on the other hand will have fluxes and so does the interior. But, it would still be better to call this function only on openings.

Kaazem_RA June 25, 2020 11:03

You're right. The fluxes will have a non-zero value only for the openings but i think convective flux of each internal face is not zero. That's why i loop over all faces(internal and external) to change convective flux to implement the equation. I guess this is the only way to manipulate convective terms of Navier-Stokes equations in ansys fluent.


All times are GMT -4. The time now is 05:07.