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

Calculates vorticity from velocity in a mesh. More...

#include <vtkvmtkUnstructuredGridVorticityFilter.h>

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

Public Types

typedef vtkUnstructuredGridAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkUnstructuredGridVorticityFilter * NewInstance () const
virtual void SetVelocityArrayName (const char *)
virtual char * GetVelocityArrayName ()
virtual void SetVorticityArrayName (const char *)
virtual char * GetVorticityArrayName ()
virtual void SetHelicityFactorArrayName (const char *)
virtual char * GetHelicityFactorArrayName ()
virtual void SetComputeHelicityFactor (int)
virtual int GetComputeHelicityFactor ()
virtual void ComputeHelicityFactorOn ()
virtual void ComputeHelicityFactorOff ()
virtual void SetConvergenceTolerance (double)
virtual double GetConvergenceTolerance ()
virtual void SetQuadratureOrder (int)
virtual int GetQuadratureOrder ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

char * VelocityArrayName
char * VorticityArrayName
char * HelicityFactorArrayName
int ComputeHelicityFactor
double ConvergenceTolerance
int QuadratureOrder

Detailed Description

Calculates vorticity from velocity in a mesh.

Computes the vorticity (curl) of the 3-component point data velocity array named VelocityArrayName using a finite-element assembly (vtkvmtkUnstructuredGridFEVorticityAssembler, one component at a time, Gauss quadrature order QuadratureOrder, solved to ConvergenceTolerance), and stores it in the point data array named VorticityArrayName. If ComputeHelicityFactor is on, also computes the normalized helicity (the cosine of the angle between the velocity and vorticity vectors at each point, in [-1,1]) into HelicityFactorArrayName – a common hemodynamic metric for identifying helical flow patterns.

See also
vtkvmtkUnstructuredGridFEVorticityAssembler

Definition at line 39 of file vtkvmtkUnstructuredGridVorticityFilter.h.

Member Typedef Documentation

◆ Superclass

typedef vtkUnstructuredGridAlgorithm vtkvmtkUnstructuredGridVorticityFilter::Superclass

Definition at line 43 of file vtkvmtkUnstructuredGridVorticityFilter.h.

Constructor & Destructor Documentation

◆ vtkvmtkUnstructuredGridVorticityFilter()

◆ ~vtkvmtkUnstructuredGridVorticityFilter()

vtkvmtkUnstructuredGridVorticityFilter::~vtkvmtkUnstructuredGridVorticityFilter ( )
protected

Definition at line 49 of file vtkvmtkUnstructuredGridVorticityFilter.cxx.

50{
51 if (this->VelocityArrayName)
52 {
53 delete[] this->VelocityArrayName;
54 this->VelocityArrayName = NULL;
55 }
56 if (this->VorticityArrayName)
57 {
58 delete[] this->VorticityArrayName;
59 this->VorticityArrayName = NULL;
60 }
62 {
63 delete[] this->HelicityFactorArrayName;
64 this->HelicityFactorArrayName = NULL;
65 }
66}

Member Function Documentation

◆ New()

vtkvmtkUnstructuredGridVorticityFilter * vtkvmtkUnstructuredGridVorticityFilter::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkUnstructuredGridVorticityFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkUnstructuredGridVorticityFilter * vtkvmtkUnstructuredGridVorticityFilter::NewInstance ( ) const

◆ SetVelocityArrayName()

virtual void vtkvmtkUnstructuredGridVorticityFilter::SetVelocityArrayName ( const char * )
virtual

Set/Get the name of the 3-component point data array holding the velocity field. Required input.

◆ GetVelocityArrayName()

virtual char * vtkvmtkUnstructuredGridVorticityFilter::GetVelocityArrayName ( )
virtual

Set/Get the name of the 3-component point data array holding the velocity field. Required input.

◆ SetVorticityArrayName()

virtual void vtkvmtkUnstructuredGridVorticityFilter::SetVorticityArrayName ( const char * )
virtual

Set/Get the name of the output 3-component point data array where the computed vorticity is stored. Commonly named "Vorticity".

◆ GetVorticityArrayName()

virtual char * vtkvmtkUnstructuredGridVorticityFilter::GetVorticityArrayName ( )
virtual

Set/Get the name of the output 3-component point data array where the computed vorticity is stored. Commonly named "Vorticity".

◆ SetHelicityFactorArrayName()

virtual void vtkvmtkUnstructuredGridVorticityFilter::SetHelicityFactorArrayName ( const char * )
virtual

Set/Get the name of the output point data array where the normalized helicity is stored, when ComputeHelicityFactor is on. Commonly named "Helicity".

◆ GetHelicityFactorArrayName()

virtual char * vtkvmtkUnstructuredGridVorticityFilter::GetHelicityFactorArrayName ( )
virtual

Set/Get the name of the output point data array where the normalized helicity is stored, when ComputeHelicityFactor is on. Commonly named "Helicity".

◆ SetComputeHelicityFactor()

virtual void vtkvmtkUnstructuredGridVorticityFilter::SetComputeHelicityFactor ( int )
virtual

Toggle computing the normalized helicity (cosine of the angle between velocity and vorticity) into HelicityFactorArrayName, in addition to the vorticity field itself. Default: off.

◆ GetComputeHelicityFactor()

virtual int vtkvmtkUnstructuredGridVorticityFilter::GetComputeHelicityFactor ( )
virtual

Toggle computing the normalized helicity (cosine of the angle between velocity and vorticity) into HelicityFactorArrayName, in addition to the vorticity field itself. Default: off.

◆ ComputeHelicityFactorOn()

virtual void vtkvmtkUnstructuredGridVorticityFilter::ComputeHelicityFactorOn ( )
virtual

Toggle computing the normalized helicity (cosine of the angle between velocity and vorticity) into HelicityFactorArrayName, in addition to the vorticity field itself. Default: off.

◆ ComputeHelicityFactorOff()

virtual void vtkvmtkUnstructuredGridVorticityFilter::ComputeHelicityFactorOff ( )
virtual

Toggle computing the normalized helicity (cosine of the angle between velocity and vorticity) into HelicityFactorArrayName, in addition to the vorticity field itself. Default: off.

◆ SetConvergenceTolerance()

virtual void vtkvmtkUnstructuredGridVorticityFilter::SetConvergenceTolerance ( double )
virtual

Set/Get the convergence tolerance of the iterative linear solver used to solve the finite-element vorticity assembly for each component.

◆ GetConvergenceTolerance()

virtual double vtkvmtkUnstructuredGridVorticityFilter::GetConvergenceTolerance ( )
virtual

Set/Get the convergence tolerance of the iterative linear solver used to solve the finite-element vorticity assembly for each component.

◆ SetQuadratureOrder()

virtual void vtkvmtkUnstructuredGridVorticityFilter::SetQuadratureOrder ( int )
virtual

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

◆ GetQuadratureOrder()

virtual int vtkvmtkUnstructuredGridVorticityFilter::GetQuadratureOrder ( )
virtual

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

◆ RequestData()

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

Definition at line 68 of file vtkvmtkUnstructuredGridVorticityFilter.cxx.

72{
73 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
75
76 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
77 inInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
79 outInfo->Get(vtkDataObject::DATA_OBJECT()));
80
81 if (!this->VelocityArrayName)
82 {
83 vtkErrorMacro(<<"VelocityArrayName not set.");
84 return 1;
85 }
86
87 if (!this->VorticityArrayName)
88 {
89 vtkErrorMacro(<<"VorticityArrayName not set.");
90 return 1;
91 }
92
93 if (this->ComputeHelicityFactor)
94 {
95 if (!this->HelicityFactorArrayName)
96 {
97 vtkErrorMacro(<<"HelicityFactorArrayName not set.");
98 return 1;
99 }
100 }
101
102 int numberOfInputPoints = input->GetNumberOfPoints();
103
104 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->VelocityArrayName);
105
106 if (!velocityArray)
107 {
108 vtkErrorMacro("VelocityArray with name specified doesn not exist!");
109 return 0;
110 }
111
112 int numberOfInputComponents = velocityArray->GetNumberOfComponents();
113
114 if (numberOfInputComponents != 3)
115 {
116 vtkErrorMacro("VelocityArray must have 3 components!");
117 return 0;
118 }
119
120 vtkDoubleArray* vorticityArray = vtkDoubleArray::New();
121 vorticityArray->SetName(this->VorticityArrayName);
122 vorticityArray->SetNumberOfComponents(numberOfInputComponents);
123 vorticityArray->SetNumberOfTuples(numberOfInputPoints);
124
125 vtkvmtkSparseMatrix* sparseMatrix = vtkvmtkSparseMatrix::New();
126
127 vtkvmtkDoubleVector* rhsVector = vtkvmtkDoubleVector::New();
128 rhsVector->SetNormTypeToLInf();
129
130 vtkvmtkDoubleVector* solutionVector = vtkvmtkDoubleVector::New();
131 solutionVector->SetNormTypeToLInf();
132
133 int i;
134 for (i=0; i<3; i++)
135 {
136 vtkvmtkUnstructuredGridFEVorticityAssembler* assembler = vtkvmtkUnstructuredGridFEVorticityAssembler::New();
137 assembler->SetDataSet(input);
138 assembler->SetVelocityArrayName(this->VelocityArrayName);
139 assembler->SetMatrix(sparseMatrix);
140 assembler->SetRHSVector(rhsVector);
141 assembler->SetSolutionVector(solutionVector);
142 assembler->SetQuadratureOrder(this->QuadratureOrder);
143 assembler->SetDirection(i);
144 assembler->Build();
145
146 vtkvmtkLinearSystem* linearSystem = vtkvmtkLinearSystem::New();
147 linearSystem->SetA(sparseMatrix);
148 linearSystem->SetB(rhsVector);
149 linearSystem->SetX(solutionVector);
150
151 vtkvmtkOpenNLLinearSystemSolver* solver = vtkvmtkOpenNLLinearSystemSolver::New();
152 solver->SetLinearSystem(linearSystem);
154 solver->SetMaximumNumberOfIterations(numberOfInputPoints);
155 solver->SetSolverTypeToCG();
157 solver->Solve();
158
159// solutionVector->CopyVariableIntoArrayComponent(vorticityArray,0,0);
160// solutionVector->CopyVariableIntoArrayComponent(vorticityArray,1,1);
161// solutionVector->CopyVariableIntoArrayComponent(vorticityArray,2,2);
162 solutionVector->CopyIntoArrayComponent(vorticityArray,i);
163
164 assembler->Delete();
165 linearSystem->Delete();
166 solver->Delete();
167 }
168
169 sparseMatrix->Delete();
170 rhsVector->Delete();
171
172 solutionVector->Delete();
173
174 output->DeepCopy(input);
175 output->GetPointData()->AddArray(vorticityArray);
176
177 if (this->ComputeHelicityFactor)
178 {
179 vtkDoubleArray* helicityFactorArray = vtkDoubleArray::New();
180 helicityFactorArray->SetName(this->HelicityFactorArrayName);
181 helicityFactorArray->SetNumberOfTuples(numberOfInputPoints);
182
183 double velocity[3], vorticity[3], velocityMagnitude, vorticityMagnitude, helicityFactor;
184 int i;
185 for (i=0; i<numberOfInputPoints; i++)
186 {
187 velocityArray->GetTuple(i,velocity);
188 vorticityArray->GetTuple(i,vorticity);
189 velocityMagnitude = vtkMath::Norm(velocity);
190 vorticityMagnitude = vtkMath::Norm(vorticity);
191 helicityFactor = 0.0;
192 if (velocityMagnitude > 0.0 && vorticityMagnitude > 0.0)
193 {
194 helicityFactor = vtkMath::Dot(velocity,vorticity) / (velocityMagnitude * vorticityMagnitude);
195 }
196 helicityFactorArray->SetValue(i,helicityFactor);
197 }
198 output->GetPointData()->AddArray(helicityFactorArray);
199 helicityFactorArray->Delete();
200 }
201
202 vorticityArray->Delete();
203
204 return 1;
205}
void DeepCopy(vtkvmtkDoubleVector *src)
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 vtkvmtkUnstructuredGridFEVorticityAssembler * New()
virtual void SetVelocityArrayName(const char *)

Member Data Documentation

◆ VelocityArrayName

char* vtkvmtkUnstructuredGridVorticityFilter::VelocityArrayName
protected

Definition at line 108 of file vtkvmtkUnstructuredGridVorticityFilter.h.

◆ VorticityArrayName

char* vtkvmtkUnstructuredGridVorticityFilter::VorticityArrayName
protected

Definition at line 109 of file vtkvmtkUnstructuredGridVorticityFilter.h.

◆ HelicityFactorArrayName

char* vtkvmtkUnstructuredGridVorticityFilter::HelicityFactorArrayName
protected

Definition at line 110 of file vtkvmtkUnstructuredGridVorticityFilter.h.

◆ ComputeHelicityFactor

int vtkvmtkUnstructuredGridVorticityFilter::ComputeHelicityFactor
protected

Definition at line 111 of file vtkvmtkUnstructuredGridVorticityFilter.h.

◆ ConvergenceTolerance

double vtkvmtkUnstructuredGridVorticityFilter::ConvergenceTolerance
protected

Definition at line 112 of file vtkvmtkUnstructuredGridVorticityFilter.h.

◆ QuadratureOrder

int vtkvmtkUnstructuredGridVorticityFilter::QuadratureOrder
protected

Definition at line 113 of file vtkvmtkUnstructuredGridVorticityFilter.h.


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