69 vtkInformation *vtkNotUsed(request),
70 vtkInformationVector **inputVector,
71 vtkInformationVector *outputVector)
73 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
76 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
77 inInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
79 outInfo->Get(vtkDataObject::DATA_OBJECT()));
83 vtkErrorMacro(<<
"VelocityArrayName not set.");
89 vtkErrorMacro(<<
"VorticityArrayName not set.");
97 vtkErrorMacro(<<
"HelicityFactorArrayName not set.");
102 int numberOfInputPoints = input->GetNumberOfPoints();
104 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->
VelocityArrayName);
108 vtkErrorMacro(
"VelocityArray with name specified doesn not exist!");
112 int numberOfInputComponents = velocityArray->GetNumberOfComponents();
114 if (numberOfInputComponents != 3)
116 vtkErrorMacro(
"VelocityArray must have 3 components!");
120 vtkDoubleArray* vorticityArray = vtkDoubleArray::New();
122 vorticityArray->SetNumberOfComponents(numberOfInputComponents);
123 vorticityArray->SetNumberOfTuples(numberOfInputPoints);
147 linearSystem->
SetA(sparseMatrix);
148 linearSystem->
SetB(rhsVector);
149 linearSystem->
SetX(solutionVector);
165 linearSystem->Delete();
169 sparseMatrix->Delete();
172 solutionVector->Delete();
175 output->GetPointData()->AddArray(vorticityArray);
179 vtkDoubleArray* helicityFactorArray = vtkDoubleArray::New();
181 helicityFactorArray->SetNumberOfTuples(numberOfInputPoints);
183 double velocity[3], vorticity[3], velocityMagnitude, vorticityMagnitude, helicityFactor;
185 for (i=0; i<numberOfInputPoints; i++)
187 velocityArray->GetTuple(i,velocity);
188 vorticityArray->GetTuple(i,vorticity);
189 velocityMagnitude = vtkMath::Norm(velocity);
190 vorticityMagnitude = vtkMath::Norm(vorticity);
191 helicityFactor = 0.0;
192 if (velocityMagnitude > 0.0 && vorticityMagnitude > 0.0)
194 helicityFactor = vtkMath::Dot(velocity,vorticity) / (velocityMagnitude * vorticityMagnitude);
196 helicityFactorArray->SetValue(i,helicityFactor);
198 output->GetPointData()->AddArray(helicityFactorArray);
199 helicityFactorArray->Delete();
202 vorticityArray->Delete();