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

Determining the cell neighbours for a given node

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 4, 2018, 16:39
Default Determining the cell neighbours for a given node
  #1
New Member
 
Join Date: Jun 2015
Posts: 7
Rep Power: 11
t4leung is on a distinguished road
I was wondering, is there a fluent macro for looping over all the cells adjacent to a given node? Thanks in advance
t4leung is offline   Reply With Quote

Old   December 4, 2018, 22:10
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
how do you know the node?

lets imagine, you know it, so you may make a loop over all cells and find, where your node is located. If nodes matches this is your node.

From Ansys Fluent Customization manual
Code:
/* Store the mesh node coordinates in user-defined node memory */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
c_node_loop (c,t,n)
{
v = C_NODE(c,t,n);
N_UDMI(v,0) = NODE_X(v);
N_UDMI(v,1) = NODE_Y(v);
#if RP_3D
N_UDMI(v,2) = NODE_Z(v);
#endif
}
}
end_c_loop (c,t)
}
best regards
AlexanderZ is offline   Reply With Quote

Old   December 4, 2018, 23:38
Default
  #3
New Member
 
Join Date: Jun 2015
Posts: 7
Rep Power: 11
t4leung is on a distinguished road
I guess what I would like to do is the opposite of c_node_loop(c,t,n). For a given cell, c_node_loop will loop over all the common nodes with that cell. For a given node, is there an easy way to identify all the cells that are common to that node?
t4leung is offline   Reply With Quote

Old   December 4, 2018, 23:53
Default
  #4
New Member
 
Join Date: Jun 2015
Posts: 7
Rep Power: 11
t4leung is on a distinguished road
One idea I had was to define a structure that stored the adjacent cell IDs. I would have an array of these structs and I could use the cell and node loops to identify which cells were associated with each node. However, for a given node ID, I want to know the adjacent cell IDs and I can't see how I can do this with my approach.

typedef struct NODE_ADJACENT{
Node *v;
cell_t c_adj[4];
int total_adj;
} node_cellneighbour;

node_cellneighbour n1[count];

#if RP_NODE
int i = 0;
thread_loop_c(t,d)
{
begin_c_loop_int(c,t)
{
c_node_loop(c,t,n)
{
n1[i].v = C_NODE(c,t,n);
n1[i].c_adj[n1[i].total_adj] = c;
n1[i].total_adj = n1[i].total_adj + 1;

i++;
}

}
end_c_loop_int(c,t)
}
#endif
t4leung is offline   Reply With Quote

Old   December 6, 2018, 23:45
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
This code is not working? that looks good.
What data is stored in your array?
Try to debug on single core first, if you are using fluent version less than 19.0
also begin_c_loop_int macro is very specific, you should check is it suitable for your case or not.

Use Ansys Fluent Customization manual for for information

best regards
AlexanderZ is offline   Reply With Quote

Old   October 19, 2020, 10:37
Default
  #6
New Member
 
Andrew
Join Date: Feb 2014
Location: Russia
Posts: 20
Rep Power: 12
Antech is on a distinguished road
The code above will just collect arrays of Node structure pointers for each cell's neighbor nodes. It will not identify nodes. I googled for the topic and found that there is no solution on the Internet. I can propose the simple "dirty" method of finding node IDs, don't know if they are local for current thread (mesh partition) or for the entire domain. If we look at Fluent's user header files we'll find that node_struct is declared in mem_grid.h and there are cxindex id and int idx fields in this struct. I didn't further into cxindex struct, but idx is not just "1, 2, 3" but looks node index or ID. Strange that there is no macro for this, so you can use it, but it's not guaranteed to work in all Fluent versions. We use old 14 and 16 versions, so may not work in newer versions. And don't forget to check what happens in parallel mode. (Node ID or index will be just v->idx with this method)
Antech is offline   Reply With Quote

Old   October 20, 2020, 05:09
Default
  #7
New Member
 
Andrew
Join Date: Feb 2014
Location: Russia
Posts: 20
Rep Power: 12
Antech is on a distinguished road
Checked for the idx if it's global or for current partition. It's for current partition, so it changes from 0 to some value around NumberOfCells/NumberOfPartitions. For Fluent release 16.
Antech 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
Node and cell in cell centred system lucamirtanini Main CFD Forum 20 November 24, 2018 07:36
Export velocity in node or in cell center jpina FLUENT 2 November 6, 2015 13:42
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
The fluent stopped and errors with "Emergency: received SIGHUP signal" yuyuxuan FLUENT 0 December 3, 2013 23:56
node values or cell values? aPpA FLUENT 0 November 10, 2006 09:56


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