|
[Sponsors] |
October 22, 2015, 08:43 |
UDF problem
|
#1 |
New Member
LAMAINA GAUDENZIO
Join Date: Oct 2015
Posts: 2
Rep Power: 0 |
hi, I have a problem with UDF, I CAN FILL MY UDF, BUT WHEN RUN CALCULATION FLUENT NOT START ITERATION.
THE ERROR THAT IS PRESENTED IS THIS: ERROR: RECEIVED A FATAL SIGNAL (SEGMENTATION FAULT) ERROR OBJECT: #f How can I solve the problem??? thanks this is mY UDF THE FIRST PART OF INITIALIZATION is OK THE PROBLEM IS IN X_MOMENTUM DEFINE_SOURCE(x_momentum,c,t,dS,eqn) { real x[ND_ND]; int p,s,ip,is; float a,ia; int iz; real phi,phideg,alfa,alfar,deltaR; real Wr,Wt,Wz,Wtz; real m,Re,mu; float valDp,valDs,valLp,valLs; real CL,CD,Cr,Ct,Cx,Cy,Cz; real Sref; float Ci,Ctot,CP,Ti,Ttot,CT; real Vcorretto; FILE *fp1; C_CENTROID(x,c,t); if(N_ITER<iterazione+1) { RA[c]=x[1]-y0; for (j=0;j<NRB;j++) { if(RA[c]>raggio[j]) p=j; } s=p+1; a=(RA[c]-raggio[p])/(raggio[s]-raggio[p]); betaR[c]=a*(beta[s]-beta[p])+beta[p]; cordaR[c]=a*(corda[s]-corda[p])+corda[p]; deltaR=intervallo/nlivelli; jr[c]= (nlivelli-(R-RA[c]-deltaR/2)/deltaR)-1+1e-1; } Wr=C_V(c,t); Wt=C_W(c,t)-(RA[c]*omega); Wz=C_U(c,t); Wtz=sqrt(pow(Wt,2)+pow(Wz,2)); phi=atan(-Wz/Wt); phideg=phi/M_PI*180; alfa=phideg-betaR[c]-degpitch; alfar=alfa*M_PI/180; iz=jr[c]; alfav[iz]=alfar; alfadeg[iz]=alfa; if (alfadeg[iz]<0) { Message("ATTENZIONE: alfa è negativo! alfadeg=%f per la cella %d\n",alfadeg[iz],iz); } m=Wtz/sqrt(1.4*287.1*288.71); mu=1.7894e-5; Re=C_R(c,t)*cordaR[c]*Wtz/mu; p=0; for(j=0; j<NNC-1; j++) { if (Re>Rey[j]) p=j; } s=p+1; ia=alfadeg[iz]; ip=floor(ia)-indiceN; is=ip+1; if(RA[c]>(R-intervallo) && RA[c]<R1) { valDp=(matrD1[ip][s]-matrD1[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD1[ip][p]; valDs=(matrD1[is][s]-matrD1[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD1[is][p]; valLp=(matrL1[ip][s]-matrL1[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL1[ip][p]; valLs=(matrL1[is][s]-matrL1[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL1[is][p]; if (Re<Rey[0]) { valDp=matrD1[ip][p]; valDs=matrD1[is][p]; valLp=matrL1[ip][p]; valLs=matrL1[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD1[ip][s]; valDs=matrD1[is][s]; valLp=matrL1[ip][s]; valLs=matrL1[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R1 && RA[c]<R2) { valDp=(matrD2[ip][s]-matrD2[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD2[ip][p]; valDs=(matrD2[is][s]-matrD2[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD2[is][p]; valLp=(matrL2[ip][s]-matrL2[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL2[ip][p]; valLs=(matrL2[is][s]-matrL2[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL2[is][p]; if (Re<Rey[0]) { valDp=matrD2[ip][p]; valDs=matrD2[is][p]; valLp=matrL2[ip][p]; valLs=matrL2[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD2[ip][s]; valDs=matrD2[is][s]; valLp=matrL2[ip][s]; valLs=matrL2[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R2 && RA[c]<R3) { valDp=(matrD3[ip][s]-matrD3[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD3[ip][p]; valDs=(matrD3[is][s]-matrD3[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD3[is][p]; valLp=(matrL3[ip][s]-matrL3[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL3[ip][p]; valLs=(matrL3[is][s]-matrL3[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL3[is][p]; if (Re<Rey[0]) { valDp=matrD3[ip][p]; valDs=matrD3[is][p]; valLp=matrL3[ip][p]; valLs=matrL3[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD3[ip][s]; valDs=matrD3[is][s]; valLp=matrL3[ip][s]; valLs=matrL3[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R3 && RA[c]<R4) { valDp=(matrD4[ip][s]-matrD4[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD4[ip][p]; valDs=(matrD4[is][s]-matrD4[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD4[is][p]; valLp=(matrL4[ip][s]-matrL4[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL4[ip][p]; valLs=(matrL4[is][s]-matrL4[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL4[is][p]; if (Re<Rey[0]) { valDp=matrD4[ip][p]; valDs=matrD4[is][p]; valLp=matrL4[ip][p]; valLs=matrL4[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD4[ip][s]; valDs=matrD4[is][s]; valLp=matrL4[ip][s]; valLs=matrL4[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R4 && RA[c]<R5) { valDp=(matrD5[ip][s]-matrD5[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD5[ip][p]; valDs=(matrD5[is][s]-matrD5[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD5[is][p]; valLp=(matrL5[ip][s]-matrL5[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL5[ip][p]; valLs=(matrL5[is][s]-matrL5[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL5[is][p]; if (Re<Rey[0]) { valDp=matrD5[ip][p]; valDs=matrD5[is][p]; valLp=matrL5[ip][p]; valLs=matrL5[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD5[ip][s]; valDs=matrD5[is][s]; valLp=matrL5[ip][s]; valLs=matrL5[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R5 && RA[c]<R6) { valDp=(matrD6[ip][s]-matrD6[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD6[ip][p]; valDs=(matrD6[is][s]-matrD6[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD6[is][p]; valLp=(matrL6[ip][s]-matrL6[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL6[ip][p]; valLs=(matrL6[is][s]-matrL6[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL6[is][p]; if (Re<Rey[0]) { valDp=matrD6[ip][p]; valDs=matrD6[is][p]; valLp=matrL6[ip][p]; valLs=matrL6[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD6[ip][s]; valDs=matrD6[is][s]; valLp=matrL6[ip][s]; valLs=matrL6[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R6 && RA[c]<R7) { valDp=(matrD7[ip][s]-matrD7[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD7[ip][p]; valDs=(matrD7[is][s]-matrD7[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD7[is][p]; valLp=(matrL7[ip][s]-matrL7[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL7[ip][p]; valLs=(matrL7[is][s]-matrL7[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL7[is][p]; if (Re<Rey[0]) { valDp=matrD7[ip][p]; valDs=matrD7[is][p]; valLp=matrL7[ip][p]; valLs=matrL7[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD7[ip][s]; valDs=matrD7[is][s]; valLp=matrL7[ip][s]; valLs=matrL7[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R7 && RA[c]<R8) { valDp=(matrD8[ip][s]-matrD8[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD8[ip][p]; valDs=(matrD8[is][s]-matrD8[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD8[is][p]; valLp=(matrL8[ip][s]-matrL8[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL8[ip][p]; valLs=(matrL8[is][s]-matrL8[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL8[is][p]; if (Re<Rey[0]) { valDp=matrD8[ip][p]; valDs=matrD8[is][p]; valLp=matrL8[ip][p]; valLs=matrL8[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD8[ip][s]; valDs=matrD8[is][s]; valLp=matrL8[ip][s]; valLs=matrL8[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R8 && RA[c]<R9) { valDp=(matrD9[ip][s]-matrD9[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD9[ip][p]; valDs=(matrD9[is][s]-matrD9[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD9[is][p]; valLp=(matrL9[ip][s]-matrL9[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL9[ip][p]; valLs=(matrL9[is][s]-matrL9[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL9[is][p]; if (Re<Rey[0]) { valDp=matrD9[ip][p]; valDs=matrD9[is][p]; valLp=matrL9[ip][p]; valLs=matrL9[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD9[ip][s]; valDs=matrD9[is][s]; valLp=matrL9[ip][s]; valLs=matrL9[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } if(RA[c]>R9 && RA[c]<R10) { valDp=(matrD10[ip][s]-matrD10[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD10[ip][p]; valDs=(matrD10[is][s]-matrD10[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrD10[is][p]; valLp=(matrL10[ip][s]-matrL10[ip][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL10[ip][p]; valLs=(matrL10[is][s]-matrL10[is][p])/(Rey[s]-Rey[p])*(Re-Rey[p])+matrL10[is][p]; if (Re<Rey[0]) { valDp=matrD10[ip][p]; valDs=matrD10[is][p]; valLp=matrL10[ip][p]; valLs=matrL10[is][p]; } if (Re>Rey[NNC-1]) { valDp=matrD10[ip][s]; valDs=matrD10[is][s]; valLp=matrL10[ip][s]; valLs=matrL10[is][s]; } CD=(valDs-valDp)*(ia-indiceN-ip)+valDp; CL=(valLs-valLp)*(ia-indiceN-ip)+valLp; } Cr=0; Ct=-CD*cos(phi)+CL*sin(phi); Cy=0; Cz=Ct; Cx=CD*sin(phi)+CL*cos(phi); Sref=-B*cordaR[c]*C_R(c,t)*pow(Wtz,2)/(4.*M_PI*deltaX*RA[c]); USx[c]=Cx*Sref; USy[c]=Cy*Sref; USz[c]=Cz*Sref; Vcorretto=C_VOLUME(c,t)*2*M_PI; if(WSTflag==1) { fp1 = fopen("dati.dat","a"); if (c==0) { fprintf (fp1, "c jr x[0] x[1] RA VOLUME Vx Vy Vz Wtz m Re phi beta alfa USx USy USz Cx Cy Cz Ct Cr CL CD\n"); } fprintf (fp1, "%d %d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n",c,jr[c],x[0],x[1],RA[c],Vcorretto,C_U(c,t),C_V(c,t),C_W(c,t),Wtz,m,Re,phi deg,betaR[c],alfa,USx[c],USy[c],USz[c],Cx,Cy,Cz,Ct,Cr,CL,CD); fclose(fp1); if (c==0) { Ctot=0.; Ttot=0.; } Ci=((x[1]-y0)*USz[c])*Vcorretto; Ti=USx[c]*Vcorretto; Ctot=Ctot+Ci; Ttot=Ttot+Ti; if (c==NNP-1) { CP=-Ctot*omega*2./(C_R(c,t)*pow(fabs(Vinf),3)*M_PI*pow(R,2)); CT=-Ttot*2./(C_R(c,t)*pow(fabs(Vinf),2)*M_PI*pow(R,2)); Message("termini sorgente stampati\n"); Message("Ctot=%g omega=%g Ttot=%g C_R(c,t)=%g Vinf=%g\n", Ctot,omega,Ttot,C_R(c,t),Vinf); Message("Il CP per lambda %g vale %g\n",lambda,CP); Message("Il CT per lambda %g vale %g\n",lambda,CT); fp1 = fopen("dati.dat","a"); fprintf (fp1, "\nAlla iterazione %d \n",N_ITER); fprintf (fp1, "Ctot= %g omega= %g Ttot= %g C_R(c,t)= %g Vinf= %g \n", Ctot,omega,Ttot,C_R(c,t),Vinf); fprintf (fp1, "Il CP per lambda %g vale %g\n",lambda,CP); fprintf (fp1, "Il CT per lambda %g vale %g\n\n",lambda,CT); fclose(fp1); } } return USx[c]; } DEFINE_SOURCE(y_momentum,c,t,dS,eqn) { real x[ND_ND]; C_CENTROID(x,c,t); return USy[c]; } DEFINE_SOURCE(z_momentum,c,t,dS,eqn) { real x[ND_ND]; C_CENTROID(x,c,t); return USz[c]; } |
|
October 22, 2015, 09:12 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You are trying to access a memory that is not assigned.
Most probably a USy for a c that was not defined. Maybe you did not define USy for all c? Maybe there is a c for which RA[c]>R10? It would be much more clear if your write your code differently. Now you have: Code:
if(RA[c]>(R-intervallo) && RA[c]<R1) {...} if(RA[c]>R1 && RA[c]<R2) {...} if(RA[c]>R2 && RA[c]<R3) {...} if(RA[c]>R3 && RA[c]<R4) {...} if(RA[c]>R4 && RA[c]<R5) {...} if(RA[c]>R5 && RA[c]<R6) {...} if(RA[c]>R6 && RA[c]<R7) {...} if(RA[c]>R7 && RA[c]<R8) {...} if(RA[c]>R8 && RA[c]<R9) {...} if(RA[c]>R9 && RA[c]<R10) {...} Code:
if(RA[c]<(R-intervallo)) { [what should happen here? not defined in your code...]} else if (RA[c]<R1) {...} else if(RA[c]<R2) {...} else if(RA[c]<R3) {...} else if(RA[c]<R4) {...} else if(RA[c]<R5) {...} else if(RA[c]<R6) {...} else if(RA[c]<R7) {...} else if(RA[c]<R8) {...} else if(RA[c]<R9) {...} else if(RA[c]<R10) {...} else { [what should happen here? not defined in your code...]} |
|
October 22, 2015, 13:49 |
|
#3 |
New Member
LAMAINA GAUDENZIO
Join Date: Oct 2015
Posts: 2
Rep Power: 0 |
I don't write this UDF, but but it has been used in other works. I think the problem is my work but I do not know what can be the cause of my error!!
|
|
October 23, 2015, 08:16 |
|
#4 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I am not your boss or supervisor, so for me it does not matter who wrote the UDF.
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM | Rizwan | Fluent UDF and Scheme Programming | 40 | March 18, 2018 07:05 |
Problem with DPM simulation with particles injection and EXECUTE_AT_THE_END UDF. | Ari | Fluent UDF and Scheme Programming | 4 | May 31, 2016 09:51 |
udf loading problem | santu | Fluent UDF and Scheme Programming | 1 | May 22, 2015 16:47 |
Vaporization pressure UDF property problem? | lehoanganh07 | Fluent UDF and Scheme Programming | 1 | September 13, 2014 11:59 |
Problem with my udf | july | Fluent UDF and Scheme Programming | 3 | June 20, 2010 07:56 |