def __init__(self, mesh, skeletontag): meshinfo = mesh.basicinfo cutvertices = getCutFaces(mesh) boundaries = list(meshinfo.boundaries) # Get the boundaries from the underlying mesh boundaries.extend([(skeletontag, vs) for vs in cutvertices]) # And add a new boundary, labelled 'skeletontag' meshinfo2 = pmm.SimplicialMeshInfo(meshinfo.nodes, meshinfo.elements, meshinfo.elemIdentity, boundaries, meshinfo.dim) # Construct a new mesh, with the new boundary information self.mesh = pmm.MeshView(meshinfo2, pmm.Topology(meshinfo2), mesh.part) self.indicator = self.mesh.topology.faceentities==skeletontag #Identify the faces that are along the skeleton boundary # print self.indicator nskelelts = sum(self.indicator) self.index = np.ones(self.mesh.nfaces, dtype=int) * -1 self.index[self.indicator] = np.arange(nskelelts) # self.index maps from mesh faces to the skeleton elements (contains -1 for non-skeleton faces) self.skeltomeshindex = self.indicator.nonzero()[0] # the indices of the faces in the mesh that are on the skeleton self.skel2mesh = pus.sparseindex(np.arange(nskelelts), self.skeltomeshindex, nskelelts, self.mesh.nfaces) # A sparse matrix that maps skeleton elements to mesh faces self.skel2oppmesh = self.skel2mesh * mesh.topology.connectivity # A sparse matrix that maps skeleton elements to the opposite mesh face self.skel2skel = self.skel2oppmesh * self.skel2mesh.transpose() # A sparse matrix that maps skeleton elements to the neighbouring skeleton element # print self.skel2skel skeletonelts = self.mesh.faces[self.indicator] meshinfo = pmm.SimplicialMeshInfo(self.mesh.nodes, skeletonelts, None, {}, self.mesh.dim -1) topology = pmm.Topology(meshinfo) partition = SkeletonPartition(mesh, meshinfo, topology, self.indicator, self.index) self.skeletonmesh = pmm.MeshView(meshinfo, topology, partition) # Build the skeleton mesh. N.B. it's topology should probably not be trusted.
def __init__(self, system, boundary, mortarsystem, skelmesh, sysargs, syskwargs): AA, G = system.getSystem(*sysargs, **syskwargs) BS = boundary.stiffness() # print 'BS',BS.tocsr() A = (AA + BS).tocsr() A.eliminate_zeros() BL = boundary.load(False).tocsr() MM = mortarsystem.getMass() self.M = MM.tocsr().transpose() idxs = mortarsystem.idxs self.skelidxs = MM.subrows(skelmesh.partition) print self.M.shape self.Ainv = ssl.splu(A[idxs, :][:, idxs]) self.Minv = ssl.splu(self.M[self.skelidxs, :][:, self.skelidxs] * (1 + 0j)) self.Brow = -BL[idxs, :] T = mortarsystem.getOppositeTrace().tocsr().transpose() self.Scol = -T[:, idxs].conj() # Why? self.G = G.tocsr().todense()[idxs].A.flatten() self.localtoglobal = pusu.sparseindex(idxs, np.arange(len(idxs)), A.shape[0], len(idxs)) # print 'localtoglobal', self.localtoglobal print "nnz", BL.nnz, self.Brow.nnz, A.nnz, A[idxs, :][:, idxs].nnz, T.nnz, T[:, idxs].nnz