get rid of scalar variables

This commit is contained in:
f.basile 2020-10-23 16:23:36 +02:00
parent 7fa31a8a1b
commit 1cbfa866d2
1 changed files with 24 additions and 31 deletions

View File

@ -849,37 +849,30 @@ class Geom:
Parameters Parameters
---------- ----------
periodic : Boolean, optional periodic : Boolean, optional
Show boundaries at periodic nodes too. Defalts to False. Show boundaries at periodic nodes too. Defaults to False.
""" """
v = VTK.from_polyData(grid_filters.node_coord0(self.grid,self.size,self.origin).reshape(-1,3,order='F')) v = VTK.from_polyData(grid_filters.node_coord0(self.grid,self.size,self.origin).reshape(-1,3,order='F'))
cells = vtk.vtkCellArray() cells = vtk.vtkCellArray()
#Grid to nodes
a=self.grid[0]+1
b=self.grid[1]+1
c=self.grid[2]+1
if periodic: if periodic:
FaceYZ_per=np.empty() FaceYZ_per=np.empty([])
FaceXY_per=np.empty() FaceXY_per=np.empty([])
FaceXZ_per=np.empty() FaceXZ_per=np.empty([])
else: else:
# get nodes of periodic boundaries in X FaceYZ_per=np.concatenate((
FaceYZ_per=np.concatenate(( np.arange(0,a*b*c,a) , np.arange(self.grid[0], a*b*c,a) )) np.arange(0 , np.prod(self.grid+1) , (self.grid[0]+1) ),
# get nodes of periodic boundaries in Z np.arange(self.grid[0] , np.prod(self.grid+1) , (self.grid[0]+1) ) ))
FaceXY_per=np.concatenate(( np.arange(0,a*b) , np.arange(a*b*c - a*b, a*b*c ) )) FaceXY_per=np.concatenate((
# get nodes of periodic boundaries in Y np.arange(0 , np.prod(self.grid[:2]+1) , 1 ),
FaceXZ_0=np.arange(0, a) # face Y=0 np.arange(np.prod(self.grid+1) - np.prod(self.grid[:2]+1), \
for i in range(c): np.prod(self.grid+1) , 1 ) ))
add=np.arange( (i+1)*(a)*(b), (i+1)*(a)*(b)+ (a)) FaceXZ_per=np.concatenate((
FaceXZ_0=np.append(FaceXZ_0, add) np.concatenate([np.arange((i)*np.prod(self.grid[:2]+1), \
FaceXZ_end=np.arange(a*b-b, a*b) # face Y=end (i)*np.prod(self.grid[:2]+1)+ (self.grid[0]+1)) for i in range(self.grid[2]+1)]) ,
for i in range(c): np.concatenate([np.arange( (i+1)*np.prod(self.grid[:2]+1)-(self.grid[0]+1),\
add= np.arange( (i+1)*a*b-b, (i+1)*a*b) (i+1)*np.prod(self.grid[:2]+1)) for i in range(self.grid[2]+1)]) ))
FaceXZ_end=np.append(FaceXZ_end, add)
FaceXZ_per=np.concatenate (( FaceXZ_0, FaceXZ_end ))
for d_s in [0,1,2]: for d_s in [0,1,2]:
base_nodes = np.where(self.material==np.roll(self.material,1,d_s),False,True) base_nodes = np.where(self.material==np.roll(self.material,1,d_s),False,True)
for d in [0,1,2]: for d in [0,1,2]:
@ -898,17 +891,17 @@ class Geom:
q = vtk.vtkQuad() q = vtk.vtkQuad()
q.GetPointIds().SetId(0, p[0]) q.GetPointIds().SetId(0, p[0])
if d_s == 0: if d_s == 0:
q.GetPointIds().SetId(1, p[0]+a) q.GetPointIds().SetId(1, p[0]+(self.grid[0]+1))
q.GetPointIds().SetId(2, p[0]+a*b+a) q.GetPointIds().SetId(2, p[0]+np.prod(self.grid[:2]+1)+(self.grid[0]+1))
q.GetPointIds().SetId(3, p[0]+a*b) q.GetPointIds().SetId(3, p[0]+np.prod(self.grid[:2]+1))
if d_s == 1: if d_s == 1:
q.GetPointIds().SetId(1, p[0]+a*b) q.GetPointIds().SetId(1, p[0]+np.prod(self.grid[:2]+1))
q.GetPointIds().SetId(2, p[0]+a*b+1) q.GetPointIds().SetId(2, p[0]+np.prod(self.grid[:2]+1)+1)
q.GetPointIds().SetId(3, p[0]+1) q.GetPointIds().SetId(3, p[0]+1)
if d_s == 2: if d_s == 2:
q.GetPointIds().SetId(1, p[0]+1) q.GetPointIds().SetId(1, p[0]+1)
q.GetPointIds().SetId(2, p[0]+a+1) q.GetPointIds().SetId(2, p[0]+(self.grid[0]+1)+1)
q.GetPointIds().SetId(3, p[0]+a) q.GetPointIds().SetId(3, p[0]+(self.grid[0]+1))
cells.InsertNextCell(q) cells.InsertNextCell(q)
v.vtk_data.SetPolys(cells) v.vtk_data.SetPolys(cells)
v.save('GrainBoundaries') v.save('GrainBoundaries')