
[Sponsors] 
June 29, 2012, 14:16 
calculate temperature gradient from temperature field

#1 
Member
yu
Join Date: Nov 2010
Posts: 39
Rep Power: 7 
Hello all,
I have a field of temperatures (on nodes) and would like to calculate the temperature gradient (at cell center) from them. I was able to do it for structured cubes using finite difference. However, I am having a hard time to do it for unstructured tetrahedrons. anyone has suggestion? best 

June 29, 2012, 20:16 

#2 
Member

Generally, there are two methods for gradient evaluation: based on Gauss Theorem and the LeastSquares approach
for unstructured grid, i advice you use the Gauss method, which is easy to implement .... the method is widely known and can be found in lots of textbook of CFD 

July 2, 2012, 12:24 

#3 
Member
yu
Join Date: Nov 2010
Posts: 39
Rep Power: 7 
Dear Wu Jian
Thank you for your reply. I will look into this. best, yu 

July 25, 2012, 00:18 

#4 
Member
yu
Join Date: Nov 2010
Posts: 39
Rep Power: 7 
Hello Wu Jian,
I have implemented this Gauss method you suggested. It works great for cells with significant volume. I have tried to run a case with very small cell volume(10^13) and with same temperature on four nodes (i use tetrahedrons). As expected I got very small flux (10^14). However, when try to get the gradient, we need to divide the flux by the volume. Therefore, I actually got a significant gradient(10^1) when I suppose to get zero. Is there anyway I can resolve this? Thanks again for your help. best, yu 

July 25, 2012, 04:53 

#5 
Member

first of all, i am glad you are working hard to solve your problem.
before my answer, i need to know something about your implementation ... 1. what do you mean by ' significant volume' ? the grid cell with large volume ? 2. I do not care about the size of your cell but the shape ... is your cell regular or not ? 3. Generally, for Gauss method, there is a grid induced error for nonorthogonal grid . To get high accuarcy, you have to make sue the value at the center of the surface is a good interpolation value from the values of central nodes .... generally, you may say : phi_surface _1 = fx*phi_left + (1fx) phi_right then the question is , if the grid is nonorthogonal, fx is not a good interpolation factor ... so you should improve your Gauss method, i think you can find some paper about this point ... 

July 25, 2012, 14:04 

#6 
Member
yu
Join Date: Nov 2010
Posts: 39
Rep Power: 7 
Thanks for your time Wu Jian,
I created a tetrahedron cell with (0,0,0) (1,0,0) (0,1,0) and (0,0,1). With the same temperature on all four points, the method work fine . When I reduced the size, the cell is now (0,0,0) (0.00001,0,0) (0,0.00001,0) and (0,0,0.00001). The answer is incorrect. 

July 25, 2012, 17:29 

#7 
Senior Member
Join Date: Aug 2011
Posts: 251
Rep Power: 8 
Hi Yu,
The proposition of Wu Jian sounds good and it's funny it doesn't work, even if I can see why. What you may do is to use an interpolation procedure as in finite element. T(x,y) = h1(x,y)*T1 + h2(x,y)*T2+h3(x,y)*T3 where Ti are the values at each node of a triangle and hi(x,y) are interpolation functions. for example h1(x,y) =(1/2A)*( (y3y2)(x2x)  (x3x2)(y2y) ) where xi,yi are the coordinates of node i... you will easily find the other interpolation functions h2(x,y) and h3(x,y) in any finite element text book. Then when you get T(x,y) you can easily derive it analytically to obtain the gradient. 

July 25, 2012, 17:36 

#8  
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 2,586
Rep Power: 32 
Quote:


July 25, 2012, 17:42 

#9 
Senior Member
Join Date: Aug 2011
Posts: 251
Rep Power: 8 

July 25, 2012, 21:53 

#10 
Senior Member

Hi Yu,
The issue you are having is divide a very small number by another very small number, which give you an erroneous answer (due to machine errors). There are a number of solution: 1  Use a normalisation factor for your coordinate system; 2  Maximise the machine precision (run double precision, on a 64bOS and check the compiler options). Good luck. Julien
__________________
 Julien de Charentenay 

July 26, 2012, 12:28 

#11 
Member
yu
Join Date: Nov 2010
Posts: 39
Rep Power: 7 
Thank you all for your replies. I think the interpolation will help with temperature averaging on each face. However, my problem is even when the temperatures are the same (i.e. no problem with averaging) I got incorrect temperature gradient. I will try what Julien suggested. Thank you to all again for your help.
best, yu 

July 26, 2012, 23:54 

#12 
Super Moderator

Division is a stable operation. You probably have problem with addition/subtraction. If you are computing determinant, you need to be careful. Check that your cell volume is correct. Write the gradient formula in terms of differences of state variables. You should then get zero gradient for a constant data.


July 27, 2012, 15:57 

#13 
Member
yu
Join Date: Nov 2010
Posts: 39
Rep Power: 7 
I think you are right, praveen. It seems when I sum the flux, I should have zero, but instead I got 10^10, but my volume is in the order of 10^10. Therefore, I am getting some nonzero gradient. Would you provide a little more details on "write the gradient formula in terms of differences of stat variables"? I am not sure what it is. Thanks!


July 27, 2012, 22:15 

#14 
Super Moderator

Write your gradient on a tetrahedron as
The coefficients should sum to zero If they dont then try to fix it. Its a round off problem, look at how you compute the coefficients and fix the round off issues. Since the coefficients should sum to zero, you can also write This gives zero gradients for constant data. You can use this, but first eliminate roundoff errors also. 

July 30, 2012, 14:38 

#15 
Member
yu
Join Date: Nov 2010
Posts: 39
Rep Power: 7 
Thank you Praveen! This is pretty much what I have. My coefficients do not add up to zero. I will try to fix the round off problem. Thanks again for your genuine help.


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Field Function relating to temperature. Please Help  kj878  STARCCM+  12  February 8, 2012 17:13 
Temperature Gradient at Wall  sven  OpenFOAM  7  November 1, 2010 18:25 
problem with temperature field in modeling evaporation with fluent  MOhaj  FLUENT  0  April 24, 2010 23:54 
calculate the temperature gradient on a profile  arther  FLUENT  0  April 19, 2006 23:12 
Question on Face Temperature Gradient  Tomasz Didenko  FLUENT  1  June 27, 2003 04:30 