UDM just for fluid zone
Hi
My domain includes both solid zone and fluid zone, but when I use -------- thread_loop_c(t,domain) { begin_c_loop(c,t) {. ---------- The UDF loops over all cells. How can I set it just for the fluid zone? Thanks |
i have tried to use the following macro FLUID_THREAD_P(t) but it is giving an error message, saying structure reference not implemented.
|
You can distinguish between cell zones using their threads. For example:
Code:
Thread *tfluid = Lookup_Thread(domain,FLUID_ID); |
Quote:
|
Quote:
For good coding practice, you should define the cell zone ID at the beginning of the file (which replaces FLUID_ID with the integer, for example 10, everywhere in the code): Code:
#define FLUID_ID 10 |
Quote:
The summary of the structure of my UDF is as follows: #include "udf.h" DEFINE_ON_DEMAND(myudftest) { Domain *d; Thread *t; cell_t c; real parameters; /*defining parameters*/ real VEL; /* Relative air velocity (m/s)*/ d=Get_Domain(1); . . . thread_loop_c(t,d) { begin_c_loop(c,t) { . . VEL=sqrt(pow(C_U(c,t),2.0)+pow(C_V(c,t),2.0)+pow(C _W(c,t),2.0)); . . C_UDMI(c,t,0)=...; } end_c_loop(c,t) } } ------------------------------ As you see, I need the velocity magnitude, but when I have solid domain because of lack of velocity in the solid domain, my UDF doesn't work. If it's possible for you, would you please tell me what you mean? You mean this? #include "udf.h" DEFINE_ON_DEMAND(myudftest) { Domain *d; Thread *t; cell_t c; real parameters; /*defining parameters*/ real VEL; /* Relative air velocity (m/s)*/ . . . Thread *tfluid=lookup_Thread(d,FLUID_ID for example 10) thread_loop_c(t,d) { if (t==tfluid) begin_c_loop(c,t) { . . VEL=sqrt(pow(C_U(c,t),2.0)+pow(C_V(c,t),2.0)+pow(C _W(c,t),2.0)); . . C_UDMI(c,t,0)=...; } end_c_loop(c,t) } } --------------------- Thank you very much. |
Yes, only operate the velocity evaluation on the fluid cell zone thread.
A few comments: initialise your VEL variable with zero such that the solid will default to zero (and avoid errors when accessing VEL for solid cells); declare tfluid with the other declarations; and include curly brackets for the code block within the if statement (for clarity and in case the compiler misinterprets what you want). |
Quote:
Thank you for your help and time. I used this structure: Code:
#include "udf.h" define>user-defined>execute on demand It doesn't work! Is there any way to solve this problem? |
Quote:
Do you get warnings? Do you get wrong results? Do you get no results? I am surprised if this code interpreted without warnings, because of the line Code:
C_UDMI(c,tf,0)=name; |
Quote:
I mean after I execute the UDM on demand, fluent give an error Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () ---------------------------------------------------- 'name' is an example here. It isn't in my UDF. For example first I define a function like F then I wrote: Code:
C_UDMI(c,tf,0)=F; |
If you want us to find the problem in your UDF, you should show us the code of your UDF. Don't show us a version where you changed things and left out things.
|
Quote:
It's a simple UDF to calculating operative temperature in the domain. Code:
#include "udf.h" Code:
#include "udf.h" ------------------------------------------------- Thanks. |
The looping macro thread_loop_c(t,d) will always loop through all cell threads in a given domain (d). The cell thread pointer (t) is an output used within the code block; I suspect Fluent is ignoring your evaluation of "tf=Lookup_Thread(d,ID);" within this code block.
Have a careful read of my example above as your code was mostly correct before (using the conditional statement to check if the current thread in the loop was the fluid thread). |
Quote:
Thank you very very much. I wrote my code like this: Code:
#include "udf.h" I think it's because of wrong Fluid thread ID. I find the fluid threads from boundary condition. Would you please tell me how I can find the true ID? Thanks. |
If the UDM-0 is zero everywhere then you may have the wrong cell zone ID of the fluid thread.
Quote:
|
Quote:
|
All times are GMT -4. The time now is 11:34. |