63 vtkInformation *vtkNotUsed(request),
64 vtkInformationVector **inputVector,
65 vtkInformationVector *outputVector)
67 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
68 vtkInformation *outInfo = outputVector->GetInformationObject(0);
70 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
71 inInfo->Get(vtkDataObject::DATA_OBJECT()));
72 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
73 outInfo->Get(vtkDataObject::DATA_OBJECT()));
77 vtkErrorMacro(
"VelocityArrayName not specified");
81 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->
VelocityArrayName);
83 if (velocityArray == NULL)
85 vtkErrorMacro(
"VelocityArray with name specified does not exist");
89 char gradientArrayName[] =
"VelocityGradient";
92 gradientFilter->SetInputData(input);
98 gradientFilter->Update();
100 vtkDataArray* velocityGradientArray = gradientFilter->GetOutput()->GetPointData()->GetArray(gradientArrayName);
102 int numberOfPoints = input->GetNumberOfPoints();
104 vtkDoubleArray* lambda2Array = vtkDoubleArray::New();
111 lambda2Array->SetName(
"Lambda2");
113 lambda2Array->SetNumberOfComponents(1);
114 lambda2Array->SetNumberOfTuples(numberOfPoints);
116 double velocityGradient[9];
117 double symmetricVelocityGradient[3][3];
118 double antiSymmetricVelocityGradient[3][3];
122 for (i=0; i<numberOfPoints; i++)
124 velocityGradientArray->GetTuple(i,velocityGradient);
129 int index0 = k + j*3;
130 int index1 = j + k*3;
131 symmetricVelocityGradient[j][k] = 0.5 * (velocityGradient[index0] + velocityGradient[index1]);
132 antiSymmetricVelocityGradient[j][k] = 0.5 * (velocityGradient[index0] - velocityGradient[index1]);
143 A[j][k] += symmetricVelocityGradient[j][l]*symmetricVelocityGradient[l][k] +
144 antiSymmetricVelocityGradient[j][l]*antiSymmetricVelocityGradient[l][k];
149 double eigenVectors[3][3];
150 double eigenValues[3];
151 vtkMath::Diagonalize3x3(A,eigenValues,eigenVectors);
159 if (eigenValues[j] > eigenValues[j+1])
162 double tmp = eigenValues[j+1];
163 eigenValues[j+1] = eigenValues[j];
164 eigenValues[j] = tmp;
168 double lambda2 = eigenValues[1];
170 lambda2Array->SetTuple1(i,lambda2);
173 output->DeepCopy(input);
174 output->GetPointData()->AddArray(lambda2Array);
176 lambda2Array->Delete();