Thursday, June 5, 2008

Polar to Cartesian Transformation in Fluent UDF

Download udf c file

When simulating a certain problem in CFD, the closer your initial values are to the exact solution, the faster your numerical solution will converge. Now of course, if we had the exact solution, who cares about CFD? That is true, but most of the time we have simplified models that describe the flowfield in a certain geometry. Therefore, it makes sense to initialize the numerical data with the quasi-exact analytical model.

On the other hand, there is a technique that I use to make high quality streamline animations for my analytical models. (I will explain this in a subsequent article). The bottom line is that I need to initialize my mesh with the analytical solution. Now this solution is most often in cylindrical/polar coordinates and Fluent does not offer that luxury (and I agree, because it is easier to write a general code for the Cartesian form of the fluid flow equations). Fluent reads the mesh and solves the problem using Cartesian coordinates and all cells are defined using (x,y,z), while all velocities refer to the x,y, and z components respectively.

It is very easy to initialize the Fluent model with your analytical solution when it is in cartesian coordinates. For polar/cylindrical models, a little bit of extra programming is required.

I have written the code to do this for 2D polar coordinates. The 3D version will follow in the next article as generalization is required (to account for axis and origin locations - In case your axis is in the z direction and located at (0,0), then you can simply extend the attached code by adding the z component for the velocity).

Please take a moment to look at the file. Everything is commented clearly and the locations where you need to make changes are capitlized. You basically have to modify the origin location and the analytical solution.

(I assume you have knowledge of how to hook a udf file to fluent. I will prepare an article on that in the future).

Download udf c file

Cite as:
Saad, T. "Polar to Cartesian Transformation in Fluent UDF". Weblog entry from Please Make A Note. https://pleasemakeanote.blogspot.com/2008/06/polar-to-cartesian-transformation-in.html?m=0

No comments:

Post a Comment