def get_surfaces(self, res=8, elements=None, groups=None, include_xi=False): self.generate() if elements == None: if groups == None: Elements = self.elements else: Elements = self.elements.get_groups(groups) else: Elements = self.elements[elements] XiT, TT = discretizer.xi_grid(shape='tri', res=res) XiQ, TQ = discretizer.xi_grid(shape='quad', res=res) NPT, NTT = XiT.shape[0], TT.shape[0] NPQ, NTQ = XiQ.shape[0], TQ.shape[0] NP, NT = 0, 0 for elem in Elements: if elem.shape == 'tri': NP += NPT NT += NTT elif elem.shape == 'quad': NP += NPQ NT += NTQ X = numpy.zeros((NP, elem.nodes[0].num_fields)) T = numpy.zeros((NT, 3), dtype='uint32') if include_xi: Xi = numpy.zeros((NP, 2)) np, nt = 0, 0 for elem in Elements: if elem.shape == 'tri': X[np:np+NPT,:] = self._core.evaluate(elem.cid, XiT) if include_xi: Xi[np:np+NPT,:] = XiT T[nt:nt+NTT,:] = TT + np np += NPT nt += NTT elif elem.shape == 'quad': X[np:np+NPQ,:] = self._core.evaluate(elem.cid, XiQ) T[nt:nt+NTQ,:] = TQ + np if include_xi: Xi[np:np+NPQ,:] = XiQ np += NPQ nt += NTQ if include_xi: return X, T, Xi return X, T
def grid(self, res=[8, 8]): return discretizer.xi_grid( shape=self.shape, res=res, units='div')[0]
def get_faces(self, res=8, exterior_only=True, include_xi=False): self.generate() if exterior_only: Faces = [face for face in self.faces if len(face.element_faces) == 1] else: Faces = self.faces XiT, TT = discretizer.xi_grid(shape='tri', res=res) XiQ, TQ = discretizer.xi_grid(shape='quad', res=res) NPT, NTT = XiT.shape[0], TT.shape[0] NPQ, NTQ = XiQ.shape[0], TQ.shape[0] XiQ0 = numpy.zeros(NPQ) XiQ1 = numpy.ones(NPQ) NP, NT = 0, 0 for face in Faces: if face.shape == 'tri': NP += NPT NT += NTT elif face.shape == 'quad': NP += NPQ NT += NTQ X = numpy.zeros((NP, 3))#######TODO#####face.nodes[0].num_fields)) T = numpy.zeros((NT, 3), dtype='uint32') if include_xi: Xi = numpy.zeros((NP, 2)) np, nt = 0, 0 for face in Faces: if face.shape == 'tri': X[np:np+NPT,:] = self._core.evaluate(face.cid, XiT) if include_xi: Xi[np:np+NPT,:] = XiT T[nt:nt+NTT,:] = TT + np np += NPT nt += NTT elif face.shape == 'quad': elem = self.elements[face.element_faces[0][0]] face_index = face.element_faces[0][1] if face_index == 0: X[np:np+NPQ,:] = self._core.evaluate(elem.cid, numpy.array([XiQ[:,0], XiQ[:,1], XiQ0]).T) elif face_index == 1: X[np:np+NPQ,:] = self._core.evaluate(elem.cid, numpy.array([XiQ[:,0], XiQ[:,1], XiQ1]).T) elif face_index == 2: X[np:np+NPQ,:] = self._core.evaluate(elem.cid, numpy.array([XiQ[:,0], XiQ0, XiQ[:,1]]).T) elif face_index == 3: X[np:np+NPQ,:] = self._core.evaluate(elem.cid, numpy.array([XiQ[:,0], XiQ1, XiQ[:,1]]).T) elif face_index == 4: X[np:np+NPQ,:] = self._core.evaluate(elem.cid, numpy.array([XiQ0, XiQ[:,0], XiQ[:,1]]).T) elif face_index == 5: X[np:np+NPQ,:] = self._core.evaluate(elem.cid, numpy.array([XiQ1, XiQ[:,0], XiQ[:,1]]).T) T[nt:nt+NTQ,:] = TQ + np if include_xi: Xi[np:np+NPQ,:] = XiQ np += NPQ nt += NTQ if include_xi: return X, T, Xi return X, T
def grid(self, res=[8, 8], shape='quad'): return discretizer.xi_grid( shape=shape, res=res, units='div')[0]