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

Execute_ At_ End udf for Time dependent toruqe

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By GM_XIII

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 13, 2014, 03:09
Default Execute_ At_ End udf for Time dependent toruqe
  #1
New Member
 
shashank mishra
Join Date: Sep 2011
Posts: 12
Rep Power: 15
shashankmechguy is on a distinguished road
Hi All,

I am using udf Execute_At_End to print in console time dependent value of torque.
The problem I have is , the example given in fluent udf manual is for entire domain. I only want to calculate torque for one boundary zone which is a face thread of blades of a rotor.

This is the code I am using

#include"udf.h"
DEFINE_EXECUTE_AT_END(torque_time)
{
Domain *d;
Thread *t;
face_t f;
real NV_VEC(A);
real NV_VEC(force);
real NV_VEC(torque);
real x[ND_ND];
real NV_VEC(radius);
real NV_VEC(torque_final);
real tor;
NV_S(force,= ,0.0);
NV_S(torque_final,= ,0.0);
NV_S(torque,= ,0.0);
d = Get_Domain(9);
begin_f_loop(f,t)
{
F_AREA(A,f,t);
F_CENTROID(x,f,t);
NV_S(force,= , F_AREA(A,f,t), * , F_P(f,t));
NV_D(radius,= ,x[0],x[1],x[2]);
NV_CROSS(torque,radius,force);
NV_VV(torque_final,= ,torque_final,+, torque);
tor= NV_MAG(torque_final);
}
end_f_loop(f,t)
printf("Value of torque at the blades is = %f", tor );
}


I used d= Get_Domain(9) because the integer id of that face thread is 9. But its not printing anything on the console and I know I cannot use Get_Domain(9).

Can anyone advise me how to specify one particular face thread for execute_at_end macro
shashankmechguy is offline   Reply With Quote

Old   July 15, 2014, 11:35
Default
  #2
Member
 
David
Join Date: Aug 2012
Posts: 48
Rep Power: 14
GM_XIII is on a distinguished road
you need to do the following:

d=Get_Domain(1);
t = Lookup_Thread(d, Zone_ID); /*Here is where you give the id read in BC as zone_id*/
shashankmechguy likes this.
GM_XIII is offline   Reply With Quote

Old   July 15, 2014, 16:04
Default
  #3
New Member
 
shashank mishra
Join Date: Sep 2011
Posts: 12
Rep Power: 15
shashankmechguy is on a distinguished road
Thanks David,

but still I am not able to print anything in console window.
I dont know why. There is no error while compiling or interpreting this udf.
shashankmechguy is offline   Reply With Quote

Old   July 16, 2014, 08:11
Default
  #4
Member
 
David
Join Date: Aug 2012
Posts: 48
Rep Power: 14
GM_XIII is on a distinguished road
Your case is multiphase? Have you tried changing the ZOne_id? Post here the new UDF code
GM_XIII is offline   Reply With Quote

Old   July 16, 2014, 22:30
Default
  #5
New Member
 
shashank mishra
Join Date: Sep 2011
Posts: 12
Rep Power: 15
shashankmechguy is on a distinguished road
Quote:
Originally Posted by GM_XIII View Post
Your case is multiphase? Have you tried changing the ZOne_id? Post here the new UDF code

It started working once I changed the printf to message but now I am getting
received a fatal signal : Segmentation violation.
shashankmechguy is offline   Reply With Quote

Old   July 16, 2014, 22:32
Default
  #6
New Member
 
shashank mishra
Join Date: Sep 2011
Posts: 12
Rep Power: 15
shashankmechguy is on a distinguished road
Here is the UDF Code:

#include"udf.h"
DEFINE_EXECUTE_AT_END(torque_time)
{
Domain *d;
Thread *t;
face_t f;
real NV_VEC(A);
real NV_VEC(force);
real NV_VEC(torque);
real x[ND_ND];
real NV_VEC(radius);
real NV_VEC(torque_final);
real tor;
NV_S(force,= ,0.0);
NV_S(torque_final,= ,0.0);
NV_S(torque,= ,0.0);
d = Get_Domain(1);
t = Lookup_Thread(d, 12);
begin_f_loop(f,t)
{
F_AREA(A,f,t);
F_CENTROID(x,f,t);
NV_S(force,= , F_AREA(A,f,t), * , F_P(f,t));
NV_D(radius,= ,x[0],x[1],x[2]);
NV_CROSS(torque,radius,force);
NV_VV(torque_final,= ,torque_final,+, torque);
tor= NV_MAG(torque_final);
}
end_f_loop(f,t)
Message("Value of torque at the blades is = %f", tor );
}


I am running Fluent on Linux.
shashankmechguy is offline   Reply With Quote

Old   July 17, 2014, 02:10
Default
  #7
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
can your code be compiled at all?
IMO,
Code:
NV_S(force,= , F_AREA(A,f,t), * , F_P(f,t));
should be replaced by
Code:
 F_AREA(A,f,t);
NV_VS(force,= , A, * , F_P(f,t));
blackmask is offline   Reply With Quote

Old   July 17, 2014, 03:12
Default
  #8
New Member
 
shashank mishra
Join Date: Sep 2011
Posts: 12
Rep Power: 15
shashankmechguy is on a distinguished road
Quote:
Originally Posted by blackmask View Post
can your code be compiled at all?
IMO,
Code:
NV_S(force,= , F_AREA(A,f,t), * , F_P(f,t));
should be replaced by
Code:
 F_AREA(A,f,t);
NV_VS(force,= , A, * , F_P(f,t));
Hi BlackMask,

Thanks for the input. I made that correction.
And now I am getting at least print message with value always =0.000.
I thought I am doing something wrong with cross product so I tried printing force value, still 0.000. Then for the sake of checking, I tried printing sum of area values, that is also 0.000.
I dont know what is wrong in the logic of udf?
shashankmechguy is offline   Reply With Quote

Old   July 17, 2014, 20:54
Default
  #9
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Make sure that your thread id is correct. What is the result of
Code:
t = Lookup_Thread(d, 12); 
printf("%d\n", THREAD_ID(t));
blackmask 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
Radiation interface hinca CFX 15 January 26, 2014 18:11
particle tracking sakurabogoda CFX 7 December 5, 2013 00:12
cyclone separator particle tracking prob.. sakurabogoda CFX 33 May 29, 2013 07:36
How tensor parameters to be entered in CFX-pre? hadi.iraji CFX 1 May 7, 2013 05:03
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 08:00


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