<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'><style>p { margin: 0; }</style><div style="font-family: Times New Roman; font-size: 12pt; color: #000000">Hello,<br><br><hr id="zwchr"><blockquote id="DWT6756" style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;">Hi Iulian,<br><br>I'll try and give an explanation of what I am doing a bit better. &nbsp;Basically, I import a mesh as a VTK. When a face meets a condition for crack insertion it is marked in a tag. Then I go about re-arranging the mesh. &nbsp;At this point I have put all the elements into a meshset.<br><br>When splitting the faces I duplicate the nodes I require to (not all nodes on the face are necessarily duplicated) and I change the connectivity of the tets, faces and edges. &nbsp;I do this in the code shown below.<br><br>MBRange entities=side_elems;<br>result = moab-&gt;get_adjacencies(side_elems,2,true,side_elems_faces,MBInterface::UNION);<br>entities.merge(side_elems_faces);<br>MBRange side_elems_edges;<br>result = moab-&gt;get_adjacencies(side_elems,1,true,side_elems_edges,MBInterface::UNION);<br>entities.merge(side_elems_edges);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>for(MBRange::iterator eit=entities.begin(); eit!=entities.end(); eit++){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const MBEntityHandle* conn;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int nb_nodes;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;get_connectivity(*eit,conn,nb_nodes);RR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBEntityHandle new_conn[nb_nodes];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int ii=0;ii&lt;nb_nodes;ii++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(conn[ii]==old_node) new_conn[ii] = new_node;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else new_conn[ii] = conn[ii];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;set_connectivity(*eit,new_conn,nb_nodes);RR //Set new connectivity<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;remove_adjacencies(*eit,&amp;old_node,1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;remove_adjacencies(old_node,&amp;*eit,1);<br>}<br><br></blockquote>So, in this piece of code, you are trying to replace one old_node with the new_node. When you set_connectivity(*eit, new_conn, ...), the up-vertex adjacencies are adjusted too, you do not have to "remove adjacency". These "removes" have no effect. I assume new_node is created already, and it is in a position close to old_node (moab does not do any quality checks at this point)<br>You could get the same effect of this code by:<br>1) get all entities adjacent to old_node&nbsp; (with create flag true, if you need to)<br>2) do the for loop over those entities only<br>Your entities range contain all faces, edges, elements in "side_elems" range (overkill)<br><blockquote id="DWT6757" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">With this change in connectivity some adjacencies are no longer physically able to be in the mesh so this is where I try and change things by removing adjacencies. To do this I use the following code.<br><br></blockquote>I don't think there is anything to remove at his point. The only thing you can remove (actually delete) here is old_node, it is free at this point.<br><blockquote id="DWT6758" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">MBRange other_side_elems = subtract(elems,side_elems);<br>for(MBRange::iterator eit = other_side_elems.begin();eit!=other_side_elems.end();eit++){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBRange other_side_elems_nodes;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;get_connectivity(&amp;*eit,1,other_side_elems_nodes); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(MBRange::iterator fit = side_elems_faces.begin();fit!=side_elems_faces.end();fit++){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBRange face_nodes;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;get_connectivity(&amp;*fit,1,face_nodes);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBRange intersect_nodes = intersect(face_nodes,other_side_elems_nodes);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assert(intersect_nodes.size()&lt;=6);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(intersect_nodes.size()!=6){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;remove_adjacencies(*eit,&amp;*fit,1);RR <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;remove_adjacencies(*fit,&amp;*eit,1);RR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBRange test1,test2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moab-&gt;get_adjacencies(&amp;*eit,1,2,false,test1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moab-&gt;get_adjacencies(&amp;*fit,1,3,false,test2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(MBRange::iterator fit = side_elems_edges.begin();fit!=side_elems_edges.end();fit++){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBRange edge_nodes;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;get_connectivity(&amp;*fit,1,edge_nodes);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBRange intersect_nodes = intersect(edge_nodes,other_side_elems_nodes);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assert(intersect_nodes.size()&lt;=3);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(intersect_nodes.size()!=3){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;remove_adjacencies(*eit,&amp;*fit,1);RR <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result = moab-&gt;remove_adjacencies(*fit,&amp;*eit,1);RR <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MBRange test1,test2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moab-&gt;get_adjacencies(&amp;*eit,1,2,false,test1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;moab-&gt;get_adjacencies(&amp;*fit,1,3,false,test2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>Obviously there are dependencies and things that I am not showing but without showing my whole code which is quite big I couldn't really do this. &nbsp;Hopefully this has given you some more clarity on what I am doing.<br><br>Regards<br><br>Graeme<br></blockquote>So I really don't get this second part of the code. You did not duplicate yet any face or edge.<br><br>Let's assume that you have this simple model, 2 quads, 1452, 2563 with 6 nodes<br>&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 <br>&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<br>You want to add a crack at 25, so you want to end up something like this<br><br>&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp; 2 2'&nbsp;&nbsp;&nbsp;&nbsp; 3<br>&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<br><br>You first create a new node, 2'. This node is, so far, free as a bird :)<br><br>Then you set_conn for the right element, set_conn ..( qr, 5632', ...)<br><br>If you have no edges created in advance, you are done. <br><br>If edge 25 was created in advance, you may want to also create edge 2'5 (with create_element method, or with get_adjacent methods, create flag true).<br><br>Node 2' will not be connected at all with element on the left (4521), and node 2 will not be connected to element on the right. You will have a crack! <br><br>Another note: in the above example, let's say that&nbsp; Range elems has 2 elements, those initial 2 quads<br>when you request edges adjacent to them with a code like<br>result = moab-&gt;get_adjacencies(elems,1,true,elems_edges,MBInterface::UNION);<br>elem_edges will have exactly 7 edges: 14, 12, 45, 25, 56, 36, 23<br>So edge 25 is not repeated, there is only one edge that connects 2 and 5. But it will be adjacent to both elements. Maybe your misunderstanding starts from here.<br><br>At the same time, if you call that code after setting new connectivity on the element on the right, your elem_edges will have exactly 8 edges!<br>(because you will have an extra edge, 2'5)<br><br><br>You may want to look over "merge" methods. It is, in a way, the opposite of what you try to achieve, but it may give you a better understanding.<br><br><br>
I hope this helps.<br><br>Iulian<br><br><br></div></div></body></html>