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/)
-   -   boundary condition in fluent, which is a function of density (https://www.cfd-online.com/Forums/fluent-udf/197112-boundary-condition-fluent-function-density.html)

m.daneshmandi` December 28, 2017 13:08

boundary condition in fluent, which is a function of density
 
Dear all

I want to add a boundary condition in fluent, which is a function of density. For this aim I wrote an UDF code to evaluate the density on the surface of boundary. But a segmentation error has occurred. I know what this error is but I do not know how to fix it and my algorithm is right or not?



Thank you in advance for your help.

#include "udf.h"

DEFINE_PROFILE(inlet_pressure1,t,i)
{
real x[ND_ND];

real rr1;
real vv;

Thread *tf;
face_t f;
cell_t c;
int n;



begin_c_loop(c, t) /* loops over cells in a cell thread */
{

rr1=C_R(c,t);

c_face_loop(c, t, n) /* loops over all faces of a cell */
{
f=C_FACE(c,t,n);
tf=C_FACE_THREAD(c,t,n);





vv=sqrt(pow (F_U(f,t),2)+pow (F_V(f,t),2)+pow (F_W(f,t),2));
F_PROFILE(f,tf,i)=40000000-0.5*rr1*pow (vv,2);

}
}
end_c_loop(c, t)



}

AlexanderZ December 28, 2017 19:41

your problem was posted on forum several times. use search first.

initialize your case, than load udf

best regards

m.daneshmandi` December 29, 2017 11:09

I could not find the similar example and I am in a hurry, and I'm new member of CFD-online.
So can you please introduce one of the examples in forum?
Ps: I initialized my case but again same error occured
Best Regards

upeksa December 29, 2017 11:54

"t" in DEFINE_PROFILE already means boundary contions, and you are looping it as it were a cell zone. Again, you are using it in a cell zone:
rr1=C_R(c,t);
and in a face:
F_U(f,t)
which is wrong.

I have not checked it and I am not sure what your idea is, but try this code:

#include "udf.h"

DEFINE_PROFILE(inlet_pressure1,t,i)
{

real rr1;
real vv;

face_t f;
Thread *t0;
cell_t c0;


//I am not sure if there is a F_R(f,t) function for face density. If not, try the density of the adjacent cell, like this:
t0 = THREAD_T0(t);
c0=F_C0(f,t);

rr1 = C_R(c0,t0);

vv= sqrt(pow(F_U(f,t),2) + pow(F_V(f,t),2) + pow(F_W(f,t),2));

F_PROFILE(f,t,i)=40000000-0.5*rr1*pow(vv,2);


}

m.daneshmandi` December 29, 2017 15:25

Thank you very much for your time and response.

I knew that density should be calculate in the grid points. But for my boundary condition, I should have it on a surafce. So that is why I wrote the loops.
In your code, there is no loop, how do you think I can calculate the density for boundary condition?

Bests

upeksa December 30, 2017 17:22

Quote:

Originally Posted by m.daneshmandi` (Post 676412)
Thank you very much for your time and response.

I knew that density should be calculate in the grid points. But for my boundary condition, I should have it on a surafce. So that is why I wrote the loops.
In your code, there is no loop, how do you think I can calculate the density for boundary condition?

Bests

My bad, you are right:

#include "udf.h"

DEFINE_PROFILE(inlet_pressure1,t,i)
{

real rr1;
real vv;

face_t f;
Thread *t0;
cell_t c0;


t0 = THREAD_T0(t);

begin_f_loop(f,t)
{
c0=F_C0(f,t);

rr1 = C_R(c0,t0);

vv= sqrt(pow(F_U(f,t),2) + pow(F_V(f,t),2) + pow(F_W(f,t),2));

F_PROFILE(f,t,i)=40000000-0.5*rr1*pow(vv,2);

}
end_f_loop(f,t)
}


All times are GMT -4. The time now is 23:25.