## Fluids

Topics relate to Fluent, CFX, Turbogrid and more

#### Help, Fluent UDF For Linear Motion

• Eliah Cameron
Subscriber

Hi all,

I am curently tring to get a UDF working to define the motion of a rigid object. Im not farmiluar with UDFs so any dialog, advice or recomendations would be helpful.

For refrence i am trying to asses diferent impact velocitys of objects into water using an overset mesh (2D).

• Atharva Nagarkar
Subscriber

Hello

I would suggest you to go through the different macros (such as DEFINE_) which are available in the Ansys Fluent UDF Manual. You will also be able to understand how to write the code for defining the UDFs, the appropriate structure and various available functions. The DEFINE_CG_MOTION could be a good fit for your application as it is used to specify the motion of a particular dynamic zone (object in your case) in Ansys Fluent by providing the linear and angular velocities at every time step. I have also shared a link of a similar discussion on the Ansys Forum related to implementation of UDF for an overset mesh case. Hope that helps!

Ansys UDF Manual: Part I: Creating and Using User Defined Functions (ansys.com)

DEFINE_CG_MOTION: 2.6. Dynamic Mesh DEFINE Macros (ansys.com) -> Check 2.6.1

Ansys Forum Post: UDF Implementation for overset mesh case (ansys.com)

If you are not able to access these links, please refer to this forum discussion: Using Help with links (ansys.com)

• Eliah Cameron
Subscriber

*Removed*

• Rob
Ansys Employee

• Rob
Ansys Employee

One comment (other than to echo reading the books) is that you've written a 3d UDF - have a look at what the vel[3] bit means, I think you'll find vel[2] to be sufficient and remember C counts from 0 not 1.

• Eliah Cameron
Subscriber

I have some follow up questions/interests.

My workflow is based of the tutorial below (URL link) below,

This tutorial comes with a UDF shown in the image below, From my understanding the ‘density’ and ‘speed of sound’ section of this UDF is used to track and update their changes due to the abrupt impact (This isn’t built in to fluent?), if this wasn’t implemented the density would retain the predefined value throughout the entirety of the impact.

The last section defines the motion of the object by defining its mass, I’m wanting to change this to linear motion.

I believe this should be simple but can’t get it working, I have tried mimicking the UDF in Ansys video below, (time 2:20). https://www.youtube.com/watch?v=BO2e9_njh5g

Below is the fluent console, don’t fully grasp the prompts.

• Rob
Ansys Employee

Density & speed of sound. Former looks to be trying to make water density pressure dependent: never a good idea - read the Properties section in the manual. Speed of sound isn't computed by default, it's only needed for compressible flows.

The UDF warnings. Use the built in compiler, and see what happens.

• Eliah Cameron
Subscriber

Thanks Rob, will look into it.
No luck with the built in compiler

• Eliah Cameron
Subscriber

Haven’t had any luck, have moved on to expression/parameter input in the wall boundary conditions. You can apply a constant velocity here for the wall condition, is there a way to define an initial velocity and then gravity dictate the rest?

• Rob
Ansys Employee

That's what the 6DOF functions are for - you can probably code that into Expressions based on the various laws & equations but you'd need to account for everything and I suspect Expressions will struggle.