# calculate temperature gradient from temperature field

 Register Blogs Members List Search Today's Posts Mark Forums Read

 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   Wu Jian Join Date: Jun 2009 Location: Poitiers Posts: 33 Rep Power: 9 Generally, there are two methods for gradient evaluation: based on Gauss Theorem and the Least-Squares 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, 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)*( (y3-y2)(x2-x) - (x3-x2)(y2-y) ) 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:
 Originally Posted by leflix Hi Yu, 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)*( (y3-y2)(x2-x) - (x3-x2)(y2-y) ) 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 to obtain the gradient.
I agree, using the shape function is very simple and you can construct also higher order shape functions by exploting suitable manipulation of the linear ones

July 25, 2012, 17:42
#9
Senior Member

Join Date: Aug 2011
Posts: 251
Rep Power: 8
Quote:
 Originally Posted by FMDenaro I agree, using the shape function is very simple and you can construct also higher order shape functions by exploting suitable manipulation of the linear ones
shape function that's it ! Thanx Filippo I missed the word !

 July 25, 2012, 21:53 #10 Senior Member   Julien de Charentenay Join Date: Jun 2009 Location: Australia Posts: 230 Rep Power: 10 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     Praveen. C Join Date: Mar 2009 Location: Bangalore Posts: 255 Blog Entries: 6 Rep Power: 10 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 non-zero 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     Praveen. C Join Date: Mar 2009 Location: Bangalore Posts: 255 Blog Entries: 6 Rep Power: 10 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 Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post kj878 STAR-CCM+ 12 February 8, 2012 17:13 sven OpenFOAM 7 November 1, 2010 18:25 MOhaj FLUENT 0 April 24, 2010 23:54 arther FLUENT 0 April 19, 2006 23:12 Tomasz Didenko FLUENT 1 June 27, 2003 04:30

All times are GMT -4. The time now is 20:54.