CFD Online URL
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

How to Read a "Profile" format file in UDF?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   July 12, 2010, 16:08
Default
  #21
Member
 
Kasra
Join Date: Jun 2010
Location: USA
Posts: 42
Rep Power: 6
gary7 is on a distinguished road
I really respect your time and appreciate it... after reading profile and setting the rp variables then I read the variables in a UDF with DEFINE_PROFILE to set the BC condition, after doing simulation for N time steps then how I can specify in EXECUTE_AT_END to reset the BC again and continue the simulation (assuming that I've done saving and reading the case in prior)?
In other words, how can I recall the DEFINE_PROFILE UDF again and again in the EXECUTE_AT_END and continue simulation after that? is that possible?
gary7 is offline   Reply With Quote

Old   July 13, 2010, 08:29
Default
  #22
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
Your questions are still confusing me, so please make a simple and clear list with your problem.
This is what I understood until now:
1. You want to read a fluent profile from a file. For this purpose you use a scheme script. You can add this scheme script in "Execute Commands", and automaticaly executed every time step or ...10 time steps.
2. You want to set some variables from the profile into rp variables. For this you use a scheme script (maybe the same as in step 1).
3. You want to access the rp variables from inside the solver. For this you use a udf DEFINE_PROFILE, and attach this udf to a surface as a boundary condition. This boundary condition will be used by the solver every iteration (wether you want it or not).
4. Every 10 time steps you want to change the values of the rp variables with a new profile. For this purpose, you try to use EXECUTE_AT_END? I suggest a simpler way: see step 1.
dmoroian is offline   Reply With Quote

Old   July 13, 2010, 12:51
Default
  #23
Member
 
Kasra
Join Date: Jun 2010
Location: USA
Posts: 42
Rep Power: 6
gary7 is on a distinguished road
Here is a clarification to the first and 4th steps which I'm trying to figure out:

After running the simulation for 10 time steps I need to check if the new profile file is ready to be used or not (the profile is provided by another simulation which I don't know how much time it takes to be ready) so my simulation should be in standby mode till that file becomes ready. I was trying to do this waiting through DEFINE_EXECUTE_AT_END in which after 10 time steps check for that file and stands till that file becomes ready...After the file was provided the steps I need to read this new file and set it as new BC. It means I need to go back to step 1 and repeat the process again and again.
1. Is that possible to go back to step 1 (reading the scheme file again) and resetting the rp variables and BC again in DEFINE_EXECUTE_AT_END macro? how?

2. If the answer to question 1 is No then do I need to read the profile file in a UDF instead of a scheme? in order to just dealing with UDFs?

Thank you in advance for your time and consideration,
gary7 is offline   Reply With Quote

Old   July 13, 2010, 16:35
Default
  #24
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
1. No it is not.
2. Yes, my choice for this case would be to do everything inside a udf.
dmoroian is offline   Reply With Quote

Old   July 13, 2010, 18:32
Default
  #25
Member
 
Kasra
Join Date: Jun 2010
Location: USA
Posts: 42
Rep Power: 6
gary7 is on a distinguished road
Ok then, I need to input required BC variables through UDF...then it'd be better to use a simple data file not a profile file format so it can be easily read and written...to have a clue about the face centers of the problem on the intended boundary I tried writing out the BC face centroids using the exact same example as in UDF manual (second example in section 3.2.6) here is what I input as a UDF:

Code:
#include "udf.h"

FILE *fout;

void Print_Thread_Face_Centroids(Domain *domain, int id)
{
    real FC[2];
    face_t f;
    int n_faces,j;
    Thread *t = Lookup_Thread(domain, id);
    
    n_faces=THREAD_N_ELEMENTS_INT(t);
    fprintf(fout,"%d\n", n_faces);
    j=0;
    begin_f_loop(f,t)
{
    F_CENTROID(FC,f,t);
    j++;
    fprintf(fout, "f%d %g %g %g %d\n", f, FC[0], FC[1], FC[2], j));
}
    end_f_loop(f,t)
    fprintf(fout, "\n");
}

DEFINE_ON_DEMAND(get_coord)
{
    Domain *domain;
    domain = Get_Domain(1);
    fout = fopen("BCData.txt", "w");
    Print_Thread_Face_Centroids(domain, 7);
    fclose(fout);
}
when I run this UDF at demand what I get in the output file "BCData.txt" is just:

Code:
2500
f1050120822 3.51252e-007 0 3.51252e-007 1
since my flow field is a cubic with 50 cells in x and z direction and 10 cells in y direction, the boundary with ID=7 is one of the y-planes and its a wall. So 2500 which is the number of faces on this boundary is OK but I don't understand why begin_f_loop is being done just once instead of 2500 times?!!! if I don't use f_loop I'll get the same result so the loop is actually doing nothing!!!!

And if I use the same procedure but instead of DEFINE_ON_DEMAND use DEFINE_EXECUTE_AT_END the code will be trapped in f_loop forever?????!!!!!!!!!!

Thanks,

Last edited by gary7; July 14, 2010 at 12:04.
gary7 is offline   Reply With Quote

Old   July 14, 2010, 14:42
Default
  #26
Member
 
Kasra
Join Date: Jun 2010
Location: USA
Posts: 42
Rep Power: 6
gary7 is on a distinguished road
OK, After a long time on it I found the problem...it was because of the defining FC[2] in the 3D model...
gary7 is offline   Reply With Quote

Old   July 15, 2010, 02:37
Default
  #27
Member
 
Kasra
Join Date: Jun 2010
Location: USA
Posts: 42
Rep Power: 6
gary7 is on a distinguished road
Ok, I'm doing all the things in a UDF now as you suggested. Now, the only thing is that when in DEFINE_EXECUTE_AT_END I read the new BC data file how can I reset the new BC from there and continue the simulation...
Any idea is highly appreciated.
gary7 is offline   Reply With Quote

Old   July 15, 2010, 03:23
Default
  #28
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
DEFINE_EXECUTE_AT_END cannot directly reset your boundary conditions, for this purpose fluent provides you with a macro called DEFINE_PROFILE. You have to present a bit more detailed what you do.
dmoroian is offline   Reply With Quote

Old   July 15, 2010, 11:18
Default
  #29
Member
 
Kasra
Join Date: Jun 2010
Location: USA
Posts: 42
Rep Power: 6
gary7 is on a distinguished road
I need to set a new BC in my simulation every time a new BC data which is provided from outside is ready, that is I first run the simulation with a specified BC for 10 time step then in EXECUTE_AT_END I check for the availability of the new BC data file upon its availability I need to reset the boundary condition with this new file and continue the simulation (if the BC data file is not still ready the simulation will be in standby mode in there checking continuously for the file till it becomes ready) ...
I know about setting boundary with DEFINE_PROFILE macro my problem is that I need to call this macro repeatedly after checking and approving the existence of the new BC data file in EXECUTE_AT_END.
gary7 is offline   Reply With Quote

Old   July 16, 2010, 05:16
Default
  #30
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
None of the DEFINE_* macros that fluent provides for you are designed to be called by you, but by fluent it self. Consequently, you cannot call any of them.
Here I think I see a missunderstanding. You don't need to call any of the DEFINE_* macros, they are called periodically by fluent, any way (excepting DEFINE_ON_DEMAND).
The simplest way would be to do the checking and reading directly inside DEFINE_PROFILE (which is called by fluent at least every iteration). The input files are small and it doesn't take that much time to read it (when the check says you have to read it).
If you insist to use DEFINE_EXECUTE_AT_END, then you need to use global defined arrays. You will use those arrays to access the data read within DEFINE_EXECUTE_AT_END from DEFINE_PROFILE.
dmoroian is offline   Reply With Quote

Old   July 18, 2010, 02:32
Default
  #31
Member
 
Kasra
Join Date: Jun 2010
Location: USA
Posts: 42
Rep Power: 6
gary7 is on a distinguished road
Thanks Dmoroian, yeah it seems that DEFINE_PROFILE is called at beginning of every time step I thought it is just called once in the beginning of the simulation...
gary7 is offline   Reply With Quote

Old   June 7, 2011, 08:44
Default UDF profile read question
  #32
New Member
 
engin leblebici
Join Date: May 2011
Posts: 7
Rep Power: 5
engin is on a distinguished road
Hi,

I am working with FLUENT 6.3.26 and I am having difficulties in reading a profile file into UDF later to be used as boundary conditions. My question is that can I assign values to a 1D array if I am working with interpreted UDF?

Thanks in advance
engin is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling gmshFoam with OpenFOAM-1.5 BlGene Open Source Meshers: Gmsh, Netgen, CGNS, ... 10 August 6, 2009 05:26
UDF to read data from a file for VOF model Pablo FLUENT 0 October 23, 2008 08:02
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 15:37
Results saving in CFD hawk Main CFD Forum 16 July 21, 2005 21:51
Format file for visualisation Ricardo Nunez Main CFD Forum 2 July 30, 1998 05:12


All times are GMT -4. The time now is 03:18.