now a library function

This commit is contained in:
Martin Diehl 2020-08-08 20:46:46 +02:00
parent 0c6ce390b5
commit 309c53dc97
3 changed files with 1 additions and 141 deletions

@ -1 +1 @@
Subproject commit 3fc9d58a35614fd8ffa1179e634431eb457d0150 Subproject commit a52584687a93b9f007cf019861fce68eb31451ab

View File

@ -1,75 +0,0 @@
#!/usr/bin/env python3
import os
from optparse import OptionParser
import damask
scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version])
#--------------------------------------------------------------------------------------------------
# MAIN
#--------------------------------------------------------------------------------------------------
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
Inserts a primitive geometric object at a given position.
These objects can be boxes, cylinders, or ellipsoids.
""", version = scriptID)
parser.add_option('-c', '--center',
dest='center',
type='float', nargs = 3, metavar=' '.join(['float']*3),
help='a,b,c origin of primitive %default')
parser.add_option('-d', '--dimension',
dest='dimension',
type='float', nargs = 3, metavar=' '.join(['float']*3),
help='a,b,c extension of hexahedral box')
parser.add_option('-e', '--exponent',
dest='exponent',
type='float', nargs = 3, metavar=' '.join(['float']*3),
help='i,j,k exponents for axes: '+
'0 gives octahedron (|x|^(2^0) + |y|^(2^0) + |z|^(2^0) < 1), '+
'1 gives a sphere (|x|^(2^1) + |y|^(2^1) + |z|^(2^1) < 1), '+
'large values produce boxes, negative turn concave.')
parser.add_option('-f', '--fill',
dest='fill',
type='float', metavar = 'int',
help='microstructure index to fill primitive, defaults to max microstructure index + 1')
parser.add_option('-q', '--quaternion',
dest='quaternion',
type='float', nargs = 4, metavar=' '.join(['float']*4),
help = 'rotation of primitive as quaternion')
parser.add_option('-a', '--angleaxis',
dest='angleaxis',
type=float, nargs = 4, metavar=' '.join(['float']*4),
help = 'axis and angle to rotate primitive')
parser.add_option( '--degrees',
dest='degrees',
action='store_true',
help = 'angle is given in degrees')
parser.add_option( '--nonperiodic',
dest='periodic',
action='store_false',
help = 'wrap around edges')
parser.add_option( '--realspace',
dest='realspace',
action='store_true',
help = '-c and -d span [origin,origin+size] instead of [0,grid] coordinates')
parser.add_option( '--invert',
dest='inside',
action='store_false',
help = 'invert the volume filled by the primitive (inside/outside)')
parser.set_defaults(center = (.0,.0,.0),
degrees = False,
exponent = (20,20,20), # box shape by default
periodic = True,
realspace = False,
inside = True,
)
print('This script is broken and does nothing')

View File

@ -1,65 +0,0 @@
#!/usr/bin/env python3
import os
import sys
from io import StringIO
from optparse import OptionParser
import numpy as np
import damask
scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version])
#--------------------------------------------------------------------------------------------------
# MAIN
#--------------------------------------------------------------------------------------------------
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
Offset microstructure index for points which see a microstructure different from themselves
(or listed as triggers) within a given (cubic) vicinity, i.e. within the region close to a grain/phase boundary.
""", version = scriptID)
parser.add_option('-v', '--vicinity',
dest = 'vicinity',
type = 'int', metavar = 'int',
help = 'voxel distance checked for presence of other microstructure [%default]')
parser.add_option('-o', '--offset',
dest='offset',
type = 'int', metavar = 'int',
help='offset (positive or negative) to tag microstructure indices, defaults to max microstructure index')
parser.add_option('-t', '--trigger',
dest = 'trigger',
action = 'extend', metavar = '<int LIST>',
help = 'list of microstructure indices triggering a change')
parser.add_option('-n', '--nonperiodic',
dest = 'mode',
action = 'store_const', const = 'nearest',
help = 'assume geometry to be non-periodic')
parser.set_defaults(vicinity = 1,
trigger = [],
mode = 'wrap',
)
(options, filenames) = parser.parse_args()
options.trigger = np.array(options.trigger, dtype=int)
if filenames == []: filenames = [None]
for name in filenames:
damask.util.report(scriptName,name)
geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name)
damask.util.croak(geom.vicinity_offset(options.vicinity,options.offset,options.trigger,
True if options.mode is 'wrap' else False))
geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:]))
geom.to_file(sys.stdout if name is None else name,pack=False)