fixed wrong variable name when using pre-existing microstructures from table.

added switch to skip effort for tolerance == 0.
This commit is contained in:
Philip Eisenlohr 2015-12-09 14:13:19 +00:00
parent 87daed84e6
commit 6de6b8b87f
1 changed files with 29 additions and 28 deletions

View File

@ -191,15 +191,13 @@ for name in filenames:
colOri = table.label_index(label)+(3-coordDim) # column(s) of orientation data (following 3 or 2 coordinates that were expanded to 3!) colOri = table.label_index(label)+(3-coordDim) # column(s) of orientation data (following 3 or 2 coordinates that were expanded to 3!)
if inputtype == 'microstructure': if inputtype == 'microstructure':
microstructure = table.data[:,colOri]
nGrains = len(np.unique(microstructure)) grain = table.data[:,colOri]
nGrains = len(np.unique(grain))
else: else:
# --- start background messaging if options.verbose: bg = damask.util.backgroundMessage(); bg.start() # start background messaging
if options.verbose:
bg = damask.util.backgroundMessage()
bg.start()
colPhase = -1 # column of phase data comes last colPhase = -1 # column of phase data comes last
if options.verbose: bg.set_message('sorting positions...') if options.verbose: bg.set_message('sorting positions...')
@ -250,6 +248,7 @@ for name in filenames:
cos_disorientations = -np.ones(1,dtype='f') # largest possible disorientation cos_disorientations = -np.ones(1,dtype='f') # largest possible disorientation
closest_grain = -1 # invalid neighbor closest_grain = -1 # invalid neighbor
if options.tolerance > 0.0: # only try to compress orientations if asked to
neighbors = np.array(KDTree.query_ball_point([x,y,z], 3)) # point indices within radius neighbors = np.array(KDTree.query_ball_point([x,y,z], 3)) # point indices within radius
neighbors = neighbors[(neighbors < myPos) & \ neighbors = neighbors[(neighbors < myPos) & \
(table.data[index[neighbors],colPhase] == myPhase)] # filter neighbors: skip myself, anyone further ahead (cannot yet have a grain ID), and other phases (table.data[index[neighbors],colPhase] == myPhase)] # filter neighbors: skip myself, anyone further ahead (cannot yet have a grain ID), and other phases
@ -281,12 +280,12 @@ for name in filenames:
multiplicity[grainID] += 1 multiplicity[grainID] += 1
statistics[match] += 1 statistics[match] += 1
else: else:
grain[myPos] = nGrains # ... and assign to me grain[myPos] = nGrains # assign new grain to me ...
nGrains += 1 # ... and update counter
orientations.append(o) # store new orientation for future comparison orientations.append(o) # store new orientation for future comparison
multiplicity.append(1) # having single occurrence so far multiplicity.append(1) # having single occurrence so far
phases.append(myPhase) # store phase info for future reporting phases.append(myPhase) # store phase info for future reporting
nGrains += 1 # update counter ... existingGrains = np.arange(nGrains) # update list of existing grains
existingGrains = np.arange(nGrains)
myPos += 1 myPos += 1
@ -296,6 +295,8 @@ for name in filenames:
damask.util.croak("{} seconds total.\n{} local and {} global matches.".\ damask.util.croak("{} seconds total.\n{} local and {} global matches.".\
format(time.clock()-tick,statistics['local'],statistics['global'])) format(time.clock()-tick,statistics['local'],statistics['global']))
grain += 1 # offset from starting index 0 to 1
# --- generate header ---------------------------------------------------------------------------- # --- generate header ----------------------------------------------------------------------------
info = { info = {
@ -343,7 +344,7 @@ for name in filenames:
# --- write microstructure information ------------------------------------------------------------ # --- write microstructure information ------------------------------------------------------------
table.data = grain.reshape(info['grid'][1]*info['grid'][2],info['grid'][0]) + 1 # offset from starting index 0 to 1 table.data = grain.reshape(info['grid'][1]*info['grid'][2],info['grid'][0])
table.data_writeArray('%%%ii'%(formatwidth),delimiter=' ') table.data_writeArray('%%%ii'%(formatwidth),delimiter=' ')
#--- output finalization -------------------------------------------------------------------------- #--- output finalization --------------------------------------------------------------------------