CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

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

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2013, 23:00
Default Can someone help me with a UDF for a simple rotatory geometry??
  #1
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
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)
{
Thread *t;
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)*/
t = DT_THREAD(dt);

/* 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
File Type: jpg Example.jpg (18.1 KB, 43 views)
Maralady is offline   Reply With Quote

Old   August 2, 2013, 00:25
Default
  #2
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
Sorry wrong forum
Maralady is offline   Reply With Quote

Old   August 2, 2013, 18:23
Default
  #3
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
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
Maralady is offline   Reply With Quote

Old   August 5, 2013, 09:07
Default
  #4
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
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.
vasava is offline   Reply With Quote

Old   August 5, 2013, 16:51
Default
  #5
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
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.
Maralady is offline   Reply With Quote

Old   August 8, 2013, 00:37
Default
  #6
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
I will try your advice tomorrow thanks for it
Maralady is offline   Reply With Quote

Old   August 8, 2013, 22:15
Default
  #7
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
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
Maralady is offline   Reply With Quote

Old   August 9, 2013, 01:55
Default
  #8
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
You need to setup your visual c++ and SDK right. Here is a document that can help you.
vasava is offline   Reply With Quote

Old   August 9, 2013, 18:33
Default
  #9
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
Thank you Mr.Vasava you have been very helpful
Maralady is offline   Reply With Quote

Old   August 9, 2013, 21:54
Default
  #10
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
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?
Maralady is offline   Reply With Quote

Old   August 9, 2013, 22:14
Default
  #11
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
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.
Maralady is offline   Reply With Quote

Old   August 9, 2013, 22:19
Default
  #12
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
Looks like it was enough to just modify Velocity to Vel
Maralady is offline   Reply With Quote

Old   August 10, 2013, 00:04
Default
  #13
Member
 
Arthur Loginow
Join Date: Aug 2012
Posts: 99
Rep Power: 14
Maralady is on a distinguished road
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...
Maralady is offline   Reply With Quote

Old   August 12, 2013, 02:28
Default
  #14
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
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.
vasava is offline   Reply With Quote

Old   August 12, 2013, 09:23
Default
  #15
New Member
 
baydu
Join Date: Sep 2011
Posts: 10
Rep Power: 15
eaxbca is on a distinguished road
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.;
}
eaxbca is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FLUENT UDF Simple error. startup0820 Fluent UDF and Scheme Programming 0 August 14, 2012 04:54
Need help on meshing this simple geometry nha1g08 ANSYS Meshing & Geometry 3 March 9, 2011 03:13
[snappyHexMesh] Irregular mesh generation for simple box geometry ajl42 OpenFOAM Meshing & Mesh Conversion 0 March 7, 2011 18:04
Problem with a simple UDF to calculate cell-averaged particle values kmayank FLUENT 1 January 18, 2011 02:40
vitual _ real deneb FLUENT 3 January 22, 2007 05:31


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