CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Calculation of Velocity u.Gradient X (https://www.cfd-online.com/Forums/cfx/162567-calculation-velocity-u-gradient-x.html)

Ever Seen a Tornado? November 12, 2015 21:04

Calculation of Velocity u.Gradient X
 
1 Attachment(s)
I am having a problem with calculating simple first derivatives of velocity fields (Velocity u and Velocity v) exported from sample planes in CFX-Post.

Specifically, when I sample on a uniform grid that is finer than the numerical mesh in a region, how the velocity field is interpolated (it appears to be using tri-linear shape functions) leads to errors in the derivative estimator (I am using central differences in MATLAB).

The result is a du/dx plot that looks like the top attached figure (notice the step changes in du/dx as the estimator passes each mesh point). Basically, when more than two points are sampled within an element, the linear interpolation scheme leads to constant du/dx within each element.

In contrast, if I plot the velocity gradient calculated within CFX (Velocity u.Gradient X) on a sample line with the same uniform discretization, the result is smooth, as shown in the bottom attached figure. How is this variable being calculated?

ghorrocks November 13, 2015 05:15

1) Are you sure CFX is plotting a smooth function? Or is there only a single point per element and therefore the chart looks smooth?
2) The CFX solver uses proper shape functions to get some high order terms for things like this. These are lost in the post processor and will result in small differences like what you report.

And no, I have never seen a tornado.

Ever Seen a Tornado? November 13, 2015 09:52

Thanks ghorrocks :D

I've checked that the plots are sampled on the same uniform grid. However, when I try to then derive the Velocity u.Gradient X data in MATLAB (d^u/dx^2), I get the same step pattern. Which makes sense, CFX is storing both the Velocity u and Velocity u.Gradient X at each element face, then interpolates when evaluating inside an element. Hence the Velocity u.Gradient X data will have the same linear segments as the Velocity u data and give the same problems when applying a differencing scheme.

As far as I can tell I have two options (since I haven't saved velocity gradient data at every timestep to save space):

1) Export data using a slice plane, and calculate my finite differences at the exact element locations, then interpolate onto a uniform grid.

2) Keep my uniform grid data, but use some piecewise polynomial fit on the data in order obtain smooth differentiation.

I'm going with 2) with a chebyshev polynomial package in order to avoid the data overhead associated with my fine near wall mesh, as well, developing a smooth differentiation code will be useful for the experiments this simulation is directed at.


--_-_-_-_---
-_-_-_
-_-_-
-__-
_-_
_-
-_
_-_

ghorrocks November 14, 2015 06:01

Sounds sensible. Both of those options should work.


All times are GMT -4. The time now is 16:10.