[Paraview] Calculation of eigenvalues of velocity tensors

Hal Canary hal at cs.unc.edu
Mon Aug 6 11:59:52 EDT 2012


On 08/06/2012 10:27 AM, Janusz Michalik wrote:
> Hi Hal. I'm trying to use this filter that you attached but I get errors. This is what I'm doing and I'm not sure what is wrong:
> 1) Take the GradientOfUnstructuredData in the Paraview filters which gives me the velocity tensor with components numbered from 0 to 8.
> 2) I modified your tensor components matrix to have
> tensor_components = [
>          'G_0', 'G_1', 'G_2',
>          'G_3', 'G_4', 'G_5',
>          'G_6', 'G_7', 'G_8']
> where G is the result array name obtained from the Gradient Filter.
> 3) I run the your eig filter but I get errors:
>


My input was six separate one-component scalar arrays.  If you have a 
nine-component array, we can deal with that slightly differently:


input_array = numpy.array(pd['G'])
N = input_array.shape[0]
assert (input_array.shape[1] == 9)
Tensors = input_array.reshape((N,3,3))
eigenvalues  = numpy.empty((N,3), dtype=numpy.float32)
eigenvectors = numpy.empty((N,3,3), dtype=numpy.float32)
for i in xrange(N):
	eigenvalues[i,:], eigenvectors[i,:,:] = ( numpy.linalg.eig(Tensors[i,:,:]))
for i in xrange(3):
	pd.AddArray(
		paraview.vtk.dataset_adapter.numpyTovtkDataArray(
			eigenvalues[:,i],
			name=('EigVal_%d' % (i+1))))
	pd.AddArray(
		paraview.vtk.dataset_adapter.numpyTovtkDataArray(
			eigenvectors[:,:,i],
			name=('EigVec_%d' % (i+1))))




More information about the ParaView mailing list