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

How to read transient velocity profile data as inlet condition at each time step

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By macfly

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 14, 2016, 03:14
Default How to read transient velocity profile data as inlet condition at each time step
  #1
New Member
 
hemant mittal
Join Date: Feb 2016
Posts: 21
Rep Power: 10
hemmt is on a distinguished road
Hello every one,

I have velocity profile (atmospheric boundary layer) data for each time step, (means X coordinate, Y coordinate, Z coordinate ,time, X velocity, Y Velocity, Z velocity) saved as .csv format.
I need to use this file as inlet boundary condition for each time step in FLUENT.

So please suggest me suitable macros to read data file as inlet boundary condition at each time step.


Thanks
hemmt is offline   Reply With Quote

Old   October 14, 2016, 09:16
Default macro
  #2
New Member
 
shreehan Abd El-Ghafour
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sh.a.ghafour is on a distinguished road
Dear hemmt,
you can use a profile in a notepad file but save it with extension .PROF (i begin with excel sheet and copy it to a notpad file then save it with the required extension)
or use can make a udf with DEFINE_PROFILE macro
good luck
sh.a.ghafour is offline   Reply With Quote

Old   October 14, 2016, 09:23
Default example
  #3
New Member
 
shreehan Abd El-Ghafour
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sh.a.ghafour is on a distinguished road
an example from my work
example.txt
sh.a.ghafour is offline   Reply With Quote

Old   October 14, 2016, 11:44
Default
  #4
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,761
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
I would also suggest to make a profile table since you already have it in a table (although it's in a csv).
LuckyTran is offline   Reply With Quote

Old   October 16, 2016, 01:09
Default
  #5
New Member
 
hemant mittal
Join Date: Feb 2016
Posts: 21
Rep Power: 10
hemmt is on a distinguished road
Quote:
Originally Posted by sh.a.ghafour View Post
Dear hemmt,
you can use a profile in a notepad file but save it with extension .PROF (i begin with excel sheet and copy it to a notpad file then save it with the required extension)
or use can make a udf with DEFINE_PROFILE macro
good luck
hello sir, Thanks for ur reply.
Actually I new to Fluent UDF.
Can u Provide me an example of UDF for using profile data(Atmospheric boundary layer)

Thanks
hemmt is offline   Reply With Quote

Old   January 10, 2017, 23:39
Default
  #6
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by sh.a.ghafour View Post
an example from my work
Attachment 51119
Your example doesn't answer the initial question because it doesn't have x-y-z coordinates.

Anybody knows how to write a transient profile .prof that contains x-y-z coordinates? The coordinates should be written only once, and then all the corresponding values for each time step... I didn't find any example like that.
macfly is offline   Reply With Quote

Old   March 1, 2017, 23:48
Default
  #7
New Member
 
Yousef
Join Date: Dec 2015
Posts: 14
Rep Power: 11
yousefaz is on a distinguished road
Quote:
Originally Posted by macfly View Post
Your example doesn't answer the initial question because it doesn't have x-y-z coordinates.

Anybody knows how to write a transient profile .prof that contains x-y-z coordinates? The coordinates should be written only once, and then all the corresponding values for each time step... I didn't find any example like that.
Macfly,

Unfortunately, I don't think that is possible even with the latest version of fluent. If I have read the Fluent manual correctly, the transient boundary profiles in fluent must be spatially uniform: https://www.sharcnet.ca/Software/Ans...transient.html

It seems there is no apparent way of specifying profile that varies with both time and space with a .prof or a .ttab file.

I am currently struggling with the same problem myself. Basically, I have a MATLAB code that generates velocity vs time data for the inlet surface (spatially and temporally non uniform) that I am not able to import into fluent with the profile tool. The only way this seems possible is with a UDF function that reads data from the csv file, and updates the profile with each time-step. For my case, it makes more sense to rewrite the MATLAB code as a UDF.
yousefaz is offline   Reply With Quote

Old   March 2, 2017, 08:24
Default
  #8
New Member
 
hemant mittal
Join Date: Feb 2016
Posts: 21
Rep Power: 10
hemmt is on a distinguished road
Quote:
Originally Posted by yousefaz View Post
Macfly,

Unfortunately, I don't think that is possible even with the latest version of fluent. If I have read the Fluent manual correctly, the transient boundary profiles in fluent must be spatially uniform: https://www.sharcnet.ca/Software/Ans...transient.html

It seems there is no apparent way of specifying profile that varies with both time and space with a .prof or a .ttab file.

I am currently struggling with the same problem myself. Basically, I have a MATLAB code that generates velocity vs time data for the inlet surface (spatially and temporally non uniform) that I am not able to import into fluent with the profile tool. The only way this seems possible is with a UDF function that reads data from the csv file, and updates the profile with each time-step. For my case, it makes more sense to rewrite the MATLAB code as a UDF.
please share the solution regarding this means udf to read this velocity profile and update at each time step.
hemmt is offline   Reply With Quote

Old   March 2, 2017, 12:32
Default
  #9
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by yousefaz View Post
Unfortunately, I don't think that is possible even with the latest version of fluent. If I have read the Fluent manual correctly, the transient boundary profiles in fluent must be spatially uniform: https://www.sharcnet.ca/Software/Ans...transient.html
I read that too, I was trying to see if someone had maybe pushed the enveloped further.

Quote:
Originally Posted by yousefaz View Post
I am currently struggling with the same problem myself. Basically, I have a MATLAB code that generates velocity vs time data for the inlet surface (spatially and temporally non uniform) that I am not able to import into fluent with the profile tool. The only way this seems possible is with a UDF function that reads data from the csv file, and updates the profile with each time-step. For my case, it makes more sense to rewrite the MATLAB code as a UDF.
It's easy to generate profile files for each time step. You don't need a udf to read a new profile file every time step, it can be programmed easily in the 'Execute Commands'. But it's kinda stupid because each profile file has the exact same coordinates data.. and when the mesh is fine and there is a lot of time steps, you end up with many useless GBs of useless coordinates on your hard disk and it slows the solver because it has to load a large profile file at each time step..
macfly is offline   Reply With Quote

Old   March 2, 2017, 22:04
Default
  #10
New Member
 
Yousef
Join Date: Dec 2015
Posts: 14
Rep Power: 11
yousefaz is on a distinguished road
Quote:
Originally Posted by macfly View Post
It's easy to generate profile files for each time step. You don't need a udf to read a new profile file every time step, it can be programmed easily in the 'Execute Commands'. But it's kinda stupid because each profile file has the exact same coordinates data.. and when the mesh is fine and there is a lot of time steps, you end up with many useless GBs of useless coordinates on your hard disk and it slows the solver because it has to load a large profile file at each time step..
Thanks for the tip! It seems so trivial now that you mention it.
I agree this method is far from perfect, but it saves me a lot of time at least for the initial stages of my project. I suspect that eventually I'll have to bite the bullet and write the UDF.
yousefaz is offline   Reply With Quote

Old   March 2, 2017, 23:17
Default
  #11
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
yousefaz, here is a Execute Commands example where your profile files would be named, for example,
profile-0001.prof
profile-0002.prof
profile-0003.prof
and so on...
Code:
(ti-menu-load-string (format #f "file read-profile profile-~04d.prof" (rpgetvar 'flow-time)))
yousefaz likes this.
macfly is offline   Reply With Quote

Old   March 2, 2017, 23:50
Default
  #12
New Member
 
Yousef
Join Date: Dec 2015
Posts: 14
Rep Power: 11
yousefaz is on a distinguished road
Much appreciated Macfly!

Hemmt,

With regards to the UDF, here is a script I found that reads data from a text file into a c++ array: (https://www.researchgate.net/post/Ca..._in_LES_FLUENT)

I will update you if I ever get around to writing the full UDF.
#include "udf.h"
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

FILE * coeff;
float var1[10000]={0},var2[10000]={0},var3[10000]={0};
int count;

DEFINE_ON_DEMAND(get_data)
{
coeff = fopen("file.txt", "r");
if (coeff == NULL)
exit(EXIT_FAILURE);

count=0;
#if RP_HOST
Message("Reading Data");
#endif
while (!feof(coeff)) /* reading columns with tabs between them */
{
fscanf(coeff,"%f %f %f",&var1[count], &var2[count], &var3[count]);
count++;
}
#if RP_HOST
Message("End of reading");
#endif
fclose(coeff);
}
yousefaz is offline   Reply With Quote

Old   July 9, 2018, 03:26
Default UDF to read transient data
  #13
New Member
 
hemant mittal
Join Date: Feb 2016
Posts: 21
Rep Power: 10
hemmt is on a distinguished road
Quote:
Originally Posted by yousefaz View Post
Much appreciated Macfly!

Hemmt,

With regards to the UDF, here is a script I found that reads data from a text file into a c++ array: (https://www.researchgate.net/post/Ca..._in_LES_FLUENT)

I will update you if I ever get around to writing the full UDF.
#include "udf.h"
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

FILE * coeff;
float var1[10000]={0},var2[10000]={0},var3[10000]={0};
int count;

DEFINE_ON_DEMAND(get_data)
{
coeff = fopen("file.txt", "r");
if (coeff == NULL)
exit(EXIT_FAILURE);

count=0;
#if RP_HOST
Message("Reading Data");
#endif
while (!feof(coeff)) /* reading columns with tabs between them */
{
fscanf(coeff,"%f %f %f",&var1[count], &var2[count], &var3[count]);
count++;
}
#if RP_HOST
Message("End of reading");
#endif
fclose(coeff);
}
Dear sir
thanks for Your kind reply

Could you help me to for full UDF regarding to read transient ABL data

Thanks
hemmt is offline   Reply With Quote

Reply


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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 03:36
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 08:31
Problem with assigned inlet velocity profile as a boundary condition Ozgur_ FLUENT 5 August 25, 2015 05:58
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20


All times are GMT -4. The time now is 14:42.