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

Wrote my first udf but nothing happens

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 12, 2012, 23:07
Question Wrote my first udf but nothing happens
  #1
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 28
diamondx will become famous soon enough
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 --> https://goo.gl/KAOIwm
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 04:44
Default
  #2
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,399
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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 05:37.
flotus1 is offline   Reply With Quote

Old   July 13, 2012, 09:12
Default
  #3
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 28
diamondx will become famous soon enough
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 --> https://goo.gl/KAOIwm
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 09:44
Default
  #4
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,399
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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, 10:48
Default
  #5
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 28
diamondx will become famous soon enough
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 --> https://goo.gl/KAOIwm
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 10:53
Default
  #6
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,399
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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, 11:04
Default
  #7
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 28
diamondx will become famous soon enough
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 --> https://goo.gl/KAOIwm
Ali
diamondx is offline   Reply With Quote

Old   July 13, 2012, 13:05
Default
  #8
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,399
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
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, 16 views)
flotus1 is offline   Reply With Quote

Old   July 13, 2012, 15:15
Default
  #9
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 28
diamondx will become famous soon enough
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 --> https://goo.gl/KAOIwm
Ali
diamondx is offline   Reply With Quote

Old   July 15, 2012, 09: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


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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 07:37
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 06:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


All times are GMT -4. The time now is 06:41.