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

Help With If statement

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 10, 2014, 07:37
Default Help With If statement
  #1
New Member
 
Join Date: Nov 2013
Posts: 6
Rep Power: 12
Franchijio is on a distinguished road
Hi, I am having problem with an if else statement for a UDF. It seems not to work. Please can anyone see what am not doing right.

DEFINE_ADJUST(experiment,domain)
{

Thread *t;
cell_t c;
real Z,l_x,A,x_p;
thread_loop_c (t,domain)
{
Thread **pt = THREAD_SUB_THREADS(t);
Thread *tp = pt[0];
/* gas phase */
Thread *ts = pt[1]; /* solid phase */
if (NULL != THREAD_STORAGE(t,SV_UDS_I(ADS))&& NULL != T_STORAGE_R_NV(t,SV_UDSI_M1(ADS)))
{
begin_c_loop (c,t)

{

if (C_VOF(c,ts) >= 0.00001)
{
Z = 4675.47;
x_p = 526890/C_UDSI(c,t,P);
l_x = log(x_p);
A = 8.31429*tem*l_x;
C_UDSI(c,t,ADS)=0.301555862*exp(-(A*A*A)/(Z*Z*Z));
}

else
{
Z = 4675.47;
x_p = 526890/C_UDSI(c,t,P);
l_x = log(x_p);
A = 8.31429*tem*l_x;

C_UDSI(c,t,ADS)=0;
}
}
end_c_loop(c,t)
}

}

}

C_UDSI(c,t,ADS)=0 is meant to be case when volume fraction of solid is less than 0.00001 but this is not happening for me in the simulation.

Franchijio is offline   Reply With Quote

Old   June 11, 2014, 10:29
Default
  #2
New Member
 
Join Date: Mar 2014
Posts: 11
Rep Power: 12
Crow is on a distinguished road
I had some similar issues and just use put another if with the inverse statement. In your case it would be

if (C_VOF(c,ts) < 0.00001)

It is anoying because it is slower but it works.
Crow is offline   Reply With Quote

Old   June 11, 2014, 10:52
Default
  #3
New Member
 
Join Date: Nov 2013
Posts: 6
Rep Power: 12
Franchijio is on a distinguished road
Thanks Crow. I don't seem to understand what you mean. Are you saying I should use another if with inverse of the logical expression instead of else logical expression in which case it will become

if (C_VOF(c,ts) >= 0.00001)
{
Z = 4675.47;
x_p = 526890/C_UDSI(c,t,P);
l_x = log(x_p);
A = 8.31429*tem*l_x;
C_UDSI(c,t,ADS)=0.301555862*exp(-(A*A*A)/(Z*Z*Z));
}

if
(C_VOF(c,ts) < 0.00001)
{
Z = 4675.47;
x_p = 526890/C_UDSI(c,t,P);
l_x = log(x_p);
A = 8.31429*tem*l_x;

C_UDSI(c,t,ADS)=0;
}
}
end_c_loop(c,t)
}

}

}

Thanks
Franchijio is offline   Reply With Quote

Old   June 11, 2014, 16:49
Default
  #4
New Member
 
Join Date: Mar 2014
Posts: 11
Rep Power: 12
Crow is on a distinguished road
Yes, this is what I mean. So if the problem is with the if else statement it should solve it. If I'm not mistaken, it should make your code looks like this:

DEFINE_ADJUST(experiment,domain)
{

Thread *t;
cell_t c;
real Z,l_x,A,x_p;

thread_loop_c (t,domain)
{
Thread **pt = THREAD_SUB_THREADS(t);
Thread *tp = pt[0]; /* gas phase */
Thread *ts = pt[1]; /* solid phase */

if (NULL != THREAD_STORAGE(t,SV_UDS_I(ADS))&& NULL != T_STORAGE_R_NV(t,SV_UDSI_M1(ADS)))
{
begin_c_loop (c,t)
{
if (C_VOF(c,ts) >= 0.00001)
{
Z = 4675.47;
x_p = 526890/C_UDSI(c,t,P);
l_x = log(x_p);
A = 8.31429*tem*l_x;
C_UDSI(c,t,ADS)=0.301555862*exp(-(A*A*A)/(Z*Z*Z));
}

if (C_VOF(c,ts) < 0.00001)
{
Z = 4675.47;
x_p = 526890/C_UDSI(c,t,P);
l_x = log(x_p);
A = 8.31429*tem*l_x;

C_UDSI(c,t,ADS)=0;
}
}
end_c_loop(c,t)
}

}

}
Crow is offline   Reply With Quote

Old   June 13, 2014, 06:47
Default
  #5
New Member
 
Join Date: Nov 2013
Posts: 6
Rep Power: 12
Franchijio is on a distinguished road
Thanks Crow. I have done exactly that and yet it is not working. Was your case similar to mine? If yes did you do any other thing different and how long did your simulation run for?

Thanks
Franchijio is offline   Reply With Quote

Old   June 13, 2014, 10:43
Default
  #6
New Member
 
Join Date: Mar 2014
Posts: 11
Rep Power: 12
Crow is on a distinguished road
More information is needed in order to help you.

1) What are you trying to accomplish exactly with your UDF?

2) What is the error message/problem you are encounting to know that your UDF is not working?

Edit: 3) What is the general configuration of your simulation? What are you simulating?
Crow is offline   Reply With Quote

Reply

Tags
if else statement, udf, uds, volume fraction

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with if statement CHARLES OpenFOAM Programming & Development 17 August 22, 2021 04:14
Restricting area in if statement Blackhawks84 Fluent UDF and Scheme Programming 4 July 22, 2012 17:50
If statement question mariam.sara CFX 3 May 24, 2012 03:33
Weak statement for Galerkin Method rugabug Main CFD Forum 0 March 26, 2010 20:19
Problem Statement balkrishna Main CFD Forum 0 October 7, 2009 00:55


All times are GMT -4. The time now is 22:08.