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

Calculates average and RMS velocity statistics. More...

#include <vtkvmtkMeshVelocityStatistics.h>

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

Public Types

typedef vtkUnstructuredGridAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkMeshVelocityStatistics * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetVelocityArrayIds (vtkIdList *)
virtual vtkIdList * GetVelocityArrayIds ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

vtkIdList * VelocityArrayIds

Detailed Description

Calculates average and RMS velocity statistics.

Given several time steps of a velocity field stored as separate 3-component point data arrays on the input mesh, computes the time-average and RMS (root-mean-square) velocity vectors at each point. Typically used to summarize unsteady/pulsatile CFD simulation results into cycle-averaged and turbulence-like statistics.

Definition at line 37 of file vtkvmtkMeshVelocityStatistics.h.

Member Typedef Documentation

◆ Superclass

typedef vtkUnstructuredGridAlgorithm vtkvmtkMeshVelocityStatistics::Superclass

Definition at line 40 of file vtkvmtkMeshVelocityStatistics.h.

Constructor & Destructor Documentation

◆ vtkvmtkMeshVelocityStatistics()

vtkvmtkMeshVelocityStatistics::vtkvmtkMeshVelocityStatistics ( )
protected

Definition at line 36 of file vtkvmtkMeshVelocityStatistics.cxx.

37{
38 this->VelocityArrayIds = NULL;
39}

◆ ~vtkvmtkMeshVelocityStatistics()

vtkvmtkMeshVelocityStatistics::~vtkvmtkMeshVelocityStatistics ( )
protected

Definition at line 41 of file vtkvmtkMeshVelocityStatistics.cxx.

42{
43 if (this->VelocityArrayIds)
44 {
45 this->VelocityArrayIds->Delete();
46 this->VelocityArrayIds = NULL;
47 }
48}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkMeshVelocityStatistics::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkMeshVelocityStatistics * vtkvmtkMeshVelocityStatistics::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 163 of file vtkvmtkMeshVelocityStatistics.cxx.

164{
165 this->Superclass::PrintSelf(os,indent);
166}

◆ New()

vtkvmtkMeshVelocityStatistics * vtkvmtkMeshVelocityStatistics::New ( )
static

◆ SetVelocityArrayIds()

virtual void vtkvmtkMeshVelocityStatistics::SetVelocityArrayIds ( vtkIdList * )
virtual

Set/Get the point data array indices (indices into the input's point data, as returned by vtkPointData::GetArray(int), not array ids) of the per-time-step velocity arrays to average. Required input; at least 2 entries are needed for RMS to be meaningful.

◆ GetVelocityArrayIds()

virtual vtkIdList * vtkvmtkMeshVelocityStatistics::GetVelocityArrayIds ( )
virtual

Set/Get the point data array indices (indices into the input's point data, as returned by vtkPointData::GetArray(int), not array ids) of the per-time-step velocity arrays to average. Required input; at least 2 entries are needed for RMS to be meaningful.

◆ RequestData()

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

Definition at line 50 of file vtkvmtkMeshVelocityStatistics.cxx.

54{
55 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
56 vtkInformation *outInfo = outputVector->GetInformationObject(0);
57
58 vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
59 inInfo->Get(vtkDataObject::DATA_OBJECT()));
60 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
61 outInfo->Get(vtkDataObject::DATA_OBJECT()));
62
63 output->CopyStructure(input);
64 output->GetPointData()->PassData(input->GetPointData());
65 output->GetCellData()->PassData(input->GetCellData());
66
67 vtkPointData* inputPointData = input->GetPointData();
68
69 if (this->VelocityArrayIds == NULL)
70 {
71 vtkErrorMacro("No VelocityArrayIds specified");
72 return 1;
73 }
74
75 int numberOfArrayIds = this->VelocityArrayIds->GetNumberOfIds();
76
77 if (numberOfArrayIds < 2)
78 {
79 vtkWarningMacro("Only 1 VelocityArrayIds specified. No point in computing statistics.");
80 return 1;
81 }
82
83 int i;
84 for (i=0; i<numberOfArrayIds; i++)
85 {
86 if (inputPointData->GetArray(this->VelocityArrayIds->GetId(i)) == NULL)
87 {
88 vtkErrorMacro("Id in VelocityArrayIds is not a PointData array.");
89 return 1;
90 }
91 }
92
93 int numberOfPoints = input->GetNumberOfPoints();
94
95 vtkDoubleArray* avgVelocityArray = vtkDoubleArray::New();
96 avgVelocityArray->SetName("AVGVelocity");
97 avgVelocityArray->SetNumberOfComponents(3);
98 avgVelocityArray->SetNumberOfTuples(numberOfPoints);
99 avgVelocityArray->FillComponent(0,0.0);
100 avgVelocityArray->FillComponent(1,0.0);
101 avgVelocityArray->FillComponent(2,0.0);
102
103 vtkDoubleArray* rmsVelocityArray = vtkDoubleArray::New();
104 rmsVelocityArray->SetName("RMSVelocity");
105 rmsVelocityArray->SetNumberOfComponents(3);
106 rmsVelocityArray->SetNumberOfTuples(numberOfPoints);
107 rmsVelocityArray->FillComponent(0,0.0);
108 rmsVelocityArray->FillComponent(1,0.0);
109 rmsVelocityArray->FillComponent(2,0.0);
110
111 double avgVelocity[3], rmsVelocity[3], velocity[3];
112
113 double weight = 1.0 / double(numberOfArrayIds);
114
115 int j;
116 for (i=0; i<numberOfPoints; i++)
117 {
118 for (j=0; j<numberOfArrayIds; j++)
119 {
120 vtkDataArray* velocityArray = inputPointData->GetArray(this->VelocityArrayIds->GetId(j));
121 avgVelocityArray->GetTuple(i,avgVelocity);
122 velocityArray->GetTuple(i,velocity);
123 avgVelocity[0] += weight * velocity[0];
124 avgVelocity[1] += weight * velocity[1];
125 avgVelocity[2] += weight * velocity[2];
126 avgVelocityArray->SetTuple(i,avgVelocity);
127 }
128 }
129
130 for (i=0; i<numberOfPoints; i++)
131 {
132 for (j=0; j<numberOfArrayIds; j++)
133 {
134 vtkDataArray* velocityArray = inputPointData->GetArray(this->VelocityArrayIds->GetId(j));
135 rmsVelocityArray->GetTuple(i,rmsVelocity);
136 avgVelocityArray->GetTuple(i,avgVelocity);
137 velocityArray->GetTuple(i,velocity);
138 rmsVelocity[0] += weight * (velocity[0] - avgVelocity[0]) * (velocity[0] - avgVelocity[0]);
139 rmsVelocity[1] += weight * (velocity[1] - avgVelocity[1]) * (velocity[1] - avgVelocity[1]);
140 rmsVelocity[2] += weight * (velocity[2] - avgVelocity[2]) * (velocity[2] - avgVelocity[2]);
141 rmsVelocityArray->SetTuple(i,rmsVelocity);
142 }
143 }
144
145 for (i=0; i<numberOfPoints; i++)
146 {
147 rmsVelocityArray->GetTuple(i,rmsVelocity);
148 rmsVelocity[0] = sqrt(rmsVelocity[0]);
149 rmsVelocity[1] = sqrt(rmsVelocity[1]);
150 rmsVelocity[2] = sqrt(rmsVelocity[2]);
151 rmsVelocityArray->SetTuple(i,rmsVelocity);
152 }
153
154 output->GetPointData()->AddArray(avgVelocityArray);
155 output->GetPointData()->AddArray(rmsVelocityArray);
156
157 avgVelocityArray->Delete();
158 rmsVelocityArray->Delete();
159
160 return 1;
161}

Member Data Documentation

◆ VelocityArrayIds

vtkIdList* vtkvmtkMeshVelocityStatistics::VelocityArrayIds
protected

Definition at line 61 of file vtkvmtkMeshVelocityStatistics.h.


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