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

Problem using flow variables inside a macro

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 27, 2022, 11:53
Default Problem using flow variables inside a macro
  #1
New Member
 
Siddharth
Join Date: Mar 2018
Posts: 4
Rep Power: 8
sidkamat is on a distinguished road
Hello. I am trying to introduce a force in the DPM_BODY_FORCE macro in the DPM model. The force is dependent on the flow velocity so I want to incorporate the flow velocity into the equation. My code is:

DEFINE_DPM_BODY_FORCE(DEP,tp,i)
{
double beta=L/D;
double xi=beta/sqrt((beta*beta-1));
double c1=0.5*log((xi+1)/(xi-1));
double f=xi*((1-xi*xi)*c1*xi+xi);
double Fd=0;
if (TP_POS(tp)[0] >= 0.05)
{
if(i == 1)
{
Fd = -1* (pi * km * epsilon * D * D * L / 6) / (alpha / (alpha - 1) - f) * pow(V / log(R2 / R1), 2) * pow(1 / TP_POS(tp)[1], 3)+pi*mu*D*4* fabs(TP_VEL(tp)[1])*(pow(beta,2)-1)/((2*pow(beta,2)-1)*(log(beta+sqrt(pow(beta,2)-1))/sqrt(pow(beta,2)-1)-beta));
}
else if (i == 0)
{
Fd = -1*pi * mu * D * fabs(C_U(c,t)-TP_VEL(tp)[0]) * 8 * (pow(beta, 2) - 1) / ((2 * pow(beta, 2) - 3) * (log(beta + sqrt(pow(beta, 2) - 1)) / sqrt(pow(beta, 2) - 1) + beta));
}
}
return(Fd/TP_MASS(tp));
}

I am getting the following error during compilation:
error: use of undeclared identifier 'c'
error: use of undeclared identifier 't'


Is this because I am using the flow variables in a different macro that does not have the variables t & c in its declaration. If yes, how do I fix this.

Some help would be appreciated.
sidkamat is offline   Reply With Quote

Old   June 30, 2022, 06:08
Default
  #2
Member
 
Mohammad Shafiee
Join Date: Apr 2021
Posts: 30
Rep Power: 7
Mohammad74 is on a distinguished road
Hi,
You have not defined c and t as variables in your macro, and thats what the error means. If you defined them somewhere else (like in another macro, in this source fille), and want to use their value here, you should define them as global variables in your source file. Which makes them visible to all the macros inside the said source file.
Mohammad74 is offline   Reply With Quote

Old   July 4, 2022, 08:47
Default Cell loop?
  #3
Member
 
thedal's Avatar
 
Thamilmani M
Join Date: Sep 2017
Location: IIT Bombay, Mumbai
Posts: 52
Rep Power: 9
thedal is on a distinguished road
Quote:
Originally Posted by sidkamat View Post
Hello. I am trying to introduce a force in the DPM_BODY_FORCE macro in the DPM model. The force is dependent on the flow velocity so I want to incorporate the flow velocity into the equation. My code is:

DEFINE_DPM_BODY_FORCE(DEP,tp,i)
{
double beta=L/D;
double xi=beta/sqrt((beta*beta-1));
double c1=0.5*log((xi+1)/(xi-1));
double f=xi*((1-xi*xi)*c1*xi+xi);
double Fd=0;
if (TP_POS(tp)[0] >= 0.05)
{
if(i == 1)
{
Fd = -1* (pi * km * epsilon * D * D * L / 6) / (alpha / (alpha - 1) - f) * pow(V / log(R2 / R1), 2) * pow(1 / TP_POS(tp)[1], 3)+pi*mu*D*4* fabs(TP_VEL(tp)[1])*(pow(beta,2)-1)/((2*pow(beta,2)-1)*(log(beta+sqrt(pow(beta,2)-1))/sqrt(pow(beta,2)-1)-beta));
}
else if (i == 0)
{
Fd = -1*pi * mu * D * fabs(C_U(c,t)-TP_VEL(tp)[0]) * 8 * (pow(beta, 2) - 1) / ((2 * pow(beta, 2) - 3) * (log(beta + sqrt(pow(beta, 2) - 1)) / sqrt(pow(beta, 2) - 1) + beta));
}
}
return(Fd/TP_MASS(tp));
}

I am getting the following error during compilation:
error: use of undeclared identifier 'c'
error: use of undeclared identifier 't'


Is this because I am using the flow variables in a different macro that does not have the variables t & c in its declaration. If yes, how do I fix this.

Some help would be appreciated.
Two things:

1. Yes, you either declare c and t as global variable and calculate the flow variable but even if you declare it outside. I am not sure where the value of cell ID and thread pointer values you will get.

2. So, I suppose you use a cell loop to loop through all the cells and calculate the value I guess for which you have to define c and t inside the macro also.
__________________
Always
Thedal
thedal is offline   Reply With Quote

Reply

Tags
dpm bodyforce, fluent - udf, udf compilation


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
Problem with FsiFOAM simulation of beams (2-4 beams) in a steady simple shear flow Aliiiii OpenFOAM Running, Solving & CFD 1 February 27, 2019 13:26
transient, impregnating flow problem fgommer FLUENT 0 February 29, 2012 17:10
Simulation of air flow inside valve - FSI? Help! farianka Main CFD Forum 0 April 17, 2011 17:30
Modelling the Heat flow inside the curing oven Marios Vlad CFX 1 February 6, 2008 08:11
Poiseuille flow problem Rosie FLUENT 1 December 6, 2002 17:52


All times are GMT -4. The time now is 12:29.