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/)
-   -   second derivation (https://www.cfd-online.com/Forums/fluent-udf/88125-second-derivation.html)

m.reza May 9, 2011 10:15

second derivation
 
Hi
How can I define second derivation of temperature and velocity in special direction in udf ???????????????????

Amir May 10, 2011 08:38

Hi,
I guess a tip may work: (do that and inform me)
1)store first gradient of T in a UDS but do not solve a UDS equation.(use that just as a storing position)
2)use C_UDSI_G to compute gradient of gradient

Regards,

Amir

m.reza May 10, 2011 09:14

Second Deivation
 
Hi Amir
I did that,but I have a error :
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()



And it's my udf for changing the energy Eq.


#include "udf.h"
#include "mem.h"
#define C_teta 0.3
#define P_t 0.85



DEFINE_SOURCE(source_ggdh , c, t, dS, eqn)
{
Domain *domain;
real coord[ND_ND];
real source,y,T,nu_t,S11,S12,S22,A,B,C,D;
real DUDX,DVDY,DVDX,DUDY,D2UDX2,D2UDXY,D2UDY2,D2VDY2,D2 VDYX,D2VDXY,D2VDX2,D2TDX2,D2TDXY,D2TDY2;

C_CENTROID(coord,c, t);
y = coord[1];

nu_t = C_MU_T(c,t)/C_R(c,t);
T = C_K(c, t)/C_D(c, t);

S11 = 0.5*(C_U_G(c,t)[0]+C_U_G(c,t)[0]);
S12 = 0.5*(C_U_G(c,t)[1]+C_V_G(c,t)[0]);
S22 = 0.5*(C_V_G(c,t)[1]+C_V_G(c,t)[1]);





C_UDSI(c,t,0) = (C_U_G(c,t)[0]);
C_UDSI(c,t,1) = (C_V_G(c,t)[1]);
C_UDSI(c,t,2) = (C_U_G(c,t)[1]);
C_UDSI(c,t,3) = (C_V_G(c,t)[0]);
C_UDSI(c,t,4) = C_T_G(c,t)[0];
C_UDSI(c,t,5) = C_T_G(c,t)[1];

DUDX = (C_UDSI(c,t,0));
DVDY = (C_UDSI(c,t,1));
DUDY = (C_UDSI(c,t,2));
DVDX = (C_UDSI(c,t,3));
D2UDX2 =(C_UDSI_G(c,t,0)[0]);
D2UDXY =(C_UDSI_G(c,t,0)[1]);
D2UDY2 =(C_UDSI_G(c,t,2)[1]);
D2VDY2 =(C_UDSI_G(c,t,1)[1]);
D2VDYX =(C_UDSI_G(c,t,1)[0]);
D2VDXY=D2VDYX;
D2VDX2 =(C_UDSI_G(c,t,3)[0]);
D2TDX2=(C_UDSI_G(c,t,4)[0]);
D2TDXY=(C_UDSI_G(c,t,4)[1]);
D2TDY2=(C_UDSI_G(c,t,5)[1]);


A = T*((-2.*nu_t*D2UDX2)*C_UDSI(c,t,4)+(2.*C_K(c, t)/3.-2.*nu_t*S11)*D2TDX2+(-nu_t*(D2UDXY+D2VDX2))*C_UDSI(c,t,5)+(-2.*nu_t*S12)*D2TDXY);
B = T*((-nu_t*(D2UDY2+D2VDXY)*C_UDSI(c,t,4))+(-2.*nu_t*S12)*D2TDXY+(-2.*nu_t*D2VDY2)*C_UDSI(c,t,5)+(2.*C_K(c, t)/3.-2.*nu_t*S22)*D2TDY2);
C = nu_t*C_T_G(c,t)[0]/P_t;
D = nu_t*C_T_G(c,t)[1]/P_t;




source = C_teta*C_R(c,t)*C_CP(c,t)*(A+B-C-D);

dS[eqn] = 0.0;

return source;
}


but I don't know to do.
Do you know where my error is?

Amir May 10, 2011 10:56

Hi,
I compiled and had some iterations with that!
note these comments:
1)activate energy and k-e model
2)you have to prevent the solver from freeing up memory by issuing the text command solve/set/expert and then answering yes to the question Keep temporary solver memory from being freed?
3)use this code:
Quote:

#include "udf.h"
#include "mem.h"
#define C_teta 0.3
#define P_t 0.85



DEFINE_SOURCE(source_ggdh,c,t,dS,eqn)
{
Domain *domain;
real coord[ND_ND];
real source,y,T,nu_t,S11,S12,S22,A,B,C,D;
real DUDX,DVDY,DVDX,DUDY,D2UDX2,D2UDXY,D2UDY2,D2VDY2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t*C_T_G(c,t)[0]/P_t;
D = nu_t*C_T_G(c,t)[1]/P_t;
source = C_teta*C_R(c,t)*C_CP(c,t)*(A+B-C-D);
dS[eqn] = 0.0;
return source;
}

m.reza May 11, 2011 10:17

second derivation
 
tnx Amir
I'm trying download C++ and Comile it.
thanks for your help
I'll inform you.


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