|
[Sponsors] |
September 20, 2015, 09:16 |
Thread has not been initialized
|
#1 |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
I would really appreciate that someone would be able to help me facing the following problem.
I am creating a (compiled) code in order to calculate the Mass flow in different sections. A part of that code is located here. I compile it, however Fluent tells me that 't' has not been initialized. Nevertheless I don't understand why when I have written Code:
Thread *t; Attached the code can be found Code:
#include "udf.h" //#include <math.h> #define Num_div 5 DEFINE_ADJUST(GetMassFlow,d) { Thread *t; face_t f; int n=0; real Area; real SUMflow=0; real x[ND_ND]; real N[ND_ND]; ///////////////////////////////////////////////////////////////////////////// begin_f_loop(f,t)//thread_loop_c(t, d) // Variable that stores the SUM of Mass Flow is initialized to zero { Message("1 "); F_CENTROID(x,f,t); Message("2 "); F_AREA(N,f,t); Message("3 "); Area= sqrt(N[0]*N[0]+N[1]*N[1]+N[2]*N[2]); Message("4 "); N[2]=N[2]/(Area); SUMflow+=F_FLUX(f,t)*N[2]; } end_f_loop(f,t) Message ("%f\t",SUMflow); Message ("\n"); } Thank you very much
__________________
Having fun with CFD =) |
|
September 21, 2015, 06:08 |
|
#2 |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
you can add this in your code:
Code:
int Zone_ID = (ID OF THE THREAD YOU WANT); Thread *t=Lookup_Thread(d,Zone_ID); |
|
September 21, 2015, 21:30 |
|
#3 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
With your advise that I solved part of the problem, because now I am facing a segmentation error when I am getting the information of density and velocity. Code:
Density=F_R(f,thread_fluid); VelocityZ=F_W(f,thread_fluid); However, I haven't managed to fix it Code:
#include "udf.h" #define Lz 0.006 //[m^2] DEFINE_ADJUST(cells_faces,domain) { //Thread *t; /* this will hold the position vector */ face_t f; int i=0; int j=0; real x[ND_ND]; real N[ND_ND]; real SumMassFlow=0; real SumArea=0; real AverageMassFlow=0; real Density=0; real VelocityZ=0; int zone_ID = 20048; Thread *thread_fluid; thread_fluid = Lookup_Thread(domain,zone_ID); //thread_loop_f(thread_fluid, domain) //{ j=j+1; begin_f_loop(f,thread_fluid) { SumArea=0; SumMassFlow=0; F_AREA(N,f,thread_fluid); F_CENTROID(x,f,thread_fluid); i=i+1; Message("Until here works properly =)"); Density=F_R(f,thread_fluid); VelocityZ=F_W(f,thread_fluid); SumMassFlow=Density*N[2]*VelocityZ+SumMassFlow; SumArea=SumArea+N[2]; } end_f_loop(f,thread_fluid) AverageMassFlow=SumMassFlow*Lz/SumArea; Message("\n%d\t%d",i,j); Message("\nSUM_FLOW : %f\n",SumMassFlow); Message("Cont_max: %d, Cont_min: %d", AverageMassFlow); //} } Edu
__________________
Having fun with CFD =) |
||
September 22, 2015, 05:38 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Compile it.
Make sure your computer can compile (explanation is elsewhere on this forum), and from then on use "compile", not "interpret". It is worth the effort. I am not sure if it will solve your current problem, but it might, and otherwise it will help you a lot in the future. |
|
September 22, 2015, 19:47 |
|
#5 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
I have already faced the problems of using interpreted codes, so I am having that error compiling the code. I am using the compiler that Fluent recommends, Visual Studio. I am using the 2012 version of this programme I am continue trying to solve that problem... Thank you very much for your comment
__________________
Having fun with CFD =) |
||
September 24, 2015, 07:51 |
|
#6 |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Does someone know why I am having that error?
I have been searching on the Internet but without success... I can't understand why when I initialize the density macro does not work, but it works perfectly with the previous functions just before Thank you very much, I would really appreciate any kind of help
__________________
Having fun with CFD =) |
|
September 24, 2015, 08:05 |
|
#7 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
|
||
September 24, 2015, 10:24 |
|
#8 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
I think that there is not mistake on the looping because according to Fluent http://jullio.pe.kr/fluent6.1/help/html/udf/node114.htm You can use begin_f_loop and end_f_loop when you want to loop over all faces f in a given face thread f_thread. I am able to run that code without the following lines: Code:
Density=F_R(f,f_thread); VelocityZ=F_W(f,f_thread); Whereas you comment opened my eyes, that may be the problem would be on the definition of the thread. I have two different matterials on my simulation, one fluid and one solid.+ I am defining the thread in the following way: Code:
int zone_ID = 20048; /* Being zone 20048 the zone corresponding to the fluid, it is a volumen/* Thread *f_thread; f_thread = Lookup_Thread(domain,zone_ID); When I change the Zone ID from a volumen to a surface, like it is the inlet or the outlet surfaces works well. So that, I want to pop up the question if the function Lookup_Thread(domain,zone_ID), work properly with volumen. And about the second solution that you proposed, I didn't really understand you. You mean to create another code to get the value of the variables and store e.g in a '.txt' file and access to that file just after it? But for that, wouldn't I need the ID face? Because I think that the problem to get the ID of the face would be the same I am really really grateful for you trying to help me Bruno, seriously Thank you very much!!
__________________
Having fun with CFD =) |
||
September 28, 2015, 15:01 |
|
#9 |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Doesn't someone know why I am facing that error?
Becuase I am trying more and more solutions but I am not able to find the problem... Thank you to one that will just pop up an idea why it is not working. Thank you beforehand
__________________
Having fun with CFD =) |
|
September 29, 2015, 04:32 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You are trying to go through all internal faces of a volume to calculate something... In a volume, Fluent typically uses the cell values, not the face values, so you cannot access them directly.
And it doesn't make much sense what you are doing... If you want to get the massflow, you should calculate this over the outside boundaries of the volume, not the volume itself! |
|
September 29, 2015, 09:54 |
|
#11 | ||
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
Firstly, I want to explain the puropose of the code, I have't done it yet and I want to apologize for it. We are using the DPM model in order to modelize evaporization. In order to validate the results, the continuty of mass flow (droplets + gas) should be costant throughout the geometry. Taking that into account, a code has successfully been created able to calculate the mass flow of the droplets in a defined region. Now, A new code focused on calculating the mass flow of gas in different sections want to be develope. The sum of both mass flow for different sections should be constant because of the continuity equation. As u pakk said, it is true that Fluent can easily calculate the mass flow on the boundaries. Nevertheless, the mass flow want to be calculate in different sections on the middle of the volume, (sections according to the ones defined for calculating the mass flow with droplets) For calculating it, I thought that a good aproximation it would be to define a possition in the axis Z (Direction of the flow), giving it a little increment, bigger than a cell (what has not been programmed yet in the code that is uploaded), and ponderate it by the number Area, which it is is known. This is done by the following coefficient. Code:
Lz/SumArea Onces, an overview of the simulation has been seen. I am really interesing in something that you said: Quote:
'Were someone find this post interesting in the future, the information of looping through the faces of a cell is here http://www.cfd-online.com/Forums/flu...-cell-udf.html So, if I am understand you properly, the loop 'begin_f_loop(f,thread_fluid)', goes to the cells of the thread_fluid and after it goes to the faces of the cells itself, am I right? I really appreciate your answer, it has been really helpful and I would love if you can answer to this message anytime that you can. Thank you very much pakk, Edu
__________________
Having fun with CFD =) |
|||
September 30, 2015, 05:57 |
|
#12 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I can not follow everything what you say, but I get the feeling that you want to know mass flows internally. So, a simplified drawing:
Code:
+---------------------+---------------------- -> volume A | volume B -> +---------------------+---------------------- You know that droplets evaporate in volume A and B, and you know that (for example) 1 kg/s gas flow goes into volume A, and that 1.5 kg/s gas flow goes out of volume B, which means that 0.5 kg/s evaporated, but you want to check where it evaporated, to validate your code. And what would help is to know the amount of gas flow that goes from volume A to B. If the boundary between A and B exists in your geometry as an interface, you can immediately calculate the mass flux through that boundary. You don't need a UDF for this. If the boundary between A and B does not yet exist in your geometry, I would say the best way to go forward is to create it. Make a bounded plane at the right location, and calculate the mass flux through that plane. You don't need a UDF for this. So, if I understand you problem correctly, it looks like you can do completely without UDFs, and can be ready in a few minutes. |
|
October 1, 2015, 09:06 |
|
#13 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
What we are trying to do it is a little trickier. Having this volume> +---------------------+---------------------------------------------- -> volume A|volume B|volume C|volume D|volume E|volume F -> +---------------------+---------------------------------------------- A lot of different volumes want to be created. The interface, won't need to be definided (here the purpose of the macro). The mass flow of the droplets vs the direction of the flow should be a graph similirar to this one ----------------------------------------------------------------- . .. ... ..... ....... .......... ............... .......................... .................................................. ... .................................................. ........................................ ------------------------------------------------------------------------- The mass flow of liquid, should be the opposite. So that, as I tell before the sum should be constant. This want to be used as a convergence criteria. So that, it is neccesary that a macro is created to calculate the mass flow of liquid for a lot of different sections in order to asure that convergence has been achieved. For this I need to create a macro and I am struggling with the coding. The problem itself it is perfectly defined. So for that, I would appreciate help with the problem that I am facing to create the macro. Just now I am going to try to loop through all the faces of a determined cell and cross my fingers in order that it works Thank you again, Edu
__________________
Having fun with CFD =) |
||
October 3, 2015, 21:46 |
|
#14 |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Finally, after having been thinking and thinking, I have encloused the problem!!
I have two different materials on the simulation. I have steel (in order to simulate the interchange of heat) and the fluid. Finally after trying a lot of different things, I am looping through all the faces of a zone_ID. But there is a problem with the boundary faces between the fluid and the steel. I can properly get the possition and the area. However, and only sometimes I get problems getting data as the density of the boundary face. This makes sense, because Fluent doesn't know which density should use. Nevertheless, I cannot undersant why it only happen sometimes and other times it give me back the density of the fluid. This problem can be solved with an if=NULL. But I cannot do it that to the thread because it is pointing to the face and it has information, less information but the result wouldn't be NULL. Because, it happens sometimes. I cannot use neither the index of the boundary, because I already tried and it didn't work So, does someone has any idea of how to do it?
__________________
Having fun with CFD =) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Divergence detected in AMG solver: k when udf loaded | google9002 | Fluent UDF and Scheme Programming | 3 | November 8, 2019 00:34 |
udf problem | jane | Fluent UDF and Scheme Programming | 37 | February 20, 2018 05:17 |
Error messages | atg | enGrid | 7 | August 30, 2013 12:16 |
Installing OpenFOAM 1.6-ext on Ubuntu 11.10 | immortality | OpenFOAM Installation | 17 | May 6, 2013 18:43 |
Phase locked average in run time | panara | OpenFOAM | 2 | February 20, 2008 15:37 |