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

Using a Plane id in Fluent UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 6, 2011, 23:31
Default Using a Plane id in Fluent UDF
  #1
Member
 
Join Date: Mar 2011
Posts: 50
Rep Power: 6
cdf_user is on a distinguished road
I did much research over the internet and on this forum but I could not find answer to this. I am trying to loop over faces in a plane that I created from Surface > Plane in fluent. My aim is to get an average temperature over all faces of that plane. I know there is another way to do it using Reports>Area_WeightedAverage>Tempature > Static Temperature. However, I want to find the bulk temperature or average temperature using udf over that plane. I know the plane id of that plane from Surface > Manage. Just like we can lookup a thread from Lookup_Thread(domain, thread_ID) provided we know the id of the thread, is there a similar function that could be used to look a plane from its plane id?
cdf_user is offline   Reply With Quote

Old   April 7, 2011, 03:21
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Hi,
I think you can loop over faces of a plane if it is part of your domain not just imaginary one. so one reasonable way is to work with cells, i.e. mark and separate your desired volume and after separation it would have a specific ID. you can separate a region with little depth to work as a plane.
Amir is offline   Reply With Quote

Old   April 7, 2011, 03:38
Default
  #3
Member
 
Join Date: Mar 2011
Posts: 50
Rep Power: 6
cdf_user is on a distinguished road
Oh!! so that plane is imaginary and not part of the domain. Is there a way to separate a region in my domain like the way you said (plane with small depth) using fluent or do I have to go all the way back to mesh generation to do that. I used ICEM CFD for mesh generation. If it is possible in fluent, could you please tell how to do it in fluent?

Thanks for the reply!
cdf_user is offline   Reply With Quote

Old   April 7, 2011, 08:41
Default
  #4
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
you can do that in FLUENT.
adapt->region then use hex or cylinder and specify its dimension and then mark that.(just mark do not adapt)
then in:
grid->separate->cells; separate your marked region. consequently it would be the combination of domain cells.

regards,

Amir
Amir is offline   Reply With Quote

Old   January 14, 2014, 20:36
Default
  #5
Member
 
Negin Nazarian
Join Date: Jan 2012
Location: San Diego
Posts: 61
Rep Power: 5
nenazarian is on a distinguished road
Hi Amir,

I know this is an old thread, but I had a quick question regarding your post.

You mentioned separating cells to create a new zone that acts as a plane, so that its id can be passed in UDF file for calculation.

My question is regarding face and cell values and how this would be affected using approach. When I try to mark a region with a small depth, the depth should be at least bigger than a cell size, meaning that the specified plane would actually consist of numbers of cells .

I would like to calculate a parameter that is the dot product of velocity and surface vector (of each patch or face) on a specified plane. I'm afraid using this approach, the udf would try to calculate the parameter in both upper and lower surfaces, using the same adjacent cell value!

I would appreciate if you let me know what you think.

Cheers,
Negin
nenazarian is offline   Reply With Quote

Old   January 15, 2014, 05:05
Default
  #6
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Quote:
Originally Posted by nenazarian View Post
I would like to calculate a parameter that is the dot product of velocity and surface vector (of each patch or face) on a specified plane. I'm afraid using this approach, the udf would try to calculate the parameter in both upper and lower surfaces, using the same adjacent cell value!

I would appreciate if you let me know what you think.

Cheers,
Negin
Dear Negin,

This method is useful for some post-processings like reporting an average of a variable over a face, which can be estimated as the average of adjacent cell values; note that we are getting average from cells not faces.
Here, in your case, if you can find the cell values of your surface vector, you can follow the same approach because as I said, we are substituting the face-average with the cell one. You should know that the velocity vector is also a surface vector variable because of using staggered grid concept in numerical analysis, so there should be a function to retrieve the cell value of your surface vector as it does for velocity.
You can also use another approach which is modifying your grid; you can put your desire planes in your domain as interiors and use it directly in UDFs.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   January 15, 2014, 15:38
Default
  #7
Member
 
Negin Nazarian
Join Date: Jan 2012
Location: San Diego
Posts: 61
Rep Power: 5
nenazarian is on a distinguished road
Dear Amir,

Thank you for your quick response.
I believe I need to explain my problem in more details, and then I would really appreciate if you give me your feedback on the accuracy of this approach.

I would like to calculate the following parameters on different planes, as specified in the image below:

For this purpose, I have wrote this UDF file.

Quote:
/************************************************** *********************
1. UDF that renames the UDMs to enhance postprocessing
2. UDF for computing the magnitude of Air Exchange Rates along the sides and top of the building arrays

************************************************** *********************/
#include "udf.h"


DEFINE_EXECUTE_ON_LOADING(udm_name, udflib)
{
Set_User_Memory_Name(0,"ACH-top");
Set_User_Memory_Name(1,"ACH-side");
}

DEFINE_EXECUTE_AT_END(sampling_face_data)
{
FILE *fp; // Pointer to the file for writing ACH
Domain *d;
Thread *t, *t0, *tt, *tt0;
face_t f;
cell_t c0, cc0;
d = Get_Domain(1);

int ID_t = 40, ID_s = 2; // This ID needs to be defined according to specified plane (!) zone being separated from main fluid zone

real NV_VEC(A); /* declaring vectors A - surface vectore */
real flow_time = CURRENT_TIME;
real dt = CURRENT_TIMESTEP;
real w, v; // w and v velocity on faces
real ACHt_in=0, ACHt_out=0, ACHt_it=0, ACHt_ot=0;
real sum_time = 0; // Sampling ACH starts after sum_time

sum_time + = sum_time + dt

t = Lookup_Thread(d, ID_t); // This command passes the specified zone id of top plane to the lookup thread
t0 = THREAD_T0(t);

tt = Lookup_Thread(d, ID_s); // This command passes the specified zone id of side plane(s) to the lookup thread
tt0 = THREAD_T0(tt);

w= F_W(f,t) ; v= F_V(f,tt) ;

begin_f_loop(f,t)
{
F_AREA(A,f,t)
ACHt = NV_DOT(w , A) ;

if (w<=0)
{
ACHt_in+ = ACHt/16;
//ACHt_it=ACHt_in*dt/flow_time; /* This would only be accurate when time averaging is started at t=0 */
ACHt_it=ACHt_in*dt/sum_time;
}
else
{
ACHt_out+ = ACHt/16;
ACHt_ot=ACHt_out*dt/sum_time;
}
}
end_f_loop(c,t)

begin_f_loop(f,tt)
{
F_AREA(A,f,tt)
ACHs = NV_DOT(v , A) ;
if (v<=0)
{
ACHs_in+ = ACHs/16;
ACHs_it=ACHs_in*dt/sum_time;
}
else
{
ACHs_out+ = ACHs/16;
ACHs_ot=ACHs_out*dt/sum_time;
}
end_f_loop(c,tt)
}
c0 = F_C0(f,t);
C_UDMI(c0,t0,0) =ACHs_it;

cc0 = F_C0(f,tt);
C_UDMI(cc0,tt0,1) =ACHs_ot;

/*fp = fopen("output_ACHt.txt","a");
fprintf(fp,"\n%d\t%e\n",f,C_UDMI(c0,t0,0));
fclose(fp);*/
}


a) I defined 2 UDMs in the same UDF, even though they are being calculated on different zones (as defined by different IDs). Would I benefit from having separate UDFs for each parameters (top and side ACH)?

b) ACH is calculated on faces, using vector A and velocity component defined on faces, but stored in the adjacent cell. In case of having a separate zone (as discussed in above conversation), representing the desired plane with one cell depth, would this calculation be accurate?


I would truly appreciate your help. I just finished the code, but still haven't compiled it. I am still trying to figure out if it physically make sense.

Cheers,
Negin
nenazarian is offline   Reply With Quote

Old   January 15, 2014, 17:22
Default
  #8
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Dear Negin,

First of all, you have to note that your UDF would need a major revision; it's not just about few typos or commands, there are some conceptual misunderstandings, and, for sure you can handle that ....
Anyway, regarding your UDF and questions, I think you're confused in some parts like recognizing cell or face threads. According your purpose, you can just use face threads not the cell ones! You should have or create your desire planes as face threads and use their IDs in the UDF. Achieving this goal would be possible in 2 ways:
1) Separating the cells of a proper marked zone while one of its faces coincides with desire plane and others out of the domain. (In this manner, you would get both cell and face threads, and you can use the face thread ID) You can check it in a simple case to be more clear...
2) Preparing your grid again according to these new planes as interiors.
And your questions:
Quote:
Originally Posted by nenazarian View Post
a) I defined 2 UDMs in the same UDF, even though they are being calculated on different zones (as defined by different IDs). Would I benefit from having separate UDFs for each parameters (top and side ACH)?
No! there is not any interference.
Quote:
Originally Posted by nenazarian View Post
b) ACH is calculated on faces, using vector A and velocity component defined on faces, but stored in the adjacent cell. In case of having a separate zone (as discussed in above conversation), representing the desired plane with one cell depth, would this calculation be accurate?
I've responded above.

Bests,
__________________
Amir
Amir 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
A Problem of Fluent Interpreted UDF: parse error knight Fluent UDF and Scheme Programming 11 December 8, 2013 10:00
Two questions on Fluent UDF Steven Fluent UDF and Scheme Programming 4 September 20, 2013 16:30
fluent UDF on linux machine Min-Hua Wang Fluent UDF and Scheme Programming 6 June 29, 2013 08:41
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 10:16
Can somebody send me a Fluent 6 UDF manual?? KKLAU FLUENT 4 April 14, 2004 16:37


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