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

UDF : Lift coefficient time history and Data sampling

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 31, 2020, 16:34
Default UDF : Lift coefficient time history and Data sampling
  #1
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 5
Bibill is on a distinguished road
Dear all,

I try to implement a UDF in Fluent that could be able to trigger data sampling and averaging for the fully developed stage in unsteady simulations.

For it, i need to have access to the full time-history of quantity of interest, for instance the lift coefficient (Cl). To assess the aerodynamic coefficients in the UDF I used the macro GET_REPORT_DEFINITION_VALUES that allows to access the last calculated value for any report definition previously created in Fluent. However, this macro only returns a single value (at the current iteration in steady simulation or at the current time-step in an unsteady simulation). Is there a solution to store the time trace of the CL such that it can be used in the UDF (from time-step 0 to the current time-step) ? Given that UDM can be used to allocate up to 500 memory locations (way less than the number of time steps in the simulation) it will not work...

Secondly, i would like to start the data sampling and time-averaging as soon as a certain accuracy is reached. Is there a possibility to make the sampling and time averaging start by means of a UDF ?

I really would appreciate your help,
Thanks in advance!
Bibill is offline   Reply With Quote

Old   June 1, 2020, 04:44
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
there is an option in Run Calculation tab, which you can use:
Data Sampling for Time Statistics
https://www.afs.enea.it/project/nept...ug/node810.htm

you have wrong idea what UDM is. It is array over cells/faces with contains information of certain variable (chosen by user). It can't store data in time.

If you don't want to use build-in tool, you can write data to file and play with it later
__________________
best regards


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

Old   June 1, 2020, 09:47
Default
  #3
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 5
Bibill is on a distinguished road
Thanks for your fast reply AlexanderZ!



Yes, i know that it is possible to start the data sampling and statistics in the GUI. However, i would like to make it automatic and on the fly by means of a UDF.

For example : "as soon as a predefined relative error on a quantity of interest is reached, the data sampling is triggered."

So my question was rather "Is there a possibility to make the sampling start by means of a UDF ?"

Thanks in advance!
Bibill is offline   Reply With Quote

Old   June 1, 2020, 17:46
Default Sampling
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
There are multiple ways to do this, such as, by setting up an rp variable of boolean type and an execute command that starts the sampling as soon as rp variable becomes true. Value of rp variable can be set by UDF. It would be difficult to start sampling using UDF.

However, what's your logic behind observing the entire history to begin sampling? Usual procedure is to start sampling after 2-3 flow-through times, since a transient simulation is inherently transient and never reaches (or at least is not supposed to reach) a steady state until the transient approach is being used for stability reason. Another approach people use is to observe the last 20-30 or may be 50 time-steps but not entire history.

UDMs are not meant for the purpose, but even one UDM is larger than the space you might need since each UDM takes space more than twice the size of cell count, e.g., if there are a million cells, then one UDM is equal to a vector capable of storing more than 2 million real values, certainly more than the time-steps the case will run for. But as mentioned above, UDMs are not meant for the purpose nor can they be used.

What you need is a vector (or an array) that can store 1000s of values of lift coefficients. This may be doable using C, but you should really be an expert to ensure that the vector is not lost every time-step, which it would, even with a static variable. So, if you want to use C, better to write data in a text file and read it back or find a way to maintain the values stored for the previous time-steps within the vector. If you use a text file, I/O would make it very slow.

So, a better alternative is to use Scheme. Define a vector in Scheme with a size equal to or more than the number of time-steps you expect the case to take for reaching a statistical steadiness. Keep on storing values for coefficient in this vector. You can do whatever checking you wish to do using the components of the vector. Once it reaches a required condition, you can enable sampling using TUI command within Scheme. So, all can be done within a single program.
Bibill likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 4, 2020, 13:22
Default
  #5
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 5
Bibill is on a distinguished road
Thank you vinerm for your precious answer!

The goal is to monitor the transient simulation in an automatic way to reduce the user burden. For it, the methodology i'm trying to implement require the lift coefficient time history.

Do you know how can i proceed with UDM or vector scheme to be abble to have a time vector in my UDF ?

Thanks in advance !
Bibill is offline   Reply With Quote

Old   June 4, 2020, 13:44
Default Vectors
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
C based UDF can work only by storing the data in a file, could even be in data file since the variables are volatile. Therefore, it is better to use Scheme. You can define a vector using vector command and give it a name using define, e.g.,

(define liftvec (make-vector len obj))

where liftvec is a user specified name for the vector, len is to be replaced by a number that defines the length of the vector, and obj are its entries. So, if you want to save 100 lift coefficients, then define it as (define liftvec (make-vector 100)). At this stage, the vector is empty. You can fetch lift coefficient value at a particular frequency and then add that as a member to the vector. To add a value to an empty vector, you need to use following

(vector-set! liftvec 4 0.43)

The command above will set fifth member as 0.43. Indexing starts from 0. To know more about Scheme you can go through the customization manual of Fluent and the following

https://groups.csail.mit.edu/mac/ftp...cheme_toc.html

If you are not comfortable with Scheme, but you are comfortable with C, then write the values in a file using C based UDF and keep on reading those back in a C vector at a set frequency. The only issue is that it is limited by the speed of I/O.

To enable the sampling, you have to use Scheme command.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 4, 2020, 14:37
Default
  #7
New Member
 
Join Date: May 2020
Posts: 23
Rep Power: 5
Bibill is on a distinguished road
Thank you again, i really appreciate your help!

Yes as you have noticed i've never used scheme before... So, if i use scheme, is it possible to fill the vector with the computed lift at each time step and then manipulate the vector in a UDF ?
Bibill is offline   Reply With Quote

Old   June 4, 2020, 14:57
Default Vector
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
You can fill the lift coefficient in a vector, however, its manipulation by a C based UDF may or may not be possible. C cannot directly access scheme vector, however, there might be a way to transfer it to C. But whatever you want to do using C can be done using Scheme. So, you may not require C at all.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 4, 2020, 20:34
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
i recommend you to use list type in scheme, not vector
__________________
best regards


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

Old   June 5, 2020, 06:31
Default List and Vector
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Yes, list will also work with an advantage that you can change the size of the list while vectors are immutable. However, random access in list will slow down significantly as its size grows. Vectors on the other hand are much faster and recommended for sizes greater than, say, 500 or 1000.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply

Tags
data sampling, time history, time statistics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
data sampling for time statistics knut FLUENT 0 May 7, 2014 19:51
use time history of input data colopolo70 FLUENT 0 October 3, 2009 00:09
air bubble is disappear increasing time using vof xujjun CFX 9 June 9, 2009 07:59
tracking data with respect to time tucker FLUENT 2 December 20, 2005 08:39
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


All times are GMT -4. The time now is 17:23.