VMTK
Loading...
Searching...
No Matches
vtkvmtkUnstructuredGridFEVorticityAssembler.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkUnstructuredGridFEVorticityAssembler.cxx,v $
5 Language: C++
6 Date: $Date: 2005/11/15 17:39:25 $
7 Version: $Revision: 1.3 $
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
25#include "vtkPointData.h"
26#include "vtkDataArray.h"
27#include "vtkCell.h"
28#include "vtkMath.h"
29#include "vtkObjectFactory.h"
30
31
33
39
48
50{
51 if (!this->VelocityArrayName)
52 {
53 vtkErrorMacro("VelocityArrayName not specified!");
54 return;
55 }
56
57 vtkDataArray* velocityArray = this->DataSet->GetPointData()->GetArray(this->VelocityArrayName);
58
59 if (!velocityArray)
60 {
61 vtkErrorMacro("VelocityArray with name specified does not exist!");
62 return;
63 }
64
65 if (velocityArray->GetNumberOfComponents() != 3)
66 {
67 vtkErrorMacro("VelocityArray must have 3 components!");
68 return;
69 }
70
71// int numberOfVariables = 3;
72 int numberOfVariables = 1;
73 this->Initialize(numberOfVariables);
74
76 gaussQuadrature->SetOrder(this->QuadratureOrder);
77
79
80 int dimension = 3;
81
82 int numberOfCells = this->DataSet->GetNumberOfCells();
83 int k;
84 for (k=0; k<numberOfCells; k++)
85 {
86 vtkCell* cell = this->DataSet->GetCell(k);
87 if (cell->GetCellDimension() != dimension)
88 {
89 continue;
90 }
91 gaussQuadrature->Initialize(cell->GetCellType());
92 feShapeFunctions->Initialize(cell,gaussQuadrature->GetQuadraturePoints());
93 int numberOfQuadraturePoints = gaussQuadrature->GetNumberOfQuadraturePoints();
94 double quadraturePCoords[3];
95 int numberOfCellPoints = cell->GetNumberOfPoints();
96 int i, j;
97 int q;
98 for (q=0; q<numberOfQuadraturePoints; q++)
99 {
100 gaussQuadrature->GetQuadraturePoint(q,quadraturePCoords);
101 double quadratureWeight = gaussQuadrature->GetQuadratureWeight(q);
102 double jacobian = feShapeFunctions->GetJacobian(q);
103 double phii, phij;
104 double dphii[3];
105 double velocityValue[3];
106// double vorticityValue[3];
107// vorticityValue[0] = vorticityValue[1] = vorticityValue[2] = 0.0;
108 double vorticityComponent = 0.0;
109 for (i=0; i<numberOfCellPoints; i++)
110 {
111 vtkIdType iId = cell->GetPointId(i);
112 feShapeFunctions->GetDPhi(q,i,dphii);
113 velocityArray->GetTuple(iId,velocityValue);
114// vorticityValue[0] += velocityValue[2] * dphii[1] - velocityValue[1] * dphii[2];
115// vorticityValue[1] += velocityValue[0] * dphii[2] - velocityValue[2] * dphii[0];
116// vorticityValue[2] += velocityValue[1] * dphii[0] - velocityValue[0] * dphii[1];
117 if (this->Direction == 0)
118 {
119 vorticityComponent += velocityValue[2] * dphii[1] - velocityValue[1] * dphii[2];
120 }
121 else if (this->Direction == 1)
122 {
123 vorticityComponent += velocityValue[0] * dphii[2] - velocityValue[2] * dphii[0];
124 }
125 else if (this->Direction == 2)
126 {
127 vorticityComponent += velocityValue[1] * dphii[0] - velocityValue[0] * dphii[1];
128 }
129 }
130 for (i=0; i<numberOfCellPoints; i++)
131 {
132 vtkIdType iId = cell->GetPointId(i);
133 phii = feShapeFunctions->GetPhi(q,i);
134// double value0 = jacobian * quadratureWeight * vorticityValue[0] * phii;
135// double value1 = jacobian * quadratureWeight * vorticityValue[1] * phii;
136// double value2 = jacobian * quadratureWeight * vorticityValue[2] * phii;
137 double value = jacobian * quadratureWeight * vorticityComponent * phii;
138// this->RHSVector->AddElement(iId,value0);
139// this->RHSVector->AddElement(iId+numberOfPoints,value1);
140// this->RHSVector->AddElement(iId+2*numberOfPoints,value2);
141 this->RHSVector->AddElement(iId,value);
142 for (j=0; j<numberOfCellPoints; j++)
143 {
144 vtkIdType jId = cell->GetPointId(j);
145 phij = feShapeFunctions->GetPhi(q,j);
146 double value = jacobian * quadratureWeight * phii * phij;
147// this->Matrix->AddElement(iId,jId,value);
148// this->Matrix->AddElement(iId+numberOfPoints,jId+numberOfPoints,value);
149// this->Matrix->AddElement(iId+2*numberOfPoints,jId+2*numberOfPoints,value);
150 this->Matrix->AddElement(iId,jId,value);
151 }
152 }
153 }
154 }
155
156 gaussQuadrature->Delete();
157 feShapeFunctions->Delete();
158}
159
vtkvmtkSparseMatrix * Matrix
vtkvmtkDoubleVector * RHSVector
void Initialize(int numberOfVariables)
Provides a set of common utility functions (calculate jacobian, interpolation function,...
void Initialize(vtkCell *cell, vtkDoubleArray *pcoords)
static vtkvmtkFEShapeFunctions * New()
double GetPhi(vtkIdType id, vtkIdType i)
double * GetDPhi(vtkIdType id, vtkIdType i)
Implements a finite element quadrature rule that approximates the definite integral of a function as ...
double * GetQuadraturePoint(vtkIdType id)
virtual vtkDoubleArray * GetQuadraturePoints()
static vtkvmtkGaussQuadrature * New()
void Initialize(vtkIdType cellType)
double GetQuadratureWeight(vtkIdType id)
virtual void SetOrder(int)
Construct a vorticity based finite element calculation on a mesh.
vtkStandardNewMacro(vtkvmtkUnstructuredGridFEVorticityAssembler)