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

ow to get DPM values as output for Design Xplorer

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 13, 2020, 16:12
Default SOLVED - How to get DPM values as output for Design Xplorer
  #1
New Member
 
Darius
Join Date: Dec 2020
Posts: 8
Rep Power: 5
Darius12345 is on a distinguished road
Hello Everyone,

I am trying to create an optimization setup with Fluent and Design Xplorer where the radial particle distribution is an input parameter for the optimization. So I want to get the x and y position of each particle when it is at a specified plane (or z-position), calculate the radius from it, and see if it is above or below a given radius. The output parameter is then the share of particles above this radius.

I first tried with DEFINE_DPM_OUTPUT to get the x and y position of my particle and then store it in a file, I then read the file back in and create an output parameter using DEFINE_REPORT_DEFINITIN_FN but the file is only updated when a sample is created, which is not useful for my problem, or is it possible to create a sample every few iterations automatically?

My current approach is a SCALAR_UPDATE-UDF, where the positions are stored in the TP_USER_REAL array for each particle, here the data should be updated after each DPM iteration. The array is then read back to create an output parameter with DEFINE_REPORT_DEFINITION, both UDFs compile but when I start simulating I am getting a SIGSEV error. If I only use the SCALAR_UPDATE_MACRO everything is working. You can see my code in the attached picture.

If you have any suggestions on how to solve this issue, your help is much appreciated, also I am not quite sure if I can call DPM functions within non-DPM UDFs, is this possible at all?

Thanks in advance for your help.
Attached Images
File Type: jpg UDF.jpg (57.5 KB, 26 views)

Last edited by Darius12345; December 17, 2020 at 12:49. Reason: solved
Darius12345 is offline   Reply With Quote

Old   December 14, 2020, 02:30
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
next time put your code here as a text, not picture

I don't have a lot experience in DPM simulations
but what can i suggest is:
1. SIGSEV error means you have problems with memory, you are trying to access something, which doesn't exit

2. Most likely you have problems with loops:
loop (I,Ilist)
{
loop(tp, I)
{

3. what I can see in your code, Ilist is defined using Ilist = get_dpm_injection() macro
But I is not defined

4. tp is not defined either in your code

5. So you may try to use only one loop with defined injecttion and particle pointers:

loop(tp,Ilist->tp)
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 14, 2020, 06:44
Default
  #3
New Member
 
Darius
Join Date: Dec 2020
Posts: 8
Rep Power: 5
Darius12345 is on a distinguished road
Hello AlexanderZ,

thank you for the reply, I thought the pointers are defined with Injection *I and Tracked Particle *tp. Also when I tried to define I and tp as integer I get error messages that these variables are already defined. Is there a way to define them like Ilist with something like get_dpm_particles()?

My explanation for the SIGSEV was that TP_USER_REAL is not available in the REPORT_DEFINITION Macro?
Darius12345 is offline   Reply With Quote

Old   December 14, 2020, 07:42
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
change
Code:
loop (I,Ilist)
{
loop(tp, I)
{
to
Code:
loop(tp,Ilist->tp)
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 14, 2020, 13:01
Default
  #5
New Member
 
Darius
Join Date: Dec 2020
Posts: 8
Rep Power: 5
Darius12345 is on a distinguished road
Thanks again, I tried with your loop but now I get the following error:

Quote:
error: no member named 'tp' in 'struct injection_struct'
loop (tp,Ilist->tp)
In the meantime I tried with global variables instead and this 2 UDFs are also compiling fine, the simulation is running (without the Messages) but my output for "a" is always 1. When I insert the mesages the DPM iterations does not finish, so I can not check if 'i' and 'j' are increased correctly. Any suggestions on why this is not working?

I tried with different DPM Setups, for my understanding if I use 'Interaction with continuous phase' or transient particle tracking the SCALAR_UPDATE Macro should be called whenever the particles are calculated and then my output parameter should also change.

Code:
#include "udf.h"

float i = 1.0;
float j = 1.0;

DEFINE_DPM_SCALAR_UPDATE(sampling_pos,cell,thread,initialize,tp)
 {
    float r = 0.0;
    if (initialize)
     {

     }
    else
     {
           r = sqrt(SQR(TP_POS(tp)[0])+SQR(TP_POS(tp)[1]));
           /*Message("r= %d\n", r);*/
           i = i + 1;
           /*printf("i= %i\n", i);*/
           if (r > 0.09)
           {
            j = j + 1;
            /*printf("j= %i\n", j);*/
           }
      }
 }

DEFINE_REPORT_DEFINITION_FN(positions)
 {
  float a = 0.0;
  a = j / i;
  return a;
 }
Darius12345 is offline   Reply With Quote

Old   December 17, 2020, 12:48
Default
  #6
New Member
 
Darius
Join Date: Dec 2020
Posts: 8
Rep Power: 5
Darius12345 is on a distinguished road
Hello,

I was able to solve the issue by creating a sample file automated after n iterations using 'execute commands' in the Solution > Activities > Create Tab. Then I used DEFINE_DPM_OUTPUT to write the desired data at these points and read it back in with a UDF for an output parameter.

Thanks for your suggestions, I will mark this Question as solved then.
Darius12345 is offline   Reply With Quote

Reply

Tags
dpm, output parameters, udf


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
Keeping intermediate files OVS SU2 5 December 5, 2021 12:41
All output values increase rapidly after one cycle 12ohan OpenFOAM Running, Solving & CFD 1 April 26, 2019 11:52
writing values to IOdictionary subDict not generating expected output? massive_turbulence OpenFOAM Programming & Development 2 January 21, 2019 09:48
Output File of DPM Modelling cwl6750084 FLUENT 0 April 16, 2017 10:41
output point values in CFX4 Dougal McQueen CFX 1 February 14, 2004 00:55


All times are GMT -4. The time now is 00:53.