CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   how to access second derivative of velocity (https://www.cfd-online.com/Forums/fluent/38870-how-access-second-derivative-velocity.html)

Lichun Dong December 7, 2005 13:28

how to access second derivative of velocity
 
hi, all:

Does anyone knows how to access second derivative of velocity in FLUENT (such like du2/d2x)?

I am thinking about calculating it using first derivative (we can access it in FLUENT). But I can not get the value of a specific cell and its neighbor cell.

Thanks very much

lichun

RoM December 8, 2005 03:26

Re: how to access second derivative of velocity
 
I have written an udf that claculates du/dx but i don think its 100% flawless. It uses equation 26.2-7 from the users guide. The calculated values for du/dx are always slightly different from the ones calculated by fluent so i guess the code needs some improvent or maybe fluents solver uses a different approach. You can alter the udf to calculate d2u/dx2 by replacing all C_U with C_DUDX.

Good luck, RoM

DEFINE_ON_DEMAND(calc_dudx)
{
Domain *d;
Thread *ct,*ft;
face_t f;
cell_t c;
int n;
real A[ND_ND],c_cen[ND_ND],f_cen[ND_ND],c_f[ND_ND];
real dudx,u_mean,sign;

d=Get_Domain(1);

thread_loop_c(ct,d)
{
begin_c_loop(c,ct)
{
dudx=0.;
C_CENTROID(c_cen,c,ct);
c_face_loop(c,ct,n)
{
f=C_FACE(c,ct,n);
ft=C_FACE_THREAD(c,ct,n);
F_AREA(A,f,ft);
F_CENTROID(f_cen,f,ft);
NV_VV(c_f,=,f_cen,-,c_cen);
if((NV_DOT(A,c_f)>0) sign = 1.; else sign -1.;
if(BOUNDARY_FACE_THREAD_P(ft))
u_mean=C_U(c,ct);
else
u_mean=0.5*(C_U(F_C0(f,ft),THREAD_T0(ft))+C_U(F_C1 (f,ft),THREAD_T1(ft)));
dudx+=(sign*u_mean*A[0]);
}
dudx/=C_VOLUME(c,ct);
C_UDMI(c,ct,0)=dudx;
}
end_c_loop(c,ct)
}
}

zxaar December 8, 2005 03:34

Re: how to access second derivative of velocity
 
fluent restricts these values of derivatives to use in the code, so they are multiplied by a factor alpha, calculated based on venkatakrishanans limiter. The derivatives that you have calculated are unbounded derivatives.


RoM December 8, 2005 03:50

Re: how to access second derivative of velocity
 
In my case the calculated values where lower (about 10%) than the ones from fluent. Dou you have ideas why this happens?

RoM

zxaar December 8, 2005 04:59

Re: how to access second derivative of velocity
 
I am not sure what exactly happened, but fluents gradient process is bit different, i will outline them for you,
[*] Calculate the gradients with face value taken as mean phi_f = 0.5 * (phi_0 + phi_1), as you have calculated[*] Restrict them, so that the face value calculated by them shall not exceed the local maxima minima, phi_f = phi_0 + grad . (delta r)[*] now calculate the face value as phi_f = 0.5 * (phi_f_0 + phi_f_1), where phi_f_0 = phi_0 + grad_0 . (delta r) and phi_f_1 = phi_1 + grad_1 . (delta r), now calculate the gradients again.

So there will be difference between what you calculate then what fluent does, wise thing is to use them directly, since it will not make the solution blow up

RoM December 8, 2005 05:34

Re: how to access second derivative of velocity
 
Thanks you very much for this explanation. I find the time i will try it out just to see if the difference between the udf and the fluent values will go away.

Btw i had a typo in the source i posted above

"if((NV_DOT(A,c_f)>0) sign = 1.; else sign -1.;" should be "if((NV_DOT(A,c_f)>0)) sign = 1.; else sign =-1.;" , just in case someone trys to compile this mess.

Thanks again, RoM

Lichun Dong December 8, 2005 11:09

Re: how to access second derivative of velocity
 
Thanks for your response. really appreciate.

lichun


All times are GMT -4. The time now is 14:52.