CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   segment violation (http://www.cfd-online.com/Forums/fluent/43110-segment-violation.html)

Peter December 12, 2006 14:59

segment violation
 
Hello,

can anybody help me? I always get the error:segment violation. I have posted my UDF below.

Thx for help.

#include <udf.h> #include <sg.h>

void Unterprg_1(cell_t,Thread *);/*Funktionsprototypendekleration*/ void Unterprg_2(cell_t,Thread *); void Unterprg_3(double,double,cell_t,Thread *); double Kapfunkt(void);

DEFINE_ADJUST(Druckgradient_und_absolut2,d) { Domain *mixture_domain=d;

Thread *c_thread; cell_t c; thread_loop_c(c_thread,mixture_domain) {

begin_c_loop(c,c_thread)

{

Unterprg_1(c,c_thread);

Unterprg_2(c,c_thread);

}

end_c_loop(c,c_thread) } }

void Unterprg_1(cell_t c1,Thread *c1_thread) { if(C_VOF(c1,c1_thread)==1.0) { C_P(c1,c1_thread)=Kapfunkt(); printf("C_P(c,c_thread)= %4.3e \n",C_P(c1,c1_thread)); } }

void Unterprg_2(cell_t c2,Thread *c2_thread) { if((C_VOF(c2,c2_thread)<1.0)&(C_VOF(c2,c2_thread)> 0.0)) { Thread *f_thread; face_t f; int i;

c_face_loop(c2,c2_thread,i)

{

double A[ND_ND];

double ds;

double es[ND_ND];

double A_by_es;

double dr0[ND_ND]; double dr1[ND_ND];

double B[2]={0.0,1.0};

double cos_alpha;

f=C_FACE(c2,c2_thread,i);

f_thread=C_FACE_THREAD(c2,c2_thread,i);

INTERIOR_FACE_GEOMETRY(f,f_thread,A,ds,es,A_by_es, dr0,dr1);

cos_alpha=NV_DOT(A,B)/(NV_MAG(A)*NV_MAG(B));

printf("NV_DOT(A,B)= %2.4e \n",NV_DOT(A,B));

printf("cos_alpha= %2.4e \n",cos_alpha);

Unterprg_3(dr0[1],cos_alpha,c2,c2_thread);

} } }

double Kapfunkt(void) { double R; double cos_theta; double theta=(67.5/180.0)*3.14; double p;

#define r 0.35 #define sigma 0.073

cos_theta=cos(theta); R=r/cos_theta; p=((2.0*sigma)/(R/1000.0));

return p; }

void Unterprg_3(double dr0_y,double cos_alpha_2,cell_t c3,Thread *c3_thread) { if(cos_alpha_2==1.0) { C_P_G(c3,c3_thread)[1]=((-1)*Kapfunkt())/(2*dr0_y); } }


RoM December 13, 2006 08:55

Re: segment violation
 
Using the thread loop with the mixture domain returns mixture threads. These threads only store information that are common to ALL phases, so you could use for instance C_VOLUME with this thread. C_VOF wont work because Fluent does not know which phase to adress. This is probably the cause of your crash. Please read udf manual chapter 6.3 on how to perfom multiphase specific loopings.

Good luck, RoM

Peter December 13, 2006 11:19

Re: segment violation
 
Hello RoM,

thank you very much for your help. Ihave read the udf manual chapter and modified my udf. Now it is working.


All times are GMT -4. The time now is 09:42.