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

Set up Dirichlet (or first-type) boundary conditions that a linear system needs to take along the boundary of the domain. More...

#include <vtkvmtkDirichletBoundaryConditions.h>

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

Public Types

typedef vtkvmtkBoundaryConditions Superclass
Public Types inherited from vtkvmtkBoundaryConditions
typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkDirichletBoundaryConditions * NewInstance () const
void Apply () override
Public Member Functions inherited from vtkvmtkBoundaryConditions
vtkvmtkBoundaryConditions * NewInstance () const
virtual void SetLinearSystem (vtkvmtkLinearSystem *)
virtual vtkvmtkLinearSystem * GetLinearSystem ()
virtual void SetBoundaryNodes (vtkIdList *)
virtual vtkIdList * GetBoundaryNodes ()
virtual void SetBoundaryValues (vtkDoubleArray *)
virtual vtkDoubleArray * GetBoundaryValues ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkDirichletBoundaryConditions ()
 ~vtkvmtkDirichletBoundaryConditions ()
Protected Member Functions inherited from vtkvmtkBoundaryConditions
 vtkvmtkBoundaryConditions ()
 ~vtkvmtkBoundaryConditions ()

Additional Inherited Members

Protected Attributes inherited from vtkvmtkBoundaryConditions
vtkvmtkLinearSystem * LinearSystem
vtkIdList * BoundaryNodes
vtkDoubleArray * BoundaryValues

Detailed Description

Set up Dirichlet (or first-type) boundary conditions that a linear system needs to take along the boundary of the domain.

vtkvmtkDirichletBoundaryConditions imposes a Dirichlet (essential) boundary condition on LinearSystem's sparse matrix A and right-hand side vector B: for every node listed in BoundaryNodes, the corresponding row of A is zeroed out except for a unit diagonal entry, and B is set to the prescribed BoundaryValues entry, so that the solution x is forced to take that value at the node. To preserve symmetry of the reduced system, the boundary node's column is also eliminated from every other row, moving its known contribution to the right-hand side. This is the standard way vmtk's finite-element solvers (e.g. distance-to-boundary / Laplacian-type problems) impose fixed values on a subset of nodes, typically the mesh boundary.

See also
vtkvmtkBoundaryConditions, vtkvmtkLinearSystem, vtkvmtkEllipticProblem

Definition at line 45 of file vtkvmtkDirichletBoundaryConditions.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkDirichletBoundaryConditions()

vtkvmtkDirichletBoundaryConditions::vtkvmtkDirichletBoundaryConditions ( )
inlineprotected

Definition at line 54 of file vtkvmtkDirichletBoundaryConditions.h.

54{};

◆ ~vtkvmtkDirichletBoundaryConditions()

vtkvmtkDirichletBoundaryConditions::~vtkvmtkDirichletBoundaryConditions ( )
inlineprotected

Definition at line 55 of file vtkvmtkDirichletBoundaryConditions.h.

55{};

Member Function Documentation

◆ New()

vtkvmtkDirichletBoundaryConditions * vtkvmtkDirichletBoundaryConditions::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

Reimplemented from vtkvmtkBoundaryConditions.

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkDirichletBoundaryConditions::NewInstanceInternal ( ) const
protectedvirtual

Reimplemented from vtkvmtkBoundaryConditions.

◆ NewInstance()

vtkvmtkDirichletBoundaryConditions * vtkvmtkDirichletBoundaryConditions::NewInstance ( ) const

◆ Apply()

void vtkvmtkDirichletBoundaryConditions::Apply ( )
overridevirtual

Impose the boundary condition on LinearSystem. This base class implementation only validates that LinearSystem, BoundaryNodes, and BoundaryValues are set and mutually consistent (same number of nodes and values); subclasses override this method to actually modify the system matrix and right-hand side.

FIXME: when boundary conditions apply is called, linear system hasn't checked if matrix and vectors exist

Reimplemented from vtkvmtkBoundaryConditions.

Definition at line 31 of file vtkvmtkDirichletBoundaryConditions.cxx.

32{
33 vtkIdType i, j, k;
34 vtkIdType systemSize;
35 vtkIdType numberOfRowElements;
36 vtkIdType boundaryNode, numberOfBoundaryNodes;
37 vtkvmtkSparseMatrix* systemMatrix;
38 vtkvmtkDoubleVector* rhsVector;
39 vtkvmtkSparseMatrixRow* row;
40 double boundaryValue;
41 double element;
42 double vectorElement;
43
44 this->Superclass::Apply();
45
46 systemSize = this->LinearSystem->GetX()->GetNumberOfElements();
47 numberOfBoundaryNodes = this->BoundaryNodes->GetNumberOfIds();
48
50 systemMatrix = this->LinearSystem->GetA();
51 rhsVector = this->LinearSystem->GetB();
52
53 for (i=0; i<numberOfBoundaryNodes; i++)
54 {
55 boundaryNode = this->BoundaryNodes->GetId(i);
56 boundaryValue = this->BoundaryValues->GetComponent(i,0);
57
58 for (j=0; j<systemSize; j++)
59 {
60 if (j==boundaryNode)
61 {
62 systemMatrix->GetRow(j)->Initialize();
63 systemMatrix->GetRow(j)->SetDiagonalElement(1.0);
64 rhsVector->SetElement(j,boundaryValue);
65 //rhsVector->SetLocked(j,true);
66 }
67 else
68 {
69 row = systemMatrix->GetRow(j);
70 numberOfRowElements = row->GetNumberOfElements();
71 for (k=0; k<numberOfRowElements; k++)
72 {
73 if (row->GetElementId(k) == boundaryNode)
74 {
75 element = row->GetElement(k);
76 row->SetElement(k,0.0);
77 vectorElement = rhsVector->GetElement(j);
78 vectorElement -= element * boundaryValue;
79 rhsVector->SetElement(j,vectorElement);
80 }
81 }
82 }
83 }
84 }
85}
double GetElement(vtkIdType i)
void SetElement(vtkIdType i, double value)
void SetElement(vtkIdType i, double element)
virtual void SetDiagonalElement(double)
double GetElement(vtkIdType i)
vtkIdType GetElementId(vtkIdType i)
vtkvmtkSparseMatrixRow * GetRow(vtkIdType i)

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