From e5b53d87d2cd9bf3afa6d1390bcc6d593f885467 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Tue, 26 Oct 2021 11:53:01 +1100 Subject: [PATCH] fix: speed up using numpy meshgrid for calculating index list for structured grid. --- LoopStructural/interpolators/structured_grid.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/LoopStructural/interpolators/structured_grid.py b/LoopStructural/interpolators/structured_grid.py index 665fa6228..d6fe20047 100644 --- a/LoopStructural/interpolators/structured_grid.py +++ b/LoopStructural/interpolators/structured_grid.py @@ -161,16 +161,7 @@ def neighbour_global_indexes(self, mask = None, **kwargs): if "indexes" in kwargs: indexes = kwargs['indexes'] if "indexes" not in kwargs: - ii = [] - jj = [] - kk = [] - for i in range(1, self.nsteps[0] - 1): - for j in range(1, self.nsteps[1] - 1): - for k in range(1, self.nsteps[2] - 1): - kk.append(k) - ii.append(i) - jj.append(j) - indexes = np.array([ii, jj, kk]) + indexes = np.array(np.meshgrid(np.arange(1,nsteps[0]-1),np.arange(1,nsteps[1]-1),np.arange(1,nsteps[1]-1))).reshape((3,-1)) # indexes = np.array(indexes).T if indexes.ndim != 2: print(indexes.ndim)