Given a mesh from triangle, returns nodes, (mesh's ['vertices']) and conn, a set of elements defined by their node ID's, eg, nodes = [[ 0.0, 0.0], [10.0, 0.0], [10.0, 1.0], ... ] conn = {(0, 3), (0, 18), (
(self, triangle_mesh)
| 37 | return (i,j) if i < j else (j,i) |
| 38 | # }}} |
| 39 | def connectivity(self, triangle_mesh): # {{{ |
| 40 | """ |
| 41 | Given a mesh from triangle, returns nodes, (mesh's ['vertices']) |
| 42 | and conn, a set of elements defined by their node ID's, eg, |
| 43 | nodes = [[ 0.0, 0.0], |
| 44 | [10.0, 0.0], |
| 45 | [10.0, 1.0], ... ] |
| 46 | conn = {(0, 3), |
| 47 | (0, 18), |
| 48 | (1, 2), |
| 49 | (1, 30), ... } |
| 50 | Node ID's begin with 0. |
| 51 | """ |
| 52 | conn = [] |
| 53 | for i,j,k in triangle_mesh['triangles']: |
| 54 | conn.append( self.ascending(i, j) ) # add node ID tuples in |
| 55 | conn.append( self.ascending(j, k) ) # ascending order so that |
| 56 | conn.append( self.ascending(i, k) ) # set() removes duplicates |
| 57 | conn = set(conn) # remove duplicates |
| 58 | return triangle_mesh['vertices'], conn |
| 59 | # }}} |
| 60 | def __init__(self, triangle_mesh): # {{{ |
| 61 | self.E = 10.0e6 # psi |