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

UDF to read a set of data?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 7, 2019, 06:40
Default UDF to read a set of data?
  #1
New Member
 
Josh
Join Date: May 2019
Posts: 16
Rep Power: 7
Helium is on a distinguished road
Hi everyone,

I have a txt document like this:

time velocity
0 0
0.1 1.3
0.2 1.7
0.3 2.5

..and so on.
My dataset unfortunately is not so easy, in fact I have a periodic function that has a pretty irregular velocity in time. The problem is that I have to impose this velocity as a UDF on a wall of my domain but I cannot find a function to properly fits those data. So my question: is there a way to write a UDF to read this dataset to impose the value of velocity for the timestep?

Thanks
Helium is offline   Reply With Quote

Old   November 7, 2019, 06:54
Default
  #2
Member
 
Join Date: Jun 2017
Posts: 43
Rep Power: 9
Large Epic Simulations is on a distinguished road
You need to load your data into a C array and use a search function to get them.
Large Epic Simulations is offline   Reply With Quote

Old   November 7, 2019, 07:02
Default
  #3
New Member
 
Josh
Join Date: May 2019
Posts: 16
Rep Power: 7
Helium is on a distinguished road
Quote:
Originally Posted by Large Epic Simulations View Post
You need to load your data into a C array and use a search function to get them.
Could you write an example?
I am not so experienced with UDF...
Helium is offline   Reply With Quote

Old   November 7, 2019, 07:20
Default
  #4
Member
 
Join Date: Jun 2017
Posts: 43
Rep Power: 9
Large Epic Simulations is on a distinguished road
https://stackoverflow.com/questions/...nto-array-in-c
Large Epic Simulations is offline   Reply With Quote

Old   November 7, 2019, 07:24
Default
  #5
New Member
 
Josh
Join Date: May 2019
Posts: 16
Rep Power: 7
Helium is on a distinguished road
Quote:
Originally Posted by Large Epic Simulations View Post
Thanks, but I know how to use C.
The problem is to write in the udf language. I have the udf manual but I cannot do it...
Helium is offline   Reply With Quote

Old   November 7, 2019, 07:46
Thumbs down
  #6
Member
 
Join Date: Jun 2017
Posts: 43
Rep Power: 9
Large Epic Simulations is on a distinguished road
You should be aware that UDF is a C code in which you load the udf header to access some of the Fluent utilities.



What I want to say is that that you can write a dummy C function which reads your file and transfers the values to a global defined array:


Code:
#include "udf.h"

double** data;
void build_table()
{
 // code to allocate data from file to the variable "data" 
}
You need to run this function just one time before you start your simulation. In the UDF context you can do:



Code:
DEFINE_ON_DEMAND(read_file)
{
 build_table();
}

This creates you an "execute on demand" function that allows the remaining part of your code to read the values in the array.
Large Epic Simulations is offline   Reply With Quote

Reply

Tags
udf, udf and programming, udf code, udf customize


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
UDF to read transient data hemmt Fluent UDF and Scheme Programming 0 January 11, 2017 01:51
UDF DPM_BC with F_UDMI not storing data balki Fluent UDF and Scheme Programming 3 June 6, 2016 23:10
999999 (../../src/mpsystem.c@1123):mpt_read: failed:errno = 11 UDS_rambler FLUENT 2 November 22, 2011 10:46
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 15:37
UDF to read and write data Mcgregor FLUENT 4 June 9, 2003 14:21


All times are GMT -4. The time now is 13:41.