UDF-DPM: Structure reference not implemented
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. |
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.
|
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 :( |
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. |
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 :D:D:D |
Quote:
And if possible, compile it instead of interpreting. I have no trust at all in interpreted codes. Good luck. |
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!! :):):):) |
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
|
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. |
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) |
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" Code:
# include "udf.h" 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? |
Quote:
Quote:
Quote:
|
It might be needed to add
Code:
# include "dpm_mem.h" |
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 |
All times are GMT -4. The time now is 14:06. |