changed default label of coordinates to "pos"
This commit is contained in:
parent
7567aae7c0
commit
81f6530f52
|
@ -71,18 +71,18 @@ Deals with both vector- and tensor-valued fields.
|
|||
|
||||
parser.add_option('-c','--coordinates',
|
||||
dest = 'coords',
|
||||
type = 'string', metavar='string',
|
||||
help = 'column heading for coordinates [%default]')
|
||||
type = 'string', metavar = 'string',
|
||||
help = 'column label of coordinates [%default]')
|
||||
parser.add_option('-v','--vector',
|
||||
dest = 'vector',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'heading of columns containing vector field values')
|
||||
help = 'column label(s) of vector field values')
|
||||
parser.add_option('-t','--tensor',
|
||||
dest = 'tensor',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'heading of columns containing tensor field values')
|
||||
help = 'column label(s) of tensor field values')
|
||||
|
||||
parser.set_defaults(coords = 'ipinitialcoord',
|
||||
parser.set_defaults(coords = 'pos',
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
|
|
@ -88,8 +88,9 @@ def displacementFluctFFT(F,grid,size,nodal=False,transformed=False):
|
|||
# --------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options file[s]', description = """
|
||||
Add deformed configuration of given initial coordinates.
|
||||
Add displacments resulting from deformation gradient field.
|
||||
Operates on periodic three-dimensional x,y,z-ordered data sets.
|
||||
Outputs at cell centers or cell nodes (into separate file).
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
|
@ -107,7 +108,7 @@ parser.add_option('--nodal',
|
|||
help = 'output nodal (not cell-centered) displacements')
|
||||
|
||||
parser.set_defaults(defgrad = 'f',
|
||||
coords = 'ipinitialcoord',
|
||||
coords = 'pos',
|
||||
nodal = False,
|
||||
)
|
||||
|
||||
|
|
|
@ -58,17 +58,17 @@ Deals with both vector- and tensor-valued fields.
|
|||
parser.add_option('-c','--coordinates',
|
||||
dest = 'coords',
|
||||
type = 'string', metavar = 'string',
|
||||
help = 'column heading for coordinates [%default]')
|
||||
help = 'column label of coordinates [%default]')
|
||||
parser.add_option('-v','--vector',
|
||||
dest = 'vector',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'heading of columns containing vector field values')
|
||||
help = 'column label(s) of vector field values')
|
||||
parser.add_option('-t','--tensor',
|
||||
dest = 'tensor',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'heading of columns containing tensor field values')
|
||||
help = 'column label(s) of tensor field values')
|
||||
|
||||
parser.set_defaults(coords = 'ipinitialcoord',
|
||||
parser.set_defaults(coords = 'pos',
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
|
|
@ -9,7 +9,9 @@ import damask
|
|||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
def gradFFT(geomdim,field):
|
||||
|
||||
grid = np.array(np.shape(field)[2::-1])
|
||||
N = grid.prod() # field size
|
||||
n = np.array(np.shape(field)[3:]).prod() # data size
|
||||
|
@ -61,17 +63,17 @@ Deals with both vector- and scalar fields.
|
|||
parser.add_option('-c','--coordinates',
|
||||
dest = 'coords',
|
||||
type = 'string', metavar='string',
|
||||
help = 'column heading for coordinates [%default]')
|
||||
help = 'column label of coordinates [%default]')
|
||||
parser.add_option('-v','--vector',
|
||||
dest = 'vector',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'heading of columns containing vector field values')
|
||||
help = 'column label(s) of vector field values')
|
||||
parser.add_option('-s','--scalar',
|
||||
dest = 'scalar',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'heading of columns containing scalar field values')
|
||||
help = 'column label(s) of scalar field values')
|
||||
|
||||
parser.set_defaults(coords = 'ipinitialcoord',
|
||||
parser.set_defaults(coords = 'pos',
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
|
|
@ -22,7 +22,7 @@ Average each data block of size 'packing' into single values thus reducing the f
|
|||
parser.add_option('-c','--coordinates',
|
||||
dest = 'coords',
|
||||
type = 'string', metavar = 'string',
|
||||
help = 'column heading for coordinates [%default]')
|
||||
help = 'column label of coordinates [%default]')
|
||||
parser.add_option('-p','--packing',
|
||||
dest = 'packing',
|
||||
type = 'int', nargs = 3, metavar = 'int int int',
|
||||
|
@ -39,7 +39,7 @@ parser.add_option('-s', '--size',
|
|||
dest = 'size',
|
||||
type = 'float', nargs = 3, metavar = 'float float float',
|
||||
help = 'size in x,y,z [autodetect]')
|
||||
parser.set_defaults(coords = 'ipinitialcoord',
|
||||
parser.set_defaults(coords = 'pos',
|
||||
packing = (2,2,2),
|
||||
shift = (0,0,0),
|
||||
grid = (0,0,0),
|
||||
|
@ -59,8 +59,7 @@ if any(shift != 0): prefix += 'shift{:+}{:+}{:+}_'.format(*shift)
|
|||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
try:
|
||||
table = damask.ASCIItable(name = name,
|
||||
try: table = damask.ASCIItable(name = name,
|
||||
outname = os.path.join(os.path.dirname(name),
|
||||
prefix+os.path.basename(name)) if name else name,
|
||||
buffered = False)
|
||||
|
@ -75,7 +74,6 @@ for name in filenames:
|
|||
|
||||
errors = []
|
||||
remarks = []
|
||||
colCoord = None
|
||||
|
||||
if table.label_dimension(options.coords) != 3: errors.append('coordinates {} are not a vector.'.format(options.coords))
|
||||
else: colCoord = table.label_index(options.coords)
|
||||
|
@ -86,7 +84,6 @@ for name in filenames:
|
|||
table.close(dismiss = True)
|
||||
continue
|
||||
|
||||
|
||||
# ------------------------------------------ assemble header ---------------------------------------
|
||||
|
||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||
|
|
|
@ -19,35 +19,37 @@ to resolution*packing.
|
|||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-c','--coordinates', dest='coords', metavar='string',
|
||||
help='column heading for coordinates [%default]')
|
||||
parser.add_option('-p','--packing', dest='packing', type='int', nargs=3, metavar='int int int',
|
||||
help='dimension of packed group [%default]')
|
||||
parser.add_option('-g','--grid', dest='resolution', type='int', nargs=3, metavar='int int int',
|
||||
help='resolution in x,y,z [autodetect]')
|
||||
parser.add_option('-s','--size', dest='dimension', type='float', nargs=3, metavar='int int int',
|
||||
help='dimension in x,y,z [autodetect]')
|
||||
parser.set_defaults(coords = 'ipinitialcoord')
|
||||
parser.set_defaults(packing = (2,2,2))
|
||||
parser.set_defaults(grid = (0,0,0))
|
||||
parser.set_defaults(size = (0.0,0.0,0.0))
|
||||
parser.add_option('-c','--coordinates',
|
||||
dest = 'coords', metavar = 'string',
|
||||
help = 'column label of coordinates [%default]')
|
||||
parser.add_option('-p','--packing',
|
||||
dest = 'packing', type = 'int', nargs = 3, metavar = 'int int int',
|
||||
help = 'dimension of packed group [%default]')
|
||||
parser.add_option('-g','--grid',
|
||||
dest = 'resolution', type = 'int', nargs = 3, metavar = 'int int int',
|
||||
help = 'resolution in x,y,z [autodetect]')
|
||||
parser.add_option('-s','--size',
|
||||
dest = 'dimension', type = 'float', nargs = 3, metavar = 'int int int',
|
||||
help = 'dimension in x,y,z [autodetect]')
|
||||
parser.set_defaults(coords = 'pos',
|
||||
packing = (2,2,2),
|
||||
grid = (0,0,0),
|
||||
size = (0.0,0.0,0.0),
|
||||
)
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
||||
|
||||
options.packing = np.array(options.packing)
|
||||
prefix = 'blowUp%ix%ix%i_'%(options.packing[0],options.packing[1],options.packing[2])
|
||||
prefix = 'blowUp{}x{}x{}_'.format(*options.packing)
|
||||
|
||||
# --- loop over input files -------------------------------------------------------------------------
|
||||
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
try:
|
||||
table = damask.ASCIItable(name = name,
|
||||
try: table = damask.ASCIItable(name = name,
|
||||
outname = os.path.join(os.path.dirname(name),
|
||||
prefix+ \
|
||||
os.path.basename(name)) if name else name,
|
||||
prefix+os.path.basename(name)) if name else name,
|
||||
buffered = False)
|
||||
except: continue
|
||||
damask.util.report(scriptName,name)
|
||||
|
@ -55,47 +57,44 @@ for name in filenames:
|
|||
# ------------------------------------------ read header ------------------------------------------
|
||||
|
||||
table.head_read()
|
||||
errors = []
|
||||
|
||||
# ------------------------------------------ sanity checks ----------------------------------------
|
||||
|
||||
if table.label_dimension(options.coords) != 3:
|
||||
damask.util.croak('coordinates {} are not a vector.'.format(options.coords))
|
||||
errors = []
|
||||
remarks = []
|
||||
|
||||
if table.label_dimension(options.coords) != 3: errors.append('coordinates {} are not a vector.'.format(options.coords))
|
||||
else: colCoord = table.label_index(options.coords)
|
||||
|
||||
colElem = table.label_index('elem')
|
||||
|
||||
if remarks != []: damask.util.croak(remarks)
|
||||
if errors != []:
|
||||
damask.util.croak(errors)
|
||||
table.close(dismiss = True)
|
||||
continue
|
||||
else:
|
||||
coordCol = table.label_index(options.coords)
|
||||
|
||||
|
||||
# ------------------------------------------ assemble header --------------------------------------
|
||||
|
||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||
|
||||
# --------------- figure out size and grid ---------------------------------------------------------
|
||||
|
||||
table.data_readArray()
|
||||
table.data_readArray(options.coords)
|
||||
|
||||
coords = [{},{},{}]
|
||||
for i in xrange(len(table.data)):
|
||||
for j in xrange(3):
|
||||
coords[j][str(table.data[i,coordCol+j])] = True
|
||||
coords = [np.unique(table.data[:,i]) for i in xrange(3)]
|
||||
mincorner = np.array(map(min,coords))
|
||||
maxcorner = np.array(map(max,coords))
|
||||
grid = np.array(map(len,coords),'i')
|
||||
size = grid/np.maximum(np.ones(3,'d'),grid-1.0)* \
|
||||
np.array([max(map(float,coords[0].keys()))-min(map(float,coords[0].keys())),\
|
||||
max(map(float,coords[1].keys()))-min(map(float,coords[1].keys())),\
|
||||
max(map(float,coords[2].keys()))-min(map(float,coords[2].keys())),\
|
||||
],'d') # size from bounding box, corrected for cell-centeredness
|
||||
|
||||
size = grid/np.maximum(np.ones(3,'d'), grid-1.0) * (maxcorner-mincorner) # size from edge to edge = dim * n/(n-1)
|
||||
size = np.where(grid > 1, size, min(size[grid > 1]/grid[grid > 1])) # spacing for grid==1 set to smallest among other spacings
|
||||
|
||||
|
||||
packing = np.array(options.packing,'i')
|
||||
outSize = grid*packing
|
||||
|
||||
# ------------------------------------------ assemble header ---------------------------------------
|
||||
# ------------------------------------------ assemble header --------------------------------------
|
||||
|
||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||
table.head_write()
|
||||
|
||||
# ------------------------------------------ process data -------------------------------------------
|
||||
|
||||
table.data_rewind()
|
||||
data = np.zeros(outSize.tolist()+[len(table.labels)])
|
||||
p = np.zeros(3,'i')
|
||||
|
@ -114,8 +113,8 @@ for name in filenames:
|
|||
for c in xrange(outSize[2]):
|
||||
for b in xrange(outSize[1]):
|
||||
for a in xrange(outSize[0]):
|
||||
data[a,b,c,coordCol:coordCol+3] = [a+0.5,b+0.5,c+0.5]*elementSize
|
||||
data[a,b,c,table.label_index('elem')] = elem
|
||||
data[a,b,c,colCoord:colCoord+3] = [a+0.5,b+0.5,c+0.5]*elementSize
|
||||
if colElem != -1: data[a,b,c,colElem] = elem
|
||||
table.data = data[a,b,c,:].tolist()
|
||||
outputAlive = table.data_write() # output processed line
|
||||
elem += 1
|
||||
|
|
Loading…
Reference in New Issue