function [ a, f ] = dirichlet_apply_sparse ( node_num, node_xy, ... node_condition, a, f ) %% DIRICHLET_APPLY_SPARSE accounts for Dirichlet boundary conditions. % % Modified: % % 07 January 2007 % % 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, real sparse A, the coefficient matrix. % % Input, real F(NODE_NUM), the right hand side. % % Output, real sparse A, the coefficient matrix, % 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 ) a(node,:) = 0.0; a(node,node) = 1.0; f(node) = node_bc(node); end end