removed useless grain selection option (--grain)
escaped MPIE\n.... in $ID$ fixed problem when writing output files into subdirectories
This commit is contained in:
parent
96a4d83b9b
commit
5e6de13962
|
@ -6,7 +6,7 @@
|
||||||
# computed using the FEM solvers. Until now, its capable to handle elements with one IP in a regular order
|
# computed using the FEM solvers. Until now, its capable to handle elements with one IP in a regular order
|
||||||
# written by M. Diehl, m.diehl@mpie.de
|
# written by M. Diehl, m.diehl@mpie.de
|
||||||
|
|
||||||
import os,sys,threading,re,numpy,time, postprocessingMath
|
import os,sys,threading,re,numpy,time,string,postprocessingMath
|
||||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
@ -115,7 +115,7 @@ def vtk_writeASCII_mesh(mesh,data,res):
|
||||||
|
|
||||||
cmds = [\
|
cmds = [\
|
||||||
'# vtk DataFile Version 3.1',
|
'# vtk DataFile Version 3.1',
|
||||||
'powered by $Id$',
|
string.replace('powered by $Id$','\n','\\n'),
|
||||||
'ASCII',
|
'ASCII',
|
||||||
'DATASET UNSTRUCTURED_GRID',
|
'DATASET UNSTRUCTURED_GRID',
|
||||||
'POINTS %i float'%N1,
|
'POINTS %i float'%N1,
|
||||||
|
@ -153,10 +153,6 @@ def vtk_writeASCII_mesh(mesh,data,res):
|
||||||
[[['\t'.join(map(str,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])],
|
[[['\t'.join(map(str,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])],
|
||||||
]
|
]
|
||||||
|
|
||||||
# vtk = open(filename, 'w')
|
|
||||||
# output(cmd,{'filepointer':vtk},'File')
|
|
||||||
# vtk.close()
|
|
||||||
|
|
||||||
return cmds
|
return cmds
|
||||||
|
|
||||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
@ -218,10 +214,6 @@ def gmsh_writeASCII_mesh(mesh,data,res):
|
||||||
[[['\t'.join(map(str,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])],
|
[[['\t'.join(map(str,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])],
|
||||||
]
|
]
|
||||||
|
|
||||||
# vtk = open(filename, 'w')
|
|
||||||
# output(cmd,{'filepointer':vtk},'File')
|
|
||||||
# vtk.close()
|
|
||||||
|
|
||||||
return cmds
|
return cmds
|
||||||
|
|
||||||
# +++++++++++++++++++++++++++++++++++++++++++++++++++
|
# +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
@ -289,7 +281,7 @@ def vtk_writeASCII_box(diag,defgrad):
|
||||||
|
|
||||||
# ----------------------- MAIN -------------------------------
|
# ----------------------- MAIN -------------------------------
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendedOption, usage='%prog [options] datafile', description = """
|
parser = OptionParser(option_class=extendedOption, usage='%prog [options] datafile[s]', description = """
|
||||||
Produce VTK file from data field. Coordinates are taken from (consecutive) ip.x, ip.y, and ip.z columns.
|
Produce VTK file from data field. Coordinates are taken from (consecutive) ip.x, ip.y, and ip.z columns.
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
|
@ -298,11 +290,8 @@ parser.add_option('-s', '--scalar', action='extend', dest='scalar', type='string
|
||||||
help='list of scalars to visualize')
|
help='list of scalars to visualize')
|
||||||
parser.add_option('-d', '--deformation', dest='defgrad', type='string', \
|
parser.add_option('-d', '--deformation', dest='defgrad', type='string', \
|
||||||
help='heading of deformation gradient columns [%default]')
|
help='heading of deformation gradient columns [%default]')
|
||||||
parser.add_option('-g', '--grain', dest='grain', type='int', \
|
|
||||||
help='grain of interest [%default]')
|
|
||||||
|
|
||||||
parser.set_defaults(defgrad = 'f')
|
parser.set_defaults(defgrad = 'f')
|
||||||
parser.set_defaults(grain = 1)
|
|
||||||
parser.set_defaults(scalar = [])
|
parser.set_defaults(scalar = [])
|
||||||
parser.set_defaults(vector = [])
|
parser.set_defaults(vector = [])
|
||||||
parser.set_defaults(tensor = [])
|
parser.set_defaults(tensor = [])
|
||||||
|
@ -340,7 +329,7 @@ for filename in args:
|
||||||
for label in [options.defgrad] + options.tensor:
|
for label in [options.defgrad] + options.tensor:
|
||||||
column['tensor'][label] = -1
|
column['tensor'][label] = -1
|
||||||
for col,head in enumerate(headings):
|
for col,head in enumerate(headings):
|
||||||
if head == label or head == '%i_1_%s'%(options.grain,label):
|
if head == label or head == '1_%s'%label:
|
||||||
column['tensor'][label] = col
|
column['tensor'][label] = col
|
||||||
maxcol = max(maxcol,col+9)
|
maxcol = max(maxcol,col+9)
|
||||||
break
|
break
|
||||||
|
@ -353,7 +342,7 @@ for filename in args:
|
||||||
for label in options.vector:
|
for label in options.vector:
|
||||||
column['vector'][label] = -1
|
column['vector'][label] = -1
|
||||||
for col,head in enumerate(headings):
|
for col,head in enumerate(headings):
|
||||||
if head == label or head == '%i_1_%s'%(options.grain,label):
|
if head == label or head == '1_%s'%label:
|
||||||
column['vector'][label] = col
|
column['vector'][label] = col
|
||||||
maxcol = max(maxcol,col+3)
|
maxcol = max(maxcol,col+3)
|
||||||
break
|
break
|
||||||
|
@ -362,7 +351,7 @@ for filename in args:
|
||||||
for label in options.scalar:
|
for label in options.scalar:
|
||||||
column['scalar'][label] = -1
|
column['scalar'][label] = -1
|
||||||
for col,head in enumerate(headings):
|
for col,head in enumerate(headings):
|
||||||
if head == label or head == '%i_%s'%(options.grain,label):
|
if head == label:
|
||||||
column['scalar'][label] = col
|
column['scalar'][label] = col
|
||||||
maxcol = max(maxcol,col+1)
|
maxcol = max(maxcol,col+1)
|
||||||
break
|
break
|
||||||
|
@ -422,7 +411,7 @@ for filename in args:
|
||||||
if col != -1:
|
if col != -1:
|
||||||
print what,
|
print what,
|
||||||
fields[datatype][what] = numpy.reshape(values[:,col:col+length[datatype]],(res[0],res[1],res[2])+reshape[datatype])
|
fields[datatype][what] = numpy.reshape(values[:,col:col+length[datatype]],(res[0],res[1],res[2])+reshape[datatype])
|
||||||
print '\n\n'
|
print '\n'
|
||||||
|
|
||||||
out = {}
|
out = {}
|
||||||
out['mesh'] = vtk_writeASCII_mesh(ms,fields,res)
|
out['mesh'] = vtk_writeASCII_mesh(ms,fields,res)
|
||||||
|
@ -431,6 +420,9 @@ for filename in args:
|
||||||
|
|
||||||
for what in out.keys():
|
for what in out.keys():
|
||||||
print what
|
print what
|
||||||
vtk = open('%s_'%what+os.path.splitext(filename)[0]+'.vtk', 'w')
|
(head,tail) = os.path.split(filename)
|
||||||
|
vtk = open(os.path.join(head,'%s_'%what+os.path.splitext(tail)[0]+'.vtk'), 'w')
|
||||||
output(out[what],{'filepointer':vtk},'File')
|
output(out[what],{'filepointer':vtk},'File')
|
||||||
vtk.close()
|
vtk.close()
|
||||||
|
print
|
||||||
|
|
Loading…
Reference in New Issue