VMTK
Loading...
Searching...
No Matches
vtkvmtkUnstructuredGridFELaplaceAssembler.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkUnstructuredGridFELaplaceAssembler.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 "vtkCell.h"
26#include "vtkMath.h"
27#include "vtkObjectFactory.h"
28
29
31
35
39
41{
42 int numberOfVariables = 1;
43 this->Initialize(numberOfVariables);
44
46 gaussQuadrature->SetOrder(this->QuadratureOrder);
47
49
50 int dimension = 3;
51
52 int numberOfCells = this->DataSet->GetNumberOfCells();
53 int k;
54 for (k=0; k<numberOfCells; k++)
55 {
56 vtkCell* cell = this->DataSet->GetCell(k);
57 if (cell->GetCellDimension() != dimension)
58 {
59 continue;
60 }
61 gaussQuadrature->Initialize(cell->GetCellType());
62 feShapeFunctions->Initialize(cell,gaussQuadrature->GetQuadraturePoints());
63 int numberOfQuadraturePoints = gaussQuadrature->GetNumberOfQuadraturePoints();
64 double quadraturePCoords[3];
65 int numberOfCellPoints = cell->GetNumberOfPoints();
66 int i, j;
67 int q;
68 for (q=0; q<numberOfQuadraturePoints; q++)
69 {
70 gaussQuadrature->GetQuadraturePoint(q,quadraturePCoords);
71 double quadratureWeight = gaussQuadrature->GetQuadratureWeight(q);
72 double jacobian = feShapeFunctions->GetJacobian(q);
73 double dphii[3], dphij[3];
74 for (i=0; i<numberOfCellPoints; i++)
75 {
76 vtkIdType iId = cell->GetPointId(i);
77 feShapeFunctions->GetDPhi(q,i,dphii);
78 for (j=0; j<numberOfCellPoints; j++)
79 {
80 vtkIdType jId = cell->GetPointId(j);
81 feShapeFunctions->GetDPhi(q,j,dphij);
82 double gradphii_gradphij = vtkMath::Dot(dphii,dphij);
83 double value = jacobian * quadratureWeight * gradphii_gradphij;
84 this->Matrix->AddElement(iId,jId,value);
85 }
86 }
87 }
88 }
89
90 gaussQuadrature->Delete();
91 feShapeFunctions->Delete();
92}
93
vtkvmtkSparseMatrix * Matrix
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 * 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 laplacian based finite element calculation on a mesh.
vtkStandardNewMacro(vtkvmtkUnstructuredGridFELaplaceAssembler)