|
[Sponsors] |
after adding if...else,the macro message cannot work |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 10, 2014, 23:38 |
after adding if...else,the macro message cannot work
|
#1 |
New Member
刘双双
Join Date: Nov 2014
Posts: 3
Rep Power: 12 |
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! |
|
November 11, 2014, 01:00 |
|
#2 |
Senior Member
Vaze
Join Date: Jun 2009
Posts: 172
Rep Power: 17 |
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 |
|
November 11, 2014, 05:38 |
|
#3 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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.) |
|
November 11, 2014, 08:13 |
|
#4 |
Member
Join Date: Jul 2013
Posts: 80
Rep Power: 13 |
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. |
|
November 12, 2014, 01:14 |
u r right, i should tell the code clearly
|
#5 | |
New Member
刘双双
Join Date: Nov 2014
Posts: 3
Rep Power: 12 |
Quote:
|
||
August 4, 2016, 11:26 |
|
#6 |
New Member
shubham jain
Join Date: Dec 2013
Posts: 25
Rep Power: 12 |
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 |
|
Tags |
macro message does't work, please give me a hand |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
warning message C4005: 'stdout' macro redefinition | Vitalij | FLUENT | 2 | August 1, 2012 21:12 |
ATTENTION! Reliability problems in CFX 5.7 | Joseph | CFX | 14 | April 20, 2010 16:45 |
Error message in CFX-10 | CFDworker | CFX | 2 | October 12, 2007 08: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 22:31 |