def acceptMPM(self, istep): if (istep % self.couplingStep == 0): #gettin nlocalfaces from MPM ( len(nlocalfaces) = remote_comm_world.size() ) print "self.nfaces = ", self.nfaces self.FVM_COMM_MPM.Allgather([None, MPI.INT], [self.nfaces, MPI.INT]) print "self.nfaces = ", self.nfaces #count count = self.nfaces * 4 * 3 # each face has four nodes and three coordinates #displ displ = zeros(len(count), dtype='i') #filling displ displ[0] = 0 for i in range(1, len(count)): displ[i] = displ[i - 1] + count[i - 1] #creating fvm array SIZE = int(self.nfaces.sum() * 4) self.faceNodesCoord = self.geomField.coordinate[ self.mesh.getCells()].newSizedClone(SIZE) self.FVM_COMM_MPM.Allgatherv( [None, 0, 0, MPI.DOUBLE], [self.faceNodesCoord.asNumPyArray(), count, displ, MPI.DOUBLE]) print "MPI_RANK = ", MPI.COMM_WORLD.Get_rank( ), " faceNodes coord = ", self.faceNodesCoord.asNumPyArray() if (self.isUnitConversion[0] == 1): self.faceNodesCoord.asNumPyArray( )[:, :] = self.faceNodesCoord.asNumPyArray()[:, :] / 1000.0 #creating meshList #self.surfaceMeshes= fvmbaseExt.MeshList( fvmbaseExt.Mesh(3,99,self.faceNodesCoord) ); self.surfaceMeshes = [fvmbaseExt.Mesh(3, 99, self.faceNodesCoord)] #self.surfaceMesh = fvmbaseExt.Mesh(3,99,self.faceNodesCoord) #count count = self.nfaces * 3 #displ displ = zeros(len(count), dtype='i') #filling displ displ[0] = 0 for i in range(1, len(count)): displ[i] = displ[i - 1] + count[i - 1] #creating fvm array SIZE = int(self.nfaces.sum()) self.FaceCentroidVels = self.geomField.coordinate[ self.mesh.getCells()].newSizedClone(SIZE) self.FVM_COMM_MPM.Allgatherv([None, 0, 0, MPI.DOUBLE], [ self.FaceCentroidVels.asNumPyArray(), count, displ, MPI.DOUBLE ]) if MPI.COMM_WORLD.Get_rank() == 0: self.dump_faces(self.faceNodesCoord.asNumPyArray(), self.FaceCentroidVels.asNumPyArray()) print "facecentroidvels = ", self.FaceCentroidVels.asNumPyArray( ), " rank = ", MPI.COMM_WORLD.Get_rank()
def makeMesh(self): nodeCoordsN = models.newVec3Array(self.nNodes) nodeCoordsA = nodeCoordsN.asNumPyArray() for n in range(self.nNodes): nodeCoordsA[n,0] = self.nodes[n].x nodeCoordsA[n,1] = self.nodes[n].y nodeCoordsA[n,2] = self.nodes[n].z nFaceZones = 7 faceGroupCountN = fvmbaseExt.newIntArray(nFaceZones) faceGroupCount = faceGroupCountN.asNumPyArray() #interior faces faceGroupCount[0] = len(self.interiorFaces) #xmin faces faceGroupCount[1] = len(self.xminFaces) #xmax faces faceGroupCount[2] = len(self.xmaxFaces) #ymin faces faceGroupCount[3] = len(self.yminFaces) #ymax faces faceGroupCount[4] = len(self.ymaxFaces) #zmin faces faceGroupCount[5] = len(self.zminFaces) #zmax faces faceGroupCount[6] = len(self.zmaxFaces) ## allocate arrays for face nodes and cells faceNodeCountN = fvmbaseExt.newIntArray(self.nFaces) faceNodesN = fvmbaseExt.newIntArray(self.nFaces*4) faceCellsN = fvmbaseExt.newIntArray(self.nFaces*2) faceNodesA = faceNodesN.asNumPyArray() faceCellsA = faceCellsN.asNumPyArray() faceNodeCountA = faceNodeCountN.asNumPyArray() faceNodeCountA[:] = 4 ## reshape for convenience faceNodes = faceNodesA.reshape((self.nFaces,4)) faceCells = faceCellsA.reshape((self.nFaces,2)) nf = 0 for f in self.interiorFaces: faceNodes[nf,0] = f.nodes[0].nID faceNodes[nf,1] = f.nodes[1].nID faceNodes[nf,2] = f.nodes[2].nID faceNodes[nf,3] = f.nodes[3].nID faceCells[nf,0] = f.cell0.cID faceCells[nf,1] = f.cell1.cID nf = nf + 1 for f in self.xminFaces: faceNodes[nf,0] = f.nodes[0].nID faceNodes[nf,1] = f.nodes[1].nID faceNodes[nf,2] = f.nodes[2].nID faceNodes[nf,3] = f.nodes[3].nID faceCells[nf,0] = f.cell0.cID faceCells[nf,1] = f.cell1.cID nf = nf + 1 for f in self.xmaxFaces: faceNodes[nf,0] = f.nodes[0].nID faceNodes[nf,1] = f.nodes[1].nID faceNodes[nf,2] = f.nodes[2].nID faceNodes[nf,3] = f.nodes[3].nID faceCells[nf,0] = f.cell0.cID faceCells[nf,1] = f.cell1.cID nf = nf + 1 for f in self.yminFaces: faceNodes[nf,0] = f.nodes[0].nID faceNodes[nf,1] = f.nodes[1].nID faceNodes[nf,2] = f.nodes[2].nID faceNodes[nf,3] = f.nodes[3].nID faceCells[nf,0] = f.cell0.cID faceCells[nf,1] = f.cell1.cID nf = nf + 1 for f in self.ymaxFaces: faceNodes[nf,0] = f.nodes[0].nID faceNodes[nf,1] = f.nodes[1].nID faceNodes[nf,2] = f.nodes[2].nID faceNodes[nf,3] = f.nodes[3].nID faceCells[nf,0] = f.cell0.cID faceCells[nf,1] = f.cell1.cID nf = nf + 1 for f in self.zminFaces: faceNodes[nf,0] = f.nodes[0].nID faceNodes[nf,1] = f.nodes[1].nID faceNodes[nf,2] = f.nodes[2].nID faceNodes[nf,3] = f.nodes[3].nID faceCells[nf,0] = f.cell0.cID faceCells[nf,1] = f.cell1.cID nf = nf + 1 for f in self.zmaxFaces: faceNodes[nf,0] = f.nodes[0].nID faceNodes[nf,1] = f.nodes[1].nID faceNodes[nf,2] = f.nodes[2].nID faceNodes[nf,3] = f.nodes[3].nID faceCells[nf,0] = f.cell0.cID faceCells[nf,1] = f.cell1.cID nf = nf + 1 pdb.set_trace() return fvmbaseExt.Mesh(3, self.nCells, nodeCoordsN, faceCellsN, faceNodesN, faceNodeCountN, faceGroupCountN)
def generate2DMesh(la, lb, ta, tb, tc, nxa, nxb, nxc, nya, nyb): # number of cells imax = 2 * (nxa + nxc) + nxb jmax = nya + nyb # cell lengths in x and y dx = numpy.zeros(shape=(imax, ), dtype='double') dy = numpy.zeros(shape=(jmax, ), dtype='double') dxa = la / nxa dxb = lb / nxb dxc = tc / nxc dx[0:nxa] = dxa dx[nxa:nxa + nxc] = dxc dx[nxa + nxc:nxa + nxc + nxb] = dxb dx[nxa + nxc + nxb:nxa + 2 * nxc + nxb] = dxc dx[nxa + 2 * nxc + nxb:] = dxa dya = ta / nya dyb = tb / nyb dy[0:nya] = dya dy[nya:] = dyb xcoord = numpy.zeros(shape=(imax + 1, ), dtype='double') ycoord = numpy.zeros(shape=(jmax + 1, ), dtype='double') xcoord[0] = ycoord[0] = 0 for i in range(0, imax): xcoord[i + 1] = xcoord[i] + dx[i] for j in range(0, jmax): ycoord[j + 1] = ycoord[j] + dy[j] ## move the x centroid to center of beam xmax = xcoord[imax] xcoord[:] -= xmax / 2.0 # this will store the node index in the mesh for the cartesian node location nodeIndex = numpy.zeros(shape=(imax + 1, jmax + 1), dtype='int') nodeIndex[:, :] = -1 nNodes = 0 ## mark nodes in left anchor for j in range(0, nya + 1): for i in range(0, nxa + nxc + 1): if nodeIndex[i, j] == -1: nodeIndex[i, j] = nNodes nNodes += 1 ## mark nodes in beam for j in range(nya, jmax + 1): for i in range(nxa, nxa + 2 * nxc + nxb + 1): if nodeIndex[i, j] == -1: nodeIndex[i, j] = nNodes nNodes += 1 ## mark nodes in right anchor for j in range(0, nya + 1): for i in range(nxa + nxc + nxb, imax + 1): if nodeIndex[i, j] == -1: nodeIndex[i, j] = nNodes nNodes += 1 nodeCoordsN = models.newVec3Array(nNodes) nodeCoordsA = nodeCoordsN.asNumPyArray() nodeCoordsA[:, 2] = 0. for i in range(0, imax + 1): for j in range(0, jmax + 1): ni = nodeIndex[i, j] if (ni >= 0): nodeCoordsA[ni, 0] = xcoord[i] nodeCoordsA[ni, 1] = ycoord[j] # this will store the cell index in the mesh for the cartesian cell location cellIndex = numpy.zeros(shape=(imax, jmax), dtype='int') cellIndex[:, :] = -1 nCells = 0 ## mark cells in left anchor for j in range(0, nya): for i in range(0, nxa + nxc): if cellIndex[i, j] == -1: cellIndex[i, j] = nCells nCells += 1 ## mark cells in beam for j in range(nya, jmax): for i in range(nxa, nxa + 2 * nxc + nxb): if cellIndex[i, j] == -1: cellIndex[i, j] = nCells nCells += 1 ## mark cells in right anchor for j in range(0, nya): for i in range(nxa + nxc + nxb, imax): if cellIndex[i, j] == -1: cellIndex[i, j] = nCells nCells += 1 nFacesInterior = 0 ## interior faces of left and right anchors nFacesInterior += (nxa + nxc - 1) * nya + (nya - 1) * (nxa + nxc) nFacesInterior += (nxa + nxc - 1) * nya + (nya - 1) * (nxa + nxc) ## interior faces of beam nFacesInterior += (nxb + 2 * nxc - 1) * nyb + (nyb - 1) * (nxb + 2 * nxc) ## interior faces between anchor and beam nFacesInterior += 2 * nxc nFaceZones = 8 faceGroupCountN = fvmbaseExt.newIntArray(nFaceZones) faceGroupCount = faceGroupCountN.asNumPyArray() faceGroupCount[0] = nFacesInterior # bottom of anchors faceGroupCount[1] = 2 * (nxa + nxc) #outer sides of anchors faceGroupCount[2] = 2 * nya #inner sides of anchors faceGroupCount[3] = 2 * nya #beam bottom faceGroupCount[4] = nxb #beam top faceGroupCount[5] = nxb + 2 * nxc #beam sides faceGroupCount[6] = 2 * nyb # top of anchors faceGroupCount[7] = 2 * nxa nFaces = int(faceGroupCount.sum()) ## allocate arrays for face nodes faceNodeCountN = fvmbaseExt.newIntArray(nFaces) faceNodesN = fvmbaseExt.newIntArray(nFaces * 2) faceCellsN = fvmbaseExt.newIntArray(nFaces * 2) faceNodesA = faceNodesN.asNumPyArray() faceCellsA = faceCellsN.asNumPyArray() faceNodeCountA = faceNodeCountN.asNumPyArray() faceNodeCountA[:] = 2 ## reshape for convenience faceNodes = faceNodesA.reshape((nFaces, 2)) faceCells = faceCellsA.reshape((nFaces, 2)) # interior x faces of left anchor nf = 0 for j in range(0, nya): for i in range(0, nxa + nxc - 1): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i + 1, j + 1] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = cellIndex[i + 1, j] nf += 1 # interior y faces of left anchor for j in range(0, nya - 1): for i in range(0, nxa + nxc): faceNodes[nf, 0] = nodeIndex[i + 1, j + 1] faceNodes[nf, 1] = nodeIndex[i, j + 1] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = cellIndex[i, j + 1] nf += 1 # interior x faces of beam for j in range(nya, jmax): for i in range(nxa, nxa + 2 * nxc + nxb - 1): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i + 1, j + 1] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = cellIndex[i + 1, j] nf += 1 # interior y faces of beam for j in range(nya, jmax - 1): for i in range(nxa, nxa + 2 * nxc + nxb): faceNodes[nf, 0] = nodeIndex[i + 1, j + 1] faceNodes[nf, 1] = nodeIndex[i, j + 1] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = cellIndex[i, j + 1] nf += 1 ## interior x faces in right anchor for j in range(0, nya): for i in range(nxa + nxc + nxb, imax - 1): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i + 1, j + 1] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = cellIndex[i + 1, j] nf += 1 ## interior y faces in right anchor for j in range(0, nya - 1): for i in range(nxa + nxc + nxb, imax): faceNodes[nf, 0] = nodeIndex[i + 1, j + 1] faceNodes[nf, 1] = nodeIndex[i, j + 1] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = cellIndex[i, j + 1] nf += 1 ## left interior faces between anchor and beam j = nya for i in range(nxa, nxa + nxc): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j - 1] faceCells[nf, 1] = cellIndex[i, j] nf += 1 ## right interior faces between anchor and beam for i in range(nxa + nxc + nxb, nxa + 2 * nxc + nxb): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j - 1] faceCells[nf, 1] = cellIndex[i, j] nf += 1 nb = 0 # left anchor bottom j = 0 for i in range(0, nxa + nxc): faceNodes[nf, 0] = nodeIndex[i, j] faceNodes[nf, 1] = nodeIndex[i + 1, j] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # right anchor bottom for i in range(nxa + nxc + nxb, imax): faceNodes[nf, 0] = nodeIndex[i, j] faceNodes[nf, 1] = nodeIndex[i + 1, j] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # left anchor outer side i = 0 for j in range(0, nya): faceNodes[nf, 0] = nodeIndex[i, j + 1] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # right anchor outer side i = imax for j in range(0, nya): faceNodes[nf, 0] = nodeIndex[i, j] faceNodes[nf, 1] = nodeIndex[i, j + 1] faceCells[nf, 0] = cellIndex[i - 1, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # left anchor inner side i = nxa + nxc for j in range(0, nya): faceNodes[nf, 0] = nodeIndex[i, j] faceNodes[nf, 1] = nodeIndex[i, j + 1] faceCells[nf, 0] = cellIndex[i - 1, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # right anchor inner side i = nxa + nxc + nxb for j in range(0, nya): faceNodes[nf, 0] = nodeIndex[i, j + 1] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # beam bottom j = nya for i in range(nxa + nxc, nxa + nxc + nxb): faceNodes[nf, 0] = nodeIndex[i, j] faceNodes[nf, 1] = nodeIndex[i + 1, j] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # beam top j = nya + nyb for i in range(nxa, nxa + 2 * nxc + nxb): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j - 1] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # left beam side i = nxa for j in range(nya, nya + nyb): faceNodes[nf, 0] = nodeIndex[i, j + 1] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # right beam side i = nxa + 2 * nxc + nxb for j in range(nya, nya + nyb): faceNodes[nf, 0] = nodeIndex[i, j] faceNodes[nf, 1] = nodeIndex[i, j + 1] faceCells[nf, 0] = cellIndex[i - 1, j] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # left anchor top j = nya for i in range(0, nxa): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j - 1] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 # right anchor top for i in range(nxa + 2 * nxc + nxb, imax): faceNodes[nf, 0] = nodeIndex[i + 1, j] faceNodes[nf, 1] = nodeIndex[i, j] faceCells[nf, 0] = cellIndex[i, j - 1] faceCells[nf, 1] = nCells + nb nf += 1 nb += 1 #numpy.set_printoptions(threshold=1e8) #print faceCellsA[:] #print faceNodesA mesh = fvmbaseExt.Mesh(2, nCells, nodeCoordsN, faceCellsN, faceNodesN, faceNodeCountN, faceGroupCountN) print '2d mesh nnodes = %s' % nNodes print 'midpoint node index is %s' % nodeIndex[imax / 2, nya] return mesh
def generateBoxMesh(xmax, ymax, zmax, imax, jmax, kmax): xcoord = np.linspace(0.0, xmax, num=(imax+1)) xcoord = xcoord.astype('double') ycoord = np.linspace(0.0, ymax, num=(jmax+1)) ycoord = ycoord.astype('double') zcoord = np.linspace(0.0, zmax, num=(kmax+1)) zcoord = zcoord.astype('double') nCells = imax*jmax*kmax nodeIndex = np.zeros(shape=(imax+1,jmax+1,kmax+1), dtype='int') nNodes = 0 nodeCoordsN = models.newVec3Array((imax+1)*(jmax+1)*(kmax+1)) nodeCoordsA = nodeCoordsN.asNumPyArray() for k in range(kmax+1): for j in range(jmax+1): for i in range(imax+1): nodeIndex[i,j,k] = nNodes nodeCoordsA[nNodes,0] = xcoord[i] nodeCoordsA[nNodes,1] = ycoord[j] nodeCoordsA[nNodes,2] = zcoord[k] nNodes = nNodes + 1 cellIndex = np.zeros(shape=(imax,jmax,kmax), dtype='int') nCells = 0 for k in range(kmax): for j in range(jmax): for i in range(imax): cellIndex[i,j,k] = nCells nCells = nCells + 1 nFacesInterior = imax*jmax*(kmax-1)+imax*(jmax-1)*kmax+(imax-1)*jmax*kmax nFaceZones = 7 faceGroupCountN = fvmbaseExt.newIntArray(nFaceZones) faceGroupCount = faceGroupCountN.asNumPyArray() #interior faces faceGroupCount[0] = nFacesInterior #xmin faces faceGroupCount[1] = jmax*kmax #xmax faces faceGroupCount[2] = jmax*kmax #ymin faces faceGroupCount[3] = imax*kmax #ymax faces faceGroupCount[4] = imax*kmax #zmin faces faceGroupCount[5] = imax*jmax #zmax faces faceGroupCount[6] = imax*jmax nFaces = int(faceGroupCount.sum()) ## allocate arrays for face nodes and cells faceNodeCountN = fvmbaseExt.newIntArray(nFaces) faceNodesN = fvmbaseExt.newIntArray(nFaces*4) faceCellsN = fvmbaseExt.newIntArray(nFaces*2) faceNodesA = faceNodesN.asNumPyArray() faceCellsA = faceCellsN.asNumPyArray() faceNodeCountA = faceNodeCountN.asNumPyArray() faceNodeCountA[:] = 4 ## reshape for convenience faceNodes = faceNodesA.reshape((nFaces,4)) faceCells = faceCellsA.reshape((nFaces,2)) nf = 0 # interior x faces for i in range(1,imax): for j in range(jmax): for k in range(kmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i,j+1,k] faceNodes[nf,2] = nodeIndex[i,j+1,k+1] faceNodes[nf,3] = nodeIndex[i,j,k+1] faceCells[nf,0] = cellIndex[i,j,k] faceCells[nf,1] = cellIndex[i-1,j,k] nf = nf + 1 # interior y faces for j in range(1,jmax): for i in range(imax): for k in range(kmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i+1,j,k] faceNodes[nf,2] = nodeIndex[i+1,j,k+1] faceNodes[nf,3] = nodeIndex[i,j,k+1] faceCells[nf,0] = cellIndex[i,j-1,k] faceCells[nf,1] = cellIndex[i,j,k] nf = nf + 1 # interior z faces for k in range(1,kmax): for i in range(imax): for j in range(jmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i+1,j,k] faceNodes[nf,2] = nodeIndex[i+1,j+1,k] faceNodes[nf,3] = nodeIndex[i,j+1,k] faceCells[nf,0] = cellIndex[i,j,k] faceCells[nf,1] = cellIndex[i,j,k-1] nf = nf + 1 nb = 0 #x-boundaries i = 0 for j in range(jmax): for k in range(kmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i,j+1,k] faceNodes[nf,2] = nodeIndex[i,j+1,k+1] faceNodes[nf,3] = nodeIndex[i,j,k+1] faceCells[nf,0] = cellIndex[i,j,k] faceCells[nf,1] = nCells + nb nf = nf + 1 nb = nb + 1 i = imax for j in range(jmax): for k in range(kmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i,j,k+1] faceNodes[nf,2] = nodeIndex[i,j+1,k+1] faceNodes[nf,3] = nodeIndex[i,j+1,k] faceCells[nf,0] = cellIndex[i-1,j,k] faceCells[nf,1] = nCells + nb nf = nf + 1 nb = nb + 1 #y-boundaries j = 0 for i in range(imax): for k in range(kmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i,j,k+1] faceNodes[nf,2] = nodeIndex[i+1,j,k+1] faceNodes[nf,3] = nodeIndex[i+1,j,k] faceCells[nf,0] = cellIndex[i,j,k] faceCells[nf,1] = nCells + nb nf = nf + 1 nb = nb + 1 j = jmax for i in range(imax): for k in range(kmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i+1,j,k] faceNodes[nf,2] = nodeIndex[i+1,j,k+1] faceNodes[nf,3] = nodeIndex[i,j,k+1] faceCells[nf,0] = cellIndex[i,j-1,k] faceCells[nf,1] = nCells + nb nf = nf + 1 nb = nb + 1 #z-boundaries k = 0 for i in range(imax): for j in range(jmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i+1,j,k] faceNodes[nf,2] = nodeIndex[i+1,j+1,k] faceNodes[nf,3] = nodeIndex[i,j+1,k] faceCells[nf,0] = cellIndex[i,j,k] faceCells[nf,1] = nCells + nb nf = nf + 1 nb = nb + 1 k = kmax for i in range(imax): for j in range(jmax): faceNodes[nf,0] = nodeIndex[i,j,k] faceNodes[nf,1] = nodeIndex[i,j+1,k] faceNodes[nf,2] = nodeIndex[i+1,j+1,k] faceNodes[nf,3] = nodeIndex[i+1,j,k] faceCells[nf,0] = cellIndex[i,j,k-1] faceCells[nf,1] = nCells + nb nf = nf + 1 nb = nb + 1 mesh = fvmbaseExt.Mesh(3, nCells, nodeCoordsN, faceCellsN, faceNodesN, faceNodeCountN, faceGroupCountN) return mesh