calculate temperature gradient from temperature field
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 
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 
Dear Wu Jian
Thank you for your reply. I will look into this. best, yu 
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 
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 ... 
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. 
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. 
Quote:

Quote:

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 
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 
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.

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!

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.

All times are GMT 4. The time now is 00:40. 