CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > 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 Search this Thread Display Modes
Old   November 10, 2014, 22:38
Question after adding if...else,the macro message cannot work
  #1
New Member
 
刘双双
Join Date: Nov 2014
Posts: 3
Rep Power: 11
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, 00:00
Default
  #2
Senior Member
 
Vaze
Join Date: Jun 2009
Posts: 172
Rep Power: 16
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, 04:38
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
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, 07:13
Default
  #4
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 12
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, 00:14
Smile u r right, i should tell the code clearly
  #5
New Member
 
刘双双
Join Date: Nov 2014
Posts: 3
Rep Power: 11
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

Old   August 4, 2016, 10:26
Default
  #6
New Member
 
shubham jain
Join Date: Dec 2013
Posts: 25
Rep Power: 12
shubham jain is on a distinguished road
Hello. I also a problem (different though than mentioned in this post earlier). I am struggling with the syntax for if else conditions. I am saving this as .cse format and then running within CFD-POST.

! open (ID, '>', 'write01.txt');
! $n=10;
if ($n==1) {
! print ID "if command executed\n";
}
else {
! print ID "else command executed\n";
}
! close ID;


Although I want to create polylines using a contour, but in order to find the error, I have shorten it out to this and even this doesnot work with following error.

ERROR
CCL parser failed with message:
invalid parameter name "if (10": contains invalid character '('

This is very very annoying as I am stuck due to this minor thing. If someone could assist me, that would be of great help. Thanks a lot
shubham jain is offline   Reply With Quote

Reply

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

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
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 22:17
Macro Message: phi Sileno Phoenics 1 May 21, 2004 21:31


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