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',
|
parser.add_option('-c','--coordinates',
|
||||||
dest = 'coords',
|
dest = 'coords',
|
||||||
type = 'string', metavar='string',
|
type = 'string', metavar = 'string',
|
||||||
help = 'column heading for coordinates [%default]')
|
help = 'column label of coordinates [%default]')
|
||||||
parser.add_option('-v','--vector',
|
parser.add_option('-v','--vector',
|
||||||
dest = 'vector',
|
dest = 'vector',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
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',
|
parser.add_option('-t','--tensor',
|
||||||
dest = 'tensor',
|
dest = 'tensor',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
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()
|
(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 = """
|
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.
|
Operates on periodic three-dimensional x,y,z-ordered data sets.
|
||||||
|
Outputs at cell centers or cell nodes (into separate file).
|
||||||
|
|
||||||
""", version = scriptID)
|
""", version = scriptID)
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ parser.add_option('--nodal',
|
||||||
help = 'output nodal (not cell-centered) displacements')
|
help = 'output nodal (not cell-centered) displacements')
|
||||||
|
|
||||||
parser.set_defaults(defgrad = 'f',
|
parser.set_defaults(defgrad = 'f',
|
||||||
coords = 'ipinitialcoord',
|
coords = 'pos',
|
||||||
nodal = False,
|
nodal = False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -58,17 +58,17 @@ Deals with both vector- and tensor-valued fields.
|
||||||
parser.add_option('-c','--coordinates',
|
parser.add_option('-c','--coordinates',
|
||||||
dest = 'coords',
|
dest = 'coords',
|
||||||
type = 'string', metavar = 'string',
|
type = 'string', metavar = 'string',
|
||||||
help = 'column heading for coordinates [%default]')
|
help = 'column label of coordinates [%default]')
|
||||||
parser.add_option('-v','--vector',
|
parser.add_option('-v','--vector',
|
||||||
dest = 'vector',
|
dest = 'vector',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
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',
|
parser.add_option('-t','--tensor',
|
||||||
dest = 'tensor',
|
dest = 'tensor',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
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()
|
(options,filenames) = parser.parse_args()
|
||||||
|
|
|
@ -9,7 +9,9 @@ import damask
|
||||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||||
scriptID = ' '.join([scriptName,damask.version])
|
scriptID = ' '.join([scriptName,damask.version])
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------------------------------
|
||||||
def gradFFT(geomdim,field):
|
def gradFFT(geomdim,field):
|
||||||
|
|
||||||
grid = np.array(np.shape(field)[2::-1])
|
grid = np.array(np.shape(field)[2::-1])
|
||||||
N = grid.prod() # field size
|
N = grid.prod() # field size
|
||||||
n = np.array(np.shape(field)[3:]).prod() # data size
|
n = np.array(np.shape(field)[3:]).prod() # data size
|
||||||
|
@ -17,7 +19,7 @@ def gradFFT(geomdim,field):
|
||||||
elif n == 1: dataType = 'scalar'
|
elif n == 1: dataType = 'scalar'
|
||||||
|
|
||||||
field_fourier = np.fft.fftpack.rfftn(field,axes=(0,1,2))
|
field_fourier = np.fft.fftpack.rfftn(field,axes=(0,1,2))
|
||||||
grad_fourier = np.zeros(field_fourier.shape+(3,),'c16')
|
grad_fourier = np.zeros(field_fourier.shape+(3,),'c16')
|
||||||
|
|
||||||
# differentiation in Fourier space
|
# differentiation in Fourier space
|
||||||
k_s = np.zeros([3],'i')
|
k_s = np.zeros([3],'i')
|
||||||
|
@ -61,17 +63,17 @@ Deals with both vector- and scalar fields.
|
||||||
parser.add_option('-c','--coordinates',
|
parser.add_option('-c','--coordinates',
|
||||||
dest = 'coords',
|
dest = 'coords',
|
||||||
type = 'string', metavar='string',
|
type = 'string', metavar='string',
|
||||||
help = 'column heading for coordinates [%default]')
|
help = 'column label of coordinates [%default]')
|
||||||
parser.add_option('-v','--vector',
|
parser.add_option('-v','--vector',
|
||||||
dest = 'vector',
|
dest = 'vector',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
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',
|
parser.add_option('-s','--scalar',
|
||||||
dest = 'scalar',
|
dest = 'scalar',
|
||||||
action = 'extend', metavar = '<string LIST>',
|
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()
|
(options,filenames) = parser.parse_args()
|
||||||
|
@ -96,7 +98,7 @@ for name in filenames:
|
||||||
|
|
||||||
items = {
|
items = {
|
||||||
'scalar': {'dim': 1, 'shape': [1], 'labels':options.scalar, 'active':[], 'column': []},
|
'scalar': {'dim': 1, 'shape': [1], 'labels':options.scalar, 'active':[], 'column': []},
|
||||||
'vector': {'dim': 3, 'shape': [3], 'labels':options.vector, 'active':[], 'column': []},
|
'vector': {'dim': 3, 'shape': [3], 'labels':options.vector, 'active':[], 'column': []},
|
||||||
}
|
}
|
||||||
errors = []
|
errors = []
|
||||||
remarks = []
|
remarks = []
|
||||||
|
|
|
@ -22,7 +22,7 @@ Average each data block of size 'packing' into single values thus reducing the f
|
||||||
parser.add_option('-c','--coordinates',
|
parser.add_option('-c','--coordinates',
|
||||||
dest = 'coords',
|
dest = 'coords',
|
||||||
type = 'string', metavar = 'string',
|
type = 'string', metavar = 'string',
|
||||||
help = 'column heading for coordinates [%default]')
|
help = 'column label of coordinates [%default]')
|
||||||
parser.add_option('-p','--packing',
|
parser.add_option('-p','--packing',
|
||||||
dest = 'packing',
|
dest = 'packing',
|
||||||
type = 'int', nargs = 3, metavar = 'int int int',
|
type = 'int', nargs = 3, metavar = 'int int int',
|
||||||
|
@ -39,7 +39,7 @@ parser.add_option('-s', '--size',
|
||||||
dest = 'size',
|
dest = 'size',
|
||||||
type = 'float', nargs = 3, metavar = 'float float float',
|
type = 'float', nargs = 3, metavar = 'float float float',
|
||||||
help = 'size in x,y,z [autodetect]')
|
help = 'size in x,y,z [autodetect]')
|
||||||
parser.set_defaults(coords = 'ipinitialcoord',
|
parser.set_defaults(coords = 'pos',
|
||||||
packing = (2,2,2),
|
packing = (2,2,2),
|
||||||
shift = (0,0,0),
|
shift = (0,0,0),
|
||||||
grid = (0,0,0),
|
grid = (0,0,0),
|
||||||
|
@ -59,11 +59,10 @@ if any(shift != 0): prefix += 'shift{:+}{:+}{:+}_'.format(*shift)
|
||||||
if filenames == []: filenames = [None]
|
if filenames == []: filenames = [None]
|
||||||
|
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
try:
|
try: table = damask.ASCIItable(name = name,
|
||||||
table = damask.ASCIItable(name = name,
|
outname = os.path.join(os.path.dirname(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)
|
||||||
buffered = False)
|
|
||||||
except: continue
|
except: continue
|
||||||
damask.util.report(scriptName,name)
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
|
@ -75,7 +74,6 @@ for name in filenames:
|
||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
remarks = []
|
remarks = []
|
||||||
colCoord = None
|
|
||||||
|
|
||||||
if table.label_dimension(options.coords) != 3: errors.append('coordinates {} are not a vector.'.format(options.coords))
|
if table.label_dimension(options.coords) != 3: errors.append('coordinates {} are not a vector.'.format(options.coords))
|
||||||
else: colCoord = table.label_index(options.coords)
|
else: colCoord = table.label_index(options.coords)
|
||||||
|
@ -86,7 +84,6 @@ for name in filenames:
|
||||||
table.close(dismiss = True)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------ assemble header ---------------------------------------
|
# ------------------------------------------ assemble header ---------------------------------------
|
||||||
|
|
||||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||||
|
|
|
@ -19,83 +19,82 @@ to resolution*packing.
|
||||||
|
|
||||||
""", version = scriptID)
|
""", version = scriptID)
|
||||||
|
|
||||||
parser.add_option('-c','--coordinates', dest='coords', metavar='string',
|
parser.add_option('-c','--coordinates',
|
||||||
help='column heading for coordinates [%default]')
|
dest = 'coords', metavar = 'string',
|
||||||
parser.add_option('-p','--packing', dest='packing', type='int', nargs=3, metavar='int int int',
|
help = 'column label of coordinates [%default]')
|
||||||
help='dimension of packed group [%default]')
|
parser.add_option('-p','--packing',
|
||||||
parser.add_option('-g','--grid', dest='resolution', type='int', nargs=3, metavar='int int int',
|
dest = 'packing', type = 'int', nargs = 3, metavar = 'int int int',
|
||||||
help='resolution in x,y,z [autodetect]')
|
help = 'dimension of packed group [%default]')
|
||||||
parser.add_option('-s','--size', dest='dimension', type='float', nargs=3, metavar='int int int',
|
parser.add_option('-g','--grid',
|
||||||
help='dimension in x,y,z [autodetect]')
|
dest = 'resolution', type = 'int', nargs = 3, metavar = 'int int int',
|
||||||
parser.set_defaults(coords = 'ipinitialcoord')
|
help = 'resolution in x,y,z [autodetect]')
|
||||||
parser.set_defaults(packing = (2,2,2))
|
parser.add_option('-s','--size',
|
||||||
parser.set_defaults(grid = (0,0,0))
|
dest = 'dimension', type = 'float', nargs = 3, metavar = 'int int int',
|
||||||
parser.set_defaults(size = (0.0,0.0,0.0))
|
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,filenames) = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
options.packing = np.array(options.packing)
|
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 -------------------------------------------------------------------------
|
# --- loop over input files -------------------------------------------------------------------------
|
||||||
|
|
||||||
if filenames == []: filenames = [None]
|
if filenames == []: filenames = [None]
|
||||||
|
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
try:
|
try: table = damask.ASCIItable(name = name,
|
||||||
table = damask.ASCIItable(name = name,
|
outname = os.path.join(os.path.dirname(name),
|
||||||
outname = os.path.join(os.path.dirname(name),
|
prefix+os.path.basename(name)) if name else name,
|
||||||
prefix+ \
|
buffered = False)
|
||||||
os.path.basename(name)) if name else name,
|
|
||||||
buffered = False)
|
|
||||||
except: continue
|
except: continue
|
||||||
damask.util.report(scriptName,name)
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
# ------------------------------------------ read header ------------------------------------------
|
# ------------------------------------------ read header ------------------------------------------
|
||||||
|
|
||||||
table.head_read()
|
table.head_read()
|
||||||
errors = []
|
|
||||||
|
|
||||||
# ------------------------------------------ sanity checks ----------------------------------------
|
# ------------------------------------------ sanity checks ----------------------------------------
|
||||||
|
|
||||||
if table.label_dimension(options.coords) != 3:
|
errors = []
|
||||||
damask.util.croak('coordinates {} are not a vector.'.format(options.coords))
|
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)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
coordCol = table.label_index(options.coords)
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------ assemble header --------------------------------------
|
|
||||||
|
|
||||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
|
||||||
|
|
||||||
# --------------- figure out size and grid ---------------------------------------------------------
|
# --------------- 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
|
|
||||||
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 = np.where(grid > 1, size, min(size[grid > 1]/grid[grid > 1])) # spacing for grid==1 set to smallest among other spacings
|
|
||||||
|
|
||||||
|
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) * (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')
|
packing = np.array(options.packing,'i')
|
||||||
outSize = grid*packing
|
outSize = grid*packing
|
||||||
|
|
||||||
# ------------------------------------------ assemble header ---------------------------------------
|
# ------------------------------------------ assemble header --------------------------------------
|
||||||
|
|
||||||
|
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||||
table.head_write()
|
table.head_write()
|
||||||
|
|
||||||
# ------------------------------------------ process data -------------------------------------------
|
# ------------------------------------------ process data -------------------------------------------
|
||||||
|
|
||||||
table.data_rewind()
|
table.data_rewind()
|
||||||
data = np.zeros(outSize.tolist()+[len(table.labels)])
|
data = np.zeros(outSize.tolist()+[len(table.labels)])
|
||||||
p = np.zeros(3,'i')
|
p = np.zeros(3,'i')
|
||||||
|
@ -107,15 +106,15 @@ for name in filenames:
|
||||||
table.data_read()
|
table.data_read()
|
||||||
data[d[0]:d[0]+packing[0],
|
data[d[0]:d[0]+packing[0],
|
||||||
d[1]:d[1]+packing[1],
|
d[1]:d[1]+packing[1],
|
||||||
d[2]:d[2]+packing[2],
|
d[2]:d[2]+packing[2],
|
||||||
: ] = np.tile(np.array(table.data_asFloat(),'d'),packing.tolist()+[1]) # tile to match blowUp voxel size
|
: ] = np.tile(np.array(table.data_asFloat(),'d'),packing.tolist()+[1]) # tile to match blowUp voxel size
|
||||||
elementSize = size/grid/packing
|
elementSize = size/grid/packing
|
||||||
elem = 1
|
elem = 1
|
||||||
for c in xrange(outSize[2]):
|
for c in xrange(outSize[2]):
|
||||||
for b in xrange(outSize[1]):
|
for b in xrange(outSize[1]):
|
||||||
for a in xrange(outSize[0]):
|
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,colCoord:colCoord+3] = [a+0.5,b+0.5,c+0.5]*elementSize
|
||||||
data[a,b,c,table.label_index('elem')] = elem
|
if colElem != -1: data[a,b,c,colElem] = elem
|
||||||
table.data = data[a,b,c,:].tolist()
|
table.data = data[a,b,c,:].tolist()
|
||||||
outputAlive = table.data_write() # output processed line
|
outputAlive = table.data_write() # output processed line
|
||||||
elem += 1
|
elem += 1
|
||||||
|
|
Loading…
Reference in New Issue