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

PB with DEFINE_RW_FILE

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 9, 2011, 10:39
Default PB with DEFINE_RW_FILE
  #1
New Member
 
Join Date: Mar 2011
Posts: 20
Rep Power: 15
saclu is on a distinguished road
Hi all,

I am using a sliding mesh with the 6dof solver to simulate the rotation of a turbine.
I wrote this UDF to write the angular velocity of my cg at each time step but i keep having mistakes, does anyone would know what's wrong with this file?

---------------------------------------------------------------------
#include"udf.h"
#include"dynamesh_tools.h"
int ZONE_ID = 7; DEFINE_RW_FILE(writer, fp)

{

real omega_Z;
/* declaration of the variable to be written*/
Domain *domain; /* domain is declared as a variable */

domain = Get_Domain(1); /* returns fluid domain pointer */
Thread *t = Lookup_Thread(domain,ZONE_ID);

Dynamic_Thread *dt = THREAD_DT(t);
omega_Z = DT_OMEGA_CG(dt);

printf(
"Writing UDF data to data file...\n");
fprintf(fp,
"%d",omega_Z); /* write out omega_Z to a data file */

}
---------------------------------------------------------------------
saclu is offline   Reply With Quote

Old   May 13, 2011, 14:19
Default
  #2
New Member
 
Join Date: Mar 2011
Posts: 28
Rep Power: 15
Tobard is on a distinguished road
Hi!

I am not an expert but I feel like your function is too complicated for what you need to do.

If you want to define the angular velocity of your CG at each time step, I suggest you write something like that:

---------------------------------------------------------
#include"udf.h"
DEFINE_CG_MOTION(rot_cg, dt, velocity, omega, time, dtime)
{
NV_S(omega, =, 0.0);

omega[2]=150; /*for 150 rad/s around z axis*/
}
---------------------------------------------------------

I hope it helps. I encounter difficulties with transition from a time step to the next one (solution is not the one that is expected despite the fact that motion is well defined) so maybe something is missing in this function. It works but be careful!
Tobard is offline   Reply With Quote

Old   May 13, 2011, 15:52
Default
  #3
New Member
 
Join Date: Mar 2011
Posts: 28
Rep Power: 15
Tobard is on a distinguished road
Ooooooops! I am sorry: my answer was out of context...(cannot delete it)

Concerning your issue I suggest you write your code outside of your DEFINE function, using something like:

static
void write_data(FILE *fp)
{
<your code>
}

Then you can call 'write_data' in your DEFINE function. It is done so in valve.c, the UDF used in Fluent tutorial 13.
Tobard is offline   Reply With Quote

Old   May 16, 2011, 05:05
Default
  #4
New Member
 
Join Date: Mar 2011
Posts: 20
Rep Power: 15
saclu is on a distinguished road
Hi!

Thanks for your reply, I had a look to the valve.c and followed your advice. However I still have some errors when I'm trying to compile the udf. The main problem comes for this line:

Thread *t = Lookup_Thread(domain,zone_id);

It says that the use of *t not conform.
saclu is offline   Reply With Quote

Old   May 16, 2011, 10:07
Default
  #5
New Member
 
Join Date: Mar 2011
Posts: 28
Rep Power: 15
Tobard is on a distinguished road
Hi!

Have you tried to split the command into two parts?

------------------------
Thread *t;
t = Lookup_Thread(domain,ZONE_ID);
------------------------

I am not sure that "Thread" works like "real"...
Tobard is offline   Reply With Quote

Old   May 16, 2011, 10:47
Default
  #6
New Member
 
Join Date: Mar 2011
Posts: 20
Rep Power: 15
saclu is on a distinguished road
Hi!
Thanks a lot for your help, I got it working with:

#include"udf.h"
#define DYNAMIC_ZONE_ID 7
DEFINE_RW_FILE(writer, fp)
{
real cg_omega[3];
Domain *d = Get_Domain(1);
Thread *t = Lookup_Thread(d, DYNAMIC_ZONE_ID);
Dynamic_Thread *t_box = THREAD_DT(t);

cg_omega[2] = DT_OMEGA_CG(t_box)[2];
printf(
"Writing UDF data to data file...\n");
fprintf(fp,
"%f",cg_omega); /* write out omega_Z to a data file */
}


I thing the problem what in the definition of cg_omega.
saclu 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



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