determine whether nodes are connected

50 views
Skip to first unread message

Marie Backman

unread,
Apr 23, 2015, 4:04:04 PM4/23/15
to moose...@googlegroups.com
Hi all,
For a mesh with 8-node bricks, is there a way to determine whether two nodes are connected, i.e. share an element edge? I can use _mesh.nodeToElemMap() to find out whether two nodes belong to the same element, but I would need information about the edges.

Thanks!
Marie

Cody Permann

unread,
Apr 23, 2015, 4:24:13 PM4/23/15
to moose...@googlegroups.com
There are lots of useful tools for getting information about neighbors in at least two places in the libMesh API:
First on the "Elem" objects themselves:
Looks for all the "neighbors" methods: "find_point_neighbors, find_edge_neighbors, etc"

Secondly, look at the tools in the MeshTools namespace:

The method I suggest that you take a look at is MeshTools::find_nodal_neighbors(). It'll give you back all of the nodes that connect to the one you pass in. The only tricky part to using that method is that you need to build a "nodes_to_elem_map" first that you have to supply as a parameter. You can do that with MeshTools::build_nodes_to_elem_map().

I've implemented all of this in the FeatureFloodCount object if you want to take a look:
modules/phase_field/src/postprocessors/FeatureFloodCount.C

Hopefully that helps,
Cody



--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at http://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/CA%2B7juhvwAqWFe2nZzFjkGAQLpQzOW%2B4SmVPcRYBO3wD3qLJBDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Peterson, JW

unread,
Apr 23, 2015, 4:57:29 PM4/23/15
to moose-users

On Thu, Apr 23, 2015 at 2:04 PM, Marie Backman <marie....@gmail.com> wrote:
Hi all,
For a mesh with 8-node bricks, is there a way to determine whether two nodes are connected, i.e. share an element edge? I can use _mesh.nodeToElemMap() to find out whether two nodes belong to the same element, but I would need information about the edges.

Hmm... if you have an Elem* and two local node numbers, n1 and n2, then for each edge_num you can check:

elem->is_node_on_edge(n1, edge_num) && elem->is_node_on_edge(n2, edge_num)

Alternatively, you could build a std::set of valid (n1,n2) pairs ahead of time (see Hex8::edge_nodes_map in libmesh/src/geom/cell_hex8.C) and search in that if you find the linear search is too slow. 

-- 
John

Marie Backman

unread,
Apr 23, 2015, 5:11:41 PM4/23/15
to moose...@googlegroups.com
Thanks for the suggestions, Cody and John! This should get me started.

Marie

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at http://groups.google.com/group/moose-users.

Derek Gaston

unread,
Apr 23, 2015, 5:15:50 PM4/23/15
to moose...@googlegroups.com
Be aware that build_nodes_to_elem_map() is very slow and uses a lot of memory. Also, if you are storing its output it's up to you to make sure to keep it in sync with the adapting mesh.

I would recommend staying away from that if you can.

Derek
Reply all
Reply to author
Forward
0 new messages