CFD Online URL
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

Wrote my first udf but nothing happens

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

Reply
 
LinkBack Thread Tools Display Modes
Old   July 13, 2012, 00:07
Question Wrote my first udf but nothing happens
  #1
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,268
Blog Entries: 23
Rep Power: 19
diamondx will become famous soon enough
Send a message via MSN to diamondx
Hello everyone,
I started learning UDF today, i created my first code. It's an easy source term that i apply on a SPECIFIC domain of fluid. the source is a x-momentum, here is my code:
Quote:
#include "udf.h"

DEFINE_SOURCE(test,c,t,dS,eqn)
{
real xc[ND_ND];
real source;

C_CENTROID(xc,c,t);

if ((xc[0] == -0.135608)&&(xc[1] == 0.179728))
{source = 1000;
dS[eqn] = 0;}
else {source = 0;dS[eqn] = 0;}
C_UDMI(c,t,0)=source;
return source;
}
The UDF is interpreted/compiled without any error. this udf applies a source in the location(x,y). I should see a change in the velocity vector, right ? nothing happens, why ? I'm trying to simulate plsma actuators and in all the article that i read, this same udf code is used...
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 05:44
Default
  #2
Senior Member
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,041
Rep Power: 17
flotus1 will become famous soon enough
Because of numerical inaccuracies, you always have to provide a small threshold for statements like "if (position != ..."
The position of the cells in your domain will never be -0.135608, but rather -0.135608000001

Make it "if(position < x_0+threshold && position > x_0-threshold)" instead

Last edited by flotus1; July 13, 2012 at 06:37.
flotus1 is offline   Reply With Quote

Old   July 13, 2012, 10:12
Default
  #3
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,268
Blog Entries: 23
Rep Power: 19
diamondx will become famous soon enough
Send a message via MSN to diamondx
thanks alexander for you reply. went back and change the code into this one:
Quote:
#include "udf.h"


DEFINE_SOURCE(test,c,t,dS,eqn)
{
real xc[ND_ND];
real source;

C_CENTROID(xc,c,t);

if ((xc[0] <= -0.1557860000)&&(xc[0] >= -0.196412000000)&&(xc[1] <= 0.189188000000)&&(xc[1] >= 0.168735000000))

{source = 1000000;
dS[eqn] = 0;}
else {source = 0;dS[eqn] = 0;}
return source;
}
Still the problem persist... if you are wondering where did i get those coordinates, i went to draw the mesh, and i used mouse probe to to determine the location where i want the source to be applied. i copy paste it in the code...
Thanks again for your help
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 10:44
Default
  #4
Senior Member
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,041
Rep Power: 17
flotus1 will become famous soon enough
Are you 100% sure that there are cell centroids within the ranges you specified?
Remember that sources are applied on a "per-cell" basis.

For debugging purposes, try applying the source to a bigger area with less restrictions, say

if (xc[0] < 0) source= 1000;
return source;

If this still has no effect... well we will have to think again.
flotus1 is offline   Reply With Quote

Old   July 13, 2012, 11:48
Default
  #5
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,268
Blog Entries: 23
Rep Power: 19
diamondx will become famous soon enough
Send a message via MSN to diamondx
thanks a lot for your support, recently compilation works but i soon as i hit on run calculation it shows me this error i dont know why:

Quote:
999999 (..\src\mpsystem.c@1149): mpt_read: failed: errno = 10054

999999: mpt_read: error: read failed trying to read 8 bytes: No such file or directory
MPI Application rank 0 exited before MPI_Finalize() with status -1073741819
The Parallel FLUENT process could not be started.
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 11:53
Default
  #6
Senior Member
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,041
Rep Power: 17
flotus1 will become famous soon enough
Are you running in parallel?

Normal UDFs do not work in parallel, but as far as I understood, they can be changed accordingly. Refer to the UDF manual.

For now, try running on 1 core only.
flotus1 is offline   Reply With Quote

Old   July 13, 2012, 12:04
Default
  #7
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,268
Blog Entries: 23
Rep Power: 19
diamondx will become famous soon enough
Send a message via MSN to diamondx
changed into serial, still error problem.
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

Yeah this is definitely the coordinates.
Quote:
#include "udf.h"
DEFINE_SOURCE(test,c,t,dS,eqn)
{
real xc[ND_ND];
real source,y;

C_CENTROID(xc,c,t);
y=xc[1];

if (y <= 0.1864891)

{source = 1000000;
dS[eqn] = 0;}
else {source = 0;dS[eqn] = 0;}
C_UDMI(c,t,0)=source;
return source;
if you were me, how will you get the coordinates, will you use the mouse probe ?
the procedure: i load the case, define then interpret the udf. i go to cell condition turn on source term , aplly x-momentum click on ok. then initialize and finally run calculation...
i appreciate your help...
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 14:05
Default
  #8
Senior Member
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 1,041
Rep Power: 17
flotus1 will become famous soon enough
Here is a source UDF I currently use (stripped it from everything but the coordinate thing):
Copy it and try to run it.

DEFINE_SOURCE(sourceterm,c,t,dS,eqn)
{
double x[ND_ND];
double x0,y0;
double y_m=0.0;
double I_0=1000;

C_CENTROID(x,c,t);
if(x[1] <= y_m)
{
source = I_0;
}
}
return source;

When you say "apply x momentum" you mean you add 1 momentum source like in my attached picture?
The rest of your procedure seems ok.
Attached Images
File Type: png Unbenannt.png (21.9 KB, 15 views)
flotus1 is offline   Reply With Quote

Old   July 13, 2012, 16:15
Default
  #9
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,268
Blog Entries: 23
Rep Power: 19
diamondx will become famous soon enough
Send a message via MSN to diamondx
finally it worked. My udf was good. it worked after i changed the scenario. i was applying the source in a convergent divergent nozzle. velocity was near transonic, may be that's why nothing was happening. after i changed the geometry into a duct where air was flowing with 1 m/s. i could see the source in the velocity contour plot. thanks a lot for you support alex, you deserve a reputation up...
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   July 15, 2012, 10:32
Default hi
  #10
New Member
 
G I Joe
Join Date: Mar 2012
Posts: 1
Rep Power: 0
kaushik_rai is on a distinguished road
how can we differentiate between a 32 & 64 bit udf in fluent???
kaushik_rai is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 07:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
Dynamic Mesh UDF Qureshi FLUENT 1 December 2, 2009 01:27
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


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