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

Ansys Fluent source term udf

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 16, 2023, 13:38
Default Ansys Fluent source term udf
  #1
New Member
 
lilas
Join Date: Feb 2023
Posts: 3
Rep Power: 3
lilas is on a distinguished road
Hello All!!

I am trying to interpret the following udf for a cylindrical heat source

#include <udf.h>

DEFINE_SOURCE(laser,cell,thread,dS,eqn)
{

real current_time=CURRENT_TIME;
real PI=acos(-1);

//parameters
real d=1e-4; // 100 micron
real P=195.0; //Power

//start pos
real xs= 5.0;
real ys=5.0;


real source;
real eta=0.5;

// cell paramters
real x[ND_ND];


C_CENTROID(x,cell,thread);
real x1=x[0];
real y1=x[0];


source= eta*2*P/(PI*d*d) * exp(-2*(pow(x1-xs,2)+pow(y1-ys,2))/pow(d,2));


dS[eqn]=0;
return source;

}

It says

line 26: parse error.
line 27: parse error.
line 30: x1: undeclared variable

The error doesn't occur when I comment the C_CENTROID line. What am I doing wrong? I have previously used C_CENTROID for initialization without any issues
lilas is offline   Reply With Quote

Old   February 17, 2023, 03:38
Default
  #2
New Member
 
Prasant
Join Date: Sep 2020
Location: India
Posts: 13
Rep Power: 5
PKP_India is on a distinguished road
hi,

you can try a cell-thread loop as below to access the centroid coordinates.

real x1;
real y1;
begin_c_loop(cell,thread)
{
C_CENTROID(x,cell,thread);
x1=x[0];
y1=x[1];
}
end_c_loop(cell,thread)

I hope it will help.
PKP_India is offline   Reply With Quote

Old   February 23, 2023, 00:47
Default
  #3
New Member
 
lilas
Join Date: Feb 2023
Posts: 3
Rep Power: 3
lilas is on a distinguished road
Thanks for the reply, I figured out that the error was that one cannot declare a variable after an assignment has been made in these versions of C. Probably the C_CENTROID macros has an implicit assignment operation somewhere
lilas 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
[OpenFOAM.com] swak4foam compiling issues on a cluster saj216 OpenFOAM Installation 5 January 17, 2023 16:05
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 16:18
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 tlcoons OpenFOAM Installation 13 April 20, 2016 17:34
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 11:44


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