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

Compute the gradient of data stored within an unstructured grid mesh. More...

#include <vtkvmtkUnstructuredGridGradientFilter.h>

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

Public Types

typedef vtkUnstructuredGridAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkUnstructuredGridGradientFilter * NewInstance () const
virtual void SetInputArrayName (const char *)
virtual char * GetInputArrayName ()
virtual void SetGradientArrayName (const char *)
virtual char * GetGradientArrayName ()
virtual void SetConvergenceTolerance (double)
virtual double GetConvergenceTolerance ()
virtual void SetQuadratureOrder (int)
virtual int GetQuadratureOrder ()
virtual void SetComputeIndividualPartialDerivatives (int)
virtual int GetComputeIndividualPartialDerivatives ()
virtual void ComputeIndividualPartialDerivativesOn ()
virtual void ComputeIndividualPartialDerivativesOff ()

Static Public Member Functions

static vtkvmtkUnstructuredGridGradientFilter * New ()
static int IsTypeOf (const char *type)
static vtkvmtkUnstructuredGridGradientFilter * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkUnstructuredGridGradientFilter ()
 ~vtkvmtkUnstructuredGridGradientFilter ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

char * InputArrayName
char * GradientArrayName
double ConvergenceTolerance
int QuadratureOrder
int ComputeIndividualPartialDerivatives

Detailed Description

Compute the gradient of data stored within an unstructured grid mesh.

The vtkUnstructuredGrid counterpart of vtkvmtkPolyDataGradientFilter: for each component of the point data array named InputArrayName, computes a smoothed nodal gradient using a finite-element L2 projection (vtkvmtkUnstructuredGridFEGradientAssembler, Gauss quadrature order QuadratureOrder), solved with vtkvmtkOpenNLLinearSystemSolver to the given ConvergenceTolerance, writing the result into GradientArrayName.

See also
vtkvmtkPolyDataGradientFilter, vtkvmtkUnstructuredGridFEGradientAssembler

Definition at line 37 of file vtkvmtkUnstructuredGridGradientFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkUnstructuredGridAlgorithm vtkvmtkUnstructuredGridGradientFilter::Superclass

Definition at line 41 of file vtkvmtkUnstructuredGridGradientFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkUnstructuredGridGradientFilter()

◆ ~vtkvmtkUnstructuredGridGradientFilter()

vtkvmtkUnstructuredGridGradientFilter::~vtkvmtkUnstructuredGridGradientFilter ( )
protected

Definition at line 49 of file vtkvmtkUnstructuredGridGradientFilter.cxx.

50{
51 if (this->InputArrayName)
52 {
53 delete[] this->InputArrayName;
54 this->InputArrayName = NULL;
55 }
56 if (this->GradientArrayName)
57 {
58 delete[] this->GradientArrayName;
59 this->GradientArrayName = NULL;
60 }
61}

Member Function Documentation

◆ New()

vtkvmtkUnstructuredGridGradientFilter * vtkvmtkUnstructuredGridGradientFilter::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkUnstructuredGridGradientFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkUnstructuredGridGradientFilter * vtkvmtkUnstructuredGridGradientFilter::NewInstance ( ) const

◆ SetInputArrayName()

virtual void vtkvmtkUnstructuredGridGradientFilter::SetInputArrayName ( const char * )
virtual

Set/Get the name of the point data array whose (per-component) gradient is computed. Must be set, and the array must exist on the input, before Update() is called.

◆ GetInputArrayName()

virtual char * vtkvmtkUnstructuredGridGradientFilter::GetInputArrayName ( )
virtual

Set/Get the name of the point data array whose (per-component) gradient is computed. Must be set, and the array must exist on the input, before Update() is called.

◆ SetGradientArrayName()

virtual void vtkvmtkUnstructuredGridGradientFilter::SetGradientArrayName ( const char * )
virtual

Set/Get the name of the point data array, with 3 components per component of InputArrayName, that the computed gradient(s) are written into on the output. Must be set before Update() is called.

◆ GetGradientArrayName()

virtual char * vtkvmtkUnstructuredGridGradientFilter::GetGradientArrayName ( )
virtual

Set/Get the name of the point data array, with 3 components per component of InputArrayName, that the computed gradient(s) are written into on the output. Must be set before Update() is called.

◆ SetConvergenceTolerance()

virtual void vtkvmtkUnstructuredGridGradientFilter::SetConvergenceTolerance ( double )
virtual

Set/Get the convergence tolerance of the iterative linear solver (see vtkvmtkOpenNLLinearSystemSolver) used to solve the finite-element gradient projection.

◆ GetConvergenceTolerance()

virtual double vtkvmtkUnstructuredGridGradientFilter::GetConvergenceTolerance ( )
virtual

Set/Get the convergence tolerance of the iterative linear solver (see vtkvmtkOpenNLLinearSystemSolver) used to solve the finite-element gradient projection.

◆ SetQuadratureOrder()

virtual void vtkvmtkUnstructuredGridGradientFilter::SetQuadratureOrder ( int )
virtual

Set/Get the order of the Gauss quadrature rule used to integrate the finite-element matrices in vtkvmtkUnstructuredGridFEGradientAssembler.

◆ GetQuadratureOrder()

virtual int vtkvmtkUnstructuredGridGradientFilter::GetQuadratureOrder ( )
virtual

Set/Get the order of the Gauss quadrature rule used to integrate the finite-element matrices in vtkvmtkUnstructuredGridFEGradientAssembler.

◆ SetComputeIndividualPartialDerivatives()

virtual void vtkvmtkUnstructuredGridGradientFilter::SetComputeIndividualPartialDerivatives ( int )
virtual

Toggle assembling and solving each partial derivative of the gradient as a separate linear system (one per coordinate direction), instead of assembling the full gradient in a single system. Default: off.

◆ GetComputeIndividualPartialDerivatives()

virtual int vtkvmtkUnstructuredGridGradientFilter::GetComputeIndividualPartialDerivatives ( )
virtual

Toggle assembling and solving each partial derivative of the gradient as a separate linear system (one per coordinate direction), instead of assembling the full gradient in a single system. Default: off.

◆ ComputeIndividualPartialDerivativesOn()

virtual void vtkvmtkUnstructuredGridGradientFilter::ComputeIndividualPartialDerivativesOn ( )
virtual

Toggle assembling and solving each partial derivative of the gradient as a separate linear system (one per coordinate direction), instead of assembling the full gradient in a single system. Default: off.

◆ ComputeIndividualPartialDerivativesOff()

virtual void vtkvmtkUnstructuredGridGradientFilter::ComputeIndividualPartialDerivativesOff ( )
virtual

Toggle assembling and solving each partial derivative of the gradient as a separate linear system (one per coordinate direction), instead of assembling the full gradient in a single system. Default: off.

◆ RequestData()

int vtkvmtkUnstructuredGridGradientFilter::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 63 of file vtkvmtkUnstructuredGridGradientFilter.cxx.

67{
68 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
69 vtkInformation *outInfo = outputVector->GetInformationObject(0);
70
71 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
72 inInfo->Get(vtkDataObject::DATA_OBJECT()));
73 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
74 outInfo->Get(vtkDataObject::DATA_OBJECT()));
75
76 if (!this->InputArrayName)
77 {
78 vtkErrorMacro(<<"InputArrayName not set.");
79 return 1;
80 }
81
82 if (!this->GradientArrayName)
83 {
84 vtkErrorMacro(<<"GradientArrayName not set.");
85 return 1;
86 }
87
88 int numberOfInputPoints = input->GetNumberOfPoints();
89
90 vtkDataArray* inputArray = input->GetPointData()->GetArray(this->InputArrayName);
91
92 if (!inputArray)
93 {
94 vtkErrorMacro("InputArray with name specified doesn not exist!");
95 return 0;
96 }
97
98 int numberOfInputComponents = inputArray->GetNumberOfComponents();
99
100 vtkDoubleArray* gradientArray = vtkDoubleArray::New();
101 gradientArray->SetName(this->GradientArrayName);
102 gradientArray->SetNumberOfComponents(3*numberOfInputComponents);
103 gradientArray->SetNumberOfTuples(numberOfInputPoints);
104
105 int i;
106 for (i=0; i<numberOfInputComponents; i++)
107 {
108 vtkvmtkSparseMatrix* sparseMatrix = vtkvmtkSparseMatrix::New();
109
110 vtkvmtkDoubleVector* rhsVector = vtkvmtkDoubleVector::New();
111 rhsVector->SetNormTypeToLInf();
112
113 vtkvmtkDoubleVector* solutionVector = vtkvmtkDoubleVector::New();
114 solutionVector->SetNormTypeToLInf();
115
117 {
118 vtkvmtkUnstructuredGridFEGradientAssembler* assembler = vtkvmtkUnstructuredGridFEGradientAssembler::New();
119 assembler->SetDataSet(input);
120 assembler->SetScalarsArrayName(this->InputArrayName);
121 assembler->SetScalarsComponent(i);
122 assembler->SetMatrix(sparseMatrix);
123 assembler->SetRHSVector(rhsVector);
124 assembler->SetSolutionVector(solutionVector);
125 assembler->SetQuadratureOrder(this->QuadratureOrder);
126 assembler->SetAssemblyModeToGradient();
127 std::cout<<"Assembling system"<<endl;
128 assembler->Build();
129 std::cout<<"Done"<<endl;
130
131 vtkvmtkLinearSystem* linearSystem = vtkvmtkLinearSystem::New();
132 linearSystem->SetA(sparseMatrix);
133 linearSystem->SetB(rhsVector);
134 linearSystem->SetX(solutionVector);
135
136 vtkvmtkOpenNLLinearSystemSolver* solver = vtkvmtkOpenNLLinearSystemSolver::New();
137 solver->SetLinearSystem(linearSystem);
139 solver->SetMaximumNumberOfIterations(numberOfInputPoints);
140 solver->SetSolverTypeToCG();
142 std::cout<<"Solving system"<<endl;
143 solver->Solve();
144 std::cout<<"Done"<<endl;
145
146 solutionVector->CopyVariableIntoArrayComponent(gradientArray,0,3*i+0);
147 solutionVector->CopyVariableIntoArrayComponent(gradientArray,1,3*i+1);
148 solutionVector->CopyVariableIntoArrayComponent(gradientArray,2,3*i+2);
149
150 assembler->Delete();
151 linearSystem->Delete();
152 solver->Delete();
153 }
154 else
155 {
156 int j;
157 for (j=0; j<3; j++)
158 {
159 vtkvmtkUnstructuredGridFEGradientAssembler* assembler = vtkvmtkUnstructuredGridFEGradientAssembler::New();
160 assembler->SetDataSet(input);
161 assembler->SetScalarsArrayName(this->InputArrayName);
162 assembler->SetScalarsComponent(i);
163 assembler->SetMatrix(sparseMatrix);
164 assembler->SetRHSVector(rhsVector);
165 assembler->SetSolutionVector(solutionVector);
166 assembler->SetQuadratureOrder(this->QuadratureOrder);
168 assembler->SetDirection(j);
169 std::cout<<"Assembling system"<<endl;
170 assembler->Build();
171 std::cout<<"Done"<<endl;
172
173 vtkvmtkLinearSystem* linearSystem = vtkvmtkLinearSystem::New();
174 linearSystem->SetA(sparseMatrix);
175 linearSystem->SetB(rhsVector);
176 linearSystem->SetX(solutionVector);
177
178 vtkvmtkOpenNLLinearSystemSolver* solver = vtkvmtkOpenNLLinearSystemSolver::New();
179 solver->SetLinearSystem(linearSystem);
181 solver->SetMaximumNumberOfIterations(numberOfInputPoints);
182 solver->SetSolverTypeToCG();
184 std::cout<<"Solving system"<<endl;
185 solver->Solve();
186 std::cout<<"Done"<<endl;
187
188 solutionVector->CopyIntoArrayComponent(gradientArray,3*i+j);
189
190 assembler->Delete();
191 linearSystem->Delete();
192 solver->Delete();
193 }
194 }
195
196 solutionVector->Delete();
197 rhsVector->Delete();
198 sparseMatrix->Delete();
199 }
200
201 output->DeepCopy(input);
202 output->GetPointData()->AddArray(gradientArray);
203
204 gradientArray->Delete();
205
206 return 1;
207}
void CopyVariableIntoArrayComponent(vtkDataArray *array, int variable, int component)
static vtkvmtkDoubleVector * New()
void CopyIntoArrayComponent(vtkDataArray *array, int component)
virtual void SetSolutionVector(vtkvmtkDoubleVector *)
virtual void SetDataSet(vtkDataSet *)
virtual void SetRHSVector(vtkvmtkDoubleVector *)
virtual void SetMatrix(vtkvmtkSparseMatrix *)
virtual void SetQuadratureOrder(int)
virtual void SetConvergenceTolerance(double)
virtual void SetMaximumNumberOfIterations(int)
virtual void SetLinearSystem(vtkvmtkLinearSystem *)
virtual void SetX(vtkvmtkDoubleVector *)
virtual void SetA(vtkvmtkSparseMatrix *)
virtual void SetB(vtkvmtkDoubleVector *)
static vtkvmtkLinearSystem * New()
static vtkvmtkOpenNLLinearSystemSolver * New()
static vtkvmtkSparseMatrix * New()
static vtkvmtkUnstructuredGridFEGradientAssembler * New()
virtual void SetScalarsArrayName(const char *)

Member Data Documentation

◆ InputArrayName

char* vtkvmtkUnstructuredGridGradientFilter::InputArrayName
protected

Definition at line 97 of file vtkvmtkUnstructuredGridGradientFilter.h.

◆ GradientArrayName

char* vtkvmtkUnstructuredGridGradientFilter::GradientArrayName
protected

Definition at line 98 of file vtkvmtkUnstructuredGridGradientFilter.h.

◆ ConvergenceTolerance

double vtkvmtkUnstructuredGridGradientFilter::ConvergenceTolerance
protected

Definition at line 99 of file vtkvmtkUnstructuredGridGradientFilter.h.

◆ QuadratureOrder

int vtkvmtkUnstructuredGridGradientFilter::QuadratureOrder
protected

Definition at line 100 of file vtkvmtkUnstructuredGridGradientFilter.h.

◆ ComputeIndividualPartialDerivatives

int vtkvmtkUnstructuredGridGradientFilter::ComputeIndividualPartialDerivatives
protected

Definition at line 101 of file vtkvmtkUnstructuredGridGradientFilter.h.


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