improved performance for non-weighted Voronoi Tessellation
This commit is contained in:
parent
6e05082133
commit
f014cef043
|
@ -5,6 +5,7 @@ import os,sys,math,string
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from scipy import spatial
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
scriptID = string.replace('$Id$','\n','\\n')
|
scriptID = string.replace('$Id$','\n','\\n')
|
||||||
|
@ -80,6 +81,11 @@ def laguerreTessellation(undeformed, coords, weights, grains, nonperiodic = Fals
|
||||||
try: seeds = np.append(seeds, coords+vec, axis=0)
|
try: seeds = np.append(seeds, coords+vec, axis=0)
|
||||||
except NameError: seeds = coords+vec
|
except NameError: seeds = coords+vec
|
||||||
|
|
||||||
|
if all(squaredweights == 0.0): # standard Voronoi (no weights, KD tree)
|
||||||
|
myKDTree = spatial.cKDTree(seeds)
|
||||||
|
devNull,closestSeeds = myKDTree.query(undeformed)
|
||||||
|
else:
|
||||||
|
damask.util.croak('...using {} cpu{}'.format(options.cpus, 's' if options.cpus > 1 else ''))
|
||||||
arguments = [[arg] + [seeds,squaredweights] for arg in list(undeformed)]
|
arguments = [[arg] + [seeds,squaredweights] for arg in list(undeformed)]
|
||||||
|
|
||||||
if cpus > 1: # use multithreading
|
if cpus > 1: # use multithreading
|
||||||
|
@ -267,8 +273,6 @@ for name in filenames:
|
||||||
|
|
||||||
damask.util.croak('tessellating...')
|
damask.util.croak('tessellating...')
|
||||||
|
|
||||||
|
|
||||||
damask.util.croak('...using {} cpu{}'.format(options.cpus, 's' if options.cpus > 1 else ''))
|
|
||||||
grid = np.vstack(meshgrid2(x, y, z)).reshape(3,-1).T
|
grid = np.vstack(meshgrid2(x, y, z)).reshape(3,-1).T
|
||||||
indices = laguerreTessellation(grid, coords, weights, grains, options.nonperiodic, options.cpus)
|
indices = laguerreTessellation(grid, coords, weights, grains, options.nonperiodic, options.cpus)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue