2019-02-15 05:13:34 +05:30
|
|
|
#!/usr/bin/env python3
|
2014-11-14 20:46:00 +05:30
|
|
|
|
2019-05-27 01:37:50 +05:30
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
from io import StringIO
|
2019-12-09 03:05:39 +05:30
|
|
|
from optparse import OptionParser
|
2019-05-27 01:37:50 +05:30
|
|
|
|
2014-11-14 20:46:00 +05:30
|
|
|
import damask
|
|
|
|
|
2019-05-27 01:37:50 +05:30
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2014-11-14 20:46:00 +05:30
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
#--------------------------------------------------------------------------------------------------
|
|
|
|
|
2016-05-12 12:24:34 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile(s)]', description = """
|
2016-05-17 14:35:50 +05:30
|
|
|
Translate geom description into ASCIItable containing position and microstructure.
|
2014-11-14 20:46:00 +05:30
|
|
|
|
2014-11-18 13:30:45 +05:30
|
|
|
""", version = scriptID)
|
2014-11-14 20:46:00 +05:30
|
|
|
|
|
|
|
(options, filenames) = parser.parse_args()
|
2015-08-21 01:12:05 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2015-08-08 00:33:26 +05:30
|
|
|
|
|
|
|
for name in filenames:
|
2019-12-09 03:05:39 +05:30
|
|
|
damask.util.report(scriptName,name)
|
2015-08-08 00:33:26 +05:30
|
|
|
|
2019-12-09 03:05:39 +05:30
|
|
|
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
|
|
|
damask.util.croak(geom)
|
2019-05-30 17:37:49 +05:30
|
|
|
|
2020-03-17 16:52:48 +05:30
|
|
|
coord0 = damask.grid_filters.cell_coord0(geom.grid,geom.size,geom.origin).reshape(-1,3)
|
2014-11-14 20:46:00 +05:30
|
|
|
|
2019-12-09 03:05:39 +05:30
|
|
|
comments = geom.comments \
|
|
|
|
+ [scriptID + ' ' + ' '.join(sys.argv[1:]),
|
2020-03-17 16:52:48 +05:30
|
|
|
'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)]
|
2014-11-14 20:46:00 +05:30
|
|
|
|
2019-12-09 03:05:39 +05:30
|
|
|
table = damask.Table(coord0,{'pos':(3,)},comments)
|
2020-01-02 22:16:14 +05:30
|
|
|
table.add('microstructure',geom.microstructure.reshape((-1,1),order='F'))
|
2019-05-28 01:30:26 +05:30
|
|
|
|
2020-03-17 16:52:48 +05:30
|
|
|
table.to_ASCII(sys.stdout if name is None else os.path.splitext(name)[0]+'.txt')
|