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

after adding if...else,the macro message cannot work

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 10, 2014, 23:38
Question after adding if...else,the macro message cannot work
  #1
New Member
 
刘双双
Join Date: Nov 2014
Posts: 3
Rep Power: 2
shuangshuang_liu is on a distinguished road
programs are as follow:
#include "udf.h"
#include "mem.h"
#include "metric.h"
int kount=0;

DEFINE_INIT(my_init,domain)
{
cell_t c;
Thread *t;
C_UDMI(c,t,0)=0;
}
DEFINE_ADJUST(demo_calc,domain)
{
kount++;
Message("\nkount=%d\n",kount);
}
DEFINE_ADJUST(best_point_temp,domain)
{
cell_t c;
Thread *t;
real xc[ND_ND];
// real temp;
/* loop over all cell threads in the domain*/
thread_loop_c(t,domain)
{
/* loop over all cells*/

begin_c_loop(c,t)
{
if((sqrt(ND_SUM(pow(xc[0]-.07,2.),pow(xc[1]-.07,2.),0.)))<.001)
{
C_UDMI(c,t,0)=C_T(c,t);
temp=C_UDMI(c,t,0);
Message("\ntemp=%1f\n",temp);
}
else
{
return;
}
}
end_c_loop(c,t)


}
}

if i get rid of if...else, i can get the values of temp,but i have no idea what's going on with if...else.
please give me a hand!
shuangshuang_liu is offline   Reply With Quote

Old   November 11, 2014, 01:00
Default
  #2
Senior Member
 
Vaze
Join Date: Jun 2009
Posts: 133
Rep Power: 8
mvee is on a distinguished road
Hi Liu

Please check your if condition. It may be wrong. To check it, put one message inside if and else. If every time else message is printing then modify if condition properly.
Also check the syntex of if condition...
Best wishes
mvee
mvee is offline   Reply With Quote

Old   November 11, 2014, 05:38
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 677
Rep Power: 9
pakk is on a distinguished road
What are we supposed to do here?

You show a code, but don't say what is does. But you say that if you remove the if-else (remove what exactly?), you can get values of temp ("get" in which way?).

What is really your question? Do you want an explanation of what the if-else statement does?

(The strange part in the code seems to be the else-part: once a cell is found that is more than 0.001 m away from your point (0.07,0.07), the loop ends and all other cells are ignored. I don't know if that is wrong, because maybe that is exactly what you want your code to do.)
pakk is offline   Reply With Quote

Old   November 11, 2014, 08:13
Default
  #4
Member
 
Join Date: Jul 2013
Posts: 70
Rep Power: 4
upeksa is on a distinguished road
I think that the problem could be your "return". if the "if" statement is false, the code will real a "return" and will exit you DEFINE_ADJUST function.
Check if your "if" statement is true in somewhere in your case anyway.
upeksa is offline   Reply With Quote

Old   November 12, 2014, 01:14
Smile u r right, i should tell the code clearly
  #5
New Member
 
刘双双
Join Date: Nov 2014
Posts: 3
Rep Power: 2
shuangshuang_liu is on a distinguished road
Quote:
Originally Posted by pakk View Post
What are we supposed to do here?

You show a code, but don't say what is does. But you say that if you remove the if-else (remove what exactly?), you can get values of temp ("get" in which way?).

What is really your question? Do you want an explanation of what the if-else statement does?

(The strange part in the code seems to be the else-part: once a cell is found that is more than 0.001 m away from your point (0.07,0.07), the loop ends and all other cells are ignored. I don't know if that is wrong, because maybe that is exactly what you want your code to do.)
u r right, i should tell the code clearly
shuangshuang_liu is offline   Reply With Quote

Reply

Tags
macro message does't work, please give me a hand

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
warning message C4005: 'stdout' macro redefinition Vitalij FLUENT 2 August 1, 2012 20:12
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 15:45
Error message in CFX-10 CFDworker CFX 2 October 12, 2007 07:23
Adding jpeg picture file in OpenFoam post in add a message window kumar2 OpenFOAM 1 March 22, 2006 23:17
Macro Message: phi Sileno Phoenics 1 May 21, 2004 21:31


All times are GMT -4. The time now is 20:57.