VMTK
Loading...
Searching...
No Matches
vtkvmtkFEShapeFunctions Class Reference

Provides a set of common utility functions (calculate jacobian, interpolation function, and interpolation function derivatives) used during assembly of certain finite element solutions. More...

#include <vtkvmtkFEShapeFunctions.h>

Inheritance diagram for vtkvmtkFEShapeFunctions:
[legend]
Collaboration diagram for vtkvmtkFEShapeFunctions:
[legend]

Public Types

typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkFEShapeFunctions * NewInstance () const
void Initialize (vtkCell *cell, vtkDoubleArray *pcoords)
double GetPhi (vtkIdType id, vtkIdType i)
double * GetDPhi (vtkIdType id, vtkIdType i)
void GetDPhi (vtkIdType id, vtkIdType i, double *dphi)
double GetDPhi (vtkIdType id, vtkIdType i, int c)
double GetJacobian (vtkIdType i)

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkFEShapeFunctions * SafeDownCast (vtkObjectBase *o)
static vtkvmtkFEShapeFunctions * New ()
static void GetInterpolationFunctions (vtkCell *cell, double *pcoords, double *sf)
static void GetInterpolationDerivs (vtkCell *cell, double *pcoords, double *derivs)
static double ComputeJacobian (vtkCell *cell, double *pcoords)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkFEShapeFunctions ()
 ~vtkvmtkFEShapeFunctions ()

Static Protected Member Functions

static void ComputeInverseJacobianMatrix2D (vtkCell *cell, double *pcoords, double inverseJacobianMatrix[2][3])
static void ComputeInverseJacobianMatrix3D (vtkCell *cell, double *pcoords, double inverseJacobianMatrix[3][3])

Protected Attributes

vtkDoubleArray * Phi
vtkDoubleArray * DPhi
vtkDoubleArray * Jacobians
vtkIdType NumberOfCellPoints

Detailed Description

Provides a set of common utility functions (calculate jacobian, interpolation function, and interpolation function derivatives) used during assembly of certain finite element solutions.

vtkvmtkFEShapeFunctions evaluates, for a given vtkCell, the isoparametric finite-element shape functions (interpolation functions Phi), their gradients with respect to physical (x,y,z) coordinates (DPhi), and the Jacobian of the parametric-to-physical mapping (Jacobians), at a set of parametric points (typically Gauss quadrature points, see vtkvmtkGaussQuadrature). Initialize() precomputes and caches these quantities for every point in pcoords so that GetPhi/GetDPhi/ GetJacobian can be queried cheaply during element assembly. The static GetInterpolationFunctions/GetInterpolationDerivs/ComputeJacobian methods dispatch to the appropriate VTK cell type's own interpolation routines and can be used standalone, without an Initialize() call, for a single evaluation point. Supported cell types include line, quad, triangle, hexahedron, wedge and tetra, and their quadratic/biquadratic variants.

See also
vtkvmtkGaussQuadrature, vtkvmtkFEAssembler

Definition at line 46 of file vtkvmtkFEShapeFunctions.h.

Member Typedef Documentation

◆ Superclass

Definition at line 49 of file vtkvmtkFEShapeFunctions.h.

Constructor & Destructor Documentation

◆ vtkvmtkFEShapeFunctions()

vtkvmtkFEShapeFunctions::vtkvmtkFEShapeFunctions ( )
protected

Definition at line 49 of file vtkvmtkFEShapeFunctions.cxx.

50{
51 this->Phi = vtkDoubleArray::New();
52 this->DPhi = vtkDoubleArray::New();
53 this->Jacobians = vtkDoubleArray::New();
54 this->NumberOfCellPoints = -1;
55}

◆ ~vtkvmtkFEShapeFunctions()

vtkvmtkFEShapeFunctions::~vtkvmtkFEShapeFunctions ( )
protected

Definition at line 57 of file vtkvmtkFEShapeFunctions.cxx.

58{
59 this->Phi->Delete();
60 this->DPhi->Delete();
61 this->Jacobians->Delete();
62}

Member Function Documentation

◆ IsTypeOf()

int vtkvmtkFEShapeFunctions::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkFEShapeFunctions::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkFEShapeFunctions * vtkvmtkFEShapeFunctions::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkFEShapeFunctions::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkFEShapeFunctions * vtkvmtkFEShapeFunctions::NewInstance ( ) const

◆ New()

vtkvmtkFEShapeFunctions * vtkvmtkFEShapeFunctions::New ( )
static

◆ Initialize()

void vtkvmtkFEShapeFunctions::Initialize ( vtkCell * cell,
vtkDoubleArray * pcoords )

Precompute and cache the shape function values (Phi), their physical-space gradients (DPhi), and the mapping Jacobian (Jacobians) at every parametric point held in pcoords, for the given cell. Subsequent GetPhi/GetDPhi/GetJacobian calls index into these cached arrays using the point index id (0-based, in the order of pcoords) and, for Phi/DPhi, the cell-local node index i (0 to cell->GetNumberOfPoints()-1).

Definition at line 64 of file vtkvmtkFEShapeFunctions.cxx.

65{
66 vtkIdType cellDimension = cell->GetCellDimension();
67 vtkIdType numberOfPCoords = pcoords->GetNumberOfTuples();
68 vtkIdType numberOfCellPoints = cell->GetNumberOfPoints();
69 this->NumberOfCellPoints = numberOfCellPoints;
70
71 this->Phi->Initialize();
72 this->Phi->SetNumberOfTuples(numberOfCellPoints*numberOfPCoords);
73
74 this->DPhi->Initialize();
75 this->DPhi->SetNumberOfComponents(3);
76 this->DPhi->SetNumberOfTuples(numberOfCellPoints*numberOfPCoords);
77
78 this->Jacobians->Initialize();
79 this->Jacobians->SetNumberOfTuples(numberOfPCoords);
80
81 int i;
82
83 //Phi
84 for (i=0; i<numberOfPCoords; i++)
85 {
86 double* sf = new double[numberOfCellPoints];
87 this->GetInterpolationFunctions(cell,pcoords->GetTuple(i),sf);
88 int j;
89 for (j=0; j<numberOfCellPoints; j++)
90 {
91 this->Phi->SetValue(i*numberOfCellPoints+j,sf[j]);
92 }
93 delete[] sf;
94
95 //DPhi
96 double* derivs = new double[cellDimension*numberOfCellPoints];
97 this->GetInterpolationDerivs(cell,pcoords->GetTuple(i),derivs);
98 if (cellDimension == 2)
99 {
100 double inverseJacobianMatrix[2][3];
101 this->ComputeInverseJacobianMatrix2D(cell,pcoords->GetTuple(i),inverseJacobianMatrix);
102 for (j=0; j<numberOfCellPoints; j++)
103 {
104 int k;
105 for (k=0; k<3; k++)
106 {
107 double dphik = derivs[j] * inverseJacobianMatrix[0][k] + derivs[j+numberOfCellPoints] * inverseJacobianMatrix[1][k];
108 this->DPhi->SetComponent(i*numberOfCellPoints+j,k,dphik);
109 }
110 }
111 }
112 else if (cellDimension == 3)
113 {
114 double inverseJacobianMatrix[3][3];
115 this->ComputeInverseJacobianMatrix3D(cell,pcoords->GetTuple(i),inverseJacobianMatrix);
116 for (j=0; j<numberOfCellPoints; j++)
117 {
118 int k;
119 for (k=0; k<3; k++)
120 {
121 double dphik = derivs[j] * inverseJacobianMatrix[0][k] + derivs[j+numberOfCellPoints] * inverseJacobianMatrix[1][k] + derivs[j+2*numberOfCellPoints] * inverseJacobianMatrix[2][k];
122 this->DPhi->SetComponent(i*numberOfCellPoints+j,k,dphik);
123 }
124 }
125 }
126 delete[] derivs;
127
128 //Jacobians
129 double jacobian = this->ComputeJacobian(cell,pcoords->GetTuple(i));
130 this->Jacobians->SetValue(i,jacobian);
131 }
132}
static void GetInterpolationDerivs(vtkCell *cell, double *pcoords, double *derivs)
static double ComputeJacobian(vtkCell *cell, double *pcoords)
static void ComputeInverseJacobianMatrix2D(vtkCell *cell, double *pcoords, double inverseJacobianMatrix[2][3])
static void ComputeInverseJacobianMatrix3D(vtkCell *cell, double *pcoords, double inverseJacobianMatrix[3][3])
static void GetInterpolationFunctions(vtkCell *cell, double *pcoords, double *sf)

◆ GetPhi()

double vtkvmtkFEShapeFunctions::GetPhi ( vtkIdType id,
vtkIdType i )
inline

Get the cached value of the i-th node's shape function at the id-th parametric point (previously computed by Initialize()).

Definition at line 65 of file vtkvmtkFEShapeFunctions.h.

66 { return this->Phi->GetValue(id*this->NumberOfCellPoints+i); }

◆ GetDPhi() [1/3]

double * vtkvmtkFEShapeFunctions::GetDPhi ( vtkIdType id,
vtkIdType i )
inline

Get a pointer to the cached 3-component physical-space gradient of the i-th node's shape function at the id-th parametric point (previously computed by Initialize()).

Definition at line 72 of file vtkvmtkFEShapeFunctions.h.

73 { return this->DPhi->GetTuple(id*this->NumberOfCellPoints+i); }

◆ GetDPhi() [2/3]

void vtkvmtkFEShapeFunctions::GetDPhi ( vtkIdType id,
vtkIdType i,
double * dphi )
inline

Copy the cached 3-component physical-space gradient of the i-th node's shape function at the id-th parametric point (previously computed by Initialize()) into dphi.

Definition at line 79 of file vtkvmtkFEShapeFunctions.h.

80 { this->DPhi->GetTuple(id*this->NumberOfCellPoints+i,dphi); }

◆ GetDPhi() [3/3]

double vtkvmtkFEShapeFunctions::GetDPhi ( vtkIdType id,
vtkIdType i,
int c )
inline

Get the c-th component of the cached physical-space gradient of the i-th node's shape function at the id-th parametric point (previously computed by Initialize()).

Definition at line 86 of file vtkvmtkFEShapeFunctions.h.

87 { return this->DPhi->GetComponent(id*this->NumberOfCellPoints+i,c); }

◆ GetJacobian()

double vtkvmtkFEShapeFunctions::GetJacobian ( vtkIdType i)
inline

Get the cached Jacobian of the parametric-to-physical mapping at the i-th parametric point (previously computed by Initialize()).

Definition at line 93 of file vtkvmtkFEShapeFunctions.h.

94 { return this->Jacobians->GetValue(i); }

◆ GetInterpolationFunctions()

void vtkvmtkFEShapeFunctions::GetInterpolationFunctions ( vtkCell * cell,
double * pcoords,
double * sf )
static

Evaluate, into sf, the shape function (interpolation function) values of cell at the parametric coordinates pcoords. Dispatches to the appropriate vtkCell subclass's InterpolationFunctions method based on cell->GetCellType(); unsupported cell types emit a warning.

Definition at line 242 of file vtkvmtkFEShapeFunctions.cxx.

243{
244 switch (cell->GetCellType())
245 {
246 case VTK_QUAD:
247 vtkQuad::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
248 break;
249 case VTK_QUADRATIC_QUAD:
250 vtkQuadraticQuad::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
251 break;
252 case VTK_TRIANGLE:
253 vtkTriangle::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
254 break;
255 case VTK_QUADRATIC_TRIANGLE:
256 vtkQuadraticTriangle::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
257 break;
258 case VTK_HEXAHEDRON:
259 vtkHexahedron::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
260 break;
261 case VTK_QUADRATIC_HEXAHEDRON:
262 vtkQuadraticHexahedron::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
263 break;
264 case VTK_TRIQUADRATIC_HEXAHEDRON:
265 vtkTriQuadraticHexahedron::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
266 break;
267 case VTK_WEDGE:
268 vtkWedge::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
269 break;
270 case VTK_QUADRATIC_WEDGE:
271 vtkQuadraticWedge::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
272 break;
273 case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
274 vtkBiQuadraticQuadraticWedge::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
275 break;
276 case VTK_TETRA:
277 vtkTetra::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
278 break;
279 case VTK_QUADRATIC_TETRA:
280 vtkQuadraticTetra::SafeDownCast(cell)->InterpolationFunctions(pcoords,sf);
281 break;
282 default:
283 vtkGenericWarningMacro("Error: unsupported cell type.");
284 return;
285 }
286}

◆ GetInterpolationDerivs()

void vtkvmtkFEShapeFunctions::GetInterpolationDerivs ( vtkCell * cell,
double * pcoords,
double * derivs )
static

Evaluate, into derivs, the parametric-space derivatives of cell's shape functions at the parametric coordinates pcoords. Dispatches to the appropriate vtkCell subclass's InterpolationDerivs (or InterpolateDerivs) method based on cell->GetCellType(); unsupported cell types emit a warning.

Definition at line 288 of file vtkvmtkFEShapeFunctions.cxx.

289{
290 switch (cell->GetCellType())
291 {
292 case VTK_QUAD:
293 vtkQuad::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
294 break;
295 case VTK_QUADRATIC_QUAD:
296 vtkQuadraticQuad::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
297 break;
298 case VTK_TRIANGLE:
299 vtkTriangle::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
300 break;
301 case VTK_QUADRATIC_TRIANGLE:
302 vtkQuadraticTriangle::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
303 break;
304 case VTK_HEXAHEDRON:
305 vtkHexahedron::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
306 break;
307 case VTK_QUADRATIC_HEXAHEDRON:
308 vtkQuadraticHexahedron::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
309 break;
310 case VTK_TRIQUADRATIC_HEXAHEDRON:
311 vtkTriQuadraticHexahedron::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
312 break;
313 case VTK_WEDGE:
314 vtkWedge::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
315 break;
316 case VTK_QUADRATIC_WEDGE:
317 vtkQuadraticWedge::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
318 break;
319 case VTK_BIQUADRATIC_QUADRATIC_WEDGE:
320 vtkBiQuadraticQuadraticWedge::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
321 break;
322 case VTK_TETRA:
323 vtkTetra::SafeDownCast(cell)->InterpolateDerivs(pcoords,derivs);
324 break;
325 case VTK_QUADRATIC_TETRA:
326 vtkQuadraticTetra::SafeDownCast(cell)->InterpolationDerivs(pcoords,derivs);
327 break;
328 default:
329 vtkGenericWarningMacro("Error: unsupported cell type.");
330 return;
331 }
332}

◆ ComputeJacobian()

double vtkvmtkFEShapeFunctions::ComputeJacobian ( vtkCell * cell,
double * pcoords )
static

Compute and return the Jacobian of the parametric-to-physical mapping of cell at the parametric coordinates pcoords, for 2D or 3D cells. A negative Jacobian (inverted/degenerate element) is reported (optionally, when the corresponding compile-time macro is enabled) and its absolute value is returned.

Definition at line 334 of file vtkvmtkFEShapeFunctions.cxx.

335{
336 double jacobian = 0.0;
337
338 int cellDimension = cell->GetCellDimension();
339
340 if (cellDimension == 2)
341 {
342 int numberOfCellPoints = cell->GetNumberOfPoints();
343 double* derivs = new double[2*numberOfCellPoints];
344
346
347 int i, j;
348
349 double jacobianMatrixTr[2][3];
350 for (i=0; i<3; i++)
351 {
352 jacobianMatrixTr[0][i] = jacobianMatrixTr[1][i] = 0.0;
353 }
354
355 double x[3];
356 for (j=0; j<numberOfCellPoints; j++)
357 {
358 cell->GetPoints()->GetPoint(j,x);
359 for (i=0; i<3; i++)
360 {
361 jacobianMatrixTr[0][i] += x[i] * derivs[j];
362 jacobianMatrixTr[1][i] += x[i] * derivs[numberOfCellPoints+j];
363 }
364 }
365 delete[] derivs;
366
367 double jacobianMatrixSquared[2][2];
368 jacobianMatrixSquared[0][0] = vtkMath::Dot(jacobianMatrixTr[0],jacobianMatrixTr[0]);
369 jacobianMatrixSquared[0][1] = vtkMath::Dot(jacobianMatrixTr[0],jacobianMatrixTr[1]);
370 jacobianMatrixSquared[1][0] = vtkMath::Dot(jacobianMatrixTr[1],jacobianMatrixTr[0]);
371 jacobianMatrixSquared[1][1] = vtkMath::Dot(jacobianMatrixTr[1],jacobianMatrixTr[1]);
372
373 double jacobianSquared = vtkMath::Determinant2x2(jacobianMatrixSquared[0],jacobianMatrixSquared[1]);
374
375 if (jacobianSquared < 0.0)
376 {
377#ifdef VTKVMTKFESHAPEFUNCTIONS_NEGATIVE_JACOBIAN_WARNING
378 vtkGenericWarningMacro("Warning: negative determinant of squared Jacobian, taking absolute value.");
379#endif
380 jacobianSquared = fabs(jacobianSquared);
381 }
382
383 jacobian = sqrt(jacobianSquared);
384 }
385 else if (cellDimension == 3)
386 {
387 int numberOfCellPoints = cell->GetNumberOfPoints();
388 double* derivs = new double[3*numberOfCellPoints];
389
391
392 int i, j;
393
394 double jacobianMatrix[3][3];
395 for (i=0; i<3; i++)
396 {
397 jacobianMatrix[0][i] = jacobianMatrix[1][i] = jacobianMatrix[2][i] = 0.0;
398 }
399
400 double x[3];
401 for (j=0; j<numberOfCellPoints; j++)
402 {
403 cell->GetPoints()->GetPoint(j,x);
404 for (i=0; i<3; i++)
405 {
406 jacobianMatrix[0][i] += x[i] * derivs[j];
407 jacobianMatrix[1][i] += x[i] * derivs[numberOfCellPoints+j];
408 jacobianMatrix[2][i] += x[i] * derivs[2*numberOfCellPoints+j];
409 }
410 }
411 delete[] derivs;
412
413 jacobian = vtkMath::Determinant3x3(jacobianMatrix);
414
415 if (jacobian < 0.0)
416 {
417#ifdef VTKVMTKFESHAPEFUNCTIONS_NEGATIVE_JACOBIAN_WARNING
418 vtkGenericWarningMacro("Warning: negative Jacobian, taking absolute value.");
419#endif
420 jacobian = fabs(jacobian);
421 }
422 }
423
424 return jacobian;
425}

◆ ComputeInverseJacobianMatrix2D()

void vtkvmtkFEShapeFunctions::ComputeInverseJacobianMatrix2D ( vtkCell * cell,
double * pcoords,
double inverseJacobianMatrix[2][3] )
staticprotected

Definition at line 134 of file vtkvmtkFEShapeFunctions.cxx.

135{
136 int cellDimension = cell->GetCellDimension();
137
138 if (cellDimension != 2)
139 {
140 vtkGenericWarningMacro("Error: ComputeInverseJacobian2D only works for 2D cells.");
141 return;
142 }
143
144 int numberOfCellPoints = cell->GetNumberOfPoints();
145 double* derivs = new double[2*numberOfCellPoints];
146
148
149 int i, j;
150
151 double jacobianMatrixTr[2][3];
152 for (i=0; i<3; i++)
153 {
154 jacobianMatrixTr[0][i] = jacobianMatrixTr[1][i] = 0.0;
155 }
156
157 double x[3];
158 for (j=0; j<numberOfCellPoints; j++)
159 {
160 cell->GetPoints()->GetPoint(j,x);
161 for (i=0; i<3; i++)
162 {
163 jacobianMatrixTr[0][i] += x[i] * derivs[j];
164 jacobianMatrixTr[1][i] += x[i] * derivs[numberOfCellPoints+j];
165 }
166 }
167 delete[] derivs;
168
169 double jacobianMatrixSquared[2][2];
170 jacobianMatrixSquared[0][0] = vtkMath::Dot(jacobianMatrixTr[0],jacobianMatrixTr[0]);
171 jacobianMatrixSquared[0][1] = vtkMath::Dot(jacobianMatrixTr[0],jacobianMatrixTr[1]);
172 jacobianMatrixSquared[1][0] = vtkMath::Dot(jacobianMatrixTr[1],jacobianMatrixTr[0]);
173 jacobianMatrixSquared[1][1] = vtkMath::Dot(jacobianMatrixTr[1],jacobianMatrixTr[1]);
174
175 double jacobianSquared = vtkMath::Determinant2x2(jacobianMatrixSquared[0],jacobianMatrixSquared[1]);
176
177 if (jacobianSquared < 0.0)
178 {
179#ifdef VTKVMTKFESHAPEFUNCTIONS_NEGATIVE_JACOBIAN_WARNING
180 vtkGenericWarningMacro("Warning: negative determinant of squared Jacobian, taking absolute value.");
181#endif
182 jacobianSquared = fabs(jacobianSquared);
183 }
184
185 double inverseJacobianSquared = 1.0 / jacobianSquared;
186
187 double inverseJacobianMatrixSquared[2][2];
188 inverseJacobianMatrixSquared[0][0] = jacobianMatrixSquared[1][1] * inverseJacobianSquared;
189 inverseJacobianMatrixSquared[0][1] = -jacobianMatrixSquared[0][1] * inverseJacobianSquared;
190 inverseJacobianMatrixSquared[1][0] = -jacobianMatrixSquared[1][0] * inverseJacobianSquared;
191 inverseJacobianMatrixSquared[1][1] = jacobianMatrixSquared[0][0] * inverseJacobianSquared;
192
193 inverseJacobianMatrix[0][0] = inverseJacobianMatrixSquared[0][0] * jacobianMatrixTr[0][0] + inverseJacobianMatrixSquared[0][1] * jacobianMatrixTr[1][0];
194 inverseJacobianMatrix[0][1] = inverseJacobianMatrixSquared[0][0] * jacobianMatrixTr[0][1] + inverseJacobianMatrixSquared[0][1] * jacobianMatrixTr[1][1];
195 inverseJacobianMatrix[0][2] = inverseJacobianMatrixSquared[0][0] * jacobianMatrixTr[0][2] + inverseJacobianMatrixSquared[0][1] * jacobianMatrixTr[1][2];
196 inverseJacobianMatrix[1][0] = inverseJacobianMatrixSquared[1][0] * jacobianMatrixTr[0][0] + inverseJacobianMatrixSquared[1][1] * jacobianMatrixTr[1][0];
197 inverseJacobianMatrix[1][1] = inverseJacobianMatrixSquared[1][0] * jacobianMatrixTr[0][1] + inverseJacobianMatrixSquared[1][1] * jacobianMatrixTr[1][1];
198 inverseJacobianMatrix[1][2] = inverseJacobianMatrixSquared[1][0] * jacobianMatrixTr[0][2] + inverseJacobianMatrixSquared[1][1] * jacobianMatrixTr[1][2];
199}

◆ ComputeInverseJacobianMatrix3D()

void vtkvmtkFEShapeFunctions::ComputeInverseJacobianMatrix3D ( vtkCell * cell,
double * pcoords,
double inverseJacobianMatrix[3][3] )
staticprotected

Definition at line 201 of file vtkvmtkFEShapeFunctions.cxx.

202{
203 int cellDimension = cell->GetCellDimension();
204
205 if (cellDimension != 3)
206 {
207 vtkGenericWarningMacro("Error: ComputeInverseJacobian3D only works for 3D cells.");
208 return;
209 }
210
211 int numberOfCellPoints = cell->GetNumberOfPoints();
212 double* derivs = new double[3*numberOfCellPoints];
213
215
216 int i, j;
217
218 double jacobianMatrix[3][3];
219 for (i=0; i<3; i++)
220 {
221 jacobianMatrix[0][i] = jacobianMatrix[1][i] = jacobianMatrix[2][i] = 0.0;
222 }
223
224 double x[3];
225 for (j=0; j<numberOfCellPoints; j++)
226 {
227 cell->GetPoints()->GetPoint(j,x);
228 for (i=0; i<3; i++)
229 {
230 jacobianMatrix[0][i] += x[i] * derivs[j];
231 jacobianMatrix[1][i] += x[i] * derivs[numberOfCellPoints+j];
232 jacobianMatrix[2][i] += x[i] * derivs[2*numberOfCellPoints+j];
233 }
234 }
235 delete[] derivs;
236
237 vtkMath::Invert3x3(jacobianMatrix,inverseJacobianMatrix);
238
239 vtkMath::Transpose3x3(inverseJacobianMatrix,inverseJacobianMatrix);
240}

Member Data Documentation

◆ Phi

vtkDoubleArray* vtkvmtkFEShapeFunctions::Phi
protected

Definition at line 126 of file vtkvmtkFEShapeFunctions.h.

◆ DPhi

vtkDoubleArray* vtkvmtkFEShapeFunctions::DPhi
protected

Definition at line 127 of file vtkvmtkFEShapeFunctions.h.

◆ Jacobians

vtkDoubleArray* vtkvmtkFEShapeFunctions::Jacobians
protected

Definition at line 128 of file vtkvmtkFEShapeFunctions.h.

◆ NumberOfCellPoints

vtkIdType vtkvmtkFEShapeFunctions::NumberOfCellPoints
protected

Definition at line 129 of file vtkvmtkFEShapeFunctions.h.


The documentation for this class was generated from the following files: