VTK
vtkLagrangeInterpolation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLagrangeInterpolation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 // .NAME vtkLagrangeInterpolation
16 // .SECTION Description
17 // .SECTION See Also
18 #ifndef vtkLagrangeInterpolation_h
19 #define vtkLagrangeInterpolation_h
20 
21 #include "vtkObject.h"
22 #include "vtkSmartPointer.h" // For API.
23 #include "vtkCommonDataModelModule.h" // For export macro.
24 
25 #include <vector> // For scratch storage.
26 
27 // Define this to include support for a "complete" (21- vs 18-point) wedge.
28 #define VTK_21_POINT_WEDGE true
29 
30 class vtkPoints;
31 class vtkVector2i;
32 class vtkVector3d;
33 
34 class VTKCOMMONDATAMODEL_EXPORT vtkLagrangeInterpolation : public vtkObject
35 {
36 public:
37  static vtkLagrangeInterpolation* New();
38  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
41  enum Constants {
42  MaxDegree = 10 // The maximum degree that VTK will support.
43  };
44 
45  static void EvaluateShapeFunctions(int order, double pcoord, double* shape);
46  static void EvaluateShapeAndGradient(int order, double pcoord, double* shape, double* grad);
47 
48  static int Tensor1ShapeFunctions(const int order[1], const double* pcoords, double* shape);
49  static int Tensor1ShapeDerivatives(const int order[1], const double* pcoords, double* derivs);
50 
51  static int Tensor2ShapeFunctions(const int order[2], const double* pcoords, double* shape);
52  static int Tensor2ShapeDerivatives(const int order[2], const double* pcoords, double* derivs);
53 
54  static int Tensor3ShapeFunctions(const int order[3], const double* pcoords, double* shape);
55  static int Tensor3ShapeDerivatives(const int order[3], const double* pcoords, double* derivs);
56 
57  void Tensor3EvaluateDerivative(
58  const int order[3],
59  const double* pcoords,
61  const double* fieldVals,
62  int fieldDim,
63  double* fieldDerivs);
64 
65  static void WedgeShapeFunctions(const int order[3], const vtkIdType numberOfPoints, const double* pcoords, double* shape);
66  static void WedgeShapeDerivatives(const int order[3], const vtkIdType numberOfPoints, const double* pcoords, double* derivs);
67 
72  int JacobianInverse(vtkPoints* points, const double* derivs, double** inverse);
73  int JacobianInverseWedge(vtkPoints* points, const double* derivs, double** inverse);
74 
75  void WedgeEvaluate(
76  const int order[3],
77  const vtkIdType numberOfPoints,
78  const double* pcoords,
79  double* fieldVals,
80  int fieldDim,
81  double* fieldAtPCoords);
82 
83  void WedgeEvaluateDerivative(
84  const int order[3],
85  const double* pcoords,
87  const double* fieldVals,
88  int fieldDim,
89  double* fieldDerivs);
90 
91  static vtkVector3d GetParametricHexCoordinates(int vertexId);
92  static vtkVector2i GetPointIndicesBoundingHexEdge(int edgeId);
93  static int GetVaryingParameterOfHexEdge(int edgeId);
94  static vtkVector2i GetFixedParametersOfHexEdge(int edgeId);
95 
96  static const int* GetPointIndicesBoundingHexFace(int faceId) VTK_SIZEHINT(4);
97  static const int* GetEdgeIndicesBoundingHexFace(int faceId) VTK_SIZEHINT(4);
98  static vtkVector2i GetVaryingParametersOfHexFace(int faceId);
99  static int GetFixedParameterOfHexFace(int faceId);
100 
101  static vtkVector3d GetParametricWedgeCoordinates(int vertexId);
102  static vtkVector2i GetPointIndicesBoundingWedgeEdge(int edgeId);
103  static int GetVaryingParameterOfWedgeEdge(int edgeId);
104  static vtkVector2i GetFixedParametersOfWedgeEdge(int edgeId);
105 
106  static const int* GetPointIndicesBoundingWedgeFace(int faceId) VTK_SIZEHINT(4);
107  static const int* GetEdgeIndicesBoundingWedgeFace(int faceId) VTK_SIZEHINT(4);
108  static vtkVector2i GetVaryingParametersOfWedgeFace(int faceId);
109  static int GetFixedParameterOfWedgeFace(int faceId);
110 
111  static void AppendCurveCollocationPoints(vtkSmartPointer<vtkPoints>& pts, const int order[1]);
112  static void AppendQuadrilateralCollocationPoints(vtkSmartPointer<vtkPoints>& pts, const int order[2]);
113  static void AppendHexahedronCollocationPoints(vtkSmartPointer<vtkPoints>& pts, const int order[3]);
114  static void AppendWedgeCollocationPoints(vtkSmartPointer<vtkPoints>& pts, const int order[3]);
115 
116  template<int N>
117  static int NumberOfIntervals(const int order[N]);
118 protected:
120  ~vtkLagrangeInterpolation() override;
121 
122  void PrepareForOrder(const int order[3], const vtkIdType numberOfPoints);
123 
124  std::vector<double> ShapeSpace;
125  std::vector<double> DerivSpace;
126 
127 private:
129  void operator=(const vtkLagrangeInterpolation&) = delete;
130 };
131 
132 template<int N>
134 {
135  int ni = 1;
136  for (int n = 0; n < N; ++n)
137  {
138  ni *= order[n];
139  }
140  return ni;
141 }
142 
143 #endif // vtkLagrangeInterpolation_h
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static int NumberOfIntervals(const int order[N])
int vtkIdType
Definition: vtkType.h:347
a simple class to control print indentation
Definition: vtkIndent.h:39
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:408
std::vector< double > DerivSpace
#define VTK_SIZEHINT(...)
std::vector< double > ShapeSpace
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3D points
Definition: vtkPoints.h:39