From 78192ef3fd1c7b6398cb9f6aa4efcf11bd4c37a7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 7 Dec 2020 17:49:37 +0100 Subject: [PATCH 1/7] clearer naming + better comments, thanks to @p.eisenlohr --- python/damask/_grid.py | 2 +- python/damask/_rotation.py | 2 +- python/damask/grid_filters.py | 30 +++++++++++++++--------------- python/damask/seeds.py | 6 +++--- python/tests/test_grid_filters.py | 20 ++++++++++---------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/python/damask/_grid.py b/python/damask/_grid.py index 2bd5a5f9e..a01c7754f 100644 --- a/python/damask/_grid.py +++ b/python/damask/_grid.py @@ -302,7 +302,7 @@ class Grid: Each unique combintation of values results in one material ID. """ - cells,size,origin = grid_filters.cellSizeOrigin_coordinates0_point(table.get(coordinates)) + cells,size,origin = grid_filters.cellsSizeOrigin_coordinates0_point(table.get(coordinates)) labels_ = [labels] if isinstance(labels,str) else labels unique,unique_inverse = np.unique(np.hstack([table.get(l) for l in labels_]),return_inverse=True,axis=0) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index e7bf50bd1..f4d2cf248 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -763,7 +763,7 @@ class Rotation: def _dg(eu,deg): """Return infinitesimal Euler space volume of bin(s).""" phi_sorted = eu[np.lexsort((eu[:,0],eu[:,1],eu[:,2]))] - steps,size,_ = grid_filters.cellSizeOrigin_coordinates0_point(phi_sorted) + steps,size,_ = grid_filters.cellsSizeOrigin_coordinates0_point(phi_sorted) delta = np.radians(size/steps) if deg else size/steps return delta[0]*2.0*np.sin(delta[1]/2.0)*delta[2] / 8.0 / np.pi**2 * np.sin(np.radians(eu[:,1]) if deg else eu[:,1]) diff --git a/python/damask/grid_filters.py b/python/damask/grid_filters.py index 4a1709c75..9e06e075a 100644 --- a/python/damask/grid_filters.py +++ b/python/damask/grid_filters.py @@ -208,7 +208,7 @@ def coordinates_point(size,F,origin=_np.zeros(3)): return coordinates0_point(F.shape[:3],size,origin) + displacement_point(size,F) -def cellSizeOrigin_coordinates0_point(coordinates0,ordered=True): +def cellsSizeOrigin_coordinates0_point(coordinates0,ordered=True): """ Return grid 'DNA', i.e. cells, size, and origin from 1D array of point positions. @@ -218,6 +218,7 @@ def cellSizeOrigin_coordinates0_point(coordinates0,ordered=True): Undeformed cell coordinates. ordered : bool, optional Expect coordinates0 data to be ordered (x fast, z slow). + Defaults to True. """ coords = [_np.unique(coordinates0[:,i]) for i in range(3)] @@ -242,7 +243,7 @@ def cellSizeOrigin_coordinates0_point(coordinates0,ordered=True): if not (_np.allclose(coords[0],_np.linspace(start[0],end[0],cells[0]),atol=atol) and \ _np.allclose(coords[1],_np.linspace(start[1],end[1],cells[1]),atol=atol) and \ _np.allclose(coords[2],_np.linspace(start[2],end[2],cells[2]),atol=atol)): - raise ValueError('Regular cells spacing violated.') + raise ValueError('Regular cell spacing violated.') if ordered and not _np.allclose(coordinates0.reshape(tuple(cells)+(3,),order='F'), coordinates0_point(cells,size,origin),atol=atol): @@ -261,7 +262,7 @@ def coordinates0_check(coordinates0): Array of undeformed cell coordinates. """ - cellSizeOrigin_coordinates0_point(coordinates0,ordered=True) + cellsSizeOrigin_coordinates0_point(coordinates0,ordered=True) def coordinates0_node(cells,size,origin=_np.zeros(3)): @@ -296,7 +297,7 @@ def displacement_fluct_node(size,F): Deformation gradient field. """ - return point_2_node(displacement_fluct_point(size,F)) + return point_to_node(displacement_fluct_point(size,F)) def displacement_avg_node(size,F): @@ -347,7 +348,7 @@ def coordinates_node(size,F,origin=_np.zeros(3)): return coordinates0_node(F.shape[:3],size,origin) + displacement_node(size,F) -def point_2_node(cell_data): +def point_to_node(cell_data): """Interpolate periodic point data to nodal data.""" n = ( cell_data + _np.roll(cell_data,1,(0,1,2)) + _np.roll(cell_data,1,(0,)) + _np.roll(cell_data,1,(1,)) + _np.roll(cell_data,1,(2,)) @@ -365,7 +366,7 @@ def node_2_point(node_data): return c[1:,1:,1:] -def cellSizeOrigin_coordinates0_node(coordinates0,ordered=True): +def cellsSizeOrigin_coordinates0_node(coordinates0,ordered=True): """ Return grid 'DNA', i.e. cells, size, and origin from 1D array of nodal positions. @@ -375,6 +376,7 @@ def cellSizeOrigin_coordinates0_node(coordinates0,ordered=True): Undeformed nodal coordinates. ordered : bool, optional Expect coordinates0 data to be ordered (x fast, z slow). + Defaults to True. """ coords = [_np.unique(coordinates0[:,i]) for i in range(3)] @@ -391,7 +393,7 @@ def cellSizeOrigin_coordinates0_node(coordinates0,ordered=True): if not (_np.allclose(coords[0],_np.linspace(mincorner[0],maxcorner[0],cells[0]+1),atol=atol) and \ _np.allclose(coords[1],_np.linspace(mincorner[1],maxcorner[1],cells[1]+1),atol=atol) and \ _np.allclose(coords[2],_np.linspace(mincorner[2],maxcorner[2],cells[2]+1),atol=atol)): - raise ValueError('Regular cells spacing violated.') + raise ValueError('Regular cell spacing violated.') if ordered and not _np.allclose(coordinates0.reshape(tuple(cells+1)+(3,),order='F'), coordinates0_node(cells,size,origin),atol=atol): @@ -400,9 +402,9 @@ def cellSizeOrigin_coordinates0_node(coordinates0,ordered=True): return (cells,size,origin) -def regrid(size,F,cells_new): +def regrid(size,F,cells): """ - Return mapping from coordinates in deformed configuration to a regular cells. + Return mapping from coordinates in deformed configuration to a regular grid. Parameters ---------- @@ -410,13 +412,11 @@ def regrid(size,F,cells_new): Physical size. F : numpy.ndarray of shape (:,:,:,3,3) Deformation gradient field. - cells_new : numpy.ndarray of shape (3) - New cells for undeformed coordinates. + cells : numpy.ndarray of shape (3) + Cell count along x,y,z of remapping grid. """ - c = coordinates0_point(F.shape[:3],size) \ - + displacement_avg_point(size,F) \ - + displacement_fluct_point(size,F) + c = coordinates_point(size,F) outer = _np.dot(_np.average(F,axis=(0,1,2)),size) for d in range(3): @@ -424,4 +424,4 @@ def regrid(size,F,cells_new): c[_np.where(c[:,:,:,d]>outer[d])] -= outer[d] tree = _spatial.cKDTree(c.reshape(-1,3),boxsize=outer) - return tree.query(coordinates0_point(cells_new,outer))[1].flatten() + return tree.query(coordinates0_point(cells,outer))[1].flatten() diff --git a/python/damask/seeds.py b/python/damask/seeds.py index cf0c0a006..8693e3549 100644 --- a/python/damask/seeds.py +++ b/python/damask/seeds.py @@ -18,8 +18,8 @@ def from_random(size,N_seeds,cells=None,rng_seed=None): N_seeds : int Number of seeds. cells : numpy.ndarray of shape (3), optional. - If given, ensures that all seeds initiate one grain if using a - standard Voronoi tessellation. + If given, ensures that each seed results in a grain for a standard + Voronoi tessellation. rng_seed : {None, int, array_like[ints], SeedSequence, BitGenerator, Generator}, optional A seed to initialize the BitGenerator. Defaults to None. If None, then fresh, unpredictable entropy will be pulled from the OS. @@ -51,7 +51,7 @@ def from_Poisson_disc(size,N_seeds,N_candidates,distance,periodic=True,rng_seed= distance : float Minimum acceptable distance to other seeds. periodic : boolean, optional - Calculate minimum distance for periodically repeated cells. + Calculate minimum distance for periodically repeated grid. rng_seed : {None, int, array_like[ints], SeedSequence, BitGenerator, Generator}, optional A seed to initialize the BitGenerator. Defaults to None. If None, then fresh, unpredictable entropy will be pulled from the OS. diff --git a/python/tests/test_grid_filters.py b/python/tests/test_grid_filters.py index c48ab39d0..d43e94c3c 100644 --- a/python/tests/test_grid_filters.py +++ b/python/tests/test_grid_filters.py @@ -26,12 +26,12 @@ class TestGridFilters: @pytest.mark.parametrize('mode',['point','node']) def test_grid_DNA(self,mode): - """Ensure that cellSizeOrigin_coordinates0_xx is the inverse of coordinates0_xx.""" + """Ensure that cellsSizeOrigin_coordinates0_xx is the inverse of coordinates0_xx.""" cells = np.random.randint(8,32,(3)) size = np.random.random(3) origin = np.random.random(3) coord0 = eval(f'grid_filters.coordinates0_{mode}(cells,size,origin)') # noqa - _cells,_size,_origin = eval(f'grid_filters.cellSizeOrigin_coordinates0_{mode}(coord0.reshape(-1,3,order="F"))') + _cells,_size,_origin = eval(f'grid_filters.cellsSizeOrigin_coordinates0_{mode}(coord0.reshape(-1,3,order="F"))') assert np.allclose(cells,_cells) and np.allclose(size,_size) and np.allclose(origin,_origin) def test_displacement_fluct_equivalence(self): @@ -40,14 +40,14 @@ class TestGridFilters: cells = np.random.randint(8,32,(3)) F = np.random.random(tuple(cells)+(3,3)) assert np.allclose(grid_filters.displacement_fluct_node(size,F), - grid_filters.point_2_node(grid_filters.displacement_fluct_point(size,F))) + grid_filters.point_to_node(grid_filters.displacement_fluct_point(size,F))) def test_interpolation_to_node(self): size = np.random.random(3) cells = np.random.randint(8,32,(3)) F = np.random.random(tuple(cells)+(3,3)) assert np.allclose(grid_filters.coordinates_node(size,F) [1:-1,1:-1,1:-1], - grid_filters.point_2_node(grid_filters.coordinates_point(size,F))[1:-1,1:-1,1:-1]) + grid_filters.point_to_node(grid_filters.coordinates_point(size,F))[1:-1,1:-1,1:-1]) def test_interpolation_to_cell(self): cells = np.random.randint(1,30,(3)) @@ -94,15 +94,15 @@ class TestGridFilters: assert np.allclose(function(size,F),0.0) @pytest.mark.parametrize('function',[grid_filters.coordinates0_check, - grid_filters.cellSizeOrigin_coordinates0_node, - grid_filters.cellSizeOrigin_coordinates0_point]) + grid_filters.cellsSizeOrigin_coordinates0_node, + grid_filters.cellsSizeOrigin_coordinates0_point]) def test_invalid_coordinates(self,function): invalid_coordinates = np.random.random((np.random.randint(12,52),3)) with pytest.raises(ValueError): function(invalid_coordinates) - @pytest.mark.parametrize('function',[grid_filters.cellSizeOrigin_coordinates0_node, - grid_filters.cellSizeOrigin_coordinates0_point]) + @pytest.mark.parametrize('function',[grid_filters.cellsSizeOrigin_coordinates0_node, + grid_filters.cellsSizeOrigin_coordinates0_point]) def test_uneven_spaced_coordinates(self,function): start = np.random.random(3) end = np.random.random(3)*10. + start @@ -116,8 +116,8 @@ class TestGridFilters: @pytest.mark.parametrize('mode',[True,False]) - @pytest.mark.parametrize('function',[grid_filters.cellSizeOrigin_coordinates0_node, - grid_filters.cellSizeOrigin_coordinates0_point]) + @pytest.mark.parametrize('function',[grid_filters.cellsSizeOrigin_coordinates0_node, + grid_filters.cellsSizeOrigin_coordinates0_point]) def test_unordered_coordinates(self,function,mode): origin = np.random.random(3) size = np.random.random(3)*10.+origin From de1708b20affdba30165fc89a8a3d27c985d8296 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 8 Dec 2020 00:36:41 +0100 Subject: [PATCH 2/7] missing renames + better help --- processing/post/addCompatibilityMismatch.py | 2 +- processing/post/addCurl.py | 2 +- processing/post/addDisplacement.py | 2 +- processing/post/addDivergence.py | 2 +- processing/post/addEuclideanDistance.py | 2 +- processing/post/addGradient.py | 2 +- python/damask/seeds.py | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/processing/post/addCompatibilityMismatch.py b/processing/post/addCompatibilityMismatch.py index e3219d839..d06eca72e 100755 --- a/processing/post/addCompatibilityMismatch.py +++ b/processing/post/addCompatibilityMismatch.py @@ -71,7 +71,7 @@ for name in filenames: damask.util.report(scriptName,name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name) - grid,size,origin = damask.grid_filters.cellSizeOrigin_coordinates0_point(table.get(options.pos)) + grid,size,origin = damask.grid_filters.cellsSizeOrigin_coordinates0_point(table.get(options.pos)) F = table.get(options.defgrad).reshape(tuple(grid)+(-1,),order='F').reshape(tuple(grid)+(3,3)) nodes = damask.grid_filters.coordinates_node(size,F) diff --git a/processing/post/addCurl.py b/processing/post/addCurl.py index a6de51445..2e45631e7 100755 --- a/processing/post/addCurl.py +++ b/processing/post/addCurl.py @@ -44,7 +44,7 @@ for name in filenames: damask.util.report(scriptName,name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name) - grid,size,origin = damask.grid_filters.cellSizeOrigin_coordinates0_point(table.get(options.pos)) + grid,size,origin = damask.grid_filters.cellsSizeOrigin_coordinates0_point(table.get(options.pos)) for label in options.labels: field = table.get(label) diff --git a/processing/post/addDisplacement.py b/processing/post/addDisplacement.py index 3d24d6f0c..6fe577ec7 100755 --- a/processing/post/addDisplacement.py +++ b/processing/post/addDisplacement.py @@ -48,7 +48,7 @@ for name in filenames: damask.util.report(scriptName,name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name) - grid,size,origin = damask.grid_filters.cellSizeOrigin_coordinates0_point(table.get(options.pos)) + grid,size,origin = damask.grid_filters.cellsSizeOrigin_coordinates0_point(table.get(options.pos)) F = table.get(options.f).reshape(tuple(grid)+(-1,),order='F').reshape(tuple(grid)+(3,3)) if options.nodal: diff --git a/processing/post/addDivergence.py b/processing/post/addDivergence.py index e6bf1caa0..25023e015 100755 --- a/processing/post/addDivergence.py +++ b/processing/post/addDivergence.py @@ -44,7 +44,7 @@ for name in filenames: damask.util.report(scriptName,name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name) - grid,size,origin = damask.grid_filters.cellSizeOrigin_coordinates0_point(table.get(options.pos)) + grid,size,origin = damask.grid_filters.cellsSizeOrigin_coordinates0_point(table.get(options.pos)) for label in options.labels: field = table.get(label) diff --git a/processing/post/addEuclideanDistance.py b/processing/post/addEuclideanDistance.py index f35f5285a..86eb46ec7 100755 --- a/processing/post/addEuclideanDistance.py +++ b/processing/post/addEuclideanDistance.py @@ -143,7 +143,7 @@ for name in filenames: damask.util.report(scriptName,name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name) - grid,size,origin = damask.grid_filters.cellSizeOrigin_coordinates0_point(table.get(options.pos)) + grid,size,origin = damask.grid_filters.cellsSizeOrigin_coordinates0_point(table.get(options.pos)) neighborhood = neighborhoods[options.neighborhood] diffToNeighbor = np.empty(list(grid+2)+[len(neighborhood)],'i') diff --git a/processing/post/addGradient.py b/processing/post/addGradient.py index 66b122082..bd6173e6e 100755 --- a/processing/post/addGradient.py +++ b/processing/post/addGradient.py @@ -44,7 +44,7 @@ for name in filenames: damask.util.report(scriptName,name) table = damask.Table.load(StringIO(''.join(sys.stdin.read())) if name is None else name) - grid,size,origin = damask.grid_filters.cellSizeOrigin_coordinates0_point(table.get(options.pos)) + grid,size,origin = damask.grid_filters.cellsSizeOrigin_coordinates0_point(table.get(options.pos)) for label in options.labels: field = table.get(label) diff --git a/python/damask/seeds.py b/python/damask/seeds.py index 8693e3549..9ab148a82 100644 --- a/python/damask/seeds.py +++ b/python/damask/seeds.py @@ -18,8 +18,8 @@ def from_random(size,N_seeds,cells=None,rng_seed=None): N_seeds : int Number of seeds. cells : numpy.ndarray of shape (3), optional. - If given, ensures that each seed results in a grain for a standard - Voronoi tessellation. + If given, ensures that each seed results in a grain when a standard Voronoi + tessellation is performed using the given grid resolution (i.e. size/cells). rng_seed : {None, int, array_like[ints], SeedSequence, BitGenerator, Generator}, optional A seed to initialize the BitGenerator. Defaults to None. If None, then fresh, unpredictable entropy will be pulled from the OS. From 14bb947c36d9a73f4a779f1793a5a0c422ab4aa5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 8 Dec 2020 08:15:27 +0100 Subject: [PATCH 3/7] updated documentation --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index a0475c50b..faf1d3700 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit a0475c50bfaf6f86f75345754188918a6e9d7134 +Subproject commit faf1d370002e0ac2496bb9b8c869d8ac0defea90 From 98328c94506cdf38ad5e8bd112860096a1408ffd Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 8 Dec 2020 20:49:04 +0100 Subject: [PATCH 4/7] PRIVATE-master has one extra merge commit --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index faf1d3700..fd99d76d1 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit faf1d370002e0ac2496bb9b8c869d8ac0defea90 +Subproject commit fd99d76d1eaa42fd36971ff2f79a59d98534fc27 From 92d21ca8887b37d16c751a95a817375b4781cb37 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 8 Dec 2020 23:08:40 +0100 Subject: [PATCH 5/7] doxygen documentation does not exist anymore --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b7f7f8b0b..062813323 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -353,7 +353,6 @@ backupData: - mkdir $BACKUP/${CI_PIPELINE_ID}_${CI_COMMIT_SHA} - mv $LOCAL_HOME/performance/time.png $BACKUP/${CI_PIPELINE_ID}_${CI_COMMIT_SHA}/ - mv $LOCAL_HOME/performance/memory.png $BACKUP/${CI_PIPELINE_ID}_${CI_COMMIT_SHA}/ - - mv $DAMASKROOT/PRIVATE/documenting/DAMASK_* $BACKUP/${CI_PIPELINE_ID}_${CI_COMMIT_SHA}/ only: - development From 170b9a27d2a464fcb95beae5331790da1d3cd5a0 Mon Sep 17 00:00:00 2001 From: Test User Date: Wed, 9 Dec 2020 01:18:48 +0100 Subject: [PATCH 6/7] [skip ci] updated version information after successful test of v3.0.0-alpha-930-g92d21ca88 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d04d76024..0a5280b61 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha-920-gccf1a849f +v3.0.0-alpha-930-g92d21ca88 From ed57bfecf201088b9e35f368a8933c6484b04f3e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 9 Dec 2020 07:46:16 +0100 Subject: [PATCH 7/7] preparing second 3.0 series alpha release --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0a5280b61..aa6647e80 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha-930-g92d21ca88 +v3.0.0-alpha2