Merge branch 'development' into 12-fixOrientationSampling

This commit is contained in:
Martin Diehl 2018-04-10 10:25:24 +02:00
commit f0f86f68b7
4 changed files with 36 additions and 16 deletions

@ -1 +1 @@
Subproject commit 563d327d92b3e22e6845080f9971e400888a8c9d
Subproject commit af851689285b8c1a633495219abd9dbbd5a11c69

View File

@ -1 +1 @@
v2.0.1-1110-g52c9954
v2.0.1-1115-gb429068

View File

@ -109,14 +109,6 @@ for name in filenames:
for smoothIter in range(options.N):
# replace immutable microstructures with closest mutable ones
index = ndimage.morphology.distance_transform_edt(np.in1d(microstructure,options.immutable).reshape(grid),
return_distances = False,
return_indices = True)
microstructure = microstructure[index[0],
index[1],
index[2]]
interfaceEnergy = np.zeros(microstructure.shape,dtype=np.float32)
for i in (-1,0,1):
for j in (-1,0,1):
@ -182,8 +174,16 @@ for name in filenames:
grid[1]/2:-grid[1]/2,
grid[2]/2:-grid[2]/2] # extent grains into interface region
# replace immutable microstructures with closest mutable ones
index = ndimage.morphology.distance_transform_edt(np.in1d(microstructure,options.immutable).reshape(grid),
return_distances = False,
return_indices = True)
microstructure = microstructure[index[0],
index[1],
index[2]]
immutable = np.zeros(microstructure.shape, dtype=np.bool)
# find locations where immutable microstructures have been (or are now)
# find locations where immutable microstructures have been in original structure
for micro in options.immutable:
immutable += microstructure_original == micro

View File

@ -10,13 +10,24 @@ import damask
scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version])
def taintedNeighborhood(stencil,trigger=[],size=1):
me = stencil[stencil.shape[0]//2]
if len(trigger) == 0:
return np.any(stencil != me)
if me in trigger:
trigger = set(trigger)
trigger.remove(me)
trigger = list(trigger)
return np.any(np.in1d(stencil,np.array(trigger)))
#--------------------------------------------------------------------------------------------------
# MAIN
#--------------------------------------------------------------------------------------------------
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
Offset microstructure index for points which see a microstructure different from themselves within a given (cubic) vicinity,
i.e. within the region close to a grain/phase boundary.
Offset microstructure index for points which see a microstructure different from themselves
(or listed as triggers) within a given (cubic) vicinity, i.e. within the region close to a grain/phase boundary.
""", version = scriptID)
@ -29,6 +40,9 @@ parser.add_option('-m', '--microstructureoffset',
type = 'int', metavar = 'int',
help = 'offset (positive or negative) for tagged microstructure indices. '+
'"0" selects maximum microstructure index [%default]')
parser.add_option('-t', '--trigger',
action = 'extend', dest = 'trigger', metavar = '<int LIST>',
help = 'list of microstructure indices triggering a change')
parser.add_option('-n', '--nonperiodic',
dest = 'mode',
action = 'store_const', const = 'nearest',
@ -36,10 +50,13 @@ parser.add_option('-n', '--nonperiodic',
parser.set_defaults(vicinity = 1,
offset = 0,
trigger = [],
mode = 'wrap',
)
(options, filenames) = parser.parse_args()
options.trigger = np.array(options.trigger, dtype=int)
# --- loop over input files -------------------------------------------------------------------------
@ -84,9 +101,12 @@ for name in filenames:
if options.offset == 0: options.offset = microstructure.max()
microstructure = np.where(ndimage.filters.maximum_filter(microstructure,size=1+2*options.vicinity,mode=options.mode) ==
ndimage.filters.minimum_filter(microstructure,size=1+2*options.vicinity,mode=options.mode),
microstructure, microstructure + options.offset)
microstructure = np.where(ndimage.filters.generic_filter(microstructure,
taintedNeighborhood,
size=1+2*options.vicinity,mode=options.mode,
extra_arguments=(),
extra_keywords={"trigger":options.trigger,"size":1+2*options.vicinity}),
microstructure + options.offset,microstructure)
newInfo['microstructures'] = microstructure.max()