CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF-DPM: Structure reference not implemented

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 6, 2015, 09:26
Question UDF-DPM: Structure reference not implemented
  #1
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 10
edu_aero is on a distinguished road
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 02:31.
edu_aero is offline   Reply With Quote

Old   September 7, 2015, 10:11
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
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.
Bruno Machado is offline   Reply With Quote

Old   September 7, 2015, 10:42
Default
  #3
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 10
edu_aero is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
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.
Firstly, I want to really grateful your colaboration because I am really struggling with this problem.

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 =)
edu_aero is offline   Reply With Quote

Old   September 7, 2015, 10:53
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
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.
Bruno Machado is offline   Reply With Quote

Old   September 7, 2015, 11:42
Default
  #5
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 10
edu_aero is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
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.
Thank you very much again
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 =)
edu_aero is offline   Reply With Quote

Old   September 7, 2015, 12:07
Default
  #6
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by edu_aero View Post
Thank you very much again
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
Yes, there is no macro to loop over particles (at least I do not know any). Although I never used particles in my problems, I am sure particles are allocated in cells and threads. So for your particles, lets say p, you probably going to have something like p(c,t) (or p = variable(c,t)) and inside the loop through all cells and threads this information is going to be defined/calculated. I do not know if I make myself clear enough.

And if possible, compile it instead of interpreting. I have no trust at all in interpreted codes.

Good luck.
Bruno Machado is offline   Reply With Quote

Old   September 7, 2015, 14:49
Default
  #7
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 10
edu_aero is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
Yes, there is no macro to loop over particles (at least I do not know any). Although I never used particles in my problems, I am sure particles are allocated in cells and threads. So for your particles, lets say p, you probably going to have something like p(c,t) (or p = variable(c,t)) and inside the loop through all cells and threads this information is going to be defined/calculated. I do not know if I make myself clear enough.

And if possible, compile it instead of interpreting. I have no trust at all in interpreted codes.

Good luck.
Thank you again for your response =)

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 =)
edu_aero is offline   Reply With Quote

Old   September 7, 2015, 17:15
Default
  #8
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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
`e` is offline   Reply With Quote

Old   September 8, 2015, 03:22
Default
  #9
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 10
edu_aero is on a distinguished road
Quote:
Originally Posted by `e` View Post
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
Thank you very much 'e', your responses are always really useful for me.

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 =)
edu_aero is offline   Reply With Quote

Old   September 8, 2015, 06:40
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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();
Then, wrap your loop within another loop of injection streams:

Code:
loop(I, Ilist) 
{ 
}
`e` is offline   Reply With Quote

Old   September 8, 2015, 09:04
Default
  #11
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 10
edu_aero is on a distinguished road
Quote:
Originally Posted by `e` View Post
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();
Then, wrap your loop within another loop of injection streams:

Code:
loop(I, Ilist) 
{ 
}

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);
}
2-b. And at changing the the loop I have in this code, I have this error "Get_dpm_injections" not found (pc=6)"
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 =)
edu_aero is offline   Reply With Quote

Old   September 8, 2015, 15:34
Default
  #12
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by edu_aero View Post
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.
Microsoft Visual Studio Express is free and works well for compiling UDFs for Fluent. Have a read of the FAQ here: http://www.cfd-online.com/Wiki/Fluen...at_is_wrong.3F

Quote:
Originally Posted by edu_aero View Post
2-a. At adding the following line in following code "Injection *Ilist = Get_dpm_injections();". The error is the same, structure reference not implemented.
The same error would be expected because you still haven't initialised the 'I' variable.

Quote:
Originally Posted by edu_aero View Post
2-b. And at changing the the loop I have in this code, I have this error "Get_dpm_injections" not found (pc=6)"
I suspect that the function Get_dpm_injections requires compiling the UDF.
`e` is offline   Reply With Quote

Old   September 9, 2015, 07:58
Default
  #13
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
It might be needed to add
Code:
# include "dpm_mem.h"
when you interpret, to get access to Get_dpm_injections. But I am not sure of that, and compiling is the better option anyway.
pakk is offline   Reply With Quote

Old   September 16, 2015, 02:33
Default
  #14
Member
 
Eduardo Tola
Join Date: Aug 2015
Location: Madrid/Haifa
Posts: 50
Rep Power: 10
edu_aero is on a distinguished road
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 =)
edu_aero is offline   Reply With Quote

Reply

Tags
dpm, fluent, mass flow rate, udf, user defined function


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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 21:43
Second Derivative Zero - Boundary Condition fu-ki-pa OpenFOAM 11 March 27, 2021 04:28
mass flow in is not equal to mass flow out saii CFX 12 March 19, 2018 05:21
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
Compiling new Solver with wmake lin123 OpenFOAM 3 April 13, 2010 14:18


All times are GMT -4. The time now is 18:19.