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
77 {
78 vtkErrorMacro(<<"InputArrayName not set.");
79 return 1;
80 }
81
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();
102 gradientArray->SetNumberOfComponents(3*numberOfInputComponents);
103 gradientArray->SetNumberOfTuples(numberOfInputPoints);
104
105 int i;
106 for (i=0; i<numberOfInputComponents; i++)
107 {
109
112
115
117 {
127 std::cout<<"Assembling system"<<endl;
129 std::cout<<"Done"<<endl;
130
132 linearSystem->
SetA(sparseMatrix);
133 linearSystem->
SetB(rhsVector);
134 linearSystem->
SetX(solutionVector);
135
142 std::cout<<"Solving system"<<endl;
144 std::cout<<"Done"<<endl;
145
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 {
169 std::cout<<"Assembling system"<<endl;
171 std::cout<<"Done"<<endl;
172
174 linearSystem->
SetA(sparseMatrix);
175 linearSystem->
SetB(rhsVector);
176 linearSystem->
SetX(solutionVector);
177
184 std::cout<<"Solving system"<<endl;
186 std::cout<<"Done"<<endl;
187
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()
void SetPreconditionerTypeToJacobi()
static vtkvmtkOpenNLLinearSystemSolver * New()
static vtkvmtkSparseMatrix * New()
virtual void SetScalarsComponent(int)
static vtkvmtkUnstructuredGridFEGradientAssembler * New()
void SetAssemblyModeToGradient()
void SetAssemblyModeToPartialDerivative()
virtual void SetScalarsArrayName(const char *)
virtual void Build() override
virtual void SetDirection(int)