function [ a, f ] = dirichlet_apply ( node_num, node_xy, node_condition, ... ib, a, f ) %% DIRICHLET_APPLY accounts for Dirichlet boundary conditions. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 14 November 2006 % % Author: % % John Burkardt % % Parameters: % % Input, integer NODE_NUM, the number of nodes. % % Input, real NODE_XY(2,NODE_NUM), the coordinates of nodes. % % Input, integer NODE_CONDITION(NODE_NUM), reports the condition % used to set the unknown associated with the node. % 0, unknown. % 1, finite element equation. % 2, Dirichlet condition; % 3, Neumann condition. % % Input, integer IB, the half-bandwidth of the matrix. % % Input, real A(3*IB+1,NODE_NUM), the NODE_NUM by NODE_NUM % coefficient matrix, stored in a compressed format. % % Input, real F(NODE_NUM), the right hand side. % % Output, real A(3*IB+1,NODE_NUM), the NODE_NUM by NODE_NUM % coefficient matrix, stored in a compressed format, % adjusted for Dirichlet boundary conditions. % % Output, real F(NODE_NUM), the right hand side, adjusted for % Dirichlet boundary conditions. % node_bc = dirichlet_condition ( node_num, node_xy ); DIRICHLET = 2; for node = 1 : node_num if ( node_condition(node) == DIRICHLET ) column_low = max ( node - ib, 1 ); column_high = min ( node + ib, node_num ); for column = column_low : column_high a(node-column+2*ib+1,column) = 0.0; end a(2*ib+1,node) = 1.0; f(node) = node_bc(node); end end return end