removed warnings by pyflakes, implemented new croak functionality
This commit is contained in:
parent
e1157126bc
commit
f4c53e0be8
|
@ -63,7 +63,7 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0] +'%s'%('_material.config' if options.config else '.geom'),
|
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0] +'%s'%('_material.config' if options.config else '.geom'),
|
||||||
buffered = False, labeled = False, readonly=True)
|
buffered = False, labeled = False, readonly=True)
|
||||||
except: continue
|
except: continue
|
||||||
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'grid': np.ones(3,'i'),
|
'grid': np.ones(3,'i'),
|
||||||
|
@ -86,7 +86,7 @@ for name in filenames:
|
||||||
if words[0] == '#': # process initial comments/header block
|
if words[0] == '#': # process initial comments/header block
|
||||||
if len(words) > 2:
|
if len(words) > 2:
|
||||||
if words[2].lower() == 'hexgrid':
|
if words[2].lower() == 'hexgrid':
|
||||||
table.croak('The file has HexGrid format. Please first convert to SquareGrid...\n')
|
damask.util.croak('The file has HexGrid format. Please first convert to SquareGrid...\n')
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
currPos = words[3:5]
|
currPos = words[3:5]
|
||||||
|
@ -110,10 +110,10 @@ for name in filenames:
|
||||||
|
|
||||||
limits = [360,180,360]
|
limits = [360,180,360]
|
||||||
if any([np.any(eulerangles[:,i]>=limits[i]) for i in [0,1,2]]):
|
if any([np.any(eulerangles[:,i]>=limits[i]) for i in [0,1,2]]):
|
||||||
table.croak('Error: euler angles out of bound. Ang file might contain unidexed poins.\n')
|
damask.util.croak('Error: euler angles out of bound. Ang file might contain unidexed poins.\n')
|
||||||
for i,angle in enumerate(['phi1','PHI','phi2']):
|
for i,angle in enumerate(['phi1','PHI','phi2']):
|
||||||
for n in np.nditer(np.where(eulerangles[:,i]>=limits[i]),['zerosize_ok']):
|
for n in np.nditer(np.where(eulerangles[:,i]>=limits[i]),['zerosize_ok']):
|
||||||
table.croak('%s in line %i (%4.2f %4.2f %4.2f)\n'
|
damask.util.croak('%s in line %i (%4.2f %4.2f %4.2f)\n'
|
||||||
%(angle,n,eulerangles[n,0],eulerangles[n,1],eulerangles[n,2]))
|
%(angle,n,eulerangles[n,0],eulerangles[n,1],eulerangles[n,2]))
|
||||||
continue
|
continue
|
||||||
eulerangles=np.around(eulerangles,int(options.precision)) # round to desired precision
|
eulerangles=np.around(eulerangles,int(options.precision)) # round to desired precision
|
||||||
|
@ -154,17 +154,17 @@ for name in filenames:
|
||||||
info['microstructures'] = len(microstructure)
|
info['microstructures'] = len(microstructure)
|
||||||
|
|
||||||
#--- report ---------------------------------------------------------------------------------------
|
#--- report ---------------------------------------------------------------------------------------
|
||||||
table.croak('grid a b c: %s\n'%(' x '.join(map(str,info['grid']))) +
|
damask.util.croak('grid a b c: %s\n'%(' x '.join(map(str,info['grid']))) +
|
||||||
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) +
|
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) +
|
||||||
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) +
|
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) +
|
||||||
'homogenization: %i\n'%info['homogenization'] +
|
'homogenization: %i\n'%info['homogenization'] +
|
||||||
'microstructures: %i\n\n'%info['microstructures'])
|
'microstructures: %i\n\n'%info['microstructures'])
|
||||||
|
|
||||||
if np.any(info['grid'] < 1):
|
if np.any(info['grid'] < 1):
|
||||||
table.croak('invalid grid a b c.\n')
|
damask.util.croak('invalid grid a b c.\n')
|
||||||
continue
|
continue
|
||||||
if np.any(info['size'] <= 0.0):
|
if np.any(info['size'] <= 0.0):
|
||||||
table.croak('invalid size x y z.\n')
|
damask.util.croak('invalid size x y z.\n')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,re,math,itertools
|
import os,sys,string,math,itertools
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy import ndimage
|
from scipy import ndimage
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -132,14 +132,14 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name,
|
table = damask.ASCIItable(name = name,
|
||||||
buffered = False, labeled = False, readonly = True)
|
buffered = False, labeled = False, readonly = True)
|
||||||
except: continue
|
except: continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
# --- interpret header ----------------------------------------------------------------------------
|
# --- interpret header ----------------------------------------------------------------------------
|
||||||
|
|
||||||
table.head_read()
|
table.head_read()
|
||||||
info,extra_header = table.head_getGeom()
|
info,extra_header = table.head_getGeom()
|
||||||
|
|
||||||
table.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||||
'homogenization: %i'%info['homogenization'],
|
'homogenization: %i'%info['homogenization'],
|
||||||
|
@ -150,7 +150,7 @@ for name in filenames:
|
||||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||||
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
||||||
if errors != []:
|
if errors != []:
|
||||||
table.croak(errors)
|
damask.util.croak(errors)
|
||||||
table.close(dismiss = True)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ for name in filenames:
|
||||||
buffered = False, labeled = False)
|
buffered = False, labeled = False)
|
||||||
except: continue
|
except: continue
|
||||||
|
|
||||||
table.croak(features[feature]['alias'][0])
|
damask.util.croak(features[feature]['alias'][0])
|
||||||
|
|
||||||
distance = np.where(uniques >= features[feature]['aliens'],0.0,1.0) # seed with 0.0 when enough unique neighbor IDs are present
|
distance = np.where(uniques >= features[feature]['aliens'],0.0,1.0) # seed with 0.0 when enough unique neighbor IDs are present
|
||||||
distance = ndimage.morphology.distance_transform_edt(distance)*[options.scale]*3
|
distance = ndimage.morphology.distance_transform_edt(distance)*[options.scale]*3
|
||||||
|
|
|
@ -80,7 +80,7 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(outname = name,
|
table = damask.ASCIItable(outname = name,
|
||||||
buffered = False, labeled = False)
|
buffered = False, labeled = False)
|
||||||
except: continue
|
except: continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------ make grid -------------------------------------
|
# ------------------------------------------ make grid -------------------------------------
|
||||||
|
@ -95,7 +95,7 @@ for name in filenames:
|
||||||
|
|
||||||
#--- report ---------------------------------------------------------------------------------------
|
#--- report ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
table.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||||
'homogenization: %i'%info['homogenization'],
|
'homogenization: %i'%info['homogenization'],
|
||||||
|
@ -106,7 +106,7 @@ for name in filenames:
|
||||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||||
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
||||||
if errors != []:
|
if errors != []:
|
||||||
table.croak(errors)
|
damask.util.croak(errors)
|
||||||
table.close(dismiss = True)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,re,string,math
|
import os,sys,string,math
|
||||||
import scipy.spatial, numpy as np
|
import scipy.spatial, numpy as np
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
@ -119,10 +119,10 @@ 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.splitext(name)[0]+'.geom' if name else name,
|
outname = os.path.splitext(name)[-2]+'.geom' if name else name,
|
||||||
buffered = False)
|
buffered = False)
|
||||||
except: continue
|
except: continue
|
||||||
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
# ------------------------------------------ read head ---------------------------------------
|
# ------------------------------------------ read head ---------------------------------------
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ for name in filenames:
|
||||||
errors.append('phase column {} is not scalar.'.format(options.phase))
|
errors.append('phase column {} is not scalar.'.format(options.phase))
|
||||||
|
|
||||||
if errors != []:
|
if errors != []:
|
||||||
table.croak(errors)
|
damask.util.croak(errors)
|
||||||
table.close(dismiss = True)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ for name in filenames:
|
||||||
errors.append('regular grid spacing {} violated.'.format(' x '.join(map(repr,delta))))
|
errors.append('regular grid spacing {} violated.'.format(' x '.join(map(repr,delta))))
|
||||||
|
|
||||||
if errors != []:
|
if errors != []:
|
||||||
table.croak(errors)
|
damask.util.croak(errors)
|
||||||
table.close(dismiss = True)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ for name in filenames:
|
||||||
for z in xrange(grid[2]):
|
for z in xrange(grid[2]):
|
||||||
for y in xrange(grid[1]):
|
for y in xrange(grid[1]):
|
||||||
for x in xrange(grid[0]):
|
for x in xrange(grid[0]):
|
||||||
if (myRank+1)%(N/100.) < 1: table.croak('.',False)
|
if (myRank+1)%(N/100.) < 1: damask.util.croak('.',False)
|
||||||
myData = table.data[index[myRank]]
|
myData = table.data[index[myRank]]
|
||||||
mySym = options.symmetry[min(int(myData[colPhase]),len(options.symmetry))-1] # select symmetry from option (take last specified option for all with higher index)
|
mySym = options.symmetry[min(int(myData[colPhase]),len(options.symmetry))-1] # select symmetry from option (take last specified option for all with higher index)
|
||||||
if inputtype == 'eulers':
|
if inputtype == 'eulers':
|
||||||
|
@ -236,7 +236,7 @@ for name in filenames:
|
||||||
|
|
||||||
myRank += 1
|
myRank += 1
|
||||||
|
|
||||||
table.croak('')
|
damask.util.croak('')
|
||||||
|
|
||||||
# --- generate header ----------------------------------------------------------------------------
|
# --- generate header ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ for name in filenames:
|
||||||
'homogenization': options.homogenization,
|
'homogenization': options.homogenization,
|
||||||
}
|
}
|
||||||
|
|
||||||
table.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||||
'homogenization: %i'%info['homogenization'],
|
'homogenization: %i'%info['homogenization'],
|
||||||
|
|
|
@ -27,8 +27,6 @@ parser.add_option('--phase', dest='phase', type='int', nargs = 2, metavar = 'int
|
||||||
help='phase indices for <microstructure> configuration %default')
|
help='phase indices for <microstructure> configuration %default')
|
||||||
parser.add_option('--crystallite', dest='crystallite', type='int', metavar = 'int',
|
parser.add_option('--crystallite', dest='crystallite', type='int', metavar = 'int',
|
||||||
help='crystallite index for <microstructure> configuration [%default]')
|
help='crystallite index for <microstructure> configuration [%default]')
|
||||||
parser.add_option('-c', '--configuration', dest='config', action='store_true',
|
|
||||||
help='output material configuration [%default]')
|
|
||||||
parser.add_option('--compress', dest='compress', action='store_true',
|
parser.add_option('--compress', dest='compress', action='store_true',
|
||||||
help='lump identical microstructure and texture information [%default]')
|
help='lump identical microstructure and texture information [%default]')
|
||||||
parser.add_option('-p', '--precision', dest='precision', choices=['0','1','2','3'], metavar = 'int',
|
parser.add_option('-p', '--precision', dest='precision', choices=['0','1','2','3'], metavar = 'int',
|
||||||
|
@ -45,27 +43,16 @@ parser.set_defaults(precision = '2')
|
||||||
|
|
||||||
(options,filenames) = parser.parse_args()
|
(options,filenames) = parser.parse_args()
|
||||||
|
|
||||||
#--- setup file handles ---------------------------------------------------------------------------
|
if filenames == []: filenames = [None]
|
||||||
files = []
|
|
||||||
if filenames == []:
|
|
||||||
files.append({'name':'STDIN',
|
|
||||||
'input':sys.stdin,
|
|
||||||
'output':sys.stdout,
|
|
||||||
'croak':sys.stderr,
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
for name in filenames:
|
for name in filenames:
|
||||||
if os.path.exists(name):
|
try:
|
||||||
files.append({'name':name,
|
table = damask.ASCIItable(name = name,
|
||||||
'input':open(name),
|
outname = os.path.splitext(name)[-2]+'.geom' if name else name,
|
||||||
'output':open(name+'_tmp','w'),
|
buffered = False,
|
||||||
'croak':sys.stdout,
|
labeled = False)
|
||||||
})
|
except: continue
|
||||||
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
#--- loop over input files ------------------------------------------------------------------------
|
|
||||||
for file in files:
|
|
||||||
file['croak'].write('\033[1m' + scriptName + '\033[0m: ' + (file['name'] if file['name'] != 'STDIN' else '') + '\n')
|
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'grid': np.zeros(3,'i'),
|
'grid': np.zeros(3,'i'),
|
||||||
|
@ -81,19 +68,20 @@ for file in files:
|
||||||
|
|
||||||
phase = []
|
phase = []
|
||||||
eulerangles = []
|
eulerangles = []
|
||||||
# --------------- read data -----------------------------------------------------------------------
|
outputAlive = True
|
||||||
for line in file['input']:
|
|
||||||
if line.strip():
|
# ------------------------------------------ process data ------------------------------------------
|
||||||
words = line.split()
|
while outputAlive and table.data_read():
|
||||||
currPos = words[3:6]
|
if table.data != []:
|
||||||
|
currPos = table.data[3:6]
|
||||||
for i in xrange(3):
|
for i in xrange(3):
|
||||||
coords[i][currPos[i]] = True
|
coords[i][currPos[i]] = True
|
||||||
currPos = map(float,currPos)
|
currPos = map(float,currPos)
|
||||||
for i in xrange(3):
|
for i in xrange(3):
|
||||||
pos['min'][i] = min(pos['min'][i],currPos[i])
|
pos['min'][i] = min(pos['min'][i],currPos[i])
|
||||||
pos['max'][i] = max(pos['max'][i],currPos[i])
|
pos['max'][i] = max(pos['max'][i],currPos[i])
|
||||||
eulerangles.append(map(math.degrees,map(float,words[:3])))
|
eulerangles.append(map(math.degrees,map(float,table.data[:3])))
|
||||||
phase.append(options.phase[int(float(words[options.column-1]) > options.threshold)])
|
phase.append(options.phase[int(float(table.data[options.column-1]) > options.threshold)])
|
||||||
|
|
||||||
# --------------- determine size and grid ---------------------------------------------------------
|
# --------------- determine size and grid ---------------------------------------------------------
|
||||||
info['grid'] = np.array(map(len,coords),'i')
|
info['grid'] = np.array(map(len,coords),'i')
|
||||||
|
@ -130,60 +118,62 @@ for file in files:
|
||||||
texture = np.arange(info['grid'].prod())
|
texture = np.arange(info['grid'].prod())
|
||||||
microstructure = np.hstack( zip(texture,phase) ).reshape(info['grid'].prod(),2) # create texture/phase pairs
|
microstructure = np.hstack( zip(texture,phase) ).reshape(info['grid'].prod(),2) # create texture/phase pairs
|
||||||
formatOut = 1+int(math.log10(len(texture)))
|
formatOut = 1+int(math.log10(len(texture)))
|
||||||
textureOut =['\n\n<texture>']
|
|
||||||
|
config_header = []
|
||||||
|
|
||||||
|
formatwidth = 1+int(math.log10(len(microstructure)))
|
||||||
|
config_header += ['<microstructure>']
|
||||||
|
for i in xrange(len(microstructure)):
|
||||||
|
config_header += ['[Grain%s]'%str(i+1).zfill(formatwidth),
|
||||||
|
'crystallite\t%i'%options.crystallite,
|
||||||
|
'(constituent)\tphase %i\ttexture %i\tfraction 1.0'%(microstructure[i,1],microstructure[i,0]+1)
|
||||||
|
]
|
||||||
|
config_header += ['<texture>']
|
||||||
|
|
||||||
eulerFormatOut='%%%i.%if'%(int(options.precision)+4,int(options.precision))
|
eulerFormatOut='%%%i.%if'%(int(options.precision)+4,int(options.precision))
|
||||||
outStringAngles='(gauss) phi1 '+eulerFormatOut+' Phi '+eulerFormatOut+' phi2 '+eulerFormatOut+' scatter 0.0 fraction 1.0\n'
|
outStringAngles='(gauss) phi1 '+eulerFormatOut+' Phi '+eulerFormatOut+' phi2 '+eulerFormatOut+' scatter 0.0 fraction 1.0'
|
||||||
for i in xrange(len(texture)):
|
for i in xrange(len(texture)):
|
||||||
textureOut += ['[Texture%s]\n'%str(i+1).zfill(formatOut) +
|
config_header += ['[Texture%s]'%str(i+1).zfill(formatOut),
|
||||||
outStringAngles%tuple(eulerangles[texture[i],...])
|
outStringAngles%tuple(eulerangles[texture[i],...])
|
||||||
]
|
]
|
||||||
formatOut = 1+int(math.log10(len(microstructure)))
|
|
||||||
microstructureOut =['<microstructure>']
|
table.labels_clear()
|
||||||
for i in xrange(len(microstructure)):
|
table.info_clear()
|
||||||
microstructureOut += ['[Grain%s]\n'%str(i+1).zfill(formatOut) +
|
|
||||||
'crystallite\t%i\n'%options.crystallite +
|
|
||||||
'(constituent)\tphase %i\ttexture %i\tfraction 1.0\n'%(microstructure[i,1],microstructure[i,0]+1)
|
|
||||||
]
|
|
||||||
|
|
||||||
info['microstructures'] = len(microstructure)
|
info['microstructures'] = len(microstructure)
|
||||||
|
|
||||||
#--- report ---------------------------------------------------------------------------------------
|
#--- report ---------------------------------------------------------------------------------------
|
||||||
file['croak'].write('grid a b c: %s\n'%(' x '.join(map(str,info['grid']))) +
|
damask.util.croak('grid a b c: %s\n'%(' x '.join(map(str,info['grid']))) +
|
||||||
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) +
|
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) +
|
||||||
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) +
|
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) +
|
||||||
'homogenization: %i\n'%info['homogenization'] +
|
'homogenization: %i\n'%info['homogenization'] +
|
||||||
'microstructures: %i\n\n'%info['microstructures'])
|
'microstructures: %i\n\n'%info['microstructures'])
|
||||||
|
|
||||||
if np.any(info['grid'] < 1):
|
if np.any(info['grid'] < 1):
|
||||||
file['croak'].write('invalid grid a b c.\n')
|
damask.util.croak('invalid grid a b c.\n')
|
||||||
continue
|
continue
|
||||||
if np.any(info['size'] <= 0.0):
|
if np.any(info['size'] <= 0.0):
|
||||||
file['croak'].write('invalid size x y z.\n')
|
damask.util.croak('invalid size x y z.\n')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
#--- write data -----------------------------------------------------------------------------------
|
#--- write data -----------------------------------------------------------------------------------
|
||||||
if options.config:
|
table.info_append([' '.join([scriptID] + sys.argv[1:]),
|
||||||
file['output'].write('\n'.join(microstructureOut+ textureOut) + '\n')
|
|
||||||
else:
|
|
||||||
header = [' '.join([scriptID] + sys.argv[1:]),
|
|
||||||
"grid\ta %i\tb %i\tc %i"%(info['grid'][0],info['grid'][1],info['grid'][2],),
|
"grid\ta %i\tb %i\tc %i"%(info['grid'][0],info['grid'][1],info['grid'][2],),
|
||||||
"size\tx %f\ty %f\tz %f"%(info['size'][0],info['size'][1],info['size'][2],),
|
"size\tx %f\ty %f\tz %f"%(info['size'][0],info['size'][1],info['size'][2],),
|
||||||
"origin\tx %f\ty %f\tz %f"%(info['origin'][0],info['origin'][1],info['origin'][2],),
|
"origin\tx %f\ty %f\tz %f"%(info['origin'][0],info['origin'][1],info['origin'][2],),
|
||||||
"microstructures\t%i"%info['microstructures'],
|
"microstructures\t%i"%info['microstructures'],
|
||||||
"homogenization\t%i"%info['homogenization'],
|
"homogenization\t%i"%info['homogenization'],
|
||||||
]
|
config_header
|
||||||
file['output'].write('\n'.join(['%i\theader'%(len(header))] + header) + '\n')
|
])
|
||||||
|
table.head_write()
|
||||||
if options.compress:
|
if options.compress:
|
||||||
matPoints = matPoints.reshape([info['grid'][1]*info['grid'][2],info['grid'][0]])
|
table.data = matPoints.reshape(info['grid'][1]*info['grid'][2],info['grid'][0])
|
||||||
np.savetxt(file['output'],matPoints,fmt='%0'+str(1+int(math.log10(np.amax(matPoints))))+'d')
|
table.data_writeArray('%%%ii'%(formatwidth),delimiter=' ')
|
||||||
else:
|
else:
|
||||||
file['output'].write("1 to %i\n"%(info['microstructures']))
|
table.data = ["1 to %i\n"%(info['microstructures'])]
|
||||||
|
|
||||||
#--- output finalization --------------------------------------------------------------------------
|
# ------------------------------------------ output finalization -----------------------------------
|
||||||
if file['name'] != 'STDIN':
|
|
||||||
file['output'].close()
|
table.close()
|
||||||
os.rename(file['name']+'_tmp',
|
|
||||||
os.path.splitext(file['name'])[0] +'%s'%('_material.config' if options.config else '.geom'))
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,re,sys,math,string
|
import os,sys,math,string
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -77,7 +77,8 @@ def laguerreTessellation(undeformed, coords, weights, grains, nonperiodic = Fals
|
||||||
squaredweights = np.power(np.tile(weights,len(copies)),2) # Laguerre weights (squared, size N*n)
|
squaredweights = np.power(np.tile(weights,len(copies)),2) # Laguerre weights (squared, size N*n)
|
||||||
|
|
||||||
for i,vec in enumerate(copies): # periodic copies of seed points (size N*n)
|
for i,vec in enumerate(copies): # periodic copies of seed points (size N*n)
|
||||||
seeds = np.append(seeds, coords+vec, axis=0) if i > 0 else coords+vec
|
try: seeds = np.append(seeds, coords+vec, axis=0)
|
||||||
|
except NameError: seeds = coords+vec
|
||||||
|
|
||||||
arguments = [[arg] + [seeds,squaredweights] for arg in list(undeformed)]
|
arguments = [[arg] + [seeds,squaredweights] for arg in list(undeformed)]
|
||||||
|
|
||||||
|
@ -196,10 +197,10 @@ 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.splitext(name)[0]+'.geom' if name else name,
|
outname = os.path.splitext(name)[-2]+'.geom' if name else name,
|
||||||
buffered = False)
|
buffered = False)
|
||||||
except: continue
|
except: continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
# --- read header ----------------------------------------------------------------------------
|
# --- read header ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -242,9 +243,9 @@ for name in filenames:
|
||||||
if options.laguerre and not hasWeights: remarks.append('missing seed weights...')
|
if options.laguerre and not hasWeights: remarks.append('missing seed weights...')
|
||||||
else: labels += [options.weight]
|
else: labels += [options.weight]
|
||||||
|
|
||||||
if remarks != []: table.croak(remarks)
|
if remarks != []: damask.util.croak(remarks)
|
||||||
if errors != []:
|
if errors != []:
|
||||||
table.croak(errors)
|
damask.util.croak(errors)
|
||||||
table.close(dismiss=True)
|
table.close(dismiss=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -264,10 +265,10 @@ for name in filenames:
|
||||||
y = (np.arange(info['grid'][1])+0.5)*info['size'][1]/info['grid'][1]
|
y = (np.arange(info['grid'][1])+0.5)*info['size'][1]/info['grid'][1]
|
||||||
z = (np.arange(info['grid'][2])+0.5)*info['size'][2]/info['grid'][2]
|
z = (np.arange(info['grid'][2])+0.5)*info['size'][2]/info['grid'][2]
|
||||||
|
|
||||||
table.croak('tessellating...')
|
damask.util.croak('tessellating...')
|
||||||
|
|
||||||
|
|
||||||
table.croak('...using {} cpu{}'.format(options.cpus, 's' if options.cpus > 1 else ''))
|
damask.util.croak('...using {} cpu{}'.format(options.cpus, 's' if options.cpus > 1 else ''))
|
||||||
grid = np.vstack(meshgrid2(x, y, z)).reshape(3,-1).T
|
grid = np.vstack(meshgrid2(x, y, z)).reshape(3,-1).T
|
||||||
indices = laguerreTessellation(grid, coords, weights, grains, options.nonperiodic, options.cpus)
|
indices = laguerreTessellation(grid, coords, weights, grains, options.nonperiodic, options.cpus)
|
||||||
|
|
||||||
|
@ -278,7 +279,7 @@ for name in filenames:
|
||||||
|
|
||||||
if info['homogenization'] == 0: info['homogenization'] = options.homogenization
|
if info['homogenization'] == 0: info['homogenization'] = options.homogenization
|
||||||
|
|
||||||
table.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||||
'homogenization: %i'%info['homogenization'],
|
'homogenization: %i'%info['homogenization'],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 no BOM -*-
|
# -*- coding: UTF-8 no BOM -*-
|
||||||
|
|
||||||
import os,sys,string,math
|
import os,sys,string
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import damask
|
import damask
|
||||||
|
@ -29,14 +29,14 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name,
|
table = damask.ASCIItable(name = name,
|
||||||
buffered = False, labeled = False)
|
buffered = False, labeled = False)
|
||||||
except: continue
|
except: continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
# --- interpret header ----------------------------------------------------------------------------
|
# --- interpret header ----------------------------------------------------------------------------
|
||||||
|
|
||||||
table.head_read()
|
table.head_read()
|
||||||
info,extra_header = table.head_getGeom()
|
info,extra_header = table.head_getGeom()
|
||||||
|
|
||||||
table.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||||
'homogenization: %i'%info['homogenization'],
|
'homogenization: %i'%info['homogenization'],
|
||||||
|
@ -47,7 +47,7 @@ for name in filenames:
|
||||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||||
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
||||||
if errors != []:
|
if errors != []:
|
||||||
table.croak(errors)
|
damask.util.croak(errors)
|
||||||
table.close(dismiss = True)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,14 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name,
|
table = damask.ASCIItable(name = name,
|
||||||
buffered = False, labeled = False)
|
buffered = False, labeled = False)
|
||||||
except: continue
|
except: continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
# --- interpret header ----------------------------------------------------------------------------
|
# --- interpret header ----------------------------------------------------------------------------
|
||||||
|
|
||||||
table.head_read()
|
table.head_read()
|
||||||
info,extra_header = table.head_getGeom()
|
info,extra_header = table.head_getGeom()
|
||||||
|
|
||||||
table.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||||
'homogenization: %i'%info['homogenization'],
|
'homogenization: %i'%info['homogenization'],
|
||||||
|
@ -54,7 +54,7 @@ for name in filenames:
|
||||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||||
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
||||||
if errors != []:
|
if errors != []:
|
||||||
table.croak(errors)
|
damask.util.croak(errors)
|
||||||
table.close(dismiss = True)
|
table.close(dismiss = True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -205,8 +205,8 @@ for name in filenames:
|
||||||
"randomSeed\t{}".format(options.randomSeed),
|
"randomSeed\t{}".format(options.randomSeed),
|
||||||
])
|
])
|
||||||
table.labels_clear()
|
table.labels_clear()
|
||||||
table.labels_append( ['{dim}_{label}'.format(dim = 1+i,label = 'pos') for i in xrange(3)] +
|
table.labels_append( ['{dim}_{label}'.format(dim = 1+k,label = 'pos') for k in xrange(3)] +
|
||||||
['{dim}_{label}'.format(dim = 1+i,label = 'eulerangles') for i in xrange(3)] +
|
['{dim}_{label}'.format(dim = 1+k,label = 'eulerangles') for k in xrange(3)] +
|
||||||
['microstructure'] +
|
['microstructure'] +
|
||||||
(['weight'] if options.weights else []))
|
(['weight'] if options.weights else []))
|
||||||
table.head_write()
|
table.head_write()
|
||||||
|
|
Loading…
Reference in New Issue