2012-11-06 02:49:12 +05:30
|
|
|
#!/usr/bin/env python
|
2014-04-02 00:59:14 +05:30
|
|
|
# -*- coding: UTF-8 no BOM -*-
|
2013-04-12 15:57:05 +05:30
|
|
|
|
2014-08-25 18:09:12 +05:30
|
|
|
import os,re,sys,math,string
|
|
|
|
import numpy as np
|
|
|
|
from optparse import OptionParser
|
|
|
|
import damask
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2014-11-17 03:14:46 +05:30
|
|
|
scriptID = string.replace('$Id$','\n','\\n')
|
2014-11-18 21:01:39 +05:30
|
|
|
scriptName = os.path.splitext(scriptID.split()[1])[0]
|
2013-07-10 14:42:00 +05:30
|
|
|
|
2014-10-09 22:33:06 +05:30
|
|
|
|
2013-06-30 06:00:06 +05:30
|
|
|
def meshgrid2(*arrs):
|
|
|
|
'''
|
2014-10-09 22:33:06 +05:30
|
|
|
code inspired by http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d
|
2013-06-30 06:00:06 +05:30
|
|
|
'''
|
|
|
|
arrs = tuple(reversed(arrs))
|
|
|
|
arrs = tuple(arrs)
|
2014-08-25 18:09:12 +05:30
|
|
|
lens = np.array(map(len, arrs))
|
2013-06-30 06:00:06 +05:30
|
|
|
dim = len(arrs)
|
|
|
|
ans = []
|
|
|
|
for i, arr in enumerate(arrs):
|
2014-10-10 14:24:48 +05:30
|
|
|
slc = np.ones(dim,'i')
|
|
|
|
slc[i] = lens[i]
|
|
|
|
arr2 = np.asarray(arr).reshape(slc)
|
|
|
|
for j, sz in enumerate(lens):
|
|
|
|
if j != i:
|
|
|
|
arr2 = arr2.repeat(sz, axis=j)
|
2013-06-30 06:00:06 +05:30
|
|
|
|
2014-10-10 14:24:48 +05:30
|
|
|
ans.insert(0,arr2)
|
2013-06-30 06:00:06 +05:30
|
|
|
return tuple(ans)
|
|
|
|
|
2015-05-29 02:27:03 +05:30
|
|
|
def laguerreTessellation(undeformed, coords, weights):
|
2015-05-02 13:11:14 +05:30
|
|
|
|
2015-06-27 14:11:08 +05:30
|
|
|
weight = np.power(np.tile(weights, 27),2) # Laguerre weights (squared)
|
|
|
|
micro = np.zeros(undeformed.shape[0])
|
|
|
|
N = coords.shape[0] # Number of seeds points
|
|
|
|
periodic = np.array([
|
|
|
|
[ -1,-1,-1 ],
|
|
|
|
[ 0,-1,-1 ],
|
|
|
|
[ 1,-1,-1 ],
|
|
|
|
[ -1, 0,-1 ],
|
|
|
|
[ 0, 0,-1 ],
|
|
|
|
[ 1, 0,-1 ],
|
|
|
|
[ -1, 1,-1 ],
|
|
|
|
[ 0, 1,-1 ],
|
|
|
|
[ 1, 1,-1 ],
|
|
|
|
[ -1,-1, 0 ],
|
|
|
|
[ 0,-1, 0 ],
|
|
|
|
[ 1,-1, 0 ],
|
|
|
|
[ -1, 0, 0 ],
|
|
|
|
[ 0, 0, 0 ],
|
|
|
|
[ 1, 0, 0 ],
|
|
|
|
[ -1, 1, 0 ],
|
|
|
|
[ 0, 1, 0 ],
|
|
|
|
[ 1, 1, 0 ],
|
|
|
|
[ -1,-1, 1 ],
|
|
|
|
[ 0,-1, 1 ],
|
|
|
|
[ 1,-1, 1 ],
|
|
|
|
[ -1, 0, 1 ],
|
|
|
|
[ 0, 0, 1 ],
|
|
|
|
[ 1, 0, 1 ],
|
|
|
|
[ -1, 1, 1 ],
|
|
|
|
[ 0, 1, 1 ],
|
|
|
|
[ 1, 1, 1 ],
|
|
|
|
]).astype(float)
|
|
|
|
|
|
|
|
for i,vec in enumerate(periodic):
|
|
|
|
seeds = np.append(seeds, coords+vec, axis=0) if i > 0 else coords+vec
|
|
|
|
|
|
|
|
for i,point in enumerate(undeformed):
|
|
|
|
|
|
|
|
tmp = np.repeat(point.reshape(3,1), N*27, axis=1).T
|
|
|
|
dist = np.sum((tmp - seeds)*(tmp - seeds),axis=1) - weight
|
2015-07-29 03:45:32 +05:30
|
|
|
micro[i] = np.argmin(dist)%N + 1
|
2015-06-27 14:11:08 +05:30
|
|
|
|
|
|
|
return micro
|
2013-06-30 06:00:06 +05:30
|
|
|
|
2014-08-25 18:09:12 +05:30
|
|
|
# --------------------------------------------------------------------
|
2012-11-06 02:49:12 +05:30
|
|
|
# MAIN
|
2014-08-25 18:09:12 +05:30
|
|
|
# --------------------------------------------------------------------
|
2012-11-06 02:49:12 +05:30
|
|
|
identifiers = {
|
2013-07-10 14:42:00 +05:30
|
|
|
'grid': ['a','b','c'],
|
|
|
|
'size': ['x','y','z'],
|
|
|
|
'origin': ['x','y','z'],
|
2012-11-06 02:49:12 +05:30
|
|
|
}
|
|
|
|
mappings = {
|
2013-07-10 14:42:00 +05:30
|
|
|
'grid': lambda x: int(x),
|
|
|
|
'size': lambda x: float(x),
|
|
|
|
'origin': lambda x: float(x),
|
|
|
|
'homogenization': lambda x: int(x),
|
|
|
|
'microstructures': lambda x: int(x),
|
2012-11-06 02:49:12 +05:30
|
|
|
}
|
2014-10-09 22:33:06 +05:30
|
|
|
|
2014-08-25 18:09:12 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
2012-11-08 21:13:38 +05:30
|
|
|
Generate geometry description and material configuration by standard Voronoi tessellation of given seeds file.
|
2014-10-10 14:24:48 +05:30
|
|
|
|
2014-08-25 18:09:12 +05:30
|
|
|
""", version = scriptID)
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2015-01-23 15:41:12 +05:30
|
|
|
parser.add_option('-g', '--grid', dest='grid', type='int', nargs = 3, metavar=' '.join(['int']*3),
|
2013-06-04 18:26:57 +05:30
|
|
|
help='a,b,c grid of hexahedral box [from seeds file]')
|
2015-01-23 15:41:12 +05:30
|
|
|
parser.add_option('-s', '--size', dest='size', type='float', nargs = 3, metavar=' '.join(['float']*3),
|
2013-04-12 15:57:05 +05:30
|
|
|
help='x,y,z size of hexahedral box [1.0 along largest grid point number]')
|
2015-01-23 15:41:12 +05:30
|
|
|
parser.add_option('-o', '--origin', dest='origin', type='float', nargs = 3, metavar=' '.join(['float']*3),
|
|
|
|
help='offset from old to new origin of grid')
|
2014-12-03 03:52:11 +05:30
|
|
|
parser.add_option('--homogenization', dest='homogenization', type='int', metavar = 'int',
|
2013-04-12 15:57:05 +05:30
|
|
|
help='homogenization index to be used [%default]')
|
2014-12-03 03:52:11 +05:30
|
|
|
parser.add_option('--phase', dest='phase', type='int', metavar = 'int',
|
2013-04-12 15:57:05 +05:30
|
|
|
help='phase index to be used [%default]')
|
2014-12-03 03:52:11 +05:30
|
|
|
parser.add_option('--crystallite', dest='crystallite', type='int', metavar = 'int',
|
2013-04-12 15:57:05 +05:30
|
|
|
help='crystallite index to be used [%default]')
|
2014-12-03 03:52:11 +05:30
|
|
|
parser.add_option('-c', '--configuration', dest='config', action='store_true',
|
2013-04-12 15:57:05 +05:30
|
|
|
help='output material configuration [%default]')
|
2015-05-22 11:26:49 +05:30
|
|
|
parser.add_option('-r', '--rnd', dest='randomSeed', type='int', metavar='int',
|
|
|
|
help='seed of random number generator for second phase distribution [%default]')
|
2014-12-03 03:52:11 +05:30
|
|
|
parser.add_option('--secondphase', type='float', dest='secondphase', metavar= 'float',
|
|
|
|
help='volume fraction of randomly distribute second phase [%default]')
|
2015-06-27 14:11:08 +05:30
|
|
|
parser.add_option('-l', '--laguerre', dest='laguerre', action='store_true',
|
|
|
|
help='use Laguerre (weighted Voronoi) tessellation [%default]')
|
|
|
|
parser.set_defaults(grid = (0,0,0),
|
|
|
|
size = (0.0,0.0,0.0),
|
|
|
|
origin = (0.0,0.0,0.0),
|
|
|
|
homogenization = 1,
|
|
|
|
phase = 1,
|
|
|
|
crystallite = 1,
|
|
|
|
secondphase = 0.0,
|
|
|
|
config = False,
|
|
|
|
laguerre = False,
|
|
|
|
randomSeed = None,
|
|
|
|
)
|
2012-11-06 02:49:12 +05:30
|
|
|
(options,filenames) = parser.parse_args()
|
|
|
|
|
2015-05-22 11:26:49 +05:30
|
|
|
if options.secondphase > 1.0 or options.secondphase < 0.0:
|
|
|
|
parser.error('volume fraction of second phase (%f) out of bounds...'%options.secondphase)
|
|
|
|
|
2015-06-27 14:11:08 +05:30
|
|
|
# --- loop over input files -------------------------------------------------------------------------
|
2012-11-06 02:49:12 +05:30
|
|
|
if filenames == []:
|
2015-06-27 14:11:08 +05:30
|
|
|
filenames = ['STDIN']
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2015-06-27 14:11:08 +05:30
|
|
|
for name in filenames:
|
|
|
|
if name == 'STDIN':
|
|
|
|
file = {'name':'STDIN', 'input':sys.stdin, 'output':sys.stdout, 'croak':sys.stderr}
|
|
|
|
file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
|
|
|
|
else:
|
|
|
|
if not os.path.exists(name): continue
|
|
|
|
file = {'name':name, 'input':open(name), 'output':open(name+'_tmp','w'), 'croak':sys.stderr}
|
|
|
|
file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2015-06-27 14:11:08 +05:30
|
|
|
table = damask.ASCIItable(file['input'],file['output'],buffered=False) # make unbuffered ASCII_table
|
|
|
|
table.head_read() # read ASCII header info
|
2014-01-01 02:36:32 +05:30
|
|
|
|
2015-05-02 13:11:14 +05:30
|
|
|
labels = []
|
2015-06-05 17:14:17 +05:30
|
|
|
if np.all(table.label_index(['1_coords','2_coords','3_coords']) != -1):
|
2015-05-08 10:32:44 +05:30
|
|
|
coords = ['1_coords','2_coords','3_coords']
|
2015-06-05 17:14:17 +05:30
|
|
|
elif np.all(table.label_index(['x','y','z']) != -1):
|
2015-05-08 10:32:44 +05:30
|
|
|
coords = ['x','y','z']
|
|
|
|
else:
|
2015-06-05 17:04:41 +05:30
|
|
|
file['croak'].write('no coordinate data (1/2/3_coords | x/y/z) found ...')
|
2015-05-08 10:32:44 +05:30
|
|
|
continue
|
2014-02-04 05:14:29 +05:30
|
|
|
|
2015-06-05 17:04:41 +05:30
|
|
|
labels += coords
|
2015-06-05 17:14:17 +05:30
|
|
|
hasEulers = np.all(table.label_index(['phi1','Phi','phi2']) != -1)
|
2015-05-02 13:11:14 +05:30
|
|
|
if hasEulers:
|
|
|
|
labels += ['phi1','Phi','phi2']
|
|
|
|
|
2015-06-05 17:14:17 +05:30
|
|
|
hasGrains = table.label_index('microstructure') != -1
|
2015-05-02 13:11:14 +05:30
|
|
|
if hasGrains:
|
|
|
|
labels += ['microstructure']
|
|
|
|
|
2015-06-05 17:14:17 +05:30
|
|
|
hasWeight = table.label_index('weight') != -1
|
2015-05-02 13:11:14 +05:30
|
|
|
if hasWeight:
|
|
|
|
labels += ['weight']
|
|
|
|
|
|
|
|
table.data_readArray(labels)
|
2015-06-05 17:14:17 +05:30
|
|
|
coords = table.data[:,table.label_index(coords)]
|
|
|
|
eulers = table.data[:,table.label_index(['phi1','Phi','phi2'])] if hasEulers else np.zeros(3*len(coords))
|
|
|
|
grain = table.data[:,table.label_index('microstructure')] if hasGrains else 1+np.arange(len(coords))
|
|
|
|
weights = table.data[:,table.label_index('weight')] if hasWeight else np.zeros(len(coords))
|
2014-08-25 18:09:12 +05:30
|
|
|
grainIDs = np.unique(grain).astype('i')
|
2014-01-01 02:36:32 +05:30
|
|
|
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2013-06-30 06:00:06 +05:30
|
|
|
#--- interpret header ----------------------------------------------------------------------------
|
2013-05-15 21:32:38 +05:30
|
|
|
info = {
|
2014-08-25 18:09:12 +05:30
|
|
|
'grid': np.zeros(3,'i'),
|
|
|
|
'size': np.array(options.size),
|
|
|
|
'origin': np.zeros(3,'d'),
|
2013-07-10 14:42:00 +05:30
|
|
|
'microstructures': 0,
|
2013-06-30 06:00:06 +05:30
|
|
|
'homogenization': options.homogenization,
|
2012-11-06 02:49:12 +05:30
|
|
|
}
|
2013-07-10 14:42:00 +05:30
|
|
|
newInfo = {
|
|
|
|
'microstructures': 0,
|
|
|
|
}
|
|
|
|
extra_header = []
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2014-08-25 18:09:12 +05:30
|
|
|
for header in table.info:
|
2012-11-06 02:49:12 +05:30
|
|
|
headitems = map(str.lower,header.split())
|
2013-07-10 14:42:00 +05:30
|
|
|
if len(headitems) == 0: continue
|
2012-11-06 02:49:12 +05:30
|
|
|
if headitems[0] in mappings.keys():
|
|
|
|
if headitems[0] in identifiers.keys():
|
|
|
|
for i in xrange(len(identifiers[headitems[0]])):
|
|
|
|
info[headitems[0]][i] = \
|
|
|
|
mappings[headitems[0]](headitems[headitems.index(identifiers[headitems[0]][i])+1])
|
|
|
|
else:
|
|
|
|
info[headitems[0]] = mappings[headitems[0]](headitems[1])
|
2013-07-10 14:42:00 +05:30
|
|
|
else:
|
|
|
|
extra_header.append(header)
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2013-07-10 14:42:00 +05:30
|
|
|
if info['microstructures'] != len(grainIDs):
|
2013-10-15 18:06:52 +05:30
|
|
|
file['croak'].write('grain data not matching grain count (%i)...\n'%(len(grainIDs)))
|
|
|
|
info['microstructures'] = len(grainIDs)
|
2013-05-15 21:32:38 +05:30
|
|
|
|
|
|
|
if 0 not in options.grid: # user-specified grid
|
2014-08-25 18:09:12 +05:30
|
|
|
info['grid'] = np.array(options.grid)
|
2012-11-06 02:49:12 +05:30
|
|
|
|
|
|
|
for i in xrange(3):
|
2013-05-15 21:32:38 +05:30
|
|
|
if info['size'][i] <= 0.0: # any invalid size?
|
2013-04-12 15:57:05 +05:30
|
|
|
info['size'][i] = float(info['grid'][i])/max(info['grid'])
|
2013-06-30 19:17:01 +05:30
|
|
|
file['croak'].write('rescaling size %s...\n'%{0:'x',1:'y',2:'z'}[i])
|
2013-04-12 15:57:05 +05:30
|
|
|
|
2013-07-10 14:42:00 +05:30
|
|
|
file['croak'].write('grains to map: %i\n'%info['microstructures'] + \
|
2013-04-12 15:57:05 +05:30
|
|
|
'grid a b c: %s\n'%(' x '.join(map(str,info['grid']))) + \
|
|
|
|
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) + \
|
|
|
|
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) + \
|
2012-11-06 02:49:12 +05:30
|
|
|
'homogenization: %i\n'%info['homogenization'])
|
2013-05-15 21:32:38 +05:30
|
|
|
|
2014-08-25 18:09:12 +05:30
|
|
|
if np.any(info['grid'] < 1):
|
2013-05-15 21:32:38 +05:30
|
|
|
file['croak'].write('invalid grid a b c.\n')
|
2013-06-30 06:00:06 +05:30
|
|
|
continue
|
2014-08-25 18:09:12 +05:30
|
|
|
if np.any(info['size'] <= 0.0):
|
2013-05-15 21:32:38 +05:30
|
|
|
file['croak'].write('invalid size x y z.\n')
|
2013-06-30 06:00:06 +05:30
|
|
|
continue
|
2013-07-10 14:42:00 +05:30
|
|
|
if info['microstructures'] == 0:
|
2013-05-15 21:32:38 +05:30
|
|
|
file['croak'].write('no grain info found.\n')
|
2013-06-30 06:00:06 +05:30
|
|
|
continue
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2013-05-15 21:32:38 +05:30
|
|
|
#--- prepare data ---------------------------------------------------------------------------------
|
2015-04-23 00:14:54 +05:30
|
|
|
eulers = eulers.T
|
2012-11-06 02:49:12 +05:30
|
|
|
|
2013-05-15 21:32:38 +05:30
|
|
|
#--- switch according to task ---------------------------------------------------------------------
|
|
|
|
if options.config: # write config file
|
2015-06-27 14:11:08 +05:30
|
|
|
phase = np.empty(info['microstructures'],'i')
|
2014-12-03 03:52:11 +05:30
|
|
|
phase.fill(options.phase)
|
|
|
|
phase[0:int(float(info['microstructures'])*options.secondphase)] = options.phase+1
|
2015-05-22 11:26:49 +05:30
|
|
|
randomSeed = int(os.urandom(4).encode('hex'), 16) if options.randomSeed == None else options.randomSeed # radom seed per file for second phase
|
|
|
|
np.random.seed(randomSeed)
|
2014-12-03 03:52:11 +05:30
|
|
|
np.random.shuffle(phase)
|
2013-07-10 14:42:00 +05:30
|
|
|
formatwidth = 1+int(math.log10(info['microstructures']))
|
2015-05-22 11:26:49 +05:30
|
|
|
file['output'].write('#' + scriptID + ' ' + ' '.join(sys.argv[1:])+'\n')
|
|
|
|
if options.secondphase > 0.0: file['output'].write('# random seed for second phase %i\n'%randomSeed)
|
2014-12-03 15:39:47 +05:30
|
|
|
file['output'].write('\n<microstructure>\n')
|
2014-12-03 03:52:11 +05:30
|
|
|
for i,ID in enumerate(grainIDs):
|
|
|
|
file['output'].write('\n[Grain%s]\n'%(str(ID).zfill(formatwidth)) + \
|
2012-11-08 21:13:38 +05:30
|
|
|
'crystallite %i\n'%options.crystallite + \
|
2014-12-03 03:52:11 +05:30
|
|
|
'(constituent)\tphase %i\ttexture %s\tfraction 1.0\n'%(phase[i],str(ID).rjust(formatwidth)))
|
2012-11-06 02:49:12 +05:30
|
|
|
|
|
|
|
file['output'].write('\n<texture>\n')
|
2014-12-03 03:52:11 +05:30
|
|
|
for ID in grainIDs:
|
|
|
|
eulerID = np.nonzero(grain == ID)[0][0] # find first occurrence of this grain id
|
|
|
|
file['output'].write('\n[Grain%s]\n'%(str(ID).zfill(formatwidth)) + \
|
2013-11-13 18:16:20 +05:30
|
|
|
'(gauss)\tphi1 %g\tPhi %g\tphi2 %g\tscatter 0.0\tfraction 1.0\n'%(eulers[0,eulerID],
|
|
|
|
eulers[1,eulerID],
|
|
|
|
eulers[2,eulerID]))
|
2013-04-12 15:57:05 +05:30
|
|
|
|
2013-06-30 06:00:06 +05:30
|
|
|
else: # write geometry file
|
2014-08-25 18:09:12 +05:30
|
|
|
x = (np.arange(info['grid'][0])+0.5)*info['size'][0]/info['grid'][0]
|
|
|
|
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]
|
2015-05-02 13:11:14 +05:30
|
|
|
|
2015-05-16 20:02:32 +05:30
|
|
|
if not options.laguerre:
|
2015-05-02 13:11:14 +05:30
|
|
|
coords = (coords*info['size']).T
|
|
|
|
undeformed = np.vstack(map(np.ravel, meshgrid2(x, y, z)))
|
|
|
|
|
|
|
|
file['croak'].write('tessellating...\n')
|
|
|
|
indices = damask.core.math.periodicNearestNeighbor(\
|
|
|
|
info['size'],\
|
|
|
|
np.eye(3),\
|
|
|
|
undeformed,coords)//3**3 + 1 # floor division to kill periodic images
|
|
|
|
indices = grain[indices-1]
|
|
|
|
else :
|
|
|
|
undeformed = np.vstack(np.meshgrid(x, y, z)).reshape(3,-1).T
|
2015-05-29 02:27:03 +05:30
|
|
|
indices = laguerreTessellation(undeformed, coords, weights)
|
2013-07-10 14:42:00 +05:30
|
|
|
|
|
|
|
newInfo['microstructures'] = info['microstructures']
|
|
|
|
for i in grainIDs:
|
|
|
|
if i not in indices: newInfo['microstructures'] -= 1
|
2015-06-27 14:11:08 +05:30
|
|
|
file['croak'].write(('all' if newInfo['microstructures'] == info['microstructures'] else 'only') +
|
2013-07-10 14:42:00 +05:30
|
|
|
' %i'%newInfo['microstructures'] +
|
2015-06-27 14:11:08 +05:30
|
|
|
('' if newInfo['microstructures'] == info['microstructures'] else \
|
|
|
|
' out of %i'%info['microstructures']) +
|
2013-07-10 14:42:00 +05:30
|
|
|
' grains mapped.\n')
|
2013-05-15 21:32:38 +05:30
|
|
|
|
|
|
|
#--- write header ---------------------------------------------------------------------------------
|
2014-08-25 18:09:12 +05:30
|
|
|
table.labels_clear()
|
|
|
|
table.info_clear()
|
|
|
|
table.info_append(extra_header+[
|
2014-01-20 20:11:56 +05:30
|
|
|
scriptID + ' ' + ' '.join(sys.argv[1:]),
|
2013-06-30 06:00:06 +05:30
|
|
|
"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],),
|
|
|
|
"origin\tx %f\ty %f\tz %f"%(info['origin'][0],info['origin'][1],info['origin'][2],),
|
|
|
|
"homogenization\t%i"%info['homogenization'],
|
2013-07-10 14:42:00 +05:30
|
|
|
"microstructures\t%i"%(newInfo['microstructures']),
|
2013-06-30 06:00:06 +05:30
|
|
|
])
|
2014-08-25 18:09:12 +05:30
|
|
|
table.head_write()
|
2013-06-30 06:00:06 +05:30
|
|
|
|
2013-05-17 22:14:03 +05:30
|
|
|
# --- write microstructure information ------------------------------------------------------------
|
2013-07-10 14:42:00 +05:30
|
|
|
formatwidth = 1+int(math.log10(newInfo['microstructures']))
|
2014-08-25 18:09:12 +05:30
|
|
|
table.data = indices.reshape(info['grid'][1]*info['grid'][2],info['grid'][0])
|
|
|
|
table.data_writeArray('%%%ii'%(formatwidth),delimiter=' ')
|
2013-06-30 06:00:06 +05:30
|
|
|
|
2013-05-15 21:32:38 +05:30
|
|
|
#--- output finalization --------------------------------------------------------------------------
|
2013-06-30 06:00:06 +05:30
|
|
|
|
2015-06-27 14:11:08 +05:30
|
|
|
table.close()
|
2012-11-06 02:49:12 +05:30
|
|
|
if file['name'] != 'STDIN':
|
2015-05-18 20:18:25 +05:30
|
|
|
os.rename(file['name']+'_tmp',
|
|
|
|
os.path.splitext(file['name'])[0] +'%s'%('_material.config' if options.config else '.geom'))
|