|
[Sponsors] |
January 30, 2019, 23:57 |
[UDF] Find and save the cells in a region
|
#1 |
New Member
zacTee
Join Date: Jan 2019
Posts: 2
Rep Power: 0 |
Hi everyone. I have a problem in the udf (FLUENT) and dont know how to start it.
I want to find a particular group of cells, i.e. located by coordinates in a cylinder region, and save these cells' index (or threads?) for further uses. Now I think I am surposed to use: begin_c_loop_int(cc,tc) C_CENTROID(xrc,cc,tc); if xrc<=... { Record cc. How to record all the cells in a variable? } end_c_loop_int(cc,tc) Moreover, if I have the cell group cc, how can I get the thread of these recorded cells? So I can allocate memory and define sources to these cells... Thank you in advance! |
|
January 31, 2019, 01:56 |
|
#2 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
Quote:
cell_t *DimensionToStore=NULL; int total_cells=0, cell_index; begin_c_loop_int(cc,tc) C_CENTROID(xrc,cc,tc); if xrc<=... { total_cells++; } end_c_loop_int(cc,tc) DimensionToStore=(cell_t*)malloc(total_cells*sizeo f(cell_t)); cell_index=0; begin_c_loop_int(cc,tc) C_CENTROID(xrc,cc,tc); if xrc<=... { DimensionToStore[cell_index]=cc; cell_index++; } end_c_loop_int(cc,tc) Now DimensionToStore is ready for use. Do not forget to free it since it is a dynamic dimension, otherwise memory leakage will occur. |
||
January 31, 2019, 02:03 |
|
#3 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
Quote:
DimensionToStore=new cell_t[total_cells]; ... delete[] imensionToStore; |
||
January 31, 2019, 03:19 |
|
#4 | |
New Member
zacTee
Join Date: Jan 2019
Posts: 2
Rep Power: 0 |
Quote:
Thank you Gearboy! Thats really helpful. Now given the DimensionToStore which stores the cell index, can I use any loop macro to loop on all these cells? Something like: begin_c_loop_int(DimensionToStore) ... end_c_loop_int(DimensionToStore) |
||
Tags |
fluent;udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] preserveFaceZones constraint on a multi region mesh | ViktorKL | OpenFOAM Meshing & Mesh Conversion | 5 | May 21, 2019 12:45 |