after adding if...else,the macro message cannot work
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! |
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 |
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.) |
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. |
u r right, i should tell the code clearly
Quote:
|
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 |
All times are GMT -4. The time now is 14:20. |