# Can someone help me with a UDF for a simple rotatory geometry??

 Register Blogs Members List Search Today's Posts Mark Forums Read

August 1, 2013, 22:00
Can someone help me with a UDF for a simple rotatory geometry??
#1
Senior Member

Join Date: Aug 2012
Posts: 102
Rep Power: 6
Hello, I am trying to create a code to this geometry, as you can see at the images it is a simple geometry, it is a pipe with 2 bodies rotating inside, so far I have been reading the UDF manual, and I made a code I would like to make some questions but first here is the code:

#include "udf.h"

DEFINE_CG_MOTION(Rotation,dt,vel,omega,time,dtime)
{
face_t f;

/*reset velocities*/
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);

/*not too sure what this is for*/
if (!Data_Valid_P())
return;
/*get the thread pointer for which this motion is defines (I assume that this is the cell zone that I made)*/

/* motion */
velocity[0] = 0;
velocity[1] = 0;
velocity[2] = 0;
omega[0] = 0;
omega[1] = 0;
/*This will be just a random number, I will try different values anyway*/
omega[2] = 120;
/*not sure how to do the loop and if I should make the loop for faces or cells*/
}

Question 1: Do I have to create a UDF for each body? Or can I include both bodies at the same UDF?

Question 2: Well as you can see at the code, I am not quite sure of how to make the loop (I have a decent programming knowledge, and because of this forced to learn C, I know how to create a loop, but I do not know what variables to include for the loop, so far I know the pointer will tell the program to use some faces/cells and that leads me to my other question)

Question 3: Should I use faces or cells for the Loop?

Question 4: There is something that I am missing?

I read just the first 2 chapters of the UDF guide, I will finish all the guide soon, but I think that the next chapters will not clear those doubts.

Thanks
Attached Images
 Example.jpg (18.1 KB, 29 views)

 August 1, 2013, 23:25 #2 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 Sorry wrong forum

 August 2, 2013, 17:23 #3 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 I would like to know if I should use the cells or the faces, so far I understand that I should use the faces because that will make the adjacent cells to move as well and that is what I am looking for

 August 5, 2013, 08:07 #4 Senior Member   Paritosh Vasava Join Date: Oct 2012 Location: Lappeenranta, Finland Posts: 657 Rep Power: 15 Question 1: You do not need separate UDFs unless you have different rotational speed for each body. Yes you can use one UDF for several bodies. Question 2: For simple rotational and translational motion there seem to be nothing wrong with the UDF. Instead of what you have you may use #include "udf.h" DEFINE_CG_MOTION(Rotation,dt,vel,omega,time,dtime) { /* motion */ velocity[0] = 0; velocity[1] = 0; velocity[2] = 0; omega[0] = 0; omega[1] = 0; /*This will be just a random number, I will try different values anyway*/ omega[2] = 120; /*not sure how to do the loop and if I should make the loop for faces or cells*/ } Question 3: I dont think so. Question 4: Again this is good enough for simple rotationg motion. Make sure you have your Dynamic mesh settings right.

 August 5, 2013, 15:51 #5 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 Vasava thanks for your reply, sadly I have to use 2 UDF because I have the same angular velocity but in different directions, therefore I will have to create a new UDF exactly the same but with Omega[2] = -120 instead of Omega[2] = 120, anyway I will try this today and post here the experience, to help others with the same problem, thanks again.

 August 7, 2013, 23:37 #6 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 I will try your advice tomorrow thanks for it

 August 8, 2013, 21:15 #7 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 Now I am getting this error: The UDF library you are trying to load (libudf) is not compiled for 3ddp on the current platform (win64). The system cannot find the file specified. Not idea what it is Saw different posts but none of them were solved

August 9, 2013, 00:55
#8
Senior Member

Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 657
Rep Power: 15
You need to setup your visual c++ and SDK right. Here is a document that can help you.
Attached Files
 2020316-Compiling and Loading FLUENT 64 - using SDKx.pdf (96.9 KB, 17 views)

 August 9, 2013, 17:33 #9 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 Thank you Mr.Vasava you have been very helpful

 August 9, 2013, 20:54 #10 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 My CMD shell says at the end v6.0 instead of v7.0, would this generate errors? Or I am able to work with this?

 August 9, 2013, 21:14 #11 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 I uploaded my code and I got this warning Rotation.c ..\..\src\Rotation.c(6) : error C2065: 'velocity' : undeclared identifier ..\..\src\Rotation.c(6) : error C2109: subscript requires array or pointer type ..\..\src\Rotation.c(7) : error C2109: subscript requires array or pointer type ..\..\src\Rotation.c(8) : error C2109: subscript requires array or pointer type I fixed the first one (pretty obvious) and I will work on the other ones.

 August 9, 2013, 21:19 #12 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 Looks like it was enough to just modify Velocity to Vel

 August 9, 2013, 23:04 #13 Senior Member   Arthur Loginow Join Date: Aug 2012 Posts: 102 Rep Power: 6 When I build the udf everything is fine, when I load the library everything is fine when I save everything is fine, when I close the program and try to open the same case again I got this error from the fluent console Auto-compilation of "libudf" failed. Please try to compile it manually. Opening library "C:\Users\Arthur\Desktop\Rotation2_files\dp0\FFF\F luent\libudf"... Error: The UDF library you are trying to load (libudf) is not compiled for 3ddp on the current platform (win64). Somehow is not working...

 August 12, 2013, 01:28 #14 Senior Member   Paritosh Vasava Join Date: Oct 2012 Location: Lappeenranta, Finland Posts: 657 Rep Power: 15 The error 'The UDF library you are trying....' means that your UDF has not been compiled. The answers to 'how to fix?' lies in the errors: ..\..\src\Rotation.c(6) : error C2065: 'velocity' : undeclared identifier ..\..\src\Rotation.c(6) : error C2109: subscript requires array or pointer type ..\..\src\Rotation.c(7) : error C2109: subscript requires array or pointer type ..\..\src\Rotation.c(8) : error C2109: subscript requires array or pointer type Usually these errors even pin-point to the line where these errors occur. If you post your UDF here we can try to fix it.

 August 12, 2013, 08:23 #15 New Member   baydu Join Date: Sep 2011 Posts: 10 Rep Power: 7 Try the following UDF, it is from the gear pump tutorial. You don't need to specify zero values because defaults are zero. Check you that tutorial how to setup dynamic mesh parameters etc. #include "udf.h" DEFINE_CG_MOTION(object1, dt, vel, omega, time, dtime) { Domain *domain; domain = Get_Domain(1); omega[2]=-220.; } DEFINE_CG_MOTION(object2, dt, vel, omega, time, dtime) { Domain *domain; domain = Get_Domain(1); omega[2]=220.; }

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post startup0820 Fluent UDF and Scheme Programming 0 August 14, 2012 03:54 nha1g08 ANSYS Meshing & Geometry 3 March 9, 2011 03:13 ajl42 OpenFOAM Native Meshers: snappyHexMesh and Others 0 March 7, 2011 18:04 kmayank FLUENT 1 January 18, 2011 02:40 deneb FLUENT 3 January 22, 2007 05:31

All times are GMT -4. The time now is 11:08.