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
This commit is contained in:
Martin Diehl 2016-10-05 15:24:37 +02:00
parent 546d83cdc3
commit f78f89fb12
1 changed files with 12 additions and 13 deletions

View File

@ -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,