|
[Sponsors] |
April 7, 2011, 00:31 |
Using a Plane id in Fluent UDF
|
#1 |
Member
Join Date: Mar 2011
Posts: 50
Rep Power: 15 |
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?
|
|
April 7, 2011, 04:21 |
|
#2 |
Senior Member
|
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. |
|
April 7, 2011, 04:38 |
|
#3 |
Member
Join Date: Mar 2011
Posts: 50
Rep Power: 15 |
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! |
|
April 7, 2011, 09:41 |
|
#4 |
Senior Member
|
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 |
|
January 14, 2014, 20:36 |
|
#5 |
Member
Negin Nazarian
Join Date: Jan 2012
Location: San Diego
Posts: 61
Rep Power: 14 |
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 |
|
January 15, 2014, 05:05 |
|
#6 | |
Senior Member
|
Quote:
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 |
||
January 15, 2014, 15:38 |
|
#7 | |
Member
Negin Nazarian
Join Date: Jan 2012
Location: San Diego
Posts: 61
Rep Power: 14 |
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:
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 |
||
January 15, 2014, 17:22 |
|
#8 | ||
Senior Member
|
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:
Quote:
Bests,
__________________
Amir |
|||
August 19, 2015, 04:48 |
udf
|
#9 |
New Member
frety
Join Date: Jul 2015
Posts: 9
Rep Power: 11 |
hi amir
i was wondering if there is any way to mark cells using udf. the problem is that i created an udf to change the porosity is some area to create a cylinder inside a volume. now i need to mark the cell with the high porosity using udf. i know i can mark cell with high velocity but its not an accurate method and there is not an option to mark cell with respect to their porosity I appreciate any help |
|
August 19, 2015, 08:34 |
|
#10 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Prepare cells to be marked by using User-Defined Memory and allocating a value of one (Boolean logic). Then mark the cells, for example where udm-0 = 1.
|
|
August 19, 2015, 09:00 |
thank you
|
#11 |
New Member
frety
Join Date: Jul 2015
Posts: 9
Rep Power: 11 |
jj fdg dsgetg ztgsfg eg stgs
Last edited by jose_zola; September 1, 2015 at 10:34. |
|
August 19, 2015, 09:46 |
|
#12 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Yes, you can separate cells which have been marked to create a new cell zone which could be switched to a porous media.
|
|
May 23, 2016, 11:38 |
|
#13 |
New Member
Join Date: Aug 2015
Posts: 10
Rep Power: 11 |
Dear fellow CFD users,
first of all I want to thank you @Amir for your support on this toppic, as I got stuck on the excact same problem and your hints were pretty useful. I managed to build my mesh out of 2 seperate meshes with openfoam and did not stitch the identical surfaces, so that i can fuse the 2 walls in fluent later to an interior to get an ID. Up to this point everything went well. I am working on a UDF that writes the temperature as a function of y and z into a text file. My case is a 3d pipe flow (flow direction is the z-axis) with an interior wall normal to the x-axis (like a cut plane). My compiled UDF is working up to the line, where I want to extract Code:
temp = C_T(c, t); Code:
Node 5: Process 6620: Received signal SIGSEGV. ============================================================================== MPI Application rank 0 exited before MPI_Finalize() with status 2 The fl process could not be started. As in this thread mentioned by others http://www.cfd-online.com/Forums/flu...sigsegv-2.html it seems that I am calling for a variable that has no value, but I've turned on the energy equation. I am pretty thankful for any advise on how to go on further, cause I've spent way to much time up to now into this case. Code:
#include "udf.h" DEFINE_EXECUTE_AT_END(cell_temp) { int i_curr_ts; FILE *f_file; char buffer[32]; Domain *d; Thread *t; cell_t c; float temp; real position[ND_ND]; float x, y, z; i_curr_ts = N_TIME; d = Get_Domain(1); snprintf(buffer, sizeof(char) * 32, "ts_%d.txt", i_curr_ts); t = Lookup_Thread(d, 4); /*Inlet: , outlet: 12 */ begin_c_loop(c, t) { temp = C_T(c, t); C_CENTROID(position, c, t); x = position[0]; y = position[1]; z = position[2]; f_file = fopen(buffer, "a"); fprintf(f_file, "X, Y, Z, %f, %f, %f, %f\n", x, y, z, temp); fclose(f_file); } end_c_loop(c, t) } Last edited by xerox; May 24, 2016 at 05:06. |
|
October 17, 2023, 01:06 |
|
#14 | |
New Member
anonymous96
Join Date: Nov 2022
Posts: 17
Rep Power: 4 |
Quote:
Hi Negin I am working on a similar problem. Can you please share your udf for ACH calculation in case you still have it? I am really stuck on it. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A Problem of Fluent Interpreted UDF: parse error | knight | Fluent UDF and Scheme Programming | 25 | August 16, 2018 11:26 |
Two questions on Fluent UDF | Steven | Fluent UDF and Scheme Programming | 7 | March 23, 2018 04:22 |
fluent UDF on linux machine | Min-Hua Wang | Fluent UDF and Scheme Programming | 6 | June 29, 2013 09:41 |
fluent UDF external library lapack problem | Rick | FLUENT | 0 | May 7, 2008 11:16 |
Can somebody send me a Fluent 6 UDF manual?? | KKLAU | FLUENT | 4 | April 14, 2004 17:37 |