There is a simple and widely used method for imposing Dirichlet conditions — direct substitution of the known boundary values into the system (the row-and-column elimination method). Suppose a node carries the Dirichlet condition , where is the known boundary value. Then on the system we perform the following operations:
Right-hand side modification: For every row subtract the contribution of the known value from the right-hand side: .
Zeroing the row and column: Replace the -th row and -th column of the matrix with zeros, except for the diagonal element: .
Setting the diagonal element: Set the diagonal element to one: .
Setting the boundary value: Replace the -th component of the right-hand side with the boundary value: .
After these operations the -th equation of the system takes the form , which guarantees that the boundary condition holds.
Let us return to our one-dimensional example with five nodes . Suppose Dirichlet conditions are prescribed at the boundaries:
Stationary case
The original system has the form:
The matrix is full (symmetric and tridiagonal); boundary conditions are imposed by replacing the boundary rows.
Denote and . We apply the direct method for the nodes and .
Step 1: Right-hand side modification for the interior nodes
For the node (index 1):
For the node (index 3):
Steps 2–4: Modifying the matrix and right-hand side for the boundary nodes
For the node (index 0):
Zero the first row:
Zero the first column:
Set the diagonal:
Set the right-hand side:
For the node (index 4):
Zero the last row:
Zero the last column:
Set the diagonal:
Set the right-hand side:
In the matrix the boundary rows and columns (nodes and ) are zeroed and the diagonal is set to one; the known values are moved to the right-hand side.
The modified right-hand side vector:
Note: since the source-density function is identically zero on the simplices and , we have and . However, the components may be nonzero.
Non-stationary case
For the non-stationary case the system has the form:
Denote and . We apply the same direct method.
Right-hand side modification for the interior nodes
For the node :
For the node :
As in the stationary case, the boundary rows and columns of are zeroed and the diagonal is set to one, while and go to the right-hand side.