def vol(self): """ Construct cell volumes of the 3D model as 1d array """ if getattr(self, '_vol', None) is None: if self.dim == 2: A, B, C, D = Utils.indexCube('ABCD', self.vnC+1) normal, area = Utils.faceInfo(np.c_[self.gridN, np.zeros( (self.nN, 1))], A, B, C, D) self._vol = area elif self.dim == 3: # Each polyhedron can be decomposed into 5 tetrahedrons # However, this presents a choice so we may as well divide in # two ways and average. A, B, C, D, E, F, G, H = Utils.indexCube('ABCDEFGH', self.vnC + 1) vol1 = (Utils.volTetra(self.gridN, A, B, D, E) + # cutted edge top Utils.volTetra(self.gridN, B, E, F, G) + # cutted edge top Utils.volTetra(self.gridN, B, D, E, G) + # middle Utils.volTetra(self.gridN, B, C, D, G) + # cutted edge bottom Utils.volTetra(self.gridN, D, E, G, H)) # cutted edge bottom vol2 = (Utils.volTetra(self.gridN, A, F, B, C) + # cutted edge top Utils.volTetra(self.gridN, A, E, F, H) + # cutted edge top Utils.volTetra(self.gridN, A, H, F, C) + # middle Utils.volTetra(self.gridN, C, H, D, A) + # cutted edge bottom Utils.volTetra(self.gridN, C, G, H, F)) # cutted edge bottom self._vol = (vol1 + vol2)/2 return self._vol
def fget(self): if(self._vol is None): if self.dim == 2: A, B, C, D = Utils.indexCube('ABCD', self.vnC+1) normal, area = Utils.faceInfo(np.c_[self.gridN, np.zeros((self.nN, 1))], A, B, C, D) self._vol = area elif self.dim == 3: # Each polyhedron can be decomposed into 5 tetrahedrons # However, this presents a choice so we may as well divide in two ways and average. A, B, C, D, E, F, G, H = Utils.indexCube('ABCDEFGH', self.vnC+1) vol1 = (Utils.volTetra(self.gridN, A, B, D, E) + # cutted edge top Utils.volTetra(self.gridN, B, E, F, G) + # cutted edge top Utils.volTetra(self.gridN, B, D, E, G) + # middle Utils.volTetra(self.gridN, B, C, D, G) + # cutted edge bottom Utils.volTetra(self.gridN, D, E, G, H)) # cutted edge bottom vol2 = (Utils.volTetra(self.gridN, A, F, B, C) + # cutted edge top Utils.volTetra(self.gridN, A, E, F, H) + # cutted edge top Utils.volTetra(self.gridN, A, H, F, C) + # middle Utils.volTetra(self.gridN, C, H, D, A) + # cutted edge bottom Utils.volTetra(self.gridN, C, G, H, F)) # cutted edge bottom self._vol = (vol1 + vol2)/2 return self._vol