using central functionality
This commit is contained in:
parent
b56864552f
commit
0bf22fd03c
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
from optparse import OptionParser
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
import damask
|
import damask
|
||||||
|
|
||||||
|
@ -24,38 +22,25 @@ Translate geom description into ASCIItable containing position and microstructur
|
||||||
""", version = scriptID)
|
""", version = scriptID)
|
||||||
|
|
||||||
(options, filenames) = parser.parse_args()
|
(options, filenames) = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
if filenames == []: filenames = [None]
|
if filenames == []: filenames = [None]
|
||||||
|
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
damask.util.report(scriptName,name)
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||||
|
|
||||||
damask.util.croak(geom)
|
damask.util.croak(geom)
|
||||||
|
|
||||||
# --- generate grid --------------------------------------------------------------------------------
|
coord0 = damask.grid_filters.cell_coord0(geom.grid,geom.size,geom.origin).reshape((-1,3),order='F')
|
||||||
|
|
||||||
grid = geom.get_grid()
|
comments = geom.comments \
|
||||||
size = geom.get_size()
|
+ [scriptID + ' ' + ' '.join(sys.argv[1:]),
|
||||||
origin = geom.get_origin()
|
"grid\ta {}\tb {}\tc {}".format(*geom.grid),
|
||||||
|
"size\tx {}\ty {}\tz {}".format(*geom.size),
|
||||||
|
"origin\tx {}\ty {}\tz {}".format(*geom.origin),
|
||||||
|
"homogenization\t{}".format(geom.homogenization)]
|
||||||
|
|
||||||
x = (0.5 + np.arange(grid[0],dtype=float))/grid[0]*size[0]+origin[0]
|
table = damask.Table(coord0,{'pos':(3,)},comments)
|
||||||
y = (0.5 + np.arange(grid[1],dtype=float))/grid[1]*size[1]+origin[1]
|
table.add('microstructure',geom.microstructure.reshape((-1,1)))
|
||||||
z = (0.5 + np.arange(grid[2],dtype=float))/grid[2]*size[2]+origin[2]
|
|
||||||
|
|
||||||
xx = np.tile( x, grid[1]* grid[2])
|
table.to_ASCII(sys.stdout if name is None else \
|
||||||
yy = np.tile(np.repeat(y,grid[0] ),grid[2])
|
os.path.splitext(name)[0]+'.txt')
|
||||||
zz = np.repeat(z,grid[0]*grid[1])
|
|
||||||
|
|
||||||
# --- create ASCII table --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
table = damask.ASCIItable(outname = os.path.splitext(name)[0]+'.txt' if name else name)
|
|
||||||
table.info_append(geom.get_comments() + [scriptID + '\t' + ' '.join(sys.argv[1:])])
|
|
||||||
table.labels_append(['{}_{}'.format(1+i,'pos') for i in range(3)]+['microstructure'])
|
|
||||||
table.head_write()
|
|
||||||
table.output_flush()
|
|
||||||
table.data = np.squeeze(np.dstack((xx,yy,zz,geom.microstructure.flatten('F'))),axis=0)
|
|
||||||
table.data_writeArray()
|
|
||||||
table.close()
|
|
||||||
|
|
Loading…
Reference in New Issue