Forced symetric tensor when adding tensor to vtk
VTK addTensor by default using the lower triangle to populate its tensor object. Enforcing the tensor to be symmetric to avoid necessary confusion when adding data (most stress/strain tensor should symmetric by default, so it should not affect the results)
This commit is contained in:
parent
20d1164e5d
commit
d9077805e4
processing/post
|
@ -131,11 +131,14 @@ for name in filenames:
|
|||
|
||||
for datatype,labels in active.items(): # loop over scalar,color
|
||||
for me in labels: # loop over all requested items
|
||||
theData = [table.data[i] for i in table.label_indexrange(me)] # read strings
|
||||
if datatype == 'color': VTKarray[me].InsertNextTuple3(*map(lambda x: int(255.*float(x)),theData))
|
||||
elif datatype == 'vector': VTKarray[me].InsertNextTuple3(*map(float,theData))
|
||||
elif datatype == 'tensor': VTKarray[me].InsertNextTuple9(*map(float,theData))
|
||||
elif datatype == 'scalar': VTKarray[me].InsertNextValue(float(theData[0]))
|
||||
theData = [float(table.data[i]) for i in table.label_indexrange(me)] # read strings
|
||||
if datatype == 'color': VTKarray[me].InsertNextTuple3(*map(lambda x: int(255.*x),theData))
|
||||
elif datatype == 'scalar': VTKarray[me].InsertNextValue(theData[0])
|
||||
elif datatype == 'vector': VTKarray[me].InsertNextTuple3(*theData)
|
||||
elif datatype == 'tensor': VTKarray[me].InsertNextTuple9(*0.5*(np.array(theData)+
|
||||
np.array(theData) \
|
||||
.reshape(3,3).T \
|
||||
.reshape(9)))
|
||||
|
||||
table.input_close() # close input ASCII table
|
||||
|
||||
|
|
|
@ -134,9 +134,12 @@ for name in filenames:
|
|||
for me in labels: # loop over all requested items
|
||||
theData = [table.data[i] for i in table.label_indexrange(me)] # read strings
|
||||
if datatype == 'color': VTKarray[me].InsertNextTuple3(*map(lambda x: int(255.*float(x)),theData))
|
||||
elif datatype == 'vector': VTKarray[me].InsertNextTuple3(*map(float,theData))
|
||||
elif datatype == 'tensor': VTKarray[me].InsertNextTuple9(*map(float,theData))
|
||||
elif datatype == 'scalar': VTKarray[me].InsertNextValue(float(theData[0]))
|
||||
elif datatype == 'vector': VTKarray[me].InsertNextTuple3(*map(float,theData))
|
||||
elif datatype == 'tensor': VTKarray[me].InsertNextTuple9(*0.5*(np.array(theData)+
|
||||
np.array(theData) \
|
||||
.reshape(3,3).T \
|
||||
.reshape(9)))
|
||||
|
||||
table.close() # close input ASCII table
|
||||
|
||||
|
|
Loading…
Reference in New Issue