2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2011-12-21 22:55:31 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2019-11-28 20:16:22 +05:30
|
|
|
from io import StringIO
|
2014-07-10 14:57:51 +05:30
|
|
|
from optparse import OptionParser
|
2019-06-14 16:33:30 +05:30
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
2014-07-10 14:57:51 +05:30
|
|
|
import damask
|
2011-12-21 22:55:31 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2011-12-21 22:55:31 +05:30
|
|
|
|
2015-04-24 13:37:13 +05:30
|
|
|
|
2011-12-21 22:55:31 +05:30
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-02-16 22:11:56 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
2011-12-21 22:55:31 +05:30
|
|
|
Add column(s) containing curl of requested column(s).
|
2019-11-28 20:16:22 +05:30
|
|
|
Operates on periodic ordered three-dimensional data sets of vector and tensor fields.
|
2014-08-06 18:57:09 +05:30
|
|
|
""", version = scriptID)
|
2011-12-21 22:55:31 +05:30
|
|
|
|
2016-04-25 16:52:34 +05:30
|
|
|
parser.add_option('-p','--pos','--periodiccellcenter',
|
2016-04-27 02:19:58 +05:30
|
|
|
dest = 'pos',
|
2016-04-16 03:57:23 +05:30
|
|
|
type = 'string', metavar = 'string',
|
2016-04-25 16:27:38 +05:30
|
|
|
help = 'label of coordinates [%default]')
|
2018-01-30 07:57:05 +05:30
|
|
|
parser.add_option('-l','--label',
|
2019-11-28 20:16:22 +05:30
|
|
|
dest = 'labels',
|
2015-08-08 00:33:26 +05:30
|
|
|
action = 'extend', metavar = '<string LIST>',
|
2018-01-29 04:55:50 +05:30
|
|
|
help = 'label(s) of field values')
|
2015-08-08 00:33:26 +05:30
|
|
|
|
2016-04-27 02:19:58 +05:30
|
|
|
parser.set_defaults(pos = 'pos',
|
2015-08-08 00:33:26 +05:30
|
|
|
)
|
2011-12-21 22:55:31 +05:30
|
|
|
|
|
|
|
(options,filenames) = parser.parse_args()
|
2015-08-13 14:02:09 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2015-08-08 00:33:26 +05:30
|
|
|
|
2019-11-28 20:16:22 +05:30
|
|
|
if options.labels is None: parser.error('no data column specified.')
|
2015-08-08 00:33:26 +05:30
|
|
|
|
2019-11-28 20:16:22 +05:30
|
|
|
for name in filenames:
|
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
|
|
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
2020-01-13 07:21:49 +05:30
|
|
|
grid,size,origin = damask.grid_filters.cell_coord0_gridSizeOrigin(table.get(options.pos))
|
2019-11-28 20:16:22 +05:30
|
|
|
|
|
|
|
for label in options.labels:
|
2019-12-05 18:05:06 +05:30
|
|
|
field = table.get(label)
|
2019-11-28 20:16:22 +05:30
|
|
|
shape = (3,) if np.prod(field.shape)//np.prod(grid) == 3 else (3,3) # vector or tensor
|
2020-04-20 16:11:03 +05:30
|
|
|
field = field.reshape(tuple(grid)+(-1,),order='F').reshape(tuple(grid)+shape)
|
|
|
|
curl = damask.grid_filters.curl(size,field)
|
2020-09-14 10:34:01 +05:30
|
|
|
table = table.add('curlFFT({})'.format(label),
|
|
|
|
curl.reshape(tuple(grid)+(-1,)).reshape(-1,np.prod(shape),order='F'),
|
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
2020-04-20 16:11:03 +05:30
|
|
|
|
2020-09-03 20:49:19 +05:30
|
|
|
table.to_file(sys.stdout if name is None else name)
|