73 vtkInformation *vtkNotUsed(request),
74 vtkInformationVector **inputVector,
75 vtkInformationVector *outputVector)
77 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
78 vtkInformation *outInfo = outputVector->GetInformationObject(0);
80 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
81 inInfo->Get(vtkDataObject::DATA_OBJECT()));
82 vtkPolyData *output = vtkPolyData::SafeDownCast(
83 outInfo->Get(vtkDataObject::DATA_OBJECT()));
87 vtkErrorMacro(
"VelocityArrayName not specified");
91 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->
VelocityArrayName);
93 if (velocityArray == NULL)
95 vtkErrorMacro(
"VelocityArray with name specified does not exist");
99 char gradientArrayName[] =
"VelocityGradient";
102 gradientFilter->SetInputData(input);
108 gradientFilter->Update();
110 vtkGeometryFilter* geometryFilter = vtkGeometryFilter::New();
111 geometryFilter->SetInputConnection(gradientFilter->GetOutputPort());
112 geometryFilter->Update();
117 vtkPolyData* surfaceWithoutNormals = vtkPolyData::New();
118 surfaceWithoutNormals->ShallowCopy(geometryFilter->GetOutput());
119 surfaceWithoutNormals->GetPointData()->SetNormals(NULL);
120 surfaceWithoutNormals->GetCellData()->SetNormals(NULL);
122 vtkPolyDataNormals* normalsFilter = vtkPolyDataNormals::New();
123 normalsFilter->SetInputData(surfaceWithoutNormals);
124 surfaceWithoutNormals->Delete();
125 normalsFilter->AutoOrientNormalsOn();
126 normalsFilter->ConsistencyOn();
127 normalsFilter->SplittingOff();
128 normalsFilter->Update();
130 vtkPolyData* outputSurface = normalsFilter->GetOutput();
132 vtkDataArray* velocityGradientArray = outputSurface->GetPointData()->GetArray(gradientArrayName);
133 vtkDataArray* normalsArray = outputSurface->GetPointData()->GetNormals();
135 int numberOfPoints = outputSurface->GetNumberOfPoints();
137 vtkDoubleArray* wallShearRateArray = vtkDoubleArray::New();
144 wallShearRateArray->SetName(
"WallShearRate");
146 wallShearRateArray->SetNumberOfComponents(3);
147 wallShearRateArray->SetNumberOfTuples(numberOfPoints);
149 double velocityGradient[9];
151 double wallShearRate[3];
157 for (i=0; i<numberOfPoints; i++)
159 velocityGradientArray->GetTuple(i,velocityGradient);
160 normalsArray->GetTuple(i,normal);
163 wallShearRate[j] = -normal[0] * velocityGradient[3*j + 0] - normal[1] * velocityGradient[3*j + 1] - normal[2] * velocityGradient[3*j + 2];
165 wallShearRateArray->SetTuple(i,wallShearRate);
177 double normalShear, shearVector[3], strainRateTensor[9];
179 for (i=0; i<numberOfPoints; i++)
183 velocityGradientArray->GetTuple(i,velocityGradient);
188 strainRateTensor[3*j + k] = 0.5 * (velocityGradient[3*j + k] + velocityGradient[3*k + j]);
193 normalsArray->GetTuple(i,normal);
197 shearVector[j] = 0.0;
200 shearVector[j] += strainRateTensor[3*j + k] * normal[k];
202 normalShear += shearVector[j] * normal[j];
209 wallShearRate[j] = -2.0 * (shearVector[j] - normalShear*normal[j]);
212 wallShearRateArray->SetTuple(i,wallShearRate);
216 output->DeepCopy(outputSurface);
217 output->GetPointData()->AddArray(wallShearRateArray);
219 wallShearRateArray->Delete();
220 geometryFilter->Delete();
221 normalsFilter->Delete();