72{
73 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
75
76 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
77 inInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
79 outInfo->Get(vtkDataObject::DATA_OBJECT()));
80
82 {
83 vtkErrorMacro(<<"VelocityArrayName not set.");
84 return 1;
85 }
86
88 {
89 vtkErrorMacro(<<"VorticityArrayName not set.");
90 return 1;
91 }
92
94 {
96 {
97 vtkErrorMacro(<<"HelicityFactorArrayName not set.");
98 return 1;
99 }
100 }
101
102 int numberOfInputPoints = input->GetNumberOfPoints();
103
104 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->
VelocityArrayName);
105
106 if (!velocityArray)
107 {
108 vtkErrorMacro("VelocityArray with name specified doesn not exist!");
109 return 0;
110 }
111
112 int numberOfInputComponents = velocityArray->GetNumberOfComponents();
113
114 if (numberOfInputComponents != 3)
115 {
116 vtkErrorMacro("VelocityArray must have 3 components!");
117 return 0;
118 }
119
120 vtkDoubleArray* vorticityArray = vtkDoubleArray::New();
122 vorticityArray->SetNumberOfComponents(numberOfInputComponents);
123 vorticityArray->SetNumberOfTuples(numberOfInputPoints);
124
126
129
132
133 int i;
134 for (i=0; i<3; i++)
135 {
145
147 linearSystem->
SetA(sparseMatrix);
148 linearSystem->
SetB(rhsVector);
149 linearSystem->
SetX(solutionVector);
150
158
159
160
161
163
164 assembler->Delete();
165 linearSystem->Delete();
166 solver->Delete();
167 }
168
169 sparseMatrix->Delete();
170 rhsVector->Delete();
171
172 solutionVector->Delete();
173
175 output->GetPointData()->AddArray(vorticityArray);
176
178 {
179 vtkDoubleArray* helicityFactorArray = vtkDoubleArray::New();
181 helicityFactorArray->SetNumberOfTuples(numberOfInputPoints);
182
183 double velocity[3], vorticity[3], velocityMagnitude, vorticityMagnitude, helicityFactor;
184 int i;
185 for (i=0; i<numberOfInputPoints; i++)
186 {
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)
193 {
194 helicityFactor = vtkMath::Dot(velocity,vorticity) / (velocityMagnitude * vorticityMagnitude);
195 }
196 helicityFactorArray->SetValue(i,helicityFactor);
197 }
198 output->GetPointData()->AddArray(helicityFactorArray);
199 helicityFactorArray->Delete();
200 }
201
202 vorticityArray->Delete();
203
204 return 1;
205}
void DeepCopy(vtkvmtkDoubleVector *src)
static vtkvmtkDoubleVector * New()
void CopyIntoArrayComponent(vtkDataArray *array, int component)
virtual void SetSolutionVector(vtkvmtkDoubleVector *)
virtual void SetDataSet(vtkDataSet *)
virtual void SetRHSVector(vtkvmtkDoubleVector *)
virtual void SetMatrix(vtkvmtkSparseMatrix *)
virtual void SetQuadratureOrder(int)
virtual void SetConvergenceTolerance(double)
virtual void SetMaximumNumberOfIterations(int)
virtual void SetLinearSystem(vtkvmtkLinearSystem *)
virtual void SetX(vtkvmtkDoubleVector *)
virtual void SetA(vtkvmtkSparseMatrix *)
virtual void SetB(vtkvmtkDoubleVector *)
static vtkvmtkLinearSystem * New()
void SetPreconditionerTypeToJacobi()
static vtkvmtkOpenNLLinearSystemSolver * New()
static vtkvmtkSparseMatrix * New()
static vtkvmtkUnstructuredGridFEVorticityAssembler * New()
virtual void SetDirection(int)
virtual void SetVelocityArrayName(const char *)
virtual void Build() override