Chapter 5: Use of UDF in Moving Deforming Mesh DOF
In the previous workshops, all the motions were imposed or controlled ones, so the flow reacted upon
the structured motion. This tutorial illustrates how to handle a case where the flow influences the motion
of an element. To do so, it requires the use of a 6DOF (Degrees of Freedom) UDF (User Defined Function)
that takes into account the forces & momentums acting on the solid in motion. This tutorial shows how
to set up a case using this kind of model.
This tutorial is written with the assumption that you are familiar with the ANSYS Fluent navigation pane
and menu structure. Some steps in the setup and solution procedure will not be shown explicitly.
5.1. Preparation
5.2. Reading and Checking the Mesh
5.3. Specifying Solver and Analysis Type
5.4. Specifying Dynamic Mesh Settings
5.5. Run the Simulation
5.6. Summary
5.1. Preparation
1. Copy the files (pipe-vane1DOF-inflation.cas/dat.gz and XDOF-vane.c) to your working
folder.
2. Launch Fluent.
a. Select 3D under Dimension in the Fluent Launcher dialog box.
b. Ensure that Display Mesh After Reading is enabled under Display Options in the Fluent
Launcher dialog box. This will ensure that the mesh is displayed automatically after reading.
c. Disable the option Workbench Color Scheme under Display Options.
d. Retain the option of Serial under Processing Options.
e. Make sure you have set the correct working directory in the General Options tab.
f. Click OK to start Fluent.
Note
• Double Precision is recommended when moving deforming mesh is handling
very thin cells (ie: width of micron - µm).
• Use of Parallel Processing Options (associated with a number of processors) is
recommended if you want to speed up your simulation.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 1
Use of UDF in Moving Deforming Mesh DOF
5.2. Reading and Checking the Mesh
1. Read the case file and data pipe-vane1DOF-inflation.cas/dat.gz.
File → Read → Case & Data...
2. Check the mesh.
General → Check
ANSYS Fluent will perform various checks on the mesh and will report the progress in the console. Ensure
that the reported minimum volume is a positive number.
3. In the mesh display check each surface of the geometry so that you know which surface corresponds
to which name.
a. Open the Mesh Display dialog box.
Display → Mesh...
b. Retain the selection of Edges and select Faces list of Options.
c. Deselect all from the list of Surfaces.
d. Select wall-vane and click Display.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
2 of ANSYS, Inc. and its subsidiaries and affiliates.
Reading and Checking the Mesh
e. Select other surfaces one by one and click Display to check which displayed surface represents
which name.
4. Create an isosurface.
Surface → Iso-Surface...
a. In the Iso-Surface dialog box select Mesh... and Z-Coordinate from the Surfaces of Constant
drop-down lists.
b. Retain 0 for Iso-Values.
c. Enter z-0 for New Surface Name.
d. Click Create.
5. Display the isosurface z-0 along with the surface wall-vane.
Display → Mesh...
6. Save the view for the animation.
Display → Views...
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 3
Use of UDF in Moving Deforming Mesh DOF
• In the Views dialog box select view-0 and click Apply.
7. To improve the display lighting select Lights... from the Display menu.
a. Select Flat from the Lighting Method drop-down list.
b. Enable Headlight On in the Lights dialog box.
c. Click Apply and close the Lights dialog box.
Note
As you can see the mesh is of a pipe. Inside the pipe you have the vane. The vane will
be moved inside the pipe. The vane will be rotating along the Z axis.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
4 of ANSYS, Inc. and its subsidiaries and affiliates.
Reading and Checking the Mesh
8. Check the UDF by opening the file XDOF-vane.c, in a text editor. You will be adding some values to
the files to make it work right for the tutorial.
a. Enter 0.1 for prop[SDOF_MASS], which will be 100 g.
b. To se up the moment of inertia enter 2.48e-5 for prop[SDOF_IXX], 3.645e-5 for
prop[SDOF_IYY], and 2.48e-5 for prop[SDOF_IZZ]
c. The actual vane definition (or properties) shows that all the motion is blocked (the three transla-
tional and rotational values are set to TRUE). So, remove the line prop[SDOF_ZERO_ROT_Z] =
TRUE;. This will allow you to move (in a rotation mode) the vane along the Z axis.
d. Save the UDf as 1-DOF-vane.c.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 5
Use of UDF in Moving Deforming Mesh DOF
9. Compile the UDF.
Define → User-Defined → Functions → Compiled
a. Click Add... under Source Files dialog box to open the Select File dialog box.
b. Select the 1-DOF-vane.c file in the Select File dialog box and click OK.
c. Click Build.
Click OK in the Question dialog box that appears.
Note
Check that there are no errors reported in the console while compiling.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
6 of ANSYS, Inc. and its subsidiaries and affiliates.
Specifying Dynamic Mesh Settings
d. Click Load and then close the Compiled UDFs dialog box.
5.3. Specifying Solver and Analysis Type
For moving deforming mesh you require the transient solver. Select Transient under Time in the
Solver group box.
5.4. Specifying Dynamic Mesh Settings
Dynamic Mesh
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 7
Use of UDF in Moving Deforming Mesh DOF
1. In the Dynamic Mesh task page enable Dynamic Mesh.
2. Enable Remeshing and retain Smoothing in the Mesh Methods group box.
3. Click Settings... to open the Mesh Method Settings dialog box.
4. In the Smoothing tab enter 50 for Number of Iterations.
5. Click the Remeshing tab.
Note
Since the vane is not in contact with anything you will retain the selection of Local Cell
in the Remeshing Methods group box.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
8 of ANSYS, Inc. and its subsidiaries and affiliates.
Specifying Dynamic Mesh Settings
a. Click Use Defaults.
b. Enter 0.0003 for Minimum Length Scale.
c. Enter 0.005 for Maximum Length Scale.
d. Enter 0.9 for Maximum Cell Skewness.
e. Enter 1 for Size Remeshing Interval.
f. Click OK to close the Mesh Method Settings dialog box.
6. Enable Six DOF in the Options group box in the Dynamic Mesh task page.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 9
Use of UDF in Moving Deforming Mesh DOF
7. Click Settings to open the Options dialog box.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
10 of ANSYS, Inc. and its subsidiaries and affiliates.
Specifying Dynamic Mesh Settings
a. In the Six DOF tab of the Options group box enter -10 for X.
b. Click OK to close the Options dialog box.
8. To set the motion to the object you need to define the dynamic mesh zones. Click Create/Edit... under
the Dynamic Mesh Zones group box.
a. In the Dynamic Mesh Zones dialog box select fluid-pipe:010 from the Zone Names drop-down
list.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 11
Use of UDF in Moving Deforming Mesh DOF
Note
If you zoom in on one end of the vane you can see that this layer will correspond
to the prism layer around the vane. The vane moves as a rigid body, according to
the fluid flow behavior. So, you want this fluid zone ( prism layer) to move with the
vane but not deformed.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
12 of ANSYS, Inc. and its subsidiaries and affiliates.
Specifying Dynamic Mesh Settings
i. Retain the selection of Rigid Body in the Type group box.
ii. Retain the selection of rota_vane::libudf from the Motion UDF/Profile drop-down list.
Note
The name rota_vane should be same as that in the UDF.
iii. Enable Passive in the Six DOF Options group box.
Note
You need to enable Passive option for the fluid zone, as you do not want to
take into account the effort and momentum exerted in this later. Only the effort
applied on the vane itself is valuable.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 13
Use of UDF in Moving Deforming Mesh DOF
iv. Enter 0.008 for X and 0.06117 for Y in the Center of Gravity Location group box.
Note
This will define the axis around which you want to rotate the vane. The axis is
off-centered.
v. Click Create.
b. Select wall-vane from the Zone Names drop-down list.
i. Retain the selection of Rigid Body in the Type group box.
ii. Retain the selection of rota_vane::libudf from the Motion UDF/Profile drop-down list.
iii. Disable Passive in the Six DOF Options group box.
Note
Passive is disabled for this because you want to take into account the effort
and momentum that will be exerted on the vane to make it work properly.
iv. Retain 0.008 for X and 0.06117 for Y in the Center of Gravity Location group box.
v. Click Create.
c. Select interior-geom_solid:004 from the Zone Names drop-down list.
Note
You need to move this interior zone like a rigid body. This interior zone is at the
edge of the two fluid zones, the one which moves with the vane and the one in
the pipe which deforms.
i. Retain the selection of Rigid Body in the Type group box.
ii. Retain the selection of rota_vane::libudf from the Motion UDF/Profile drop-down list.
iii. Enable Passive in the Six DOF Options group box.
Note
As you want to take into account the effort and momentum you will enable
Passive.
iv. Retain 0.008 for X and 0.06117 for Y in the Center of Gravity Location group box.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
14 of ANSYS, Inc. and its subsidiaries and affiliates.
Run the Simulation
v. Click Create.
d. Close the Dynamic Mesh Zones dialog box.
9. Save the case file, pipe-vane1DOF-inflation-mdm.cas.gz.
File → Write → Case...
Note
Using the 6DOF UDF, requires to have efforts and momentums, or eventually external forces
(which is not the case) to move the vane. Therefore, it is not so simple to check the motion
of the vane via the Preview. To do so, an imposed motion would be necessary, but for the
purpose of the tutorial we assume that this is correct.
5.5. Run the Simulation
You can save the mesh picture at each time step so that after the run is over you can make an animation
which will show how the mesh changes in the process.
Calculation Activities
1. In the Calculation Activities task page click Create/Edit....
a. In the Execute Commands dialog box enter 2 for Defined Commands.
b. Select Time Step from the When drop-down list for both commands.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 15
Use of UDF in Moving Deforming Mesh DOF
c. For command- 1 enter /display/surface-mesh wall-vane z-0 ().
Note
This command will display the mesh of wall-vane at every time step.
d. For command- 2 enter /display/save-picture "mesh-i%.jpeg".
Note
This command will save the picture of the mesh at every time step. You can make
a movie after this of all the saved pictures.
e. Enable Active for both commands.
f. Click OK to close the Execute Commands dialog box.
2. Save the case and data files together by using Autosave. Save them according a defined number of
time steps.
Calculation Activities
a. Click Edit... in the Calculation Activities task page next to Autosave Every (Time Steps).
b. Enter the required value for Save Data File Every (Time Steps).
c. Give a generic name for the case and data files, vane-1DOF-timestep.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
16 of ANSYS, Inc. and its subsidiaries and affiliates.
Run the Simulation
d. Click OK to validate and close the window.
Note
To keep the execution time of this tutorial short, you will not enable this option, so retain
0 for Save Data File Every (Time Steps).
3. Now you can start the calculation.
Run Calculation
a. Enter 0.0025 for Time Step Size.
b. Enter 20 for Number of Time Steps.
c. Click Calculate.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 17
Use of UDF in Moving Deforming Mesh DOF
4. Open the Dynamic Mesh Zones dialog box and you can see that the value of Theta_Z has under
Center of Gravity Orientation and Omega_Z has under Center of Gravity Angular Velocity, has
changed. This also confirms that the vane has moved.
Note
• Run the tutorial for a longer time to get a more detailed picture of how the vane moves.
• You can make an animation of the saved images.
5.6. Summary
In this tutorial you have learned one more step in the process of setting up a moving deforming mesh,
how to move an object according to fluid flow influence.
To run such an application, you need to use the 6DOF UDF.
• First write the appropriate UDF by defining the properties of the 6DOF and compile it.
• Next enable the Six DOF option in the Dynamic Mesh model and define the Gravitational Acceleration.
• Lastly define correctly which zones are actively involved in the evaluation of the forces and momentums.
Release 15.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
18 of ANSYS, Inc. and its subsidiaries and affiliates.