def setNodes(self, indices, coords, peOwners=None): """ Set the nodal coordinates @param indices Ids of the nodes (0-based) @param coords nodal coordinates @param peOwners processor ranks where the coordinates reside (0-based) """ n = len(indices) if not self.nodesAdded: if peOwners is None: peOwners = numpy.ones((n,), numpy.int32) * self.pe # node indices are 1-based indices += 1 ESMP.ESMP_MeshAddNodes(self.grid, n, indices, coords, peOwners) self.nodesAdded = True
def mesh_create_3x3(mesh): ''' PRECONDITIONS: An ESMP_Mesh has been declared. POSTCONDITIONS: A 3x3 ESMP_Mesh has been created. 3x3 Mesh 3.0 2.0 13 -------14 --------15--------16 | | | | | 7 | 8 | 9 | | | | | 2.5 1.5 9 ------- 10 --------11--------12 | | | | | 4 | 5 | 6 | | | | | 1.5 0.5 5 ------- 6 -------- 7-------- 8 | | | | | 1 | 2 | 3 | | | | | 1.0 0.0 1 ------- 2 -------- 3-------- 4 0.0 0.5 1.5 2.0 1.0 1.5 2.5 3.0 Node Ids at corners Element Ids in centers (Everything owned by PET 0) ''' # set up a simple mesh num_node = 16 num_elem = 9 nodeId = _NP.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]) ''' # this is for grid to mesh nodeCoord = _NP.array([1.0,1.0, 1.5,1.0, 2.5,1.0, 3.0,1.0, 1.0,1.5, 1.5,1.5, 2.5,1.5, 3.0,1.5, 1.0,2.5, 1.5,2.5, 2.5,2.5, 3.0,2.5, 1.0,3.0, 1.5,3.0, 2.5,3.0, 3.0,3.0]) ''' # this is for mesh to grid nodeCoord = _NP.array([0.0,0.0, 1.5,0.0, 2.5,0.0, 4.0,0.0, 0.0,1.5, 1.5,1.5, 2.5,1.5, 4.0,1.5, 0.0,2.5, 1.5,2.5, 2.5,2.5, 4.0,2.5, 0.0,4.0, 1.5,4.0, 2.5,4.0, 4.0,4.0]) nodeOwner = _NP.zeros(num_node, dtype=_NP.int32) elemId = _NP.array([1,2,3,4,5,6,7,8,9], dtype=_NP.int32) elemType = _NP.ones(num_elem, dtype=_NP.int32) elemType*=ESMP.ESMP_MESHELEMTYPE_QUAD elemConn = _NP.array([0,1,5,4, 1,2,6,5, 2,3,7,6, 4,5,9,8, 5,6,10,9, 6,7,11,10, 8,9,13,12, 9,10,14,13, 10,11,15,14], dtype=_NP.int32) ESMP.ESMP_MeshAddNodes(mesh,num_node,nodeId,nodeCoord,nodeOwner) ESMP.ESMP_MeshAddElements(mesh,num_elem,elemId,elemType,elemConn) #print 'Mesh coordinates:' for i in range(num_node): x = nodeCoord[2*i] y = nodeCoord[2*i+1] #print '[{0},{1}]'.format(x, y) #print '\n' return mesh, nodeCoord, elemType, elemConn