23#include "vtkUnstructuredGrid.h"
24#include "vtkPointData.h"
25#include "vtkDoubleArray.h"
32#include "vtkInformation.h"
33#include "vtkInformationVector.h"
34#include "vtkObjectFactory.h"
64 vtkInformation *vtkNotUsed(request),
65 vtkInformationVector **inputVector,
66 vtkInformationVector *outputVector)
68 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
69 vtkInformation *outInfo = outputVector->GetInformationObject(0);
71 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
72 inInfo->Get(vtkDataObject::DATA_OBJECT()));
73 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
74 outInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkErrorMacro(<<
"InputArrayName not set.");
84 vtkErrorMacro(<<
"GradientArrayName not set.");
88 int numberOfInputPoints = input->GetNumberOfPoints();
90 vtkDataArray* inputArray = input->GetPointData()->GetArray(this->
InputArrayName);
94 vtkErrorMacro(
"InputArray with name specified doesn not exist!");
98 int numberOfInputComponents = inputArray->GetNumberOfComponents();
100 vtkDoubleArray* gradientArray = vtkDoubleArray::New();
102 gradientArray->SetNumberOfComponents(3*numberOfInputComponents);
103 gradientArray->SetNumberOfTuples(numberOfInputPoints);
106 for (i=0; i<numberOfInputComponents; i++)
127 std::cout<<
"Assembling system"<<endl;
129 std::cout<<
"Done"<<endl;
132 linearSystem->
SetA(sparseMatrix);
133 linearSystem->
SetB(rhsVector);
134 linearSystem->
SetX(solutionVector);
142 std::cout<<
"Solving system"<<endl;
144 std::cout<<
"Done"<<endl;
151 linearSystem->Delete();
169 std::cout<<
"Assembling system"<<endl;
171 std::cout<<
"Done"<<endl;
174 linearSystem->
SetA(sparseMatrix);
175 linearSystem->
SetB(rhsVector);
176 linearSystem->
SetX(solutionVector);
184 std::cout<<
"Solving system"<<endl;
186 std::cout<<
"Done"<<endl;
191 linearSystem->Delete();
196 solutionVector->Delete();
198 sparseMatrix->Delete();
201 output->DeepCopy(input);
202 output->GetPointData()->AddArray(gradientArray);
204 gradientArray->Delete();
Serves as the base class for vectors utilized in finite-element and other PDE evaluations.
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 *)
Serves as the base container holding sparse matrix objects that represent a linear system of equation...
virtual void SetX(vtkvmtkDoubleVector *)
virtual void SetA(vtkvmtkSparseMatrix *)
virtual void SetB(vtkvmtkDoubleVector *)
static vtkvmtkLinearSystem * New()
Solve a linear system of equations using open NL.
void SetPreconditionerTypeToJacobi()
static vtkvmtkOpenNLLinearSystemSolver * New()
Implements a row-based sparse matrix built from mesh neighborhoods or stencils, supporting basic line...
static vtkvmtkSparseMatrix * New()
Construct a gradient based finite element calculation on a mesh.
virtual void SetScalarsComponent(int)
static vtkvmtkUnstructuredGridFEGradientAssembler * New()
void SetAssemblyModeToGradient()
void SetAssemblyModeToPartialDerivative()
virtual void SetScalarsArrayName(const char *)
virtual void Build() override
virtual void SetDirection(int)
Compute the gradient of data stored within an unstructured grid mesh.
vtkvmtkUnstructuredGridGradientFilter()
double ConvergenceTolerance
~vtkvmtkUnstructuredGridGradientFilter()
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
int ComputeIndividualPartialDerivatives
vtkStandardNewMacro(vtkvmtkUnstructuredGridGradientFilter)