|
[Sponsors] |
Opening a file and if statement before a DPM UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 12, 2014, 00:16 |
Opening a file and if statement before a DPM UDF
|
#1 |
New Member
Anthony
Join Date: Jul 2013
Posts: 15
Rep Power: 13 |
I am currently using a UDF for DEFINE_DPM_PROPERTY and it involves an If statement, reading a file, and then modifying a particle property.
So the very simplified file looks like, DEFINE_DPM_PROPERTY >if 1 condition >open file A else >open file B >modify particle property This works but is extremely slow due to the way the file opens. Is there anyway I can open the file before the UDF loops over every particle? This was not a problem when I was using DEFINE_PROPERTY since the loop over every cell was contained within a for loop and the file could be opened before this. However if I put the file opening part before DEFINE_DPM_PROPERTY line I get 2 compiler errors since 'If' statements cannot be used outside of a function and my file opening needs an address operator (&) which also seems to not work outside of a function. The compiler errors I receive are: error C2143: syntax error : missing ')' before '&' error C2143: syntax error : missing '{' before '&' error C2059: syntax error : '&' error C2059: syntax error : ')' error C2059: syntax error : 'if' Thanks in advance to anyone that can help |
|
August 12, 2014, 02:48 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Simplified:
DEFINE_ON_DEMAND >open file A >save data in variable C >open file B >save data in variable D DEFINE_DPM_PROPERTY >if 1 condition >read variable C else >read variable D >modify particle property |
|
August 12, 2014, 10:29 |
|
#3 |
New Member
Anthony
Join Date: Jul 2013
Posts: 15
Rep Power: 13 |
I should have said before that the file is being read by proprietary software. Once the file is read, the same program needs to use that data which it stores internally to evaluate the conditions in the Fluent simulation such as temperature, pressure and species concentrations. So it isn't possible for me to save the data to a variable. Once the end of a function is reached, the program closes and the data is lost.
|
|
August 12, 2014, 12:04 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Just to be sure if I understand it, does the following describe the workflow (excluding the if-statement)?
- Fluent has flow data in memory. - PropSoftware reads flow data directly from Fluent's memory. - PropSoftware writes dpm data to file. - Fluent reads dpm data from file. - Fluent calculates next time step. - Go back to beginning. Do you think the following pseudo-code would work in your situation? DEFINE_DPM_PROPERTY >if (first particle in current time step): > read files A and B, store in variables C and D >endif >if 1 condition > read variable C >else > read variable D >endif >modify particle property |
|
August 14, 2014, 01:39 |
|
#5 |
New Member
Anthony
Join Date: Jul 2013
Posts: 15
Rep Power: 13 |
Hi pakk,
Thanks for your help, it appears it does work with something close to your first solution. With your help and help from Ansys, I was able to make it work with DEFINE_EXECUTE_ON_LOADING for the first function. The program doesn't close in between functions as I first thought. |
|
Tags |
dpm, fluent, udf |
|
|