2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2012-11-14 16:16:51 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2019-11-27 03:25:38 +05:30
|
|
|
from io import StringIO
|
2014-07-22 01:25:05 +05:30
|
|
|
from optparse import OptionParser
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2014-07-22 01:25:05 +05:30
|
|
|
import damask
|
2012-11-14 16:16:51 +05:30
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2012-11-14 16:16:51 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2012-11-14 16:16:51 +05:30
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-02-16 22:11:56 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(2)]', description = """
|
2012-11-14 16:16:51 +05:30
|
|
|
Add column(s) containing deviator of requested tensor column(s).
|
|
|
|
|
2014-08-06 18:57:09 +05:30
|
|
|
""", version = scriptID)
|
2012-11-14 16:16:51 +05:30
|
|
|
|
2015-08-08 00:33:26 +05:30
|
|
|
parser.add_option('-t','--tensor',
|
|
|
|
dest = 'tensor',
|
|
|
|
action = 'extend', metavar='<string LIST>',
|
|
|
|
help = 'heading of columns containing tensor field values')
|
|
|
|
parser.add_option('-s','--spherical',
|
|
|
|
dest = 'spherical',
|
|
|
|
action = 'store_true',
|
|
|
|
help = 'report spherical part of tensor (hydrostatic component, pressure)')
|
2012-11-14 16:16:51 +05:30
|
|
|
|
|
|
|
(options,filenames) = parser.parse_args()
|
2019-11-27 13:14:38 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2012-11-14 16:16:51 +05:30
|
|
|
|
2016-03-02 01:14:43 +05:30
|
|
|
if options.tensor is None:
|
2019-11-27 13:14:38 +05:30
|
|
|
parser.error('no data column specified...')
|
2015-08-08 00:33:26 +05:30
|
|
|
|
|
|
|
for name in filenames:
|
2019-11-27 03:25:38 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
|
|
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
|
|
|
for tensor in options.tensor:
|
2019-12-05 10:40:27 +05:30
|
|
|
table.add('dev({})'.format(tensor),
|
|
|
|
damask.mechanics.deviatoric_part(table.get(tensor).reshape(-1,3,3)).reshape((-1,9)),
|
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
2019-11-27 03:25:38 +05:30
|
|
|
if options.spherical:
|
2019-12-05 10:40:27 +05:30
|
|
|
table.add('sph({})'.format(tensor),
|
|
|
|
damask.mechanics.spherical_part(table.get(tensor).reshape(-1,3,3)),
|
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
2019-11-27 13:14:38 +05:30
|
|
|
|
2019-11-27 03:25:38 +05:30
|
|
|
table.to_ASCII(sys.stdout if name is None else name)
|