76{
77 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
78 vtkInformation *outInfo = outputVector->GetInformationObject(0);
79
80 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
81 inInfo->Get(vtkDataObject::DATA_OBJECT()));
82 vtkPolyData *output = vtkPolyData::SafeDownCast(
83 outInfo->Get(vtkDataObject::DATA_OBJECT()));
84
86 {
87 vtkErrorMacro("VelocityArrayName not specified");
88 return 1;
89 }
90
91 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->
VelocityArrayName);
92
93 if (velocityArray == NULL)
94 {
95 vtkErrorMacro("VelocityArray with name specified does not exist");
96 return 1;
97 }
98
99 char gradientArrayName[] = "VelocityGradient";
100
102 gradientFilter->SetInputData(input);
108 gradientFilter->Update();
109
110 vtkGeometryFilter* geometryFilter = vtkGeometryFilter::New();
111 geometryFilter->SetInputConnection(gradientFilter->GetOutputPort());
112 geometryFilter->Update();
113
114
115
116
117 vtkPolyData* surfaceWithoutNormals = vtkPolyData::New();
118 surfaceWithoutNormals->ShallowCopy(geometryFilter->GetOutput());
119 surfaceWithoutNormals->GetPointData()->SetNormals(NULL);
120 surfaceWithoutNormals->GetCellData()->SetNormals(NULL);
121
122 vtkPolyDataNormals* normalsFilter = vtkPolyDataNormals::New();
123 normalsFilter->SetInputData(surfaceWithoutNormals);
124 surfaceWithoutNormals->Delete();
125 normalsFilter->AutoOrientNormalsOn();
126 normalsFilter->ConsistencyOn();
127 normalsFilter->SplittingOff();
128 normalsFilter->Update();
129
130 vtkPolyData* outputSurface = normalsFilter->GetOutput();
131
132 vtkDataArray* velocityGradientArray = outputSurface->GetPointData()->GetArray(gradientArrayName);
133 vtkDataArray* normalsArray = outputSurface->GetPointData()->GetNormals();
134
135 int numberOfPoints = outputSurface->GetNumberOfPoints();
136
137 vtkDoubleArray* wallShearRateArray = vtkDoubleArray::New();
139 {
141 }
142 else
143 {
144 wallShearRateArray->SetName("WallShearRate");
145 }
146 wallShearRateArray->SetNumberOfComponents(3);
147 wallShearRateArray->SetNumberOfTuples(numberOfPoints);
148
149 double velocityGradient[9];
150 double normal[3];
151 double wallShearRate[3];
152
153 int i, j, k;
154
156 {
157 for (i=0; i<numberOfPoints; i++)
158 {
159 velocityGradientArray->GetTuple(i,velocityGradient);
160 normalsArray->GetTuple(i,normal);
161 for (j=0; j<3; j++)
162 {
163 wallShearRate[j] = -normal[0] * velocityGradient[3*j + 0] - normal[1] * velocityGradient[3*j + 1] - normal[2] * velocityGradient[3*j + 2];
164 }
165 wallShearRateArray->SetTuple(i,wallShearRate);
166 }
167 }
168 else
169 {
170
171
172
173
174
175
176
177 double normalShear, shearVector[3], strainRateTensor[9];
178
179 for (i=0; i<numberOfPoints; i++)
180 {
181
182
183 velocityGradientArray->GetTuple(i,velocityGradient);
184 for (j=0; j<3; j++)
185 {
186 for (k=0; k<3; k++)
187 {
188 strainRateTensor[3*j + k] = 0.5 * (velocityGradient[3*j + k] + velocityGradient[3*k + j]);
189 }
190 }
191
192
193 normalsArray->GetTuple(i,normal);
194 normalShear = 0.0;
195 for (j=0; j<3; j++)
196 {
197 shearVector[j] = 0.0;
198 for (k=0; k<3; k++)
199 {
200 shearVector[j] += strainRateTensor[3*j + k] * normal[k];
201 }
202 normalShear += shearVector[j] * normal[j];
203 }
204
205
206 for (j=0; j<3; j++)
207 {
208
209 wallShearRate[j] = -2.0 * (shearVector[j] - normalShear*normal[j]);
210 }
211
212 wallShearRateArray->SetTuple(i,wallShearRate);
213 }
214 }
215
216 output->DeepCopy(outputSurface);
217 output->GetPointData()->AddArray(wallShearRateArray);
218
219 wallShearRateArray->Delete();
220 geometryFilter->Delete();
221 normalsFilter->Delete();
222
223 return 1;
224}
virtual void SetComputeIndividualPartialDerivatives(int)
virtual void SetInputArrayName(const char *)
virtual void SetQuadratureOrder(int)
virtual void SetGradientArrayName(const char *)
virtual void SetConvergenceTolerance(double)
static vtkvmtkUnstructuredGridGradientFilter * New()