now fully supports output of vector fields (needs POINT data for useful visualization!!)
This commit is contained in:
parent
b134ec7a39
commit
076fef3323
|
@ -105,6 +105,12 @@ def transliterateToFloat(x):
|
||||||
except:
|
except:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
||||||
|
def unravel(item):
|
||||||
|
if hasattr(item,'__contains__'): return ' '.join(map(unravel,item))
|
||||||
|
else: return str(item)
|
||||||
|
|
||||||
|
|
||||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
def vtk_writeASCII_mesh(mesh,data,res):
|
def vtk_writeASCII_mesh(mesh,data,res):
|
||||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
@ -148,8 +154,8 @@ def vtk_writeASCII_mesh(mesh,data,res):
|
||||||
for item in data[type]:
|
for item in data[type]:
|
||||||
cmds += [\
|
cmds += [\
|
||||||
'%s %s float'%(type.upper()+plural,item),
|
'%s %s float'%(type.upper()+plural,item),
|
||||||
'LOOKUP_TABLE default',
|
{True:'LOOKUP_TABLE default',False:''}[type.lower()[:3]=='sca'],
|
||||||
[[['\t'.join(map(str,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])],
|
[[['\t'.join(map(unravel,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])],
|
||||||
]
|
]
|
||||||
|
|
||||||
return cmds
|
return cmds
|
||||||
|
@ -240,8 +246,8 @@ def vtk_writeASCII_points(coordinates,data,res):
|
||||||
for item in data[type]:
|
for item in data[type]:
|
||||||
cmds += [\
|
cmds += [\
|
||||||
'%s %s float'%(type.upper()+plural,item),
|
'%s %s float'%(type.upper()+plural,item),
|
||||||
'LOOKUP_TABLE default',
|
{True:'LOOKUP_TABLE default',False:''}[type.lower()[:3]=='sca'],
|
||||||
[[['\t'.join(map(str,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])]
|
[[['\t'.join(map(unravel,data[type][item][:,j,k]))] for j in range(res[1])] for k in range(res[2])],
|
||||||
]
|
]
|
||||||
|
|
||||||
return cmds
|
return cmds
|
||||||
|
@ -410,6 +416,7 @@ for filename in args:
|
||||||
dim[2] = min(dim/res)
|
dim[2] = min(dim/res)
|
||||||
else:
|
else:
|
||||||
dim[2] = options.unitlength
|
dim[2] = options.unitlength
|
||||||
|
|
||||||
if options.undeformed:
|
if options.undeformed:
|
||||||
defgrad_av = numpy.eye(3)
|
defgrad_av = numpy.eye(3)
|
||||||
else:
|
else:
|
||||||
|
@ -429,9 +436,9 @@ for filename in args:
|
||||||
'scalar': {},\
|
'scalar': {},\
|
||||||
}
|
}
|
||||||
reshape = {\
|
reshape = {\
|
||||||
'tensor': (3,3),\
|
'tensor': [3,3],\
|
||||||
'vector': (3),\
|
'vector': [3],\
|
||||||
'scalar': (),\
|
'scalar': [],\
|
||||||
}
|
}
|
||||||
length = {\
|
length = {\
|
||||||
'tensor': 9,\
|
'tensor': 9,\
|
||||||
|
@ -445,7 +452,7 @@ for filename in args:
|
||||||
col = column[datatype][what]
|
col = column[datatype][what]
|
||||||
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'
|
print '\n'
|
||||||
|
|
||||||
out = {}
|
out = {}
|
||||||
|
|
Loading…
Reference in New Issue