VMTK
Loading...
Searching...
No Matches
vtkvmtkUnstructuredGridHarmonicMappingFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkUnstructuredGridHarmonicMappingFilter.cxx,v $
5 Language: C++
6 Date: $Date: 2006/04/06 16:46:44 $
7 Version: $Revision: 1.7 $
8
9 Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 See LICENSE file for details.
11
12 Portions of this code are covered under the VTK copyright.
13 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
14 for details.
15
16 This software is distributed WITHOUT ANY WARRANTY; without even
17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE. See the above copyright notices for more information.
19
20=========================================================================*/
21
23#include "vtkUnstructuredGrid.h"
24#include "vtkPointData.h"
25#include "vtkDoubleArray.h"
26#include "vtkvmtkDoubleVector.h"
28#include "vtkvmtkSparseMatrix.h"
29#include "vtkvmtkLinearSystem.h"
31
33#include "vtkInformation.h"
34#include "vtkInformationVector.h"
35#include "vtkObjectFactory.h"
36
37
39
49
51{
52 if (this->BoundaryPointIds)
53 {
54 this->BoundaryPointIds->Delete();
55 this->BoundaryPointIds = NULL;
56 }
57
58 if (this->BoundaryValues)
59 {
60 this->BoundaryValues->Delete();
61 this->BoundaryValues = NULL;
62 }
63
65 {
66 delete[] this->HarmonicMappingArrayName;
67 this->HarmonicMappingArrayName = NULL;
68 }
69}
70
72 vtkInformation *vtkNotUsed(request),
73 vtkInformationVector **inputVector,
74 vtkInformationVector *outputVector)
75{
76 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
77 vtkInformation *outInfo = outputVector->GetInformationObject(0);
78
79 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
80 inInfo->Get(vtkDataObject::DATA_OBJECT()));
81 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
82 outInfo->Get(vtkDataObject::DATA_OBJECT()));
83
84 if (!this->BoundaryPointIds)
85 {
86 vtkErrorMacro(<<"BoundaryPointIds not set.");
87 return 1;
88 }
89
90 if (!this->BoundaryValues)
91 {
92 vtkErrorMacro(<<"BoundaryValues not set.");
93 return 1;
94 }
95
96 if (!this->HarmonicMappingArrayName)
97 {
98 vtkErrorMacro(<<"HarmonicMappingArrayName not set.");
99 return 1;
100 }
101
102 int numberOfInputPoints = input->GetNumberOfPoints();
103
105
107 rhsVector->SetNormTypeToLInf();
108
110 solutionVector->SetNormTypeToLInf();
111
113 assembler->SetDataSet(input);
114 assembler->SetMatrix(sparseMatrix);
115 assembler->SetRHSVector(rhsVector);
116 assembler->SetSolutionVector(solutionVector);
117 assembler->SetQuadratureOrder(this->QuadratureOrder);
118 assembler->Build();
119
121 linearSystem->SetA(sparseMatrix);
122 linearSystem->SetB(rhsVector);
123 linearSystem->SetX(solutionVector);
124
126 dirichetBoundaryConditions->SetLinearSystem(linearSystem);
127 dirichetBoundaryConditions->SetBoundaryNodes(this->BoundaryPointIds);
128 dirichetBoundaryConditions->SetBoundaryValues(this->BoundaryValues);
129 dirichetBoundaryConditions->Apply();
130
132 solver->SetLinearSystem(linearSystem);
134 solver->SetMaximumNumberOfIterations(numberOfInputPoints);
135 solver->SetSolverTypeToCG();
137 solver->Solve();
138
139 vtkDoubleArray* harmonicMappingArray = vtkDoubleArray::New();
140 harmonicMappingArray->SetName(this->HarmonicMappingArrayName);
141 harmonicMappingArray->SetNumberOfComponents(1);
142 harmonicMappingArray->SetNumberOfTuples(numberOfInputPoints);
143
144 solutionVector->CopyIntoArrayComponent(harmonicMappingArray,0);
145
146 output->DeepCopy(input);
147
148 output->GetPointData()->AddArray(harmonicMappingArray);
149
150 assembler->Delete();
151 solver->Delete();
152 harmonicMappingArray->Delete();
153 sparseMatrix->Delete();
154 rhsVector->Delete();
155 solutionVector->Delete();
156 linearSystem->Delete();
157 dirichetBoundaryConditions->Delete();
158
159 return 1;
160}
virtual void SetBoundaryValues(vtkDoubleArray *)
virtual void SetBoundaryNodes(vtkIdList *)
virtual void SetLinearSystem(vtkvmtkLinearSystem *)
Set up Dirichlet (or first-type) boundary conditions that a linear system needs to take along the bou...
static vtkvmtkDirichletBoundaryConditions * New()
Serves as the base class for vectors utilized in finite-element and other PDE evaluations.
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.
static vtkvmtkOpenNLLinearSystemSolver * New()
Implements a row-based sparse matrix built from mesh neighborhoods or stencils, supporting basic line...
static vtkvmtkSparseMatrix * New()
Construct a laplacian based finite element calculation on a mesh.
static vtkvmtkUnstructuredGridFELaplaceAssembler * New()
Construct a harmonic function over each vascular mesh segment used during mapping order to stretch th...
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkStandardNewMacro(vtkvmtkUnstructuredGridHarmonicMappingFilter)