62 vtkInformation *vtkNotUsed(request),
63 vtkInformationVector **inputVector,
64 vtkInformationVector *outputVector)
66 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
67 vtkInformation *outInfo = outputVector->GetInformationObject(0);
69 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
70 inInfo->Get(vtkDataObject::DATA_OBJECT()));
71 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
72 outInfo->Get(vtkDataObject::DATA_OBJECT()));
76 vtkErrorMacro(
"VelocityArrayName not specified");
80 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->
VelocityArrayName);
82 if (velocityArray == NULL)
84 vtkErrorMacro(
"VelocityArray with name specified does not exist");
88 char gradientArrayName[] =
"VelocityGradient";
91 gradientFilter->SetInputData(input);
97 gradientFilter->Update();
99 vtkDataArray* velocityGradientArray = gradientFilter->GetOutput()->GetPointData()->GetArray(gradientArrayName);
101 int numberOfPoints = input->GetNumberOfPoints();
103 vtkDoubleArray* vorticityArray = vtkDoubleArray::New();
110 vorticityArray->SetName(
"Vorticity");
112 vorticityArray->SetNumberOfComponents(3);
113 vorticityArray->SetNumberOfTuples(numberOfPoints);
115 double velocityGradient[9];
119 for (i=0; i<numberOfPoints; i++)
121 velocityGradientArray->GetTuple(i,velocityGradient);
122 vorticity[0] = velocityGradient[7] - velocityGradient[5];
123 vorticity[1] = velocityGradient[2] - velocityGradient[6];
124 vorticity[2] = velocityGradient[3] - velocityGradient[1];
125 vorticityArray->SetTuple(i,vorticity);
128 output->DeepCopy(input);
129 output->GetPointData()->AddArray(vorticityArray);
131 vorticityArray->Delete();