2019-05-30 05:23:45 +05:30
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2019-05-30 13:50:07 +05:30
|
|
|
from optparse import OptionParser
|
|
|
|
|
2019-05-30 05:23:45 +05:30
|
|
|
import numpy as np
|
2019-05-30 13:50:07 +05:30
|
|
|
|
2019-05-30 05:23:45 +05:30
|
|
|
import damask
|
|
|
|
|
|
|
|
|
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
|
2019-05-30 05:23:45 +05:30
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
|
2019-05-30 05:23:45 +05:30
|
|
|
Generate homogeneous geometry.
|
|
|
|
|
|
|
|
""", version = scriptID)
|
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
parser.add_option('-g','--grid',
|
2019-05-30 05:23:45 +05:30
|
|
|
dest = 'grid',
|
2019-05-30 13:50:07 +05:30
|
|
|
type = 'int', nargs = 3, metavar = ' '.join(['int']*3),
|
2019-05-30 05:23:45 +05:30
|
|
|
help = 'a,b,c grid of hexahedral box %default')
|
2019-05-30 13:50:07 +05:30
|
|
|
parser.add_option('-s', '--size',
|
2019-05-30 05:23:45 +05:30
|
|
|
dest = 'size',
|
|
|
|
type = 'float', nargs = 3, metavar = ' '.join(['float']*3),
|
2019-06-03 23:08:48 +05:30
|
|
|
help = 'x,y,z of geometry size')
|
2019-05-30 13:50:07 +05:30
|
|
|
parser.add_option('-o','--origin',
|
2019-05-30 05:23:45 +05:30
|
|
|
dest = 'origin',
|
|
|
|
type = 'float', nargs = 3, metavar = ' '.join(['float']*3),
|
|
|
|
help = 'x,y,z of geometry origin %default')
|
|
|
|
parser.add_option('--homogenization',
|
|
|
|
dest = 'homogenization',
|
|
|
|
type = 'int', metavar = 'int',
|
|
|
|
help = 'homogenization index [%default]')
|
2019-05-30 13:50:07 +05:30
|
|
|
parser.add_option('-f','--fill',
|
2019-05-30 05:23:45 +05:30
|
|
|
dest = 'fill',
|
2019-05-30 13:50:07 +05:30
|
|
|
type = 'float', metavar = 'int',
|
2019-05-30 05:23:45 +05:30
|
|
|
help = 'microstructure index [%default]')
|
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
parser.set_defaults(grid = (16,16,16),
|
|
|
|
origin = (0.,0.,0.),
|
2019-05-30 05:23:45 +05:30
|
|
|
homogenization = 1,
|
|
|
|
fill = 1,
|
|
|
|
)
|
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
(options, filename) = parser.parse_args()
|
2019-05-30 05:23:45 +05:30
|
|
|
|
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
name = None if filename == [] else filename[0]
|
|
|
|
damask.util.report(scriptName,name)
|
2019-05-30 05:23:45 +05:30
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
dtype = float if np.isnan(options.fill) or int(options.fill) != options.fill else int
|
|
|
|
geom = damask.Geom(microstructure=np.full(options.grid,options.fill,dtype=dtype),
|
|
|
|
size=options.size,
|
|
|
|
origin=options.origin,
|
|
|
|
homogenization=options.homogenization,
|
2019-05-30 05:23:45 +05:30
|
|
|
comments=scriptID + ' ' + ' '.join(sys.argv[1:]))
|
|
|
|
damask.util.croak(geom)
|
2019-05-30 17:37:49 +05:30
|
|
|
|
2019-05-30 13:50:07 +05:30
|
|
|
if name is None:
|
|
|
|
sys.stdout.write(str(geom.show()))
|
|
|
|
else:
|
|
|
|
geom.to_file(name)
|