|
[Sponsors] |
January 6, 2016, 12:05 |
UDM just for fluid zone
|
#1 |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
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 |
|
January 6, 2016, 14:45 |
|
#2 |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
i have tried to use the following macro FLUID_THREAD_P(t) but it is giving an error message, saying structure reference not implemented.
|
|
January 6, 2016, 16:41 |
|
#3 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
You can distinguish between cell zones using their threads. For example:
Code:
Thread *tfluid = Lookup_Thread(domain,FLUID_ID); thread_loop_c(t,domain) { if (t==tfluid) Message("This cell belongs to the fluid cell zone!"); } |
|
January 8, 2016, 16:43 |
|
#4 | |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
Quote:
|
||
January 8, 2016, 18:26 |
|
#5 | |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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 |
||
January 10, 2016, 03:45 |
|
#6 | |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
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. |
||
January 10, 2016, 21:42 |
|
#7 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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). |
|
January 11, 2016, 07:34 |
|
#8 | |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
Quote:
Thank you for your help and time. I used this structure: Code:
#include "udf.h" DEFINE_ON_DEMAND(myudftest) { Domain *d; Thread *tf; cell_t c; real parameter; . . . int ID=5; d=Get_Domain(1); tf=Lookup_Thread(d,ID); . . . thread_loop_c(tf,d) { begin_c_loop(c,tf) { . VEL=sqrt(pow(C_U(c,tf),2.0)+pow(C_V(c,tf),2.0)+pow(C_W(c,tf),2.0)); . . . C_UDMI(c,tf,0)=name; } end_c_loop(c,tf) } } define>user-defined>execute on demand It doesn't work! Is there any way to solve this problem? |
||
January 11, 2016, 09:15 |
|
#9 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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; |
||
January 11, 2016, 09:28 |
|
#10 | |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
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; |
||
January 11, 2016, 09:42 |
|
#11 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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.
|
|
January 11, 2016, 10:30 |
|
#12 | |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
Quote:
It's a simple UDF to calculating operative temperature in the domain. Code:
#include "udf.h" DEFINE_ON_DEMAND(Opertemp) { Domain *d; Thread *t; cell_t c; real TA; /* Air temperature (°C)*/ real TR; /* Mean radiant temperature (°C)*/ real VEL; /* Relative air velocity (m/s)*/ real OT; /*operative temperature*/ d=Get_Domain(1); /* Get the domain using ANSYS FLUENT utility */ thread_loop_c(t,d) /* Loop over all cell threads in the domain */ { begin_c_loop(c,t) /* Loop over all cells */ { TA=C_T(c,t)-273.15; TR=26.563; /*Mean radiant temperature*/ VEL=sqrt(pow(C_U(c,t),2.0)+pow(C_V(c,t),2.0)+pow(C_W(c,t),2.0)); OT=(TR+(TA*sqrt(10*VEL)))/(1+sqrt(10*VEL)); C_UDMI(c,t,0)=OT; } end_c_loop(c,t) } } Code:
#include "udf.h" DEFINE_ON_DEMAND(Opertemp) { Domain *d; Thread *t; cell_t c; real TA; /* Air temperature (°C)*/ real TR; /* Mean radiant temperature (°C)*/ real VEL; /* Relative air velocity (m/s)*/ real OT; /*operative temperature*/ d=Get_Domain(1); /* Get the domain using ANSYS FLUENT utility */ thread_loop_c(t,d) /* Loop over all cell threads in the domain */ { begin_c_loop(c,t) /* Loop over all cells */ { TA=C_T(c,t)-273.15; TR=26.563; /*Mean radiant temperature*/ VEL=0.15; OT=(TR+(TA*sqrt(10*VEL)))/(1+sqrt(10*VEL)); C_UDMI(c,t,0)=OT; } end_c_loop(c,t) } } ------------------------------------------------- Thanks. |
||
January 11, 2016, 19:15 |
|
#13 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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). |
|
January 12, 2016, 04:09 |
|
#14 | |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
Quote:
Thank you very very much. I wrote my code like this: Code:
#include "udf.h" DEFINE_ON_DEMAND(Opertemp) { Domain *d; Thread *t; cell_t c; int ID=29; Thread *tf=Lookup_Thread(d,ID); real TA; /* Air temperature (°C)*/ real TR; /* Mean radiant temperature (°C)*/ real VEL; /* Relative air velocity (m/s)*/ real OT; /*operative temperature*/ d=Get_Domain(1); /* Get the domain using ANSYS FLUENT utility */ thread_loop_c(t,d) /* Loop over all cell threads in the domain */ { if(t==tf) { begin_c_loop(c,t) /* Loop over all cells */ { TA=C_T(c,t)-273.15; TR=26.563; /*Mean radiant temperature*/ VEL=sqrt(pow(C_U(c,t),2.0)+pow(C_V(c,t),2.0)+pow(C_W(c,t),2.0)); OT=(TR+(TA*sqrt(10*VEL)))/(1+sqrt(10*VEL)); C_UDMI(c,t,0)=OT; } end_c_loop(c,t) } else { begin_c_loop(c,t) /* Loop over all cells */ { OT=0; C_UDMI(c,t,0)=OT; } end_c_loop(c,t) } } } 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. |
||
January 12, 2016, 18:29 |
|
#15 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
If the UDM-0 is zero everywhere then you may have the wrong cell zone ID of the fluid thread.
Specifically: left click the fluid cell zone under "Zone" and read the integer underneath "ID" on the lower right of the panel. The "Type" should also be set to "fluid". |
|
January 13, 2016, 03:45 |
|
#16 |
Member
Nima
Join Date: May 2014
Location: Ireland
Posts: 51
Rep Power: 12 |
Thanks a lot.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Commercial meshers] Mesh conversion problem (fluent3DMeshToFoam) | Aadhavan | OpenFOAM Meshing & Mesh Conversion | 2 | March 8, 2018 02:47 |
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) | cfdonline2mohsen | OpenFOAM | 3 | October 21, 2013 10:28 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 11:52 |
Problem in running ICEM grid in Openfoam | Tarak | OpenFOAM | 6 | September 9, 2011 18:51 |
Problem in IMPORT of ICEM input file in FLUENT | csvirume | FLUENT | 2 | September 9, 2009 02:08 |