From f78f89fb12e3306b70296379d2cf1452894918e6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 5 Oct 2016 15:24:37 +0200 Subject: [PATCH] periodic microstructure needs to be updated per iteration (N). now calling script twice gives the same result as one call with N=2. results for N=1 are not affected --- processing/pre/geom_grainGrowth.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/processing/pre/geom_grainGrowth.py b/processing/pre/geom_grainGrowth.py index 2781f90d9..55b98e627 100755 --- a/processing/pre/geom_grainGrowth.py +++ b/processing/pre/geom_grainGrowth.py @@ -78,9 +78,6 @@ for name in filenames: #--- initialize support data ----------------------------------------------------------------------- - periodic_microstructure = np.tile(microstructure,(3,3,3))[grid[0]/2:-grid[0]/2, - grid[1]/2:-grid[1]/2, - grid[2]/2:-grid[2]/2] # periodically extend the microstructure # store a copy the initial microstructure to find locations of immutable indices microstructure_original = np.copy(microstructure) @@ -94,25 +91,27 @@ for name in filenames: gauss[grid[0]/2::,:,:] = gauss[int(round(grid[0]/2.))-1::-1,:,:] gauss = np.fft.rfftn(gauss) - interfacialEnergy = lambda A,B: (A*B != 0)*(A != B)*1.0 #1.0 if A & B are distinct & nonzero, 0.0 otherwise - struc = ndimage.generate_binary_structure(3,1) # 3D von Neumann neighborhood + getInterfaceEnergy = lambda A,B: (A*B != 0)*(A != B)*1.0 # 1.0 if A & B are distinct & nonzero, 0.0 otherwise + struc = ndimage.generate_binary_structure(3,1) # 3D von Neumann neighborhood for smoothIter in xrange(options.N): - boundary = np.zeros(microstructure.shape) + periodic_microstructure = np.tile(microstructure,(3,3,3))[grid[0]/2:-grid[0]/2, + grid[1]/2:-grid[1]/2, + grid[2]/2:-grid[2]/2] # periodically extend the microstructure + interfaceEnergy = np.zeros(microstructure.shape) for i in (-1,0,1): for j in (-1,0,1): for k in (-1,0,1): # assign interfacial energy to all voxels that have a differing neighbor (in Moore neighborhood) - boundary = np.maximum(boundary, - interfacialEnergy(microstructure,np.roll(np.roll(np.roll( - microstructure,i,axis=0), j,axis=1), k,axis=2))) - interfaceEnergy = boundary - + interfaceEnergy = np.maximum(interfaceEnergy, + getInterfaceEnergy(microstructure,np.roll(np.roll(np.roll( + microstructure,i,axis=0), j,axis=1), k,axis=2))) + # periodically extend interfacial energy array by half a grid size in positive and negative directions periodic_interfaceEnergy = np.tile(interfaceEnergy,(3,3,3))[grid[0]/2:-grid[0]/2, - grid[1]/2:-grid[1]/2, - grid[2]/2:-grid[2]/2] + grid[1]/2:-grid[1]/2, + grid[2]/2:-grid[2]/2] # transform bulk volume (i.e. where interfacial energy is zero) index = ndimage.morphology.distance_transform_edt(periodic_interfaceEnergy == 0., return_distances = False,