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

If scheme doesn't work

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2020, 14:37
Default If scheme doesn't work
  #1
p.1
New Member
 
Italia
Join Date: Oct 2020
Posts: 19
Rep Power: 5
p.1 is on a distinguished road
Hi, I have write this udf but the if statement seems not work. Someone can help me?

#include "udf.h"

DEFINE_ADJUST(dudy, domain)
{
Thread *t;
cell_t c;
real xc[ND_ND];
real x;
real y;

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
C_CENTROID(xc, c, t);
x = xc[0];
y = xc[1];
if(y < 0 && x<6)
{
C_UDMI(c, t, 0) = -(C_V(c, t)*C_U_G(c, t)[1])
}

else if(y<0 && x>6)
{

C_UDMI(c, t, 0) = -(C_V(c, t)*-C_U_G(c, t)[1])
}

else if(y>0 && x<6)
{

C_UDMI(c, t, 0) = -(-C_V(c, t)*C_U_G(c, t)[1])
}

else if(y>0 && x>6)
{

C_UDMI(c, t, 0) = -(-C_V(c, t)*-C_U_G(c, t)[1])
}

}
end_c_loop(c, t)
}
}
p.1 is offline   Reply With Quote

Old   November 30, 2020, 21:10
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
how could you know that it doesnt work?
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 1, 2020, 02:28
Default
  #3
p.1
New Member
 
Italia
Join Date: Oct 2020
Posts: 19
Rep Power: 5
p.1 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
how could you know that it doesnt work?
Beacuse if I change the x value (for example x<10 or x>10) the results are the same.
p.1 is offline   Reply With Quote

Old   December 1, 2020, 02:41
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Try this, to see if it works:

Code:
DEFINE_ADJUST(dudy, domain)
{
Thread *t;
cell_t c;
real xc[ND_ND];
real x;
real y;

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
C_CENTROID(xc, c, t);
x = xc[0];
y = xc[1];
if(y < 0 && x<6)
{
C_UDMI(c, t, 0) = 1;
}

else if(y<0 && x>6)
{

C_UDMI(c, t, 0) = 2;
}

else if(y>0 && x<6)
{

C_UDMI(c, t, 0) = 3;
}

else if(y>0 && x>6)
{
C_UDMI(c, t, 0) = 4;
}

}
end_c_loop(c, t)
}
}
By the way: are you sure you did not get any compile error? Because I think you forgot some semicolons, and the compiler should complain about that.
pakk is offline   Reply With Quote

Old   December 1, 2020, 02:52
Default
  #5
p.1
New Member
 
Italia
Join Date: Oct 2020
Posts: 19
Rep Power: 5
p.1 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Try this, to see if it works:

Code:
DEFINE_ADJUST(dudy, domain)
{
Thread *t;
cell_t c;
real xc[ND_ND];
real x;
real y;

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
C_CENTROID(xc, c, t);
x = xc[0];
y = xc[1];
if(y < 0 && x<6)
{
C_UDMI(c, t, 0) = 1;
}

else if(y<0 && x>6)
{

C_UDMI(c, t, 0) = 2;
}

else if(y>0 && x<6)
{

C_UDMI(c, t, 0) = 3;
}

else if(y>0 && x>6)
{
C_UDMI(c, t, 0) = 4;
}

}
end_c_loop(c, t)
}
}
By the way: are you sure you did not get any compile error? Because I think you forgot some semicolons, and the compiler should complain about that.
Thank you, no when I compile the UDF on Fluent there aren't errors.
Where I forgot some semicolons?
p.1 is offline   Reply With Quote

Old   December 1, 2020, 12:38
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
You forgot semicolons where i changed the code, obviously.

You also forgot to show the test result. How does UDM 0 look like if you plot with this UDF?
pakk is offline   Reply With Quote

Old   December 1, 2020, 12:40
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
And does this give errors?
Code:
DEFINE_ADJUST(dudy, domain)
{
Thisshouldgiveanerror() ;
}
pakk is offline   Reply With Quote

Old   December 1, 2020, 12:57
Default
  #8
p.1
New Member
 
Italia
Join Date: Oct 2020
Posts: 19
Rep Power: 5
p.1 is on a distinguished road
Quote:
Originally Posted by pakk View Post
You forgot semicolons where i changed the code, obviously.

You also forgot to show the test result. How does UDM 0 look like if you plot with this UDF?
It works. Thank you.
p.1 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
Implementation of QUICK scheme Romuald Skoda Main CFD Forum 11 November 6, 2017 21:20
Problem using Central differencing scheme with LES WALE selvam2487 CFX 8 July 23, 2017 15:33
forward diff scheme vs backward diff scheme zdunol Main CFD Forum 5 November 30, 2015 13:42
RP_Set_Integer does not work in parallel 86lolo Fluent UDF and Scheme Programming 2 July 3, 2014 11:37
Why FVM for high-Re flows? Zhong Lei Main CFD Forum 23 May 14, 1999 13:22


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