shortest possible way i found to include directions in an elegant way

This commit is contained in:
f.basile 2020-11-24 17:49:58 +01:00
parent b885e38b3f
commit c8b1f8d9f1
1 changed files with 6 additions and 6 deletions

View File

@ -914,16 +914,16 @@ class Geom:
v.save('GrainBoundaries') v.save('GrainBoundaries')
def ShowGBoptimized(self,periodic=True,direction='xyz'): def get_grain_boundaries(self,periodic=True,direction='xyz'):
""" """
Create an VTK files to show grain boundaries as feature edges. Create VTK files to show grain boundaries as feature edges.
Parameters Parameters
---------- ----------
periodic : Boolean, optional periodic : Boolean, optional
Show boundaries at periodic nodes too. Defaults to False. Show boundaries at periodic nodes too. Defaults to True.
across : list of lists direction : string
Show grain boundaries only across certain axis. [X=0,Y=1,Z=2]. Defaults to all possible. Show grain boundaries only across certain directions. [X=0,Y=1,Z=2]. Defaults to all possible.
""" """
coord=grid_filters.node_coord0(self.grid,self.size,self.origin).reshape(-1,3,order='F') coord=grid_filters.node_coord0(self.grid,self.size,self.origin).reshape(-1,3,order='F')
@ -933,7 +933,7 @@ class Geom:
[0, np.prod(self.grid[:2]+1), np.prod(self.grid[:2]+1)+1, 1], [0, np.prod(self.grid[:2]+1), np.prod(self.grid[:2]+1)+1, 1],
[0, 1, self.grid[0]+1+1, self.grid[0]+1]] [0, 1, self.grid[0]+1+1, self.grid[0]+1]]
for d_s in [0,1,2]: for d_s in [ord(i)-120 for i in direction]:
mask = self.material != np.roll(self.material,1,d_s) mask = self.material != np.roll(self.material,1,d_s)
for d in [0,1,2]: for d in [0,1,2]:
extra_layer = np.take(mask,[0],d) if d_s == d else np.zeros_like(np.take(mask,[0],d),bool) extra_layer = np.take(mask,[0],d) if d_s == d else np.zeros_like(np.take(mask,[0],d),bool)