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

Compute the Lambda2 surface for a given flow field which allow for the visualization of fluid vortex cores. More...

#include <vtkvmtkMeshLambda2.h>

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

Public Types

typedef vtkUnstructuredGridAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkMeshLambda2 * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetVelocityArrayName (const char *)
virtual char * GetVelocityArrayName ()
virtual void SetLambda2ArrayName (const char *)
virtual char * GetLambda2ArrayName ()
virtual void SetComputeIndividualPartialDerivatives (int)
virtual int GetComputeIndividualPartialDerivatives ()
virtual void ComputeIndividualPartialDerivativesOn ()
virtual void ComputeIndividualPartialDerivativesOff ()
virtual void SetConvergenceTolerance (double)
virtual double GetConvergenceTolerance ()
virtual void SetQuadratureOrder (int)
virtual int GetQuadratureOrder ()
virtual void SetForceBoundaryToNegative (int)
virtual int GetForceBoundaryToNegative ()
virtual void ForceBoundaryToNegativeOn ()
virtual void ForceBoundaryToNegativeOff ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

char * VelocityArrayName
char * Lambda2ArrayName
int ComputeIndividualPartialDerivatives
double ConvergenceTolerance
int QuadratureOrder
int ForceBoundaryToNegative

Detailed Description

Compute the Lambda2 surface for a given flow field which allow for the visualization of fluid vortex cores.

This filter implements the lambda2 vortex-core identification criterion (Jeong & Hussain): for every point of an input volumetric mesh, it computes the velocity gradient tensor (via vtkvmtkUnstructuredGridGradientFilter on the array named VelocityArrayName) and splits it into its symmetric (strain-rate, S) and antisymmetric (spin/vorticity, Omega) parts, forms the tensor S^2 + Omega^2, and stores its second-largest eigenvalue as a new point data array (Lambda2ArrayName). Points where this value is negative lie inside a vortex core, so thresholding/isosurfacing the output array below zero visualizes the vortex structures of the flow.

This is the filter behind the vmtkmeshlambda2 pype script, typically run on CFD velocity fields to extract and visualize coherent vortical structures.

Definition at line 42 of file vtkvmtkMeshLambda2.h.

Member Typedef Documentation

◆ Superclass

typedef vtkUnstructuredGridAlgorithm vtkvmtkMeshLambda2::Superclass

Definition at line 45 of file vtkvmtkMeshLambda2.h.

Constructor & Destructor Documentation

◆ vtkvmtkMeshLambda2()

vtkvmtkMeshLambda2::vtkvmtkMeshLambda2 ( )
protected

Definition at line 38 of file vtkvmtkMeshLambda2.cxx.

◆ ~vtkvmtkMeshLambda2()

vtkvmtkMeshLambda2::~vtkvmtkMeshLambda2 ( )
protected

Definition at line 48 of file vtkvmtkMeshLambda2.cxx.

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

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkMeshLambda2::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkMeshLambda2 * vtkvmtkMeshLambda2::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkMeshLambda2::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 181 of file vtkvmtkMeshLambda2.cxx.

182{
183 this->Superclass::PrintSelf(os,indent);
184}

◆ New()

vtkvmtkMeshLambda2 * vtkvmtkMeshLambda2::New ( )
static

◆ SetVelocityArrayName()

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

Set/Get the name of the input point data array holding the (3-component) velocity field. Required before Update() is called.

◆ GetVelocityArrayName()

virtual char * vtkvmtkMeshLambda2::GetVelocityArrayName ( )
virtual

Set/Get the name of the input point data array holding the (3-component) velocity field. Required before Update() is called.

◆ SetLambda2ArrayName()

virtual void vtkvmtkMeshLambda2::SetLambda2ArrayName ( const char * )
virtual

Set/Get the name of the output point data array where the computed lambda2 values are stored. If not set, defaults to "Lambda2".

◆ GetLambda2ArrayName()

virtual char * vtkvmtkMeshLambda2::GetLambda2ArrayName ( )
virtual

Set/Get the name of the output point data array where the computed lambda2 values are stored. If not set, defaults to "Lambda2".

◆ SetComputeIndividualPartialDerivatives()

virtual void vtkvmtkMeshLambda2::SetComputeIndividualPartialDerivatives ( int )
virtual

Toggle computing the individual partial derivatives of the velocity gradient in vtkvmtkUnstructuredGridGradientFilter, rather than only the quantities strictly needed for the gradient tensor. Passed through to the internal gradient filter. Default: off.

◆ GetComputeIndividualPartialDerivatives()

virtual int vtkvmtkMeshLambda2::GetComputeIndividualPartialDerivatives ( )
virtual

Toggle computing the individual partial derivatives of the velocity gradient in vtkvmtkUnstructuredGridGradientFilter, rather than only the quantities strictly needed for the gradient tensor. Passed through to the internal gradient filter. Default: off.

◆ ComputeIndividualPartialDerivativesOn()

virtual void vtkvmtkMeshLambda2::ComputeIndividualPartialDerivativesOn ( )
virtual

Toggle computing the individual partial derivatives of the velocity gradient in vtkvmtkUnstructuredGridGradientFilter, rather than only the quantities strictly needed for the gradient tensor. Passed through to the internal gradient filter. Default: off.

◆ ComputeIndividualPartialDerivativesOff()

virtual void vtkvmtkMeshLambda2::ComputeIndividualPartialDerivativesOff ( )
virtual

Toggle computing the individual partial derivatives of the velocity gradient in vtkvmtkUnstructuredGridGradientFilter, rather than only the quantities strictly needed for the gradient tensor. Passed through to the internal gradient filter. Default: off.

◆ SetConvergenceTolerance()

virtual void vtkvmtkMeshLambda2::SetConvergenceTolerance ( double )
virtual

Set/Get the convergence tolerance used by the internal vtkvmtkUnstructuredGridGradientFilter when recovering the point-wise velocity gradient tensor. Default: 1E-6.

◆ GetConvergenceTolerance()

virtual double vtkvmtkMeshLambda2::GetConvergenceTolerance ( )
virtual

Set/Get the convergence tolerance used by the internal vtkvmtkUnstructuredGridGradientFilter when recovering the point-wise velocity gradient tensor. Default: 1E-6.

◆ SetQuadratureOrder()

virtual void vtkvmtkMeshLambda2::SetQuadratureOrder ( int )
virtual

Set/Get the Gauss quadrature order used by the internal vtkvmtkUnstructuredGridGradientFilter when recovering the point-wise velocity gradient tensor. Default: 3.

◆ GetQuadratureOrder()

virtual int vtkvmtkMeshLambda2::GetQuadratureOrder ( )
virtual

Set/Get the Gauss quadrature order used by the internal vtkvmtkUnstructuredGridGradientFilter when recovering the point-wise velocity gradient tensor. Default: 3.

◆ SetForceBoundaryToNegative()

virtual void vtkvmtkMeshLambda2::SetForceBoundaryToNegative ( int )
virtual

Toggle forcing the lambda2 value at mesh boundary points to be negative, to suppress spurious vortex-core detections caused by the (typically fixed/no-slip) boundary conditions of the underlying flow simulation. Default: off.

◆ GetForceBoundaryToNegative()

virtual int vtkvmtkMeshLambda2::GetForceBoundaryToNegative ( )
virtual

Toggle forcing the lambda2 value at mesh boundary points to be negative, to suppress spurious vortex-core detections caused by the (typically fixed/no-slip) boundary conditions of the underlying flow simulation. Default: off.

◆ ForceBoundaryToNegativeOn()

virtual void vtkvmtkMeshLambda2::ForceBoundaryToNegativeOn ( )
virtual

Toggle forcing the lambda2 value at mesh boundary points to be negative, to suppress spurious vortex-core detections caused by the (typically fixed/no-slip) boundary conditions of the underlying flow simulation. Default: off.

◆ ForceBoundaryToNegativeOff()

virtual void vtkvmtkMeshLambda2::ForceBoundaryToNegativeOff ( )
virtual

Toggle forcing the lambda2 value at mesh boundary points to be negative, to suppress spurious vortex-core detections caused by the (typically fixed/no-slip) boundary conditions of the underlying flow simulation. Default: off.

◆ RequestData()

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

Definition at line 62 of file vtkvmtkMeshLambda2.cxx.

66{
67 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
68 vtkInformation *outInfo = outputVector->GetInformationObject(0);
69
70 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
71 inInfo->Get(vtkDataObject::DATA_OBJECT()));
72 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
73 outInfo->Get(vtkDataObject::DATA_OBJECT()));
74
75 if (this->VelocityArrayName == NULL)
76 {
77 vtkErrorMacro("VelocityArrayName not specified");
78 return 1;
79 }
80
81 vtkDataArray* velocityArray = input->GetPointData()->GetArray(this->VelocityArrayName);
82
83 if (velocityArray == NULL)
84 {
85 vtkErrorMacro("VelocityArray with name specified does not exist");
86 return 1;
87 }
88
89 char gradientArrayName[] = "VelocityGradient";
90
91 vtkvmtkUnstructuredGridGradientFilter* gradientFilter = vtkvmtkUnstructuredGridGradientFilter::New();
92 gradientFilter->SetInputData(input);
93 gradientFilter->SetInputArrayName(this->VelocityArrayName);
94 gradientFilter->SetGradientArrayName(gradientArrayName);
95 gradientFilter->SetQuadratureOrder(this->QuadratureOrder);
96 gradientFilter->SetConvergenceTolerance(this->ConvergenceTolerance);
98 gradientFilter->Update();
99
100 vtkDataArray* velocityGradientArray = gradientFilter->GetOutput()->GetPointData()->GetArray(gradientArrayName);
101
102 int numberOfPoints = input->GetNumberOfPoints();
103
104 vtkDoubleArray* lambda2Array = vtkDoubleArray::New();
105 if (this->Lambda2ArrayName)
106 {
107 lambda2Array->SetName(this->Lambda2ArrayName);
108 }
109 else
110 {
111 lambda2Array->SetName("Lambda2");
112 }
113 lambda2Array->SetNumberOfComponents(1);
114 lambda2Array->SetNumberOfTuples(numberOfPoints);
115
116 double velocityGradient[9];
117 double symmetricVelocityGradient[3][3];
118 double antiSymmetricVelocityGradient[3][3];
119 double A[3][3];
120
121 int i, j, k, l;
122 for (i=0; i<numberOfPoints; i++)
123 {
124 velocityGradientArray->GetTuple(i,velocityGradient);
125 for (j=0; j<3; j++)
126 {
127 for (k=0; k<3; k++)
128 {
129 int index0 = k + j*3;
130 int index1 = j + k*3;
131 symmetricVelocityGradient[j][k] = 0.5 * (velocityGradient[index0] + velocityGradient[index1]);
132 antiSymmetricVelocityGradient[j][k] = 0.5 * (velocityGradient[index0] - velocityGradient[index1]);
133 }
134 }
135
136 for (j=0; j<3; j++)
137 {
138 for (k=0; k<3; k++)
139 {
140 A[j][k] = 0.0;
141 for (l=0; l<3; l++)
142 {
143 A[j][k] += symmetricVelocityGradient[j][l]*symmetricVelocityGradient[l][k] +
144 antiSymmetricVelocityGradient[j][l]*antiSymmetricVelocityGradient[l][k];
145 }
146 }
147 }
148
149 double eigenVectors[3][3];
150 double eigenValues[3];
151 vtkMath::Diagonalize3x3(A,eigenValues,eigenVectors);
152
153 bool done = false;
154 while (!done)
155 {
156 done = true;
157 for (j=0; j<2; j++)
158 {
159 if (eigenValues[j] > eigenValues[j+1])
160 {
161 done = false;
162 double tmp = eigenValues[j+1];
163 eigenValues[j+1] = eigenValues[j];
164 eigenValues[j] = tmp;
165 }
166 }
167 }
168 double lambda2 = eigenValues[1];
169
170 lambda2Array->SetTuple1(i,lambda2);
171 }
172
173 output->DeepCopy(input);
174 output->GetPointData()->AddArray(lambda2Array);
175
176 lambda2Array->Delete();
177
178 return 1;
179}
virtual void SetComputeIndividualPartialDerivatives(int)
virtual void SetInputArrayName(const char *)
virtual void SetGradientArrayName(const char *)
virtual void SetConvergenceTolerance(double)
static vtkvmtkUnstructuredGridGradientFilter * New()

Member Data Documentation

◆ VelocityArrayName

char* vtkvmtkMeshLambda2::VelocityArrayName
protected

Definition at line 114 of file vtkvmtkMeshLambda2.h.

◆ Lambda2ArrayName

char* vtkvmtkMeshLambda2::Lambda2ArrayName
protected

Definition at line 115 of file vtkvmtkMeshLambda2.h.

◆ ComputeIndividualPartialDerivatives

int vtkvmtkMeshLambda2::ComputeIndividualPartialDerivatives
protected

Definition at line 117 of file vtkvmtkMeshLambda2.h.

◆ ConvergenceTolerance

double vtkvmtkMeshLambda2::ConvergenceTolerance
protected

Definition at line 118 of file vtkvmtkMeshLambda2.h.

◆ QuadratureOrder

int vtkvmtkMeshLambda2::QuadratureOrder
protected

Definition at line 119 of file vtkvmtkMeshLambda2.h.

◆ ForceBoundaryToNegative

int vtkvmtkMeshLambda2::ForceBoundaryToNegative
protected

Definition at line 120 of file vtkvmtkMeshLambda2.h.


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