polishing

This commit is contained in:
Martin Diehl 2019-12-08 18:33:43 +01:00
parent 3d09a82f41
commit 7dc128ad12
5 changed files with 33 additions and 11 deletions

View File

@ -44,7 +44,7 @@ for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos),True) grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos))
for label in options.labels: for label in options.labels:
field = table.get(label) field = table.get(label)

View File

@ -50,7 +50,7 @@ for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos),True) grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos))
F = table.get(options.f).reshape(np.append(grid[::-1],(3,3))) F = table.get(options.f).reshape(np.append(grid[::-1],(3,3)))
if options.nodal: if options.nodal:

View File

@ -44,7 +44,7 @@ for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos),True) grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos))
for label in options.labels: for label in options.labels:
field = table.get(label) field = table.get(label)

View File

@ -44,7 +44,7 @@ for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos),True) grid,size,origin = damask.grid_filters.cell_coord0_2_DNA(table.get(options.pos))
for label in options.labels: for label in options.labels:
field = table.get(label) field = table.get(label)

View File

@ -89,7 +89,18 @@ def cell_displacement_avg(size,F):
F_avg = np.average(F,axis=(0,1,2)) F_avg = np.average(F,axis=(0,1,2))
return np.einsum('ml,ijkl->ijkm',F_avg-np.eye(3),cell_coord0(F.shape[:3],size)) return np.einsum('ml,ijkl->ijkm',F_avg-np.eye(3),cell_coord0(F.shape[:3],size))
def cell_coord0_2_DNA(coord0,ordered=False): def cell_coord0_2_DNA(coord0,ordered=True):
"""
Return grid 'DNA', i.e. grid, size, and origin from array of cell positions.
Parameters
----------
coord0 : numpy.ndarray
array of undeformed cell coordinates
ordered : bool, optional
expect coord0 data to be ordered (x fast, z slow).
"""
coords = [np.unique(coord0[:,i]) for i in range(3)] coords = [np.unique(coord0[:,i]) for i in range(3)]
mincorner = np.array(list(map(min,coords))) mincorner = np.array(list(map(min,coords)))
maxcorner = np.array(list(map(max,coords))) maxcorner = np.array(list(map(max,coords)))
@ -109,9 +120,9 @@ def cell_coord0_2_DNA(coord0,ordered=False):
np.allclose(coords[2],np.linspace(start[2],end[2],grid[2])): np.allclose(coords[2],np.linspace(start[2],end[2],grid[2])):
raise ValueError('Regular grid spacing violated.') raise ValueError('Regular grid spacing violated.')
if ordered: if ordered and not np.allclose(coord0.reshape(tuple(grid[::-1])+(3,)),cell_coord0(grid,size,origin)):
if not np.allclose(coord0.reshape(tuple(grid[::-1])+(3,)),cell_coord0(grid,size,origin)): raise ValueError('Input data is not a regular grid.')
raise ValueError('Input data is not a regular grid.')
return (grid,size,origin) return (grid,size,origin)
@ -151,6 +162,17 @@ def node_2_cell(node_data):
return c[:-1,:-1,:-1] return c[:-1,:-1,:-1]
def node_coord0_2_DNA(coord0,ordered=False): def node_coord0_2_DNA(coord0,ordered=False):
"""
Return grid 'DNA', i.e. grid, size, and origin from array of nodal positions.
Parameters
----------
coord0 : numpy.ndarray
array of undeformed nodal coordinates
ordered : bool, optional
expect coord0 data to be ordered (x fast, z slow).
"""
coords = [np.unique(coord0[:,i]) for i in range(3)] coords = [np.unique(coord0[:,i]) for i in range(3)]
mincorner = np.array(list(map(min,coords))) mincorner = np.array(list(map(min,coords)))
maxcorner = np.array(list(map(max,coords))) maxcorner = np.array(list(map(max,coords)))
@ -166,9 +188,9 @@ def node_coord0_2_DNA(coord0,ordered=False):
np.allclose(coords[2],np.linspace(mincorner[2],maxcorner[2],grid[2]+1)): np.allclose(coords[2],np.linspace(mincorner[2],maxcorner[2],grid[2]+1)):
raise ValueError('Regular grid spacing violated.') raise ValueError('Regular grid spacing violated.')
if ordered: if ordered and not np.allclose(coord0.reshape(tuple((grid+1)[::-1])+(3,)),node_coord0(grid,size,origin)):
if not np.allclose(coord0.reshape(tuple((grid+1)[::-1])+(3,)),node_coord0(grid,size,origin)): raise ValueError('Input data is not a regular grid.')
raise ValueError('Input data is not a regular grid.')
return (grid,size,origin) return (grid,size,origin)