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

Construct a gradient based finite element calculation on a surface. More...

#include <vtkvmtkPolyDataFEGradientAssembler.h>

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

Public Types

typedef vtkvmtkFEAssembler Superclass
Public Types inherited from vtkvmtkFEAssembler
typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataFEGradientAssembler * NewInstance () const
virtual void Build () override
virtual void SetScalarsArrayName (const char *)
virtual char * GetScalarsArrayName ()
virtual void SetScalarsComponent (int)
virtual int GetScalarsComponent ()
Public Member Functions inherited from vtkvmtkFEAssembler
vtkvmtkFEAssembler * NewInstance () const
virtual int GetNumberOfVariables ()
void DeepCopy (vtkvmtkFEAssembler *src)
void ShallowCopy (vtkvmtkFEAssembler *src)
virtual void SetDataSet (vtkDataSet *)
virtual vtkDataSet * GetDataSet ()
virtual void SetMatrix (vtkvmtkSparseMatrix *)
virtual vtkvmtkSparseMatrix * GetMatrix ()
virtual void SetRHSVector (vtkvmtkDoubleVector *)
virtual vtkvmtkDoubleVector * GetRHSVector ()
virtual void SetSolutionVector (vtkvmtkDoubleVector *)
virtual vtkvmtkDoubleVector * GetSolutionVector ()
virtual void SetQuadratureOrder (int)
virtual int GetQuadratureOrder ()

Static Public Member Functions

static vtkvmtkPolyDataFEGradientAssembler * New ()
static int IsTypeOf (const char *type)
static vtkvmtkPolyDataFEGradientAssembler * SafeDownCast (vtkObjectBase *o)
Static Public Member Functions inherited from vtkvmtkFEAssembler
static int IsTypeOf (const char *type)
static vtkvmtkFEAssembler * SafeDownCast (vtkObjectBase *o)

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataFEGradientAssembler ()
 ~vtkvmtkPolyDataFEGradientAssembler ()
Protected Member Functions inherited from vtkvmtkFEAssembler
 vtkvmtkFEAssembler ()
 ~vtkvmtkFEAssembler ()
void Initialize (int numberOfVariables)

Protected Attributes

char * ScalarsArrayName
int ScalarsComponent
Protected Attributes inherited from vtkvmtkFEAssembler
vtkDataSet * DataSet
vtkvmtkSparseMatrix * Matrix
vtkvmtkDoubleVector * RHSVector
vtkvmtkDoubleVector * SolutionVector
int NumberOfVariables
int QuadratureOrder

Detailed Description

Construct a gradient based finite element calculation on a surface.

vtkvmtkPolyDataFEGradientAssembler implements vtkvmtkFEAssembler::Build() to assemble, over every 2D (triangle) cell of DataSet, the finite-element mass matrix and the right-hand-side vector of the L2 projection of the surface gradient of a scalar point data array (ScalarsArrayName / ScalarsComponent) onto the mesh's piecewise-linear basis functions. Gauss quadrature (order QuadratureOrder, inherited from vtkvmtkFEAssembler) is used to integrate shape functions and their derivatives (via vtkvmtkGaussQuadrature / vtkvmtkFEShapeFunctions). Because the projected gradient is a 3-component vector, three copies of the same mass matrix (block-diagonal) and three RHS components are assembled at once (see Initialize(3) in Build()). Solving the resulting linear system (e.g. with vtkvmtkOpenNLLinearSystemSolver) yields a smoothed nodal gradient field; this is the assembler used internally by vtkvmtkPolyDataGradientFilter.

See also
vtkvmtkFEAssembler, vtkvmtkPolyDataGradientFilter, vtkvmtkPolyDataFELaplaceAssembler

Definition at line 42 of file vtkvmtkPolyDataFEGradientAssembler.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataFEGradientAssembler()

vtkvmtkPolyDataFEGradientAssembler::vtkvmtkPolyDataFEGradientAssembler ( )
protected

◆ ~vtkvmtkPolyDataFEGradientAssembler()

vtkvmtkPolyDataFEGradientAssembler::~vtkvmtkPolyDataFEGradientAssembler ( )
protected

Definition at line 40 of file vtkvmtkPolyDataFEGradientAssembler.cxx.

41{
42 if (this->ScalarsArrayName)
43 {
44 delete[] this->ScalarsArrayName;
45 this->ScalarsArrayName = NULL;
46 }
47}

Member Function Documentation

◆ New()

vtkvmtkPolyDataFEGradientAssembler * vtkvmtkPolyDataFEGradientAssembler::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

Reimplemented from vtkvmtkFEAssembler.

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataFEGradientAssembler::NewInstanceInternal ( ) const
protectedvirtual

Reimplemented from vtkvmtkFEAssembler.

◆ NewInstance()

vtkvmtkPolyDataFEGradientAssembler * vtkvmtkPolyDataFEGradientAssembler::NewInstance ( ) const

◆ Build()

void vtkvmtkPolyDataFEGradientAssembler::Build ( )
overridevirtual

Assemble the finite-element system (Matrix and RHSVector) from DataSet. Implemented by subclasses for a specific PDE/discretization.

Implements vtkvmtkFEAssembler.

Definition at line 49 of file vtkvmtkPolyDataFEGradientAssembler.cxx.

50{
51 if (!this->ScalarsArrayName)
52 {
53 vtkErrorMacro("ScalarsArrayName not specified!");
54 return;
55 }
56
57 vtkDataArray* scalarsArray = this->DataSet->GetPointData()->GetArray(this->ScalarsArrayName);
58
59 if (!scalarsArray)
60 {
61 vtkErrorMacro("ScalarsArray with name specified does not exist!");
62 return;
63 }
64
65 int numberOfVariables = 3;
66 this->Initialize(numberOfVariables);
67
68 vtkvmtkGaussQuadrature* gaussQuadrature = vtkvmtkGaussQuadrature::New();
69 gaussQuadrature->SetOrder(this->QuadratureOrder);
70
71 vtkvmtkFEShapeFunctions* feShapeFunctions = vtkvmtkFEShapeFunctions::New();
72
73 int dimension = 2;
74
75 int numberOfCells = this->DataSet->GetNumberOfCells();
76 int numberOfPoints = this->DataSet->GetNumberOfPoints();
77 int k;
78 for (k=0; k<numberOfCells; k++)
79 {
80 vtkCell* cell = this->DataSet->GetCell(k);
81 if (cell->GetCellDimension() != dimension)
82 {
83 continue;
84 }
85 gaussQuadrature->Initialize(cell->GetCellType());
86 feShapeFunctions->Initialize(cell,gaussQuadrature->GetQuadraturePoints());
87 int numberOfQuadraturePoints = gaussQuadrature->GetNumberOfQuadraturePoints();
88 double quadraturePCoords[3];
89 int numberOfCellPoints = cell->GetNumberOfPoints();
90 int i, j;
91 int q;
92 for (q=0; q<numberOfQuadraturePoints; q++)
93 {
94 gaussQuadrature->GetQuadraturePoint(q,quadraturePCoords);
95 double quadratureWeight = gaussQuadrature->GetQuadratureWeight(q);
96 double jacobian = feShapeFunctions->GetJacobian(q);
97 double phii, phij;
98 double dphii[3];
99 double gradientValue[3];
100 gradientValue[0] = gradientValue[1] = gradientValue[2] = 0.0;
101 for (i=0; i<numberOfCellPoints; i++)
102 {
103 vtkIdType iId = cell->GetPointId(i);
104 feShapeFunctions->GetDPhi(q,i,dphii);
105 double nodalValue = scalarsArray->GetComponent(iId,this->ScalarsComponent);
106 gradientValue[0] += nodalValue * dphii[0];
107 gradientValue[1] += nodalValue * dphii[1];
108 gradientValue[2] += nodalValue * dphii[2];
109 }
110 for (i=0; i<numberOfCellPoints; i++)
111 {
112 vtkIdType iId = cell->GetPointId(i);
113 phii = feShapeFunctions->GetPhi(q,i);
114 double value0 = jacobian * quadratureWeight * gradientValue[0] * phii;
115 double value1 = jacobian * quadratureWeight * gradientValue[1] * phii;
116 double value2 = jacobian * quadratureWeight * gradientValue[2] * phii;
117 this->RHSVector->AddElement(iId,value0);
118 this->RHSVector->AddElement(iId+numberOfPoints,value1);
119 this->RHSVector->AddElement(iId+2*numberOfPoints,value2);
120 for (j=0; j<numberOfCellPoints; j++)
121 {
122 vtkIdType jId = cell->GetPointId(j);
123 phij = feShapeFunctions->GetPhi(q,j);
124 double value = jacobian * quadratureWeight * phii * phij;
125 this->Matrix->AddElement(iId,jId,value);
126 this->Matrix->AddElement(iId+numberOfPoints,jId+numberOfPoints,value);
127 this->Matrix->AddElement(iId+2*numberOfPoints,jId+2*numberOfPoints,value);
128 }
129 }
130 }
131 }
132
133 gaussQuadrature->Delete();
134 feShapeFunctions->Delete();
135}
vtkvmtkSparseMatrix * Matrix
vtkvmtkDoubleVector * RHSVector
void Initialize(int numberOfVariables)
void Initialize(vtkCell *cell, vtkDoubleArray *pcoords)
static vtkvmtkFEShapeFunctions * New()
double GetPhi(vtkIdType id, vtkIdType i)
double * GetDPhi(vtkIdType id, vtkIdType i)
double * GetQuadraturePoint(vtkIdType id)
virtual vtkDoubleArray * GetQuadraturePoints()
static vtkvmtkGaussQuadrature * New()
void Initialize(vtkIdType cellType)
double GetQuadratureWeight(vtkIdType id)
virtual void SetOrder(int)

◆ SetScalarsArrayName()

virtual void vtkvmtkPolyDataFEGradientAssembler::SetScalarsArrayName ( const char * )
virtual

Set/get the name of the point data scalar array whose surface gradient is assembled by Build(). Must be set, and the array must exist on DataSet, before calling Build().

◆ GetScalarsArrayName()

virtual char * vtkvmtkPolyDataFEGradientAssembler::GetScalarsArrayName ( )
virtual

Set/get the name of the point data scalar array whose surface gradient is assembled by Build(). Must be set, and the array must exist on DataSet, before calling Build().

◆ SetScalarsComponent()

virtual void vtkvmtkPolyDataFEGradientAssembler::SetScalarsComponent ( int )
virtual

Set/get the component of the ScalarsArrayName array (for multi-component arrays) whose gradient is computed. Default: 0.

◆ GetScalarsComponent()

virtual int vtkvmtkPolyDataFEGradientAssembler::GetScalarsComponent ( )
virtual

Set/get the component of the ScalarsArrayName array (for multi-component arrays) whose gradient is computed. Default: 0.

Member Data Documentation

◆ ScalarsArrayName

char* vtkvmtkPolyDataFEGradientAssembler::ScalarsArrayName
protected

Definition at line 73 of file vtkvmtkPolyDataFEGradientAssembler.h.

◆ ScalarsComponent

int vtkvmtkPolyDataFEGradientAssembler::ScalarsComponent
protected

Definition at line 74 of file vtkvmtkPolyDataFEGradientAssembler.h.


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