def test2to3(self): """ build an affine map to map 3 points in 2-space to 3 points in 3-space """ for _ in range(self.N): pf = numpy.random.random((3,2)) pt = numpy.random.random((3,3)) A = buildaffine(pf, pt) numpy.testing.assert_array_almost_equal(A.apply(pf), pt)
def test3to3(self): """ build an affine map to map 4 points in 3-space to 4 other points in 3-space """ for _ in range(self.N): pf = numpy.random.random((4,3)) pt = numpy.random.random((4,3)) A = buildaffine(pf, pt) numpy.testing.assert_array_almost_equal(A.apply(pf), pt) numpy.testing.assert_array_almost_equal(A.applyinv(A.apply(pf)), pf)
def pyramid(self, points, degrees): indices = sum([d.indices for d in degrees if d is not None], []) ninternal = self.pyramidform.nfns - len(indices) indices.extend(range(self.index, self.index + ninternal)) self.index += ninternal map = buildaffine(points[[0,1,3,4]], refpyramid[[0,1,3,4]]) pullback = self.createpullback(map) elt = Element(self.pyramidform, degrees, pullback, map.applyinv, indices) return elt
def test3to3missing(self): """ build an affine map to map 3 points in 3-space to 3 points in 3-space, preserving orthogonal vectors""" for _ in range(self.N): pf = numpy.random.random((3,3)) pt = numpy.random.random((3,3)) A = buildaffine(pf, pt) numpy.testing.assert_array_almost_equal(A.apply(pf), pt) # construct the orthogonal vector fognal = numpy.cross(pf[1] - pf[0], pf[2] - pf[0]) + pf[0] numpy.testing.assert_array_almost_equal(numpy.dot(A.apply(fognal) - pt[0], (pt[1:] - pt[0]).transpose()), [[0,0]]) numpy.testing.assert_array_almost_equal(A.applyinv(A.apply(pf)), pf)
def createExternalDegree(vertices): if len(refvertices) == 0: pullback = Pullback(lambda p: vertices[numpy.ix_([0])]) else: map = buildaffine(refvertices, vertices[0:len(refvertices)]) pullback = self.createpullback(map) # print "vertices", vertices # print "affine", map.linear indices = range(self.index, self.index + len(dofs)) self.index += len(dofs) return ExternalDegree(pullback, refpoints, dofs, indices)