limit search space to actual RVE

periodic copies of the seeds are sufficient, no need to copy the grid
This commit is contained in:
Martin Diehl 2021-07-09 12:13:18 +02:00
parent 8e75e87ad9
commit abf7c8e9f1
1 changed files with 4 additions and 8 deletions

View File

@ -406,23 +406,19 @@ class Grid:
seeds_p = np.vstack((seeds -np.array([size[0],0.,0.]),seeds, seeds +np.array([size[0],0.,0.]))) seeds_p = np.vstack((seeds -np.array([size[0],0.,0.]),seeds, seeds +np.array([size[0],0.,0.])))
seeds_p = np.vstack((seeds_p-np.array([0.,size[1],0.]),seeds_p,seeds_p+np.array([0.,size[1],0.]))) seeds_p = np.vstack((seeds_p-np.array([0.,size[1],0.]),seeds_p,seeds_p+np.array([0.,size[1],0.])))
seeds_p = np.vstack((seeds_p-np.array([0.,0.,size[2]]),seeds_p,seeds_p+np.array([0.,0.,size[2]]))) seeds_p = np.vstack((seeds_p-np.array([0.,0.,size[2]]),seeds_p,seeds_p+np.array([0.,0.,size[2]])))
coords = grid_filters.coordinates0_point(cells*3,size*3,-size).reshape(-1,3)
else: else:
weights_p = weights weights_p = weights
seeds_p = seeds seeds_p = seeds
coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3) coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3)
pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',4))) pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',4)))
result = pool.map_async(partial(Grid._find_closest_seed,seeds_p,weights_p), coords) result = pool.map_async(partial(Grid._find_closest_seed,seeds_p,weights_p), coords)
pool.close() pool.close()
pool.join() pool.join()
material_ = np.array(result.get()) material_ = np.array(result.get()).reshape(cells)
if periodic: if periodic: material_ %= len(weights)
material_ = material_.reshape(cells*3)
material_ = material_[cells[0]:cells[0]*2,cells[1]:cells[1]*2,cells[2]:cells[2]*2]%seeds.shape[0]
else:
material_ = material_.reshape(cells)
return Grid(material = material_ if material is None else material[material_], return Grid(material = material_ if material is None else material[material_],
size = size, size = size,