Ejemplo n.º 1
0
    def addFace(self, du, dv, d, ru=0.5, rv=0.5):
        """ Creates a set of rectangular surfaces, their IDs, and face dims.
        nu,nv: number of surfaces in the u and v directions
        du,dv: {1,2,3} maps to {x,y,z}; negative sign means reverse order
        d: position of the surfaces in the remaining coordinate axis
        ru,rv: surfaces span -ru to +ru in u dir. and -rv to +rv in v dir.

        Adds to self.Ps and self.Ks
        """
        self.faces.append([du, dv])
        nP = 10
        ni = self.ms[abs(du) - 1].shape[0]
        nj = self.ms[abs(dv) - 1].shape[0]
        verts = numpy.zeros((2, 2, 3), order="F")
        verts[:, :, :] = d
        verts[0, :, abs(du) - 1] = -ru * numpy.sign(du)
        verts[1, :, abs(du) - 1] = ru * numpy.sign(du)
        verts[:, 0, abs(dv) - 1] = -rv * numpy.sign(dv)
        verts[:, 1, abs(dv) - 1] = rv * numpy.sign(dv)
        for j in range(nj):
            for i in range(ni):
                self.Ps.append(PAMlib.bilinearinterp(nP, ni, nj, i + 1, j + 1, verts))

        if len(self.Ks) > 0:
            counter = numpy.max(self.Ks[-1]) + 1
        else:
            counter = 0
        K = numpy.zeros((ni, nj), int)
        for j in range(nj):
            for i in range(ni):
                K[i, j] = counter
                counter += 1
        self.Ks.append(K)
Ejemplo n.º 2
0
    def addFace(self, du, dv, d, ru=0.5, rv=0.5):
        """ Creates a set of rectangular surfaces, their IDs, and face dims.
        nu,nv: number of surfaces in the u and v directions
        du,dv: {1,2,3} maps to {x,y,z}; negative sign means reverse order
        d: position of the surfaces in the remaining coordinate axis
        ru,rv: surfaces span -ru to +ru in u dir. and -rv to +rv in v dir.

        Adds to self.Ps and self.Ks
        """
        self.faces.append([du, dv])
        nP = 10
        ni = self.ms[abs(du) - 1].shape[0]
        nj = self.ms[abs(dv) - 1].shape[0]
        verts = numpy.zeros((2, 2, 3), order='F')
        verts[:, :, :] = d
        verts[0, :, abs(du) - 1] = -ru * numpy.sign(du)
        verts[1, :, abs(du) - 1] = ru * numpy.sign(du)
        verts[:, 0, abs(dv) - 1] = -rv * numpy.sign(dv)
        verts[:, 1, abs(dv) - 1] = rv * numpy.sign(dv)
        for j in range(nj):
            for i in range(ni):
                self.Ps.append(
                    PAMlib.bilinearinterp(nP, ni, nj, i + 1, j + 1, verts))

        if len(self.Ks) > 0:
            counter = numpy.max(self.Ks[-1]) + 1
        else:
            counter = 0
        K = numpy.zeros((ni, nj), int)
        for j in range(nj):
            for i in range(ni):
                K[i, j] = counter
                counter += 1
        self.Ks.append(K)
Ejemplo n.º 3
0
    def initializeSurfaces(self):
        vtx = lambda f, i, j: self.comp.Ps[self.comp.Ks[f][i,j]][i,j,:]
        verts = numpy.zeros((2,2,3),order='F')
        if self.face==0:
            verts[0,0,:] = vtx(0, -1, 0)
            verts[1,0,:] = vtx(0, 0, 0)
            verts[0,1,:] = vtx(2, 0, 0)
            verts[1,1,:] = vtx(2, -1, 0)
        else:
            verts[0,0,:] = vtx(2, 0, -1)
            verts[1,0,:] = vtx(2, -1, -1)
            verts[0,1,:] = vtx(0, -1, -1)
            verts[1,1,:] = vtx(0, 0, -1)
        ni = sum(self.ni)
        nj = sum(self.nj)

        self.Ps = []
        self.Ks = [-numpy.ones((ni,nj),int)]
        for j in range(nj):
            for i in range(ni):
                self.Ps.append(PAMlib.bilinearinterp(self.nP, ni, nj, i+1, j+1, verts))
                self.Ks[0][i,j] = j*ni + i
Ejemplo n.º 4
0
    def initializeSurfaces(self):
        vtx = lambda f, i, j: self.comp.Ps[self.comp.Ks[f][i, j]][i, j, :]
        verts = numpy.zeros((2, 2, 3), order='F')
        if self.face == 0:
            verts[0, 0, :] = vtx(0, -1, 0)
            verts[1, 0, :] = vtx(0, 0, 0)
            verts[0, 1, :] = vtx(2, 0, 0)
            verts[1, 1, :] = vtx(2, -1, 0)
        else:
            verts[0, 0, :] = vtx(2, 0, -1)
            verts[1, 0, :] = vtx(2, -1, -1)
            verts[0, 1, :] = vtx(0, -1, -1)
            verts[1, 1, :] = vtx(0, 0, -1)
        ni = sum(self.ni)
        nj = sum(self.nj)

        self.Ps = []
        self.Ks = [-numpy.ones((ni, nj), int)]
        for j in range(nj):
            for i in range(ni):
                self.Ps.append(
                    PAMlib.bilinearinterp(self.nP, ni, nj, i + 1, j + 1,
                                          verts))
                self.Ks[0][i, j] = j * ni + i
Ejemplo n.º 5
0
    def initializeSurfaces(self):
        def get(P, u, v, d):
            edge = P[u,:,:] if not u==None else P[:,v,:]
            return edge if d==1 else edge[::-1,:]

        getM = lambda f, i, j: self.mComp.Ps[self.mComp.Ks[f][i,j]]
        getI = lambda i, j: self.Ps[self.Ks[0][i,j]]
        getF = lambda i, j: self.rotate(self.fComp.Ps[self.fK[i,j]])

        def copy(iI, jI, fM, iM, jM, uI=None, vI=None, uM=None, vM=None, d=1):
            edgeI = get(getI(iI, jI), uI, vI, 1)
            edgeM = get(getM(fM, iM, jM), uM, vM, d)
            edgeI[:,:] = edgeM[:,:]

        def copy2(i, j, u=None, v=None):
            edgeI = get(getI(i, j), u, v, 1)
            edgeF = get(getF(i, j), u, v, 1)
            edgeI[:,:] = edgeF[:,:]

        verts = self.initializeVerts()
        
        nP = self.nP
        ni = self.ni
        nj = self.nj
        si = self.si
        sj = self.sj

        self.Ps = []
        self.Ks = [-numpy.ones((si[3],sj[3]),int)]
        counter = 0
        for j in range(sj[3]):
            for i in range(si[3]):
                if i<si[1] or j<sj[1] or i>=si[2] or j>=sj[2]:
                    self.Ps.append(numpy.zeros((nP,nP,3),order='F'))
                    self.Ks[0][i,j] = counter
                    counter += 1

        for b in range(3):
            for a in range(3):
                for j in range(nj[b]):
                    jj = sj[b] + j
                    for i in range(ni[a]):
                        ii = si[a] + i
                        if not self.Ks[0][ii,jj]==-1:
                            self.Ps[self.Ks[0][ii,jj]][:,:,:] = PAMlib.bilinearinterp(nP, ni[a], nj[b], i+1, j+1, verts[a:a+2,b:b+2,:])

        for i in [0,-1]:
            for j in range(self.Ks[0].shape[1]):
                copy2(i, j, u=i)
        for j in [0,-1]:
            for i in range(self.Ks[0].shape[0]):
                copy2(i, j, v=j)

        if not self.mSide==-1:
            mComp = self.mComp
            ii = si[1] - 1
            for j in range(nj[1]):
                jj = sj[1] + j
                if self.mSide==0:
                    copy(ii, jj, 0, -1-j, 0, uI=-1, vM=0, d=-1)
                else:
                    copy(ii, jj, 0, j, -1, uI=-1, vM=-1, d=1)
            ii = si[2]
            for j in range(nj[1]):
                jj = sj[1] + j
                if self.mSide==0:
                    copy(ii, jj, 1, j, 0, uI=0, vM=0, d=1)
                else:
                    copy(ii, jj, 1, -1-j, -1, uI=0, vM=-1, d=-1)
Ejemplo n.º 6
0
    def initializeSurfaces(self):
        def get(P, u, v, d):
            edge = P[u, :, :] if not u == None else P[:, v, :]
            return edge if d == 1 else edge[::-1, :]

        getM = lambda f, i, j: self.mComp.Ps[self.mComp.Ks[f][i, j]]
        getI = lambda i, j: self.Ps[self.Ks[0][i, j]]
        getF = lambda i, j: self.rotate(self.fComp.Ps[self.fK[i, j]])

        def copy(iI, jI, fM, iM, jM, uI=None, vI=None, uM=None, vM=None, d=1):
            edgeI = get(getI(iI, jI), uI, vI, 1)
            edgeM = get(getM(fM, iM, jM), uM, vM, d)
            edgeI[:, :] = edgeM[:, :]

        def copy2(i, j, u=None, v=None):
            edgeI = get(getI(i, j), u, v, 1)
            edgeF = get(getF(i, j), u, v, 1)
            edgeI[:, :] = edgeF[:, :]

        verts = self.initializeVerts()

        nP = self.nP
        ni = self.ni
        nj = self.nj
        si = self.si
        sj = self.sj

        self.Ps = []
        self.Ks = [-numpy.ones((si[3], sj[3]), int)]
        counter = 0
        for j in range(sj[3]):
            for i in range(si[3]):
                if i < si[1] or j < sj[1] or i >= si[2] or j >= sj[2]:
                    self.Ps.append(numpy.zeros((nP, nP, 3), order='F'))
                    self.Ks[0][i, j] = counter
                    counter += 1

        for b in range(3):
            for a in range(3):
                for j in range(nj[b]):
                    jj = sj[b] + j
                    for i in range(ni[a]):
                        ii = si[a] + i
                        if not self.Ks[0][ii, jj] == -1:
                            self.Ps[self.Ks[0][
                                ii, jj]][:, :, :] = PAMlib.bilinearinterp(
                                    nP, ni[a], nj[b], i + 1, j + 1,
                                    verts[a:a + 2, b:b + 2, :])

        for i in [0, -1]:
            for j in range(self.Ks[0].shape[1]):
                copy2(i, j, u=i)
        for j in [0, -1]:
            for i in range(self.Ks[0].shape[0]):
                copy2(i, j, v=j)

        if not self.mSide == -1:
            mComp = self.mComp
            ii = si[1] - 1
            for j in range(nj[1]):
                jj = sj[1] + j
                if self.mSide == 0:
                    copy(ii, jj, 0, -1 - j, 0, uI=-1, vM=0, d=-1)
                else:
                    copy(ii, jj, 0, j, -1, uI=-1, vM=-1, d=1)
            ii = si[2]
            for j in range(nj[1]):
                jj = sj[1] + j
                if self.mSide == 0:
                    copy(ii, jj, 1, j, 0, uI=0, vM=0, d=1)
                else:
                    copy(ii, jj, 1, -1 - j, -1, uI=0, vM=-1, d=-1)