2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2012-11-07 22:22:10 +05:30
|
|
|
|
2019-05-25 02:01:34 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2014-10-09 22:33:06 +05:30
|
|
|
from optparse import OptionParser
|
2019-05-27 02:22:23 +05:30
|
|
|
|
2014-10-09 22:33:06 +05:30
|
|
|
import damask
|
|
|
|
|
2019-05-27 02:22:23 +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-10-09 22:33:06 +05:30
|
|
|
|
|
|
|
|
2019-05-27 02:22:23 +05:30
|
|
|
minimal_surfaces = ['primitive','gyroid','diamond']
|
2012-11-07 22:22:10 +05:30
|
|
|
|
2019-05-27 02:22:23 +05:30
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile]', description = """
|
|
|
|
Generate a bicontinuous structure of given type.
|
2014-10-09 22:33:06 +05:30
|
|
|
|
|
|
|
""", version = scriptID)
|
|
|
|
|
2012-11-07 22:22:10 +05:30
|
|
|
|
2015-08-08 00:33:26 +05:30
|
|
|
parser.add_option('-t','--type',
|
|
|
|
dest = 'type',
|
|
|
|
choices = minimal_surfaces, metavar = 'string',
|
|
|
|
help = 'type of minimal surface [primitive] {%s}' %(','.join(minimal_surfaces)))
|
|
|
|
parser.add_option('-f','--threshold',
|
|
|
|
dest = 'threshold',
|
|
|
|
type = 'float', metavar = 'float',
|
|
|
|
help = 'threshold value defining minimal surface [%default]')
|
|
|
|
parser.add_option('-g', '--grid',
|
|
|
|
dest = 'grid',
|
|
|
|
type = 'int', nargs = 3, metavar = 'int int int',
|
|
|
|
help = 'a,b,c grid of hexahedral box [%default]')
|
|
|
|
parser.add_option('-s', '--size',
|
|
|
|
dest = 'size',
|
|
|
|
type = 'float', nargs = 3, metavar = 'float float float',
|
|
|
|
help = 'x,y,z size of hexahedral box [%default]')
|
|
|
|
parser.add_option('-p', '--periods',
|
|
|
|
dest = 'periods',
|
|
|
|
type = 'int', metavar = 'int',
|
|
|
|
help = 'number of repetitions of unit cell [%default]')
|
|
|
|
parser.add_option('--m',
|
|
|
|
dest = 'microstructure',
|
|
|
|
type = 'int', nargs = 2, metavar = 'int int',
|
|
|
|
help = 'two microstructure indices to be used [%default]')
|
2019-05-27 02:22:23 +05:30
|
|
|
|
2015-08-08 00:33:26 +05:30
|
|
|
parser.set_defaults(type = minimal_surfaces[0],
|
|
|
|
threshold = 0.0,
|
|
|
|
periods = 1,
|
|
|
|
grid = (16,16,16),
|
|
|
|
size = (1.0,1.0,1.0),
|
|
|
|
microstructure = (1,2),
|
|
|
|
)
|
|
|
|
|
2019-05-30 13:01:14 +05:30
|
|
|
(options,filename) = parser.parse_args()
|
2015-08-08 00:33:26 +05:30
|
|
|
|
|
|
|
|
2019-05-30 13:01:14 +05:30
|
|
|
name = None if filename == [] else filename[0]
|
|
|
|
damask.util.report(scriptName,name)
|
2015-08-08 00:33:26 +05:30
|
|
|
|
2020-09-30 10:40:15 +05:30
|
|
|
geom=damask.Geom.from_minimal_surface(options.grid,options.size,options.type,options.threshold,
|
|
|
|
options.periods,options.microstructure)
|
2019-05-30 13:01:14 +05:30
|
|
|
damask.util.croak(geom)
|
2019-05-30 14:15:17 +05:30
|
|
|
|
2020-09-21 01:21:09 +05:30
|
|
|
geom.save_ASCII(sys.stdout if name is None else name,compress=False)
|