def getQuadratures(self, tag, squarequad, trianglequad): """ For a boundary identified by tag, return a list of quadrature points, weights and normals for each element """ from mappings import buildaffine from elements import refpyramid bdy = set(self.boundaries[tag].__iter__()) sx,sw = squarequad sx = np.hstack((sx, np.zeros((len(sx),1)))) tx,tw = trianglequad tx = np.hstack((np.zeros((len(tx),1)))) for ppoints in self.pyramidpoints: x = [] w = [] normals = [] pyramidcentre = np.sum(self.getPoints(ppoints), axis=0) / 5.0 for tripoints in [[0,1,4],[1,2,4],[2,3,4],[3,0,4]]: if bdy.issuperset(ppoints[tripoints]): m = buildaffine(refpyramid[[0,1,4]], self.getPoints(ppoints[tripoints])) x.append(m.apply(tx)) w.append(numpy.abs(m.dets(tx))*tw) x0 = m.apply(refpyramid[0])[0] n = m.apply(refpyramid[3])[0] - x0 normals.append(np.tile(-n * np.sign(np.dot(pyramidcentre - x0, n)), (len(tx),1) )) if bdy.issuperset(ppoints[0:4]): m = buildaffine(refpyramid[[0,1,3]], self.getPoints(ppoints[[0,1,3]])) x.append(m.apply(sx)) w.append(numpy.abs(m.dets(sx)) * sw) x0 = m.apply(refpyramid[0])[0] n = m.apply(refpyramid[4])[0] - x0 # print pyramidcentre, x0, n, -n * np.sign(np.dot(pyramidcentre - x0, n)) normals.append(np.tile(-n * np.sign(np.dot(pyramidcentre - x0, n)), (len(sx),1) )) if x: yield numpy.vstack(x), numpy.concatenate(w), numpy.vstack(normals) else: yield numpy.zeros((0,3)), numpy.zeros((0,0)), numpy.zeros((0,3))
def addPyramid(self, pointids): from elements import refpyramid from mappings import buildaffine points = self.getPoints(pointids) self.maps.append(buildaffine(refpyramid[[0,1,3,4]], points[[0,1,3,4]]))