1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkQuadratureSchemeDefinition.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 vtkQuadratureSchemeDefinition 16 // .SECTION Description 17 // An Elemental data type that holds a definition of a 18 // numerical quadrature scheme. The definition contains 19 // the requisite information to interpolate to the so called 20 // quadrature points of the specific scheme. namely: 21 // 22 // <pre> 23 // 1) 24 // A matrix of shape function weights(shape functions evaluated 25 // at parametric coordinates of the quadrature points). 26 // 27 // 2) 28 // The number of quadrature points and cell nodes. These parameters 29 // size the matrix, and allow for convinent evaluation by users 30 // of the definition. 31 // </pre> 32 33 #ifndef vtkQuadratureSchemeDefinition_h 34 #define vtkQuadratureSchemeDefinition_h 35 36 #include "vtkCommonDataModelModule.h" // For export macro 37 #include "vtkObject.h" 38 39 class vtkInformationQuadratureSchemeDefinitionVectorKey; 40 class vtkInformationStringKey; 41 class vtkXMLDataElement; 42 43 class VTKCOMMONDATAMODEL_EXPORT vtkQuadratureSchemeDefinition : public vtkObject 44 { 45 public: 46 // vtk stuff 47 vtkTypeMacro(vtkQuadratureSchemeDefinition,vtkObject); 48 void PrintSelf(ostream& os, vtkIndent indent); 49 static vtkInformationQuadratureSchemeDefinitionVectorKey* DICTIONARY(); 50 static vtkInformationStringKey* QUADRATURE_OFFSET_ARRAY_NAME(); 51 52 // Description: 53 // New object in an unsuable state. You'll have to call 54 // "Initilaize" to get the definition in to a usable state. 55 static vtkQuadratureSchemeDefinition *New(); 56 57 // Description: 58 // Deep copy. 59 int DeepCopy(const vtkQuadratureSchemeDefinition *other); 60 61 // Description: 62 // Put the object into an XML representation. The element 63 // passed in is assumed to be empty. 64 int SaveState(vtkXMLDataElement *e); 65 // Description: 66 // Restore the object from an XML representation. 67 int RestoreState(vtkXMLDataElement *e); 68 69 // Description: 70 // Release all allocated resources and set the 71 // object to an unitialized state. 72 void Clear(); 73 74 // Description: 75 // Initialize the object allocating resources as needed. 76 void Initialize(int cellType, 77 int numberOfNodes, 78 int numberOfQuadraturePoints, 79 double *shapeFunctionWeights); 80 // Description: 81 // Initialize the object allocating resources as needed. 82 void Initialize(int cellType, 83 int numberOfNodes, 84 int numberOfQuadraturePoints, 85 double *shapeFunctionWeights, 86 double *quadratureWeights); 87 88 // Description: 89 // Access the VTK cell type id. GetCellType()90 int GetCellType() const { return this->CellType; } 91 // Description: 92 // Access to an alternative key. GetQuadratureKey()93 int GetQuadratureKey() const { return this->QuadratureKey; } 94 // Description: 95 // Get the number of nodes associated with the interpolation. GetNumberOfNodes()96 int GetNumberOfNodes() const { return this->NumberOfNodes; } 97 // Description: 98 // Get the number of quadrature points associated with the scheme. GetNumberOfQuadraturePoints()99 int GetNumberOfQuadraturePoints() const { return this->NumberOfQuadraturePoints; } 100 // Description: 101 // Get the array of shape function weights. Shape function weights are 102 // the shape functions evaluated at the quadrature points. There are 103 // "NumberOfNodes" weights for each quadrature point. GetShapeFunctionWeights()104 const double *GetShapeFunctionWeights() const { return this->ShapeFunctionWeights; } 105 // Description: 106 // Get the array of shape function weights associated with a 107 // single quadrature point. GetShapeFunctionWeights(int quadraturePointId)108 const double *GetShapeFunctionWeights(int quadraturePointId) const 109 { 110 int idx=quadraturePointId*this->NumberOfNodes; 111 return this->ShapeFunctionWeights+idx; 112 } 113 // Description: 114 // Access to the quadrature weights. GetQuadratureWeights()115 const double *GetQuadratureWeights() const { return this->QuadratureWeights; } 116 117 protected: 118 vtkQuadratureSchemeDefinition(); 119 ~vtkQuadratureSchemeDefinition(); 120 private: 121 // Description: 122 // Allocate/De-allocate resources that will be used by the definition. 123 // This must be called after Set*. Caller's responsibility. 124 void ReleaseResources(); 125 // Description: 126 // Allocate resources according to the objects 127 // current internal state. 128 int SecureResources(); 129 // Description: 130 // Initialize the shape function weights definition. 131 // Must call SecureResources prior. 132 void SetShapeFunctionWeights(const double *W); 133 // Description: 134 // Initialize the shape function weights definition. 135 // Must call SecureResources prior. 136 void SetQuadratureWeights(const double *W); 137 138 // 139 vtkQuadratureSchemeDefinition(const vtkQuadratureSchemeDefinition &); // Not implemented. 140 void operator=(const vtkQuadratureSchemeDefinition &); // Not implemented. 141 friend ostream &operator<<(ostream &s, const vtkQuadratureSchemeDefinition &d); 142 friend istream &operator>>(istream &s, vtkQuadratureSchemeDefinition &d); 143 // 144 int CellType; 145 int QuadratureKey; 146 int NumberOfNodes; 147 int NumberOfQuadraturePoints; 148 double *ShapeFunctionWeights; 149 double *QuadratureWeights; 150 }; 151 152 #endif 153 154