|
[Sponsors] |
September 6, 2015, 10:26 |
UDF-DPM: Structure reference not implemented
|
#1 |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
16-09-2015
Taking into account my experience related with udf and DPM. I strongly recommend to use 'compiled' functions, because structures as loop(p,I->p_init) or get Ilist = Get_dpm_injections() ONLY WORK WITH COMPILED CODES!! --------------------------------------------------------------------------------------------------------------------------------------- Hello to everyone =) I would like to ask you all a problem that I am facing with UDF. It is likely that it is something quite easy. But it is the same time that I am using udf which I am struggling with it. I am trying to implement a code in order to calculate the flow mass ratio of some droplets in the outlet. In order to do that, I want to develope a programme. However, while trying I have created some codes and all have a common same mistake, structure reference not implemented in the line where 'loop(p,I->p_init) ' is implemented.On the Internet, it seems like this loop is the way of looping through all the particles. This is my code: # include "udf.h" # include "dpm.h" // However it is not neccesary, included in udf.h DEFINE_ADJUST(TRY1, domain) { Particle *p; Injection *I; int i=0; real sum=0; loop(p,I->p_init) { i=i+1; sum=sum+P_FLOW_RATE(p); } printf("P_FLOW_RATE(p)/i%s\n", sum/i); } I am not able even to loop through all the particles because the loop is not working.
__________________
Having fun with CFD =) Last edited by edu_aero; September 16, 2015 at 03:31. |
|
September 7, 2015, 11:11 |
|
#2 |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
you are using a different language for the code than the UDF language used by Fluent. You should have a look at the macros in the fluent manual.
|
|
September 7, 2015, 11:42 |
|
#3 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
I have checked the Fluent macro manual, and especially the chapter about DPM. All specific DPM funtions are definided for all the particles, not just for some of them. So that, the manual doesn't describe how to do a loop through all the particles in order to get some data every iteration with a macro as DEFINE_ADJUST. That was the reason that I started looking on the Internet, finding these loops that are not working for me. May be, these functions are not working because I am creating an interpreted macro and in order to use these macros instead of a compiled macro. I do not find the way to do a loop all over the particles
__________________
Having fun with CFD =) |
||
September 7, 2015, 11:53 |
|
#4 |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Hi,
you can have a look at this link. All the loop macros are there. You need to define the cell and thread variables (cell_t c; Thread *t; for example) to loop all over the domain. https://www.sharcnet.ca/Software/Flu...udf/node97.htm To print a message in the screen you should use Message("TEXT YOU WANT %f, TEXT %f\n", VARIABLE, VARIABLE1); each %f shows one variable. \n is for new line. I think this is a good start for you. Good luck. |
|
September 7, 2015, 12:42 |
|
#5 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
But on that website, it is describe all the loops through cell, faces... However, there is nothing said on that website about looping through particles. So I am on the same situation, I do not know who to get the information of all the particles. Thank you very much, I appreciate it
__________________
Having fun with CFD =) |
||
September 7, 2015, 13:07 |
|
#6 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
And if possible, compile it instead of interpreting. I have no trust at all in interpreted codes. Good luck. |
||
September 7, 2015, 15:49 |
|
#7 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
When I struggled doing a loop through all the particles . So that, I thought about doing it on the way that you are telling me now, looping through all the cells instead of particles. However, I will need a function that tell me 'TRUE' or 'FALSE' if a particle is inside a cell and the number of particles per ell, am I right? With that, it will be easy to create a macro to calculate anything related with the particles. Nevertheless, the solution that you are telling me, it seems like the most likely to success. Thank you again for your response, I really really appreciate it!!
__________________
Having fun with CFD =) |
||
September 7, 2015, 18:15 |
|
#8 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
You were correct in using "loop" (from your first post). However, "loop(p,I->p_init)" is only used for initialising unsteady particles; "loop(p,I->p)" is used otherwise. Have a read of this post for an example: http://www.cfd-online.com/Forums/flu...tml#post291187
|
|
September 8, 2015, 04:22 |
|
#9 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
I have to admit that you are right about it and I missunderstood, here it is the difference between both loops from this website: http://www.eureka.im/357.html loop(p, I->p) { } In unsteady DPM calculations, if you want to initialize the transient particles, you will require the following loop loop(p, I->p_init) { } However, by changing in the intial code that I proposed the loop loop(p, I->p_init), for the one that you told me (the corrected one)loop(p, I->p) I am facing the same mistake, 'structure reference not implemented'. So, I want to ask to you. Are this loops definied for interpreted codes? Because, I have not been able to run a code using them yet.
__________________
Having fun with CFD =) |
||
September 8, 2015, 07:40 |
|
#10 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
I recommend compiling all UDFs to avoid potentially creating extra errors (some functions require compiling the UDF instead of interpreting).
However, the injection stream 'I' in your UDF is not initialised. The macro you took this code snippet from must have already set an injection stream (for example with the DEFINE_DPM_INJECTION_INIT macro, 'I' is an argument). First, declare an injection list variable: Code:
Injection *Ilist = Get_dpm_injections(); Code:
loop(I, Ilist) { } |
|
September 8, 2015, 10:04 |
|
#11 | |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Quote:
Thank you again for your fast response 1-. I have read on the Fluent macro tutorial guide that it is neccesary to have installed Visual Studio in order to run compiled code in a Windows computer, am I right? For me, and taking into account my little knowledge about this part of Fluent, it seems that the errors that I am facing is because using interpreted instead of compiled codes. 2-a. At adding the following line in following code "Injection *Ilist = Get_dpm_injections();". The error is the same, structure reference not implemented. Code:
# include "udf.h" # include "dpm.h" DEFINE_ADJUST(TRY1, domain) { Particle *p; Injection *I; Injection *Ilist = Get_dpm_injections(); int i=0; real sum=0; loop(p, I->p) { i=i+1+;//P_DIAM(p); } printf("P_FLOW_RATE(p)/i%s\n", i); } Code:
# include "udf.h" # include "dpm.h" DEFINE_ADJUST(TRY1, domain) { Particle *p; Injection *I; Injection *Ilist = Get_dpm_injections(); Thread *thread; int i=0; real sum=0; thread_loop_c(thread, domain) /*loops over all cell threads in domain*/ { loop(I, Ilist) { i=i+P_DIAM(p); } } printf("P_FLOW_RATE(p)/i%s\n", i); } Thank you very much, I think I will try to compile the code instead of interpreting it, facing the problem that I don't have Visual Studio. After investigating I think that it can be because of that. Has someone been able to do a loop through particles in an interpreted code?
__________________
Having fun with CFD =) |
||
September 8, 2015, 16:34 |
|
#12 | ||
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Quote:
Quote:
I suspect that the function Get_dpm_injections requires compiling the UDF. |
|||
September 9, 2015, 08:58 |
|
#13 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
It might be needed to add
Code:
# include "dpm_mem.h" |
|
September 16, 2015, 03:33 |
|
#14 |
Member
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 11 |
Thank you all for your help, the problem that I was facing it was that it is that for making a loop through every particle, compiled functions need to be used.
Now I can develope the code without struggling with computers programmes, just struggling with theoretical problems hehehe
__________________
Having fun with CFD =) |
|
Tags |
dpm, fluent, mass flow rate, udf, user defined function |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting the height of the stream in the free channel | kevinmccartin | CFX | 12 | October 13, 2022 22:43 |
Second Derivative Zero - Boundary Condition | fu-ki-pa | OpenFOAM | 11 | March 27, 2021 05:28 |
mass flow in is not equal to mass flow out | saii | CFX | 12 | March 19, 2018 06:21 |
Constant velocity of the material | Sas | CFX | 15 | July 13, 2010 09:56 |
Compiling new Solver with wmake | lin123 | OpenFOAM | 3 | April 13, 2010 15:18 |