<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. 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. 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. I do this in the code shown below.<br><br>MBRange entities=side_elems;<br>result = moab->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->get_adjacencies(side_elems,1,true,side_elems_edges,MBInterface::UNION);<br>entities.merge(side_elems_edges); <br>for(MBRange::iterator eit=entities.begin(); eit!=entities.end(); eit++){ <br> const MBEntityHandle* conn;<br> int nb_nodes;<br> result = moab->get_connectivity(*eit,conn,nb_nodes);RR<br> MBEntityHandle new_conn[nb_nodes];<br> for(int ii=0;ii<nb_nodes;ii++)<br> {<br> if(conn[ii]==old_node) new_conn[ii] = new_node;<br> else new_conn[ii] = conn[ii];<br> }<br> result = moab->set_connectivity(*eit,new_conn,nb_nodes);RR //Set new connectivity<br> result = moab->remove_adjacencies(*eit,&old_node,1);<br> result = moab->remove_adjacencies(old_node,&*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 (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> MBRange other_side_elems_nodes;<br> result = moab->get_connectivity(&*eit,1,other_side_elems_nodes); <br> for(MBRange::iterator fit = side_elems_faces.begin();fit!=side_elems_faces.end();fit++){<br> MBRange face_nodes;<br> result = moab->get_connectivity(&*fit,1,face_nodes);<br> MBRange intersect_nodes = intersect(face_nodes,other_side_elems_nodes);<br> assert(intersect_nodes.size()<=6);<br> if(intersect_nodes.size()!=6){<br> result = moab->remove_adjacencies(*eit,&*fit,1);RR <br> result = moab->remove_adjacencies(*fit,&*eit,1);RR<br> }<br> MBRange test1,test2;<br> moab->get_adjacencies(&*eit,1,2,false,test1);<br> moab->get_adjacencies(&*fit,1,3,false,test2);<br> }<br> for(MBRange::iterator fit = side_elems_edges.begin();fit!=side_elems_edges.end();fit++){<br> MBRange edge_nodes;<br> result = moab->get_connectivity(&*fit,1,edge_nodes);<br> MBRange intersect_nodes = intersect(edge_nodes,other_side_elems_nodes);<br> assert(intersect_nodes.size()<=3);<br> if(intersect_nodes.size()!=3){<br> result = moab->remove_adjacencies(*eit,&*fit,1);RR <br> result = moab->remove_adjacencies(*fit,&*eit,1);RR <br> }<br> MBRange test1,test2;<br> moab->get_adjacencies(&*eit,1,2,false,test1);<br> moab->get_adjacencies(&*fit,1,3,false,test2);<br> }<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. 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> 1 2 3 <br> 4 5 6<br>You want to add a crack at 25, so you want to end up something like this<br><br> 1 2 2' 3<br> 4 5 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 Range elems has 2 elements, those initial 2 quads<br>when you request edges adjacent to them with a code like<br>result = moab->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>